File tree 2 files changed +10
-7
lines changed
2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change 346
346
- Bug in :func:`read_csv` when called with a single-element list ``header`` would return a ``DataFrame`` of all NaN values (:issue:`7757`)
347
347
- Bug in :func:`read_stata` where value labels could not be read when using an iterator (:issue:`16923`)
348
348
- Bug in :func:`read_html` where import check fails when run in multiple threads (:issue:`16928`)
349
+ - Bug in ``pd.read_msgpack()`` with a non existent file is passed in Python 2 (:issue:`15296`)
349
350
350
351
Plotting
351
352
^^^^^^^^
Original file line number Diff line number Diff line change @@ -193,7 +193,6 @@ def read(fh):
193
193
194
194
# see if we have an actual file
195
195
if isinstance (path_or_buf , compat .string_types ):
196
-
197
196
try :
198
197
exists = os .path .exists (path_or_buf )
199
198
except (TypeError , ValueError ):
@@ -203,18 +202,21 @@ def read(fh):
203
202
with open (path_or_buf , 'rb' ) as fh :
204
203
return read (fh )
205
204
206
- # treat as a binary-like
207
205
if isinstance (path_or_buf , compat .binary_type ):
206
+ # treat as a binary-like
208
207
fh = None
209
208
try :
210
- fh = compat .BytesIO (path_or_buf )
211
- return read (fh )
209
+ # We can't distinguish between a path and a buffer of bytes in
210
+ # Python 2 so instead assume the first byte of a valid path is
211
+ # less than 0x80.
212
+ if compat .PY3 or ord (path_or_buf [0 ]) >= 0x80 :
213
+ fh = compat .BytesIO (path_or_buf )
214
+ return read (fh )
212
215
finally :
213
216
if fh is not None :
214
217
fh .close ()
215
-
216
- # a buffer like
217
- if hasattr (path_or_buf , 'read' ) and compat .callable (path_or_buf .read ):
218
+ elif hasattr (path_or_buf , 'read' ) and compat .callable (path_or_buf .read ):
219
+ # treat as a buffer like
218
220
return read (path_or_buf )
219
221
220
222
raise ValueError ('path_or_buf needs to be a string file path or file-like' )
You can’t perform that action at this time.
0 commit comments