pyserial errorhandling in plotter.py tries to iterate over wrong Exception attribute
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Inkscape |
Fix Released
|
Low
|
jazzynico | ||
0.92.x |
Fix Released
|
Low
|
jazzynico |
Bug Description
When opening the serial connection using pyserial 3.x in plotter.py fails ( https:/
Traceback (most recent call last):
File "plotter.py", line 227, in <module>
e.affect()
File "/usr/share/
self.effect()
File "plotter.py", line 96, in effect
self.
File "plotter.py", line 162, in sendHpglToSerial
if 'ould not open port' in inst.args[0]:
TypeError: argument of type 'int' is not iterable
Minimal example in the python interpreter (somehow launchpad ignores the spaces before the commands in the lines after try and except when displaying the text):
>>> import serial
>>> mySerial = serial.Serial()
>>> mySerial.port = '/dev/ttyS0'
>>> try:
... mySerial.open()
... except Exception as inst:
... inst.args
... inst.args[0]
... inst.strerror
...
(13, "could not open port /dev/ttyS0: [Errno 13] Keine Berechtigung: '/dev/ttyS0'")
13
"could not open port /dev/ttyS0: [Errno 13] Keine Berechtigung: '/dev/ttyS0'"
It should be more reliable to use the inst.strerror Attribute of the Exception or str(inst) instead of an index-Based value in the Exception.
description: | updated |
description: | updated |
description: | updated |
tags: | removed: backport-proposed |
Changed in inkscape: | |
status: | Fix Committed → Fix Released |
Thanks for taking the time to file a report!
Bug reproduced on Xubuntu 16.04, Inkscape 0.91 and lp:inkscape/0.92.x rev.15315.