Menu

#184 Getting PySerial 2.7 working under Windows Python 3.4

v2.7
closed
None
5
2015-08-04
2015-05-01
No

To get the latest PySerial 2.7 running under Windows Python 3.4, I had to do the following:

(1) Remove trailing L from integers in win32.py (i.e. PEP 237)
#192 GENERIC_WRITE
#196 MAXDWORD
#216 INFINITE

(2) Converted ',' syntax to 'as' syntax (required in Python 3.x, I believe) in serialutil.py
#535 except TypeError, err --> except TypeError as err

(3) Added hack as per https://github.com/oxplot/fysom/issues/1 to the top of serialutil.py to get round the use of 'basestring' (which is deprecated in Python 3.x)

try:
unicode = unicode
except NameError:
# 'unicode' is undefined, must be Python 3
str = str
unicode = str
bytes = bytes
basestring = (str,bytes)
else:
# 'unicode' exists, must be Python 2
str = str
unicode = unicode
bytes = str
basestring = basestring

Obviously it would be better if this hack was added to the code, or (better still) the code could be refactored so as not to use basestring (the quick hack worked, so I didn't feel the need to look any further, but I thought I'd mention it).

Cheers!

Discussion

  • Nick Pelling

    Nick Pelling - 2015-05-01

    Sorry about the lost formatting, I thought (wrongly) that I could edit it after posting. :-(

     
  • Chris Liechti

    Chris Liechti - 2015-08-04

    The 3.x series (https://github.com/pyserial/pyserial) will support Python 3 natively.

    For the 2.x series, you need to use "python3 setup.py install" where it invokes 2to3.py to convert the mentioned items.

     
  • Chris Liechti

    Chris Liechti - 2015-08-04
    • status: open --> closed
    • Group: v1.0 (example) --> v2.7
     

Log in to post a comment.