所以我有foo
,一个普通的浮点数的普通元组。在我的脚本中调用映射是莫名其妙地抛出所有事物的Numpy错误,尽管代码没有任何问题。进入调试器并执行完全相同的代码不会产生错误。有谁知道可能会发生什么?我完全丧失了。这有什么可能?不可能的Python错误
此外,对于那些要求最小脚本重现问题的人:我无法使用短片段重现该问题,而且我无法发布整个脚本,因为它是用于作业分配的。
Traceback (most recent call last):
File "py_code\ps4-code.py", line 240, in <module>
doPairMatch(transA, transB, tapoints, tbpoints, 1, ransacTranslate)
File "py_code\ps4-code.py", line 217, in doPairMatch
print map(int, foo)
TypeError: expected a single-segment buffer object
>>> import pdb;pdb.pm()
> c:\homework\cs4495\ps4\py_code\ps4-code.py(217)doPairMatch()
-> print map(int, foo)
(Pdb) print foo
(603.0, 437.0)
(Pdb) print map(int, foo)
[603, 437]
(Pdb) print type(foo)
<type 'tuple'>
(Pdb) print int, map, type
<type 'int'> <built-in function map> <type 'type'>
(Pdb) map(type, foo)
[<type 'float'>, <type 'float'>]
(Pdb)
编辑:至少我想出了这是如何可能的。看起来问题在垃圾收集期间发生,这就是为什么错误随机出现在代码的无关部分。据推测,gc在OpenCV的某个地方触发了一个错误,导致一切都崩溃。
Exception TypeError: 'expected a single-segment buffer object' in 'garbage colle
ction' ignored
Fatal Python error: unexpected exception during garbage collection
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
向我们展示它按照预期在提示符下工作并不会帮助我们找出它为什么不*在您的脚本中工作。 – colons
那我还能做什么?我不知道可能发生了什么,所以我想到Stack Overflow的人可能知道。 – Antimony
发布一个简短的(最简单的!)脚本来重现问题。 –