#114 ctypes.WinError() unicode error

v2.6
closed-accepted
None
5
2013-10-17
2011-11-29
No

If the port string is unicode and some error happens in Windows and WinError returns string with non-ascii characters then an unicode error is raised:

File "C:\Python26\lib\site-packages\serial\serialwin32.py", line 59, in open
raise SerialException("could not open port %s: %s" % (self.portstr, ctypes.WinError()))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xf8 in position 0: ordinal not in range(128)

I suggest to change that line to:

raise SerialException("could not open port %r: %r" % (self.portstr, ctypes.WinError()))

Discussion

  • Chris Liechti

    Chris Liechti - 2011-12-28

    Too bad that the messages are then not so easy to read with the escapes. But better than unicode errors anyway... so committed, will be in 2.7

     
  • Chris Liechti

    Chris Liechti - 2011-12-28
    • status: open --> pending-accepted
     
  • Chris Liechti

    Chris Liechti - 2013-10-17
    • status: pending-accepted --> closed-accepted
    • assigned_to: Chris Liechti
    • Group: --> v2.6
     
  • Chris Liechti

    Chris Liechti - 2013-10-17

    2.7 released

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks