Tracker: Bugs

5 Can't change line ending type with RawIOBase derived Serial - ID: 3426131
Last Update: Comment added ( cliechti )

As it noted in the documentation, with sufficiently new python versions the Serial class will inherit from RawIOBase. The readline implementation of RawIOBase does not allow the eol keyword argument to be passed, instead deriving its line ending from the newline keyword argument passed to the constructor. Unfortunately, the Serial constructor does not have a newline keyword argument. This is a severe regression.

While the RawIOBase approach is acceptable for some cases, it is convenient to be able to choose delimiters on a case-by-case basis when working with many serial devices. For this reason, it would be nice if a readuntil function were implemented in the Serial class, allowing one to easily read until some delimiting sequence (e.g. the old behavior of readline).


https://www.google.com/accounts ( https://www.google.com/accounts ) - 2011-10-19 15:30:58 PDT

5

Pending

Rejected

Nobody/Anonymous

None

None

Public


Comment ( 1 )

Date: 2011-11-01 18:01:48 PDT
Sender: cliechtiProject Admin

looking for lines implies that it is a text based protocol. in that case
the encoding should also be considered.

the io module provides filter classes that cope with both problems: eg.
io.TextIOWrapper translates a raw stream (such as pySerial's port) to a
text based stream including EOL handling.

see also test/test_iolib.py

Regarding eol keyword for the Serial class:
As I see it, it is in line with other classes provided by the io module.
RawIO streams do not have an eol or newline parameter (e.g. see io.FileIO)
and the eol character for the readline functions of raw streams is always
'\n'. pySerials Serial class is a RawIO stream and therefore behaves as
expected.



Attached File

No Files Currently Attached

Changes ( 3 )

Field Old Value Date By
status_id Open 2011-11-01 18:01:48 PDT cliechti
resolution_id None 2011-11-01 18:01:48 PDT cliechti
close_date - 2011-11-01 18:01:48 PDT cliechti