The destructor of a _SaneIterator object calls device.cancel(), which may lead to exceptions if the user has already closed the device.
Consider the following code:
sane.init()
dev = sane.open("device")
iterator = dev.multi_scan()
while True:
try:
image = iterator.next()
except:
break
dev.cancel()
dev.close()
sane.exit()
This will cause an exception when the garbage collector destroys iterator. The only reasonable work-around I found is to manually destroy the _SaneIterator object before closing the device, but having to do that is not what I would expect at all.
The destructor of a
_SaneIterator
object callsdevice.cancel()
, which may lead to exceptions if the user has already closed the device.Consider the following code:
This will cause an exception when the garbage collector destroys
iterator
. The only reasonable work-around I found is to manually destroy the_SaneIterator
object before closing the device, but having to do that is not what I would expect at all.