Skip to content

Commit ca2e5f5

Browse files
committed
check if already bytes before encoding attempt
1 parent 9823b15 commit ca2e5f5

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

pandas_datareader/compat/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ def get_filepath_or_buffer(filepath_or_buffer, encoding=None, compression=None):
5151

5252

5353
def str_to_bytes(s, encoding=None):
54+
if isinstance(s, bytes):
55+
return s
5456
return s.encode(encoding or "ascii")
5557

5658

0 commit comments

Comments
 (0)