#36 pyserial.readline got unexpected keyword 'size'

v1.0 (example)
John E. A.


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...



  • 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.

  • Hans-Christoph Steiner

    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):

  • Chris Liechti

    Chris Liechti - 2011-08-04
    • assigned_to: nobody --> cliechti
    • status: open --> pending
  • Chris Liechti

    Chris Liechti - 2014-08-04
    • status: pending --> closed
    • Group: --> v1.0 (example)

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