Convert PySerial to python 3.0
Seth
king.seth at gmail.com
Wed Feb 25 10:07:51 EST 2009
I tried all three ways you guys listed nothing seems to convert the
string to bytes.
It may have to do with the makeDeviceName function, but I can't find
where that is defined.
Any thoughts??
Here is the whole block of code:
if type(port) in (str, bytes): #strings are taken directly
Originally: if type(port) in [type(''), type(u'')]
self.portstr = port
else:
self.portstr = self.makeDeviceName(port)
On Feb 25, 8:47 am, Christian Heimes <li... at cheimes.de> wrote:
> Seth wrote:
> > I implemented "if isinstance(port, str): " that seems to work for now.
>
> > Currently I am running into:
>
> > err, n = win32file.WriteFile(self.hComPort, data,
> > self._overlappedWrite)
> > TypeError: expected an object with a buffer interface
>
> Unicode objects (in Py3k: str) don't implement the buffer interface. You
> have to apply a bytes or bytearray instance.
>
> Christian
More information about the Python-list
mailing list