Skip to content

Commit 2b422d2

Browse files
committed
TST: Testing bug in reading json/msgpack from a non-filepath on windows under py3 (GH5874)
1 parent caec432 commit 2b422d2

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

doc/source/release.rst

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ Bug Fixes
8383
- Bug in groupby dtype conversion with datetimelike (:issue:`5869`)
8484
- Regresssion in handling of empty Series as indexers to Series (:issue:`5877`)
8585
- Bug in internal caching, related to (:issue:`5727`)
86+
- Testing bug in reading json/msgpack from a non-filepath on windows under py3 (:issue:`5874`)
8687

8788
pandas 0.13.0
8889
-------------

pandas/io/json.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,15 @@ def read_json(path_or_buf=None, orient=None, typ='frame', dtype=True,
173173

174174
filepath_or_buffer, _ = get_filepath_or_buffer(path_or_buf)
175175
if isinstance(filepath_or_buffer, compat.string_types):
176-
if os.path.exists(filepath_or_buffer):
176+
try:
177+
exists = os.path.exists(filepath_or_buffer)
178+
179+
# if the filepath is too long will raise here
180+
# 5874
181+
except (TypeError,ValueError):
182+
exists = False
183+
184+
if exists:
177185
with open(filepath_or_buffer, 'r') as fh:
178186
json = fh.read()
179187
else:

pandas/io/packers.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ def read(fh):
147147
if isinstance(path_or_buf, compat.string_types):
148148

149149
try:
150-
path_exists = os.path.exists(path_or_buf)
151-
except (TypeError):
152-
path_exists = False
150+
exists = os.path.exists(path_or_buf)
151+
except (TypeError,ValueError):
152+
exists = False
153153

154-
if path_exists:
154+
if exists:
155155
with open(path_or_buf, 'rb') as fh:
156156
return read(fh)
157157

0 commit comments

Comments
 (0)