在擱置模塊(以及擱置幫助程序copy_reg模塊)中看到一個奇怪的異常??匆幌拢趪L試調用對Pickler類的__getstate__方法的引用。但是,由于某種原因,這似乎返回了None。只是想知道是否還有其他人經歷過這種情況,是否可以做一些事情以使貨架正確工作?這是我看到的異常的返回堆棧: File "/usr/local/lib/python2.7/dist-packages/libgsync/drive/__init__.py", line 497, in stat self._pcache[search] = ent File "/usr/lib/python2.7/shelve.py", line 132, in __setitem__ p.dump(value) File "/usr/lib/python2.7/copy_reg.py", line 84, in _reduce_ex dict = getstate()DEBUG: libgsync/drive/__init__.py:387:walk(): Exception: 'NoneType' object is not callable我隨意查看代碼,這是_reduce_ex()函數中發生故障的地方:try: getstate = self.__getstate__except AttributeError: if getattr(self, "__slots__", None): raise TypeError("a class that defines __slots__ without " "defining __getstate__ cannot be pickled") try: dict = self.__dict__ except AttributeError: dict = Noneelse: dict = getstate()最初,它將self .__ getstate__分配給getstat,因此這時應該可以調用。它似乎沒有引發異常,因為它是在else塊的上下文中執行的。奇怪的...這是發生異常的代碼行的調試輸出:DEBUG: libgsync/drive/__init__.py:496:stat(): Updating path cache: /unittest這是導致異常的代碼:# Update path cache.if self._pcache.get(search) is None: debug("Updating path cache: %s" % search) self._pcache[search] = ent
添加回答
舉報
0/150
提交
取消