Opened 3 years ago

Closed 2 years ago

#23859 closed defect (fixed)

stem parse_file doesn't handle stdin

Reported by: teor Owned by: atagar
Priority: Medium Milestone:
Component: Archived/Stem Version:
Severity: Normal Keywords: descriptor easy
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:


The code looks like:

from sys import stdin

from stem.descriptor import parse_file

new_micro_digests = set()

for desc in parse_file(stdin, validate = True):

The stack trace looks like:

$ cat 2017-10-14-17-05-00-micro | ./
Traceback (most recent call last):
  File "./", line 9, in <module>
    for desc in parse_file(stdin, validate = True):
  File "/Users/dev/stem/stem/descriptor/", line 196, in parse_file
    initial_position = descriptor_file.tell()
IOError: [Errno 29] Illegal seek

Child Tickets

Change History (2)

comment:1 Changed 2 years ago by atagar

Keywords: descriptor easy added

comment:2 Changed 2 years ago by atagar

Resolution: fixed
Status: newclosed

Thanks teor. Looked into this for a while but seems we can't safely convert non-seekable streams like stdin into buffered streams. Adjusted the exception to hopefully provide a more helpful message. See the commit message for all the details.

Feel free to reopen if there's a better way for us to handle this.

Note: See TracTickets for help on using tickets.