This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add support to load from paths to json.load
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.8
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: DaniFojo, ezio.melotti, methane, rhettinger, xtreak
Priority: normal Keywords: patch

Created on 2019-03-20 08:44 by DaniFojo, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 12465 closed python-dev, 2019-03-20 08:49
Messages (3)
msg338442 - (view) Author: Dani Fojo (DaniFojo) * Date: 2019-03-20 08:44
Add support to json.load to read from a string or Path object containing the path to a json file. Many libraries (like Numpy) support this behavior.
msg338448 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-03-20 10:02
This expands the API where json.load now only accepts open file objects to support str and pathlike objects. This was discussed in https://mail.python.org/pipermail/python-ideas/2017-March/045303.html where there were alternatives proposed as below : 

with path.open() as f: obj = json.load(f)

some_path.write_text(json.dumps(obj), encoding='utf8')
json.loads(some_path.read_text(encoding='utf8'))

Also supporting str and pathlib passes responsibility to json.load to open them and also close them properly? I think this needs a python-ideas discussion if the proposal has something to add other than the previous thread where many alternatives were mentioned for terse code.
msg339974 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2019-04-11 13:45
I close this because PR is closed already, and same idea
was discussed on -ideas ML.
History
Date User Action Args
2022-04-11 14:59:12adminsetgithub: 80559
2019-07-18 06:18:56serhiy.storchakalinkissue37615 superseder
2019-04-11 13:45:33methanesetstatus: open -> closed

nosy: + methane
messages: + msg339974

resolution: rejected
stage: patch review -> resolved
2019-03-20 10:02:10xtreaksetmessages: + msg338448
2019-03-20 09:07:28xtreaksetnosy: + xtreak
2019-03-20 08:49:21python-devsetkeywords: + patch
stage: patch review
pull_requests: + pull_request12417
2019-03-20 08:47:20SilentGhostsetnosy: + rhettinger, ezio.melotti
2019-03-20 08:44:18DaniFojocreate