在擱置模塊(以及擱置幫助程序copy_reg模塊)中看到一個(gè)奇怪的異常??匆幌?,它正在嘗試調(diào)用對(duì)Pickler類的__getstate__方法的引用。但是,由于某種原因,這似乎返回了None。只是想知道是否還有其他人經(jīng)歷過這種情況,是否可以做一些事情以使貨架正確工作?這是我看到的異常的返回堆棧: 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()函數(shù)中發(fā)生故障的地方: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,因此這時(shí)應(yīng)該可以調(diào)用。它似乎沒有引發(fā)異常,因?yàn)樗窃趀lse塊的上下文中執(zhí)行的。奇怪的...這是發(fā)生異常的代碼行的調(diào)試輸出:DEBUG: libgsync/drive/__init__.py:496:stat(): Updating path cache: /unittest這是導(dǎo)致異常的代碼:# Update path cache.if self._pcache.get(search) is None: debug("Updating path cache: %s" % search) self._pcache[search] = ent
添加回答
舉報(bào)
0/150
提交
取消