Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue35942

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:posixmodule.c:path_converter() returns an invalid exception message for broken PathLike objects
Type:behaviorStage:resolved
Components:Versions:Python 3.8, Python 3.7
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To:Nosy List: lukasz.langa, miss-islington, pablogsal, serhiy.storchaka
Priority:normalKeywords:patch

Created on2019-02-08 16:34 bylukasz.langa, last changed2022-04-11 14:59 byadmin. This issue is nowclosed.

Pull Requests
URLStatusLinkedEdit
PR 11831mergedpablogsal,2019-02-12 22:40
PR 11912mergedmiss-islington,2019-02-18 10:46
PR 11934mergedserhiy.storchaka,2019-02-19 11:23
PR 11932mergedserhiy.storchaka,2019-02-19 11:50
PR 11937mergedmiss-islington,2019-02-19 11:55
Messages (6)
msg335094 -(view)Author: Łukasz Langa (lukasz.langa)*(Python committer)Date: 2019-02-08 16:34
>>> class K:...   def __fspath__(self):...     return 1...>>> import os>>> os.stat(K())Traceback (most recent call last):  File "<stdin>", line 1, in <module>TypeError: stat: path should be string, bytes, os.PathLike or integer, not intThis error message is internally inconsistent:- it suggests that the error is about the path argument whereas it's in fact about the value returned from `__fspath__()`- it hilariously states "should be integer, not int"- it claims os.PathLike is fine as a return value from `__fspath__()` whereas it's notI would advise removing the custom `__fspath__()` handling from `path_converter` and just directly using PyOS_FSPath which returns a valid error in this case (example from pypy3):>>>> class K:....   def __fspath__(self):....     return 1....>>>> import os>>>> os.open(K(), os.O_RDONLY)Traceback (most recent call last):  File "<stdin>", line 1, in <module>TypeError: expected K.__fspath__() to return str or bytes, not int
msg335756 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2019-02-17 06:39
The custom `__fspath__()` handling is used in `path_converter` for better error reporting. The error message can include names of the function and the argument. PyOS_FSPath() can not provides this information.I agree that error reporting about incorrect type of the __fspath__() result should be improved.
msg335804 -(view)Author: Pablo Galindo Salgado (pablogsal)*(Python committer)Date: 2019-02-18 10:46
New changeset09fbcd6085e18b534fd4161844ff39f77eb4a082 by Pablo Galindo in branch 'master':bpo-35942: Improve the error message if __fspath__ returns invalid types in path_converter (GH-11831)https://github.com/python/cpython/commit/09fbcd6085e18b534fd4161844ff39f77eb4a082
msg335809 -(view)Author: miss-islington (miss-islington)Date: 2019-02-18 11:05
New changeseta01065a3588d3f0d0c57ea35107aa97e722fe2b2 by Miss Islington (bot) in branch '3.7':bpo-35942: Improve the error message if __fspath__ returns invalid types in path_converter (GH-11831)https://github.com/python/cpython/commit/a01065a3588d3f0d0c57ea35107aa97e722fe2b2
msg335935 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2019-02-19 11:52
New changeset8d01eb49fc7ff914feeb2e2090d1d6ef15c932ab by Serhiy Storchaka in branch 'master':Fix syntax warnings in tests introduced inbpo-35942. (GH-11934)https://github.com/python/cpython/commit/8d01eb49fc7ff914feeb2e2090d1d6ef15c932ab
msg335939 -(view)Author: miss-islington (miss-islington)Date: 2019-02-19 12:16
New changeseta8834905df853510f38d4e2d628bed8229fd7482 by Miss Islington (bot) in branch '3.7':Fix syntax warnings in tests introduced inbpo-35942. (GH-11934)https://github.com/python/cpython/commit/a8834905df853510f38d4e2d628bed8229fd7482
History
DateUserActionArgs
2022-04-11 14:59:11adminsetgithub: 80123
2019-02-19 12:16:41miss-islingtonsetmessages: +msg335939
2019-02-19 11:55:22miss-islingtonsetpull_requests: +pull_request11962
2019-02-19 11:52:37serhiy.storchakasetmessages: +msg335935
2019-02-19 11:50:38serhiy.storchakasetpull_requests: +pull_request11961
2019-02-19 11:24:56serhiy.storchakasetpull_requests: -pull_request11956
2019-02-19 11:23:24serhiy.storchakasetpull_requests: +pull_request11958
2019-02-19 11:08:26serhiy.storchakasetpull_requests: +pull_request11956
2019-02-18 11:38:39pablogsalsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-02-18 11:05:55miss-islingtonsetnosy: +miss-islington
messages: +msg335809
2019-02-18 10:46:48miss-islingtonsetpull_requests: +pull_request11938
2019-02-18 10:46:48pablogsalsetnosy: +pablogsal
messages: +msg335804
2019-02-17 06:39:18serhiy.storchakasetnosy: +serhiy.storchaka
messages: +msg335756
2019-02-12 22:40:57pablogsalsetkeywords: +patch
stage: needs patch -> patch review
pull_requests: +pull_request11862
2019-02-08 16:34:39lukasz.langacreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp