Skip to content

TST: Testing bug in reading json/msgpack from a non-filepath on windows under py3 (GH5874) #5894

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 9, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Bug Fixes
- Bug in groupby dtype conversion with datetimelike (:issue:`5869`)
- Regresssion in handling of empty Series as indexers to Series (:issue:`5877`)
- Bug in internal caching, related to (:issue:`5727`)
- Testing bug in reading json/msgpack from a non-filepath on windows under py3 (:issue:`5874`)

pandas 0.13.0
-------------
Expand Down
10 changes: 9 additions & 1 deletion pandas/io/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,15 @@ def read_json(path_or_buf=None, orient=None, typ='frame', dtype=True,

filepath_or_buffer, _ = get_filepath_or_buffer(path_or_buf)
if isinstance(filepath_or_buffer, compat.string_types):
if os.path.exists(filepath_or_buffer):
try:
exists = os.path.exists(filepath_or_buffer)

# if the filepath is too long will raise here
# 5874
except (TypeError,ValueError):
exists = False

if exists:
with open(filepath_or_buffer, 'r') as fh:
json = fh.read()
else:
Expand Down
8 changes: 4 additions & 4 deletions pandas/io/packers.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ def read(fh):
if isinstance(path_or_buf, compat.string_types):

try:
path_exists = os.path.exists(path_or_buf)
except (TypeError):
path_exists = False
exists = os.path.exists(path_or_buf)
except (TypeError,ValueError):
exists = False

if path_exists:
if exists:
with open(path_or_buf, 'rb') as fh:
return read(fh)

Expand Down