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: Allow passing Pathlike objects to io.open_code
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.9, Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, hauntsaninja, kmaork, miss-islington, steve.dower
Priority: normal Keywords: patch

Created on 2020-02-19 23:02 by kmaork, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 19824 merged hauntsaninja, 2020-04-30 23:35
PR 19840 merged miss-islington, 2020-05-01 17:57
Messages (4)
msg362292 - (view) Author: Maor Kleinberger (kmaork) * Date: 2020-02-19 23:02
As in many functions in python3, io.open_code should probably accept pathlike objects and not just path strings.

Below is  open_code's docstring:
> Opens the provided file with the intent to import the contents.
> This may perform extra validation beyond open(), but is otherwise interchangeable with calling open(path, 'rb').

The second bit is not entirely true, as open accepts pathlike objects and open_code doesn't.
Fixing this will help solve future bugs and existing bugs like https://bugs.python.org/issue39517

I'd be happy to open a pull request if it is agreed that this should be changed.
msg362522 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2020-02-23 16:54
As per PEP 578 it only accepts absolute path str.

Requires a documentation update to clarify, as this is not the only report. And issue39517 should add a str() call and ensure that the path is absolute.
msg367867 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2020-05-01 17:52
New changeset 831d58d7865cb98fa09227dc614f4f3ce6af968b by Shantanu in branch 'master':
bpo-39691: Clarify io.open_code behavior (GH-19824)
https://github.com/python/cpython/commit/831d58d7865cb98fa09227dc614f4f3ce6af968b
msg367868 - (view) Author: miss-islington (miss-islington) Date: 2020-05-01 18:04
New changeset c9d7d32b6dc6140f7fcbf1ae1120df6d59fc28d0 by Miss Islington (bot) in branch '3.8':
bpo-39691: Clarify io.open_code behavior (GH-19824)
https://github.com/python/cpython/commit/c9d7d32b6dc6140f7fcbf1ae1120df6d59fc28d0
History
Date User Action Args
2022-04-11 14:59:26adminsetgithub: 83872
2020-05-01 18:32:33steve.dowersetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-05-01 18:04:32miss-islingtonsetmessages: + msg367868
2020-05-01 17:57:02miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request19158
2020-05-01 17:52:13steve.dowersetmessages: + msg367867
2020-04-30 23:35:20hauntsaninjasetkeywords: + patch
nosy: + hauntsaninja

pull_requests: + pull_request19145
stage: patch review
2020-02-23 16:55:12steve.dowerlinkissue39723 superseder
2020-02-23 16:54:05steve.dowersetversions: + Python 3.8
nosy: + docs@python, steve.dower

messages: + msg362522

assignee: docs@python
components: + Documentation, - Library (Lib)
2020-02-19 23:02:30kmaorkcreate