如何确定在库中引起TypeError的变量的值?



我希望能够看到哪些值导致TypeError以避免读取库代码。

例如,我的Traceback是:

Traceback (most recent call last):
File "/censored/trunk/censored-cli/censored.py", line 945, in <module>
detection(filelist, []) #empty options for now because we dont need any
File "/censored/trunk/censored-cli/censored.py", line 770, in detection
subprocess.run(analysis_cmd,env=env,check=True)
File "/home/name/.julia/conda/3/lib/python3.9/subprocess.py", line 505, in run
with Popen(*popenargs, **kwargs) as process:
File "/home/name/.julia/conda/3/lib/python3.9/subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/home/name/.julia/conda/3/lib/python3.9/subprocess.py", line 1741, in _execute_child
env_list.append(k + b'=' + os.fsencode(v))
File "/home/name/.julia/conda/3/lib/python3.9/os.py", line 810, in fsencode
filename = fspath(filename)  # Does type-checking of `filename`.
TypeError: expected str, bytes or os.PathLike object, not int

我更愿意在fsencode中看到第810行filename的值,而不是知道它被解释为int。

我知道我可以在我的安装中找到fsencode并将其更改为打印值,但我更喜欢内置的方式来检查导致错误的变量的值。

有办法做到这一点吗?

  1. 使用集成调试器的IDE,如PyCharm
  2. 在产生错误
  3. 的代码行设置断点
  4. 调试程序-它将在断点处停止,然后您将看到所有变量

相关内容

  • 没有找到相关文章

最新更新