Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue30879

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:os.listdir(bytes) gives a list of bytes, but os.listdir(buffer) gives a list of unicodes
Type:behaviorStage:resolved
Components:Library (Lib)Versions:Python 3.7, Python 3.6, Python 3.5
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To:Nosy List: alex, arigo, serhiy.storchaka
Priority:normalKeywords:

Created on2017-07-08 16:27 byarigo, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Pull Requests
URLStatusLinkedEdit
PR 2634mergedserhiy.storchaka,2017-07-08 17:28
PR 2656mergedserhiy.storchaka,2017-07-11 03:45
PR 2657mergedserhiy.storchaka,2017-07-11 03:52
Messages (7)
msg297960 -(view)Author: Armin Rigo (arigo)*(Python committer)Date: 2017-07-08 16:27
The ``os`` functions generally accept any buffer-supporting object as file names, and interpret it as if ``bytes()`` had been called on it.  However, ``os.listdir(x)`` uses the type of ``x`` to know if it should return a list of bytes or a list of unicodes---and the condition seems to be ``isinstance(x, bytes)``.  So we get this kind of inconsistent behaviour:>>> os.listdir(b".")[b'python', b'Include', b'python-config.py', ...]>>> os.listdir(bytearray(b"."))['python', 'Include', 'python-config.py', ...]
msg297962 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2017-07-08 17:33
Good catch Armin!PR 2634 fixes this inconsistency.Maybe it is worth to deprecate support of other bytes-like object except bytes. open(), os.fspath() and os.path functions don't support them.
msg297963 -(view)Author: Armin Rigo (arigo)*(Python committer)Date: 2017-07-08 18:21
I've also been pointed tohttps://bugs.python.org/issue26800 .
msg297984 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2017-07-09 03:59
Oh, I forgot that this feature already is deprecated!
msg298111 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2017-07-11 03:36
New changeset1180e5a51871fa53ca6892e83fd2e69dc2600447 by Serhiy Storchaka in branch 'master':bpo-30879: os.listdir() and os.scandir() now emit bytes names when (#2634)https://github.com/python/cpython/commit/1180e5a51871fa53ca6892e83fd2e69dc2600447
msg298116 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2017-07-11 04:16
New changesetecfe4f678bfb0e3c19c90fd7db79c5f3c76023e4 by Serhiy Storchaka in branch '3.6':[3.6]bpo-30879: os.listdir() and os.scandir() now emit bytes names when (GH-2634) (#2656)https://github.com/python/cpython/commit/ecfe4f678bfb0e3c19c90fd7db79c5f3c76023e4
msg298118 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2017-07-11 04:43
New changeset7527c32f5fedc3260d767900f1014495c0a1b7a5 by Serhiy Storchaka in branch '3.5':[3.5]bpo-30879: os.listdir() and os.scandir() now emit bytes names when (GH-2634) (#2657)https://github.com/python/cpython/commit/7527c32f5fedc3260d767900f1014495c0a1b7a5
History
DateUserActionArgs
2022-04-11 14:58:48adminsetgithub: 75062
2017-07-11 04:44:12serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2017-07-11 04:43:16serhiy.storchakasetmessages: +msg298118
2017-07-11 04:16:13serhiy.storchakasetmessages: +msg298116
2017-07-11 03:52:49serhiy.storchakasetpull_requests: +pull_request2722
2017-07-11 03:45:18serhiy.storchakasetpull_requests: +pull_request2721
2017-07-11 03:36:48serhiy.storchakasetmessages: +msg298111
2017-07-09 03:59:36serhiy.storchakasetmessages: +msg297984
2017-07-08 18:21:16arigosetmessages: +msg297963
2017-07-08 17:33:56serhiy.storchakasetversions: + Python 3.6
nosy: +serhiy.storchaka

messages: +msg297962

stage: patch review
2017-07-08 17:28:27serhiy.storchakasetpull_requests: +pull_request2699
2017-07-08 16:28:28alexsetnosy: +alex
2017-07-08 16:27:45arigocreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp