Python/IronPython 日志记录 : 'NoneType' object has no attribute 'f_back'

标签 python logging ironpython

当在 IronPython 脚本中实例化 collections.OrderedDict() 时,我得到以下结果:

System.MissingMemberException: 'NoneType' object has no attribute 'f_back'
at logging$33.findCaller$1681(PythonFunction $function, Object self) in C:\Python26\Lib\logging\__init__.py:line     1101
at logging$33._log$1683(PythonFunction $function, Object self, Object level, Object msg, Object args, Object         exc_info, Object extra) in C:\Python26\Lib\logging\__init__.py:line 1129
at logging$33.info$1675(PythonFunction $function, Object self, Object msg, Object args, Object kwargs) in        C:\Python26\Lib\logging\__init__.py:line 1021

调用此命令的脚本在其他 Windows 机器上运行良好,但仅出现在我的机器上。我根本不熟悉日志记录功能 - 谁能解释一下?

Python 版本 2.6

IronPython 版本 2.7.1

非常感谢

最佳答案

您似乎正在尝试将 Python 2.6 中的库与 IronPython 2.7 一起使用。您应该改用 IronPython 2.7 的标准库,它有很多修复和变通方法,可以使其正常工作(并不完美,但好多了)。

例如,我在 IronPython 2.7.3 上得到以下信息:

>>> from collections import OrderedDict
>>> od = OrderedDict()
>>> od[1] = 2
>>> od[0] = 4
>>> od
OrderedDict([(1, 2), (0, 4)])
>>>

很可能您将 IRONPYTHONPATH 变量设置为在 IronPython 的 Lib 之前拥有 Python 的 Lib。这曾经是必需的(对于 IronPython < 2.6),但现在不推荐。

关于Python/IronPython 日志记录 : 'NoneType' object has no attribute 'f_back' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17301287/

相关文章:

sql - 记录 SQL Server 2008 Express 数据库上的所有查询?

c# - 为什么公共(public)语言运行库不能支持 Java

python - Rpy2 错误 wac-a-mole : R_USER not defined

Python float 舍入错误 117.285 舍入到 117.28 而不是 117.29

python - OpenCV 'SIFT' 属性错误

python - 为外部/第三方库自定义日志记录

java - 如何禁用 Hibernate 4 登录 Eclipse 控制台?

python - 在 python 中运行 hdfs dfsadmin 命令

Python 返回的字符串既是 str 又是 unicode 类型

python - 检测 IronPython 的最佳方法