test for stream-ness in Py 3/Py 2 compatible manner
This commit is contained in:
committed by
Matvey Adzhigirey
parent
9ebc76bcdc
commit
91925bb920
@@ -23,7 +23,8 @@ def open_file_for_reading(filename):
|
||||
the object is just passed through (the stream is attempted to be
|
||||
reset to the beginning with ``fseek(0)``).
|
||||
"""
|
||||
if hasattr(filename, 'next') and hasattr(filename, 'read') \
|
||||
if (hasattr(filename, 'next') or hasattr(filename, '__next__')) \
|
||||
and hasattr(filename, 'read') \
|
||||
and hasattr(filename, 'readline') and hasattr(filename, 'readlines') \
|
||||
and hasattr(filename, 'close'):
|
||||
# already a stream
|
||||
|
||||
Reference in New Issue
Block a user