gpt4 book ai didi

python - 当我尝试打开模块时 pudb3 引发 TypeError

转载 作者:太空宇宙 更新时间:2023-11-03 21:00:27 26 4
gpt4 key购买 nike

最近,我注意到我无法打开 pudb3 中的任何模块。以前我经常使用这个系统。我不确定哪些更改破坏了我的 pudb 环境。如何解决这个问题?

我的环境

  • Ubuntu 16.04
  • pudb。版本:2018.1
$ python -V
Python 3.7.2
$ which python
/home/jef/anaconda3/bin/python
$ which pudb3
/home/jef/anaconda3/bin/pudb3

重现错误

  1. 运行$ pudb3 my_program.py --x y
  2. m打开模块。
  3. 然后,它引发以下异常

traceback.txt

Traceback (most recent call last):
File "/home/jef/anaconda3/lib/python3.7/site-packages/pudb/__init__.py", line 119, in runscript
dbg._runscript(mainpyfile)
File "/home/jef/anaconda3/lib/python3.7/site-packages/pudb/debugger.py", line 457, in _runscript
self.run(statement, globals=globals_, locals=locals_)
File "/home/jef/anaconda3/lib/python3.7/bdb.py", line 585, in run
exec(cmd, globals, locals)
File "<string>", line 1, in <module>
File "eval.py", line 1, in <module>
"""An evaluation tool for various semantic analytis desigining services"""
File "eval.py", line 1, in <module>
"""An evaluation tool for various semantic analytis desigining services"""
File "/home/jef/anaconda3/lib/python3.7/bdb.py", line 88, in trace_dispatch
return self.dispatch_line(frame)
File "/home/jef/anaconda3/lib/python3.7/site-packages/pudb/debugger.py", line 187, in dispatch_line
self.user_line(frame)
File "/home/jef/anaconda3/lib/python3.7/site-packages/pudb/debugger.py", line 408, in user_line
self.interaction(frame)
File "/home/jef/anaconda3/lib/python3.7/site-packages/pudb/debugger.py", line 376, in interaction
show_exc_dialog=show_exc_dialog)
File "/home/jef/anaconda3/lib/python3.7/site-packages/pudb/debugger.py", line 2118, in call_with_ui
return f(*args, **kwargs)
File "/home/jef/anaconda3/lib/python3.7/site-packages/pudb/debugger.py", line 2362, in interaction
self.event_loop()
File "/home/jef/anaconda3/lib/python3.7/site-packages/pudb/debugger.py", line 2328, in event_loop
toplevel.keypress(self.size, k)
File "/home/jef/anaconda3/lib/python3.7/site-packages/pudb/ui_tools.py", line 106, in keypress
result = self._w.keypress(size, key)
File "/home/jef/anaconda3/lib/python3.7/site-packages/urwid/container.py", line 1131, in keypress
return self.body.keypress( (maxcol, remaining), key )
File "/home/jef/anaconda3/lib/python3.7/site-packages/urwid/container.py", line 2271, in keypress
key = w.keypress((mc,) + size[1:], key)
File "/home/jef/anaconda3/lib/python3.7/site-packages/urwid/container.py", line 1590, in keypress
key = self.focus.keypress(tsize, key)
File "/home/jef/anaconda3/lib/python3.7/site-packages/pudb/ui_tools.py", line 111, in keypress
return handler(self, size, key)
File "/home/jef/anaconda3/lib/python3.7/site-packages/pudb/debugger.py", line 1355, in pick_module
build_filtered_mod_list(filt_edit.get_edit_text()))
File "/home/jef/anaconda3/lib/python3.7/site-packages/pudb/debugger.py", line 1319, in build_filtered_mod_list
for name, mod in list(sys.modules.items())
File "/home/jef/anaconda3/lib/python3.7/site-packages/pudb/debugger.py", line 1320, in <genexpr>
if mod_exists(mod))
File "/home/jef/anaconda3/lib/python3.7/site-packages/pudb/debugger.py", line 1301, in mod_exists
base, ext = splitext(filename)
File "/home/jef/anaconda3/lib/python3.7/posixpath.py", line 122, in splitext
p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType

更新 1

我通过删除 .zshrc 禁用了 zsh,并且不使用 tmux。然而,它仍然引发同样的错误。

最佳答案

正在申请this patch/usr/lib/python3.7/site-packages/pudb/debugger.py 解决了我的 Fedora 31 系统上的相同问题。将 pudb 升级到较新版本将具有相同的效果(2019.12019.2 都有此更改)。

该补丁很小,因此我将其包含在此处。

commit af3bdb6e7c81b036dbc71690109b81e30b3c1185
Author: Alex Fikl <alexfikl@gmail.com>
Date: Thu Aug 9 09:53:39 2018 -0500

debugger: skip namespace packages in module listing

diff --git a/pudb/debugger.py b/pudb/debugger.py
index 444eaa6..da66884 100644
--- a/pudb/debugger.py
+++ b/pudb/debugger.py
@@ -1297,6 +1297,8 @@ class DebuggerUI(FrameVarInfoKeeper):
def mod_exists(mod):
if not hasattr(mod, "__file__"):
return False
+ if mod.__file__ is None:
+ return False
filename = mod.__file__

base, ext = splitext(filename)

关于python - 当我尝试打开模块时 pudb3 引发 TypeError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55737826/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com