当在 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/