Issue : python2 => python3 : AIterator object is not an iterator
Closed this issue · 13 comments
File "/casa/build/python/anatomist/direct/api.py", line 1496, in getattr
for c in self.getInternalRep():
File "/casa/build/python/anatomist/cpp/mobject.py", line 66, in next
return next(iterator)
TypeError: AIterator object is not an iterator
#4 is as a temporary fix, but it should be reverted once the proper fix is implemented (i.e. implement AIterator.__next__
).
This rose a new error :
File "/casa/build/python/anatomist/direct/api.py", line 1496, in getattr
for c in self.getInternalRep():
TypeError: instance has no next() method
as next()
method seems to have been replaced by __next__()
@rbonicel We need a bit more information in order to reproduce the issue on our side. Can you insert these print
lines to /casa/build/python/anatomist/direct/api.py
, just before line 1495, the code block should look like this:
elif name == "children":
objects = []
print(type(self))
print(type(self.getInternalRep()))
if issubclass(type(self.getInternalRep()), cpp.MObject): # if internalRep is a multi object, it is iterable and can have children
for c in self.getInternalRep():
objects.append(self.anatomistinstance.typedObject(c))
return objects
Then, post the output of the crash here.
The prints return :
<class 'anatomist.direct.api.AObject'>
<class 'anatomist.cpp.SliceableObject'>
Hope this helps
Hi @rbonicel, thanks for sending this. However, I still cannot reproduce the issue here.
Can you please send the full log, starting from the two print
s up to and including the whole stack trace? If that does not work, we should maybe set up a teleconference with screen sharing, to speed up the debugging process.
The full log is :
<class 'anatomist.direct.api.AObject'>
<class 'anatomist.cpp.MObject'>
Exception in thread Thread-6:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/casa/src/qualicati/bug_fix/python/qualiCATI/T2Star_quality_check/T2StarQualityCheckTask.py", line 60, in showsubjectFunction
functors'['viewer-reset']'()
File "/casa/src/qualicati/bug_fix/python/pyptk/Task.py", line 444, in viewerReset
self._application.getParentToolBox().resetViewers )
File "/casa/src/qualicati/bug_fix/python/pyptk/MainThreadActionManager.py", line 108, in _callAndWakeUp
self._results[ index ] = apply( function, args )
File "/casa/src/qualicati/bug_fix/python/pyptk/ToolBox.py", line 808, in resetViewers
application.getViewer().reset()
File "/casa/src/qualicati/bug_fix/python/pyptk/Viewer.py", line 2439, in reset
self.deleteObject( key )
File "/casa/src/qualicati/bug_fix/python/pyptk/Viewer.py", line 2549, in deleteObject
self.removeObjectFromAllWindows( objectName, viewName )
File "/casa/src/qualicati/bug_fix/python/pyptk/Viewer.py", line 2763, in removeObjectFromAllWindows
self.removeObjectFromWindow( objectName, viewName, w )
File "/casa/src/qualicati/bug_fix/python/pyptk/Viewer.py", line 2743, in removeObjectFromWindow
self._anatomist.removeObjects( self.getObject( objectName ).children,
File "/casa/build/python/anatomist/direct/api.py", line 1498, in __getattr__
for c in self.getInternalRep():
TypeError: instance has no next() method
The main error is raised by the next()
method which doesn't exist anymore. If it has been replaced by __next__()
, the issue is probably here.
As the last commit on /casa/src/anatomist/anatomist-gpl/master
is AIterator.next to AIterator.__next__
, the issue seems to be here. I'm doing a bv_maker complete to see if I still get the error
The commit that renames AIterator.next
to AIterator.__next__
is not on the master
branch, but on the fix_AIterator
branch (that “fix” was incorrect, so I deleted that branch and closed #5). Your issue cannot come from there, unless you explicitly switched to that branch. In that case, you should switch back to origin/master
(git checkout master
followed by git reset --hard origin/master
, beware it will erase local changes).
Just to be sure, you encounter this issue under Python 2, right?
Okay, since the start I was assuming that you were on the master
branch, but in fact you were on the fix_AIterator
branch. I can reproduce the exact same issue on fix_AIterator
, which confirms that that “fix” was incorrect. I will push an updated fix soon.
Yeah, I confirm that with the rebranching on origin/master
, the issue has desappeared.
Sorry for the trouble.
And yes, I was using an Python2.7 version of the projects
@Hboni I understand now why AIterator
is not patched as we expected: @denisri changed the behaviour of __fixsipclasses__
in brainvisa/aims-free@43f4ede.
@hdary, just to be sure, the original issue (TypeError: AIterator object is not an iterator
) was under Python 3, right?
"TypeError: AIterator object is not an iterator" was under Python 2.7
Hopefully this issue was fixed properly in #6 (see also brainvisa/aims-free@eae6882).
If you encounter this bug again, feel free to reopen this issue.