pyserial errorhandling in tries to iterate over wrong Exception attribute

Bug #1650480 reported by seahawk1986 on 2016-12-16
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

When opening the serial connection using pyserial 3.x in fails ( ), the script looks at the wrong element of the exception (which results in raising another Exception like in this post: ):

Traceback (most recent call last):
  File "", line 227, in <module>
  File "/usr/share/inkscape/extensions/", line 268, in affect
  File "", line 96, in effect
  File "", 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:
... except Exception as inst:
... inst.args
... inst.args[0]
... inst.strerror
(13, "could not open port /dev/ttyS0: [Errno 13] Keine Berechtigung: '/dev/ttyS0'")
"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
jazzynico (jazzynico) wrote :

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.

Changed in inkscape:
importance: Undecided → Low
status: New → Triaged
jazzynico (jazzynico) wrote :
Changed in inkscape:
assignee: nobody → jazzynico (jazzynico)
milestone: none → 0.93
status: Triaged → In Progress
tags: added: exporting
removed: python
jazzynico (jazzynico) wrote :

Patch committed in lp:inkscape rev. 15413.
Proposing to backport to 0.92.1.

Changed in inkscape:
status: In Progress → Fix Committed
tags: added: backport-proposed
Bryce Harrington (bryce) wrote :

+1 for backport to 0.92.1.

Thanks jazzynico for the fix, and seahawk1986 for the analysis.

jazzynico (jazzynico) wrote :

Fixed in lp:inkscape/0.92.x rev. 15316.

jazzynico (jazzynico) on 2017-01-21
tags: removed: backport-proposed
Changed in inkscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers