Skip to content

Commit

Permalink
Call .decode() only for binary data
Browse files Browse the repository at this point in the history
  • Loading branch information
frenzymadness committed Jun 22, 2020
1 parent 43b7838 commit e626838
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions dateutil/parser/_parser.py
Expand Up @@ -60,14 +60,8 @@ class _timelex(object):
_split_decimal = re.compile("([.,])")

def __init__(self, instream):
if six.PY2:
# In Python 2, we can't duck type properly because unicode has
# a 'decode' function, and we'd be double-decoding
if isinstance(instream, (bytes, bytearray)):
instream = instream.decode()
else:
if getattr(instream, 'decode', None) is not None:
instream = instream.decode()
if isinstance(instream, (bytes, bytearray)):
instream = instream.decode()

if isinstance(instream, text_type):
instream = StringIO(instream)
Expand Down

0 comments on commit e626838

Please sign in to comment.