pyserial ser.write('string') TypeError in OS X

Rodrigo rodrigososa at gmail.com
Tue Oct 20 17:02:03 EDT 2009


Maybe this is not a bug at all, but i have installed python2.5. 3.01
and 3.1.1. In python 2.5 ser. write('this is a string') works just
fine.
On the other hand, with 3.01 and 3.1.1 (pyserial 2.5 rc1) when i do a
ser.write('this is a string') i get the following error"

>>> import serial
>>> ser = serial.Serial('/dev/tty.usbserial')
>>> ser.write('this is a string')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.1/lib/
python3.1/site-packages/serial/serialposix.py", line 466, in write
    raise TypeError('expected %s or bytearray, got %s' % (bytes, type
(data)))
TypeError: expected <class 'bytes'> or bytearray, got <class 'str'>

I honestly dont get what im doing wrong here

any feedback much appreciated

regards
r



More information about the Python-list mailing list