#36 pyserial.readline got unexpected keyword 'size'

pending
Chris Liechti
None
5
2011-08-04
2010-09-12
John E. A.
No

Hi,

Thanks for pyserial! I use it cross platform routinely.

After a recent upgrade from 2.4 to 2.5 I get the following error from readline:

Traceback (most recent call last):
File "./temptest.py", line 30, in <module>
line = ser.readline(size=None, eol='\x03') # read a ETX terminated line
TypeError: readline() got an unexpected keyword argument 'size'

Perhaps there's a change to the API. However the class API docs still report readline as expecting size and eol as paramters.

I downgraded to maintain operation of installations here. The affected systems are running archlinux.

Thanks again! Please contact me if I can provide further details...

johnea

Discussion

  • Chris Liechti
    Chris Liechti
    2011-03-19

    Starting from pySerial 2.5 it is using the io module as base (when available, which it is starting from Python 2.6). the readline from io unfortunately has a different signature (no eol parameter and apparently a different name for the 1st parameter).

     
  • Chris Liechti
    Chris Liechti
    2011-03-19

    • status: open --> pending
     
  • John E. A.
    John E. A.
    2011-03-19

    • status: pending --> open
     
  • John E. A.
    John E. A.
    2011-03-19

    Thanks for looking at this!

    For us the eol specification is critical.

    The strings come from an embedded system which uses no nul termination, instead encapsulated strings arive like so: <STX>some text string<ETX>

    We're still using 2.4-2 and the lack of eol support will prevent us from migrating to the 2.5 versions.

     
  • Michael Hipp
    Michael Hipp
    2011-04-30

    I'm getting a similar error:
    line = self.ser.readline(eol='\r')
    TypeError: readline() takes no keyword arguments

    Is there any way to get back the 'eol' keyword argument? I've had to revert to 2.4 for the time being. Is it possible to use the 'FileLike' variant, the docs don't say much about it and I don't see any examples of its use. Thanks.

     
  • the eol keyword makes life so much easier, it would be really great to have it back. It makes implementing a wide range of protocols much much easier.

     
  • Chris Liechti
    Chris Liechti
    2011-08-04

    on Python's >= V2.6 pySerial inherits from the io module where the basic readline function calls this parameter 'limit' and does not support a 'eol' parameter (you could use a positional parameter instead of a keyword one to avoid the error about the name).

    To get control for over the eol character, consider using (for text based communications):
    http://docs.python.org/library/io.html#io.TextIOWrapper

     
  • Chris Liechti
    Chris Liechti
    2011-08-04

    • assigned_to: nobody --> cliechti
    • status: open --> pending