Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue26754

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:PyUnicode_FSDecoder() accepts arbitrary iterable
Type:behaviorStage:resolved
Components:Interpreter CoreVersions:Python 3.6
process
Status:closedResolution:fixed
Dependencies:26800Superseder:
Assigned To: serhiy.storchakaNosy List: martin.panter, pitrou, pjenvey, python-dev, serhiy.storchaka, vstinner
Priority:normalKeywords:patch

Created on2016-04-14 08:06 byserhiy.storchaka, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
PyUnicode_FSDecoder-no-list.patchserhiy.storchaka,2016-06-11 14:38review
PyUnicode_FSDecoder-deprecate-buffer.patchserhiy.storchaka,2016-06-18 11:45review
Messages (9)
msg263378 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2016-04-14 08:06
PyUnicode_FSDecoder() accepts not only str and bytes or bytes-like object, but arbitrary iterable, e.g. list.Example:>>> compile('', [116, 101, 115, 116], 'exec')<code object <module> at 0xb6fb1340, file "test", line 1>I think accepting arbitrary iterables is unintentional and weird behavior.
msg263388 -(view)Author: Antoine Pitrou (pitrou)*(Python committer)Date: 2016-04-14 09:16
I agree this doens't make sense.
msg263394 -(view)Author: Martin Panter (martin.panter)*(Python committer)Date: 2016-04-14 09:59
I agree it is a bit strange. It looks like it is a victim of PyBytes_FromObject() doing more than it says; its documentation only mentions the buffer protocol, not accepting iterables.
msg263396 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2016-04-14 10:51
PyUnicode_FSDecoder() is used in following functions in the stdlib:compile()symtable.symtable()parser.compile()parser.compilest()zipimporter.zipimporter()_imp.load_dynamic() (before 3.5)This is behavior of PyUnicode_FSDecoder() from the start (issue9542). All above functions accepted only str in 3.1, thus accepting bytes object and others was new feature.None tests are failed if reject non-str and non-bytes argument in PyUnicode_FSDecoder(). But none tests are failed even if disable support of bytes argument (there is a lack of tests for bytes path).What should we do?1. Add a warning when the argument neither str nor supporting the buffer protocol.2. Drop support of non-str and not supporting the buffer protocol arguments without a warning.3. Drop support of non-str and not supporting the buffer protocol arguments without a warning, and add a warning when the argument neither str nor bytes.4. Drop support of non-str and non-bytes arguments without a warning.
msg263695 -(view)Author: Philip Jenvey (pjenvey)*(Python committer)Date: 2016-04-18 21:36
Seeissue26800 for reasoning to go with #4
msg268213 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2016-06-11 14:38
Proposed patch makes PyUnicode_FSDecoder() rejecting arbitrary iterables.
msg268795 -(view)Author: Roundup Robot (python-dev)(Python triager)Date: 2016-06-18 10:56
New changeset2e48c2c4c733 by Serhiy Storchaka in branch '3.5':Issue#26754: PyUnicode_FSDecoder() accepted a filename argument encoded ashttps://hg.python.org/cpython/rev/2e48c2c4c733New changesete18ac7370113 by Serhiy Storchaka in branch 'default':Issue#26754: PyUnicode_FSDecoder() accepted a filename argument encoded ashttps://hg.python.org/cpython/rev/e18ac7370113
msg268798 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2016-06-18 11:45
Following patch deprecates the support of bytes-like objects (except bytes itself) in PyUnicode_FSDecoder() for consistency withissue26800.
msg272107 -(view)Author: Roundup Robot (python-dev)(Python triager)Date: 2016-08-06 20:29
New changeset818f22f9ab02 by Serhiy Storchaka in branch 'default':Issue#26754: Undocumented support of general bytes-like objectshttps://hg.python.org/cpython/rev/818f22f9ab02
History
DateUserActionArgs
2022-04-11 14:58:29adminsetgithub: 70941
2016-08-14 06:30:31serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2016-08-06 20:29:49python-devsetmessages: +msg272107
2016-06-18 11:45:35serhiy.storchakasetfiles: +PyUnicode_FSDecoder-deprecate-buffer.patch

dependencies: +Don't accept bytearray as filenames part 2
messages: +msg268798
versions: - Python 3.5
2016-06-18 10:56:41python-devsetnosy: +python-dev
messages: +msg268795
2016-06-11 14:38:32serhiy.storchakasetfiles: +PyUnicode_FSDecoder-no-list.patch
versions: + Python 3.5
messages: +msg268213

assignee:serhiy.storchaka
keywords: +patch
stage: patch review
2016-04-18 21:36:11pjenveysetnosy: +pjenvey
messages: +msg263695
2016-04-14 10:51:13serhiy.storchakasetnosy: +vstinner
messages: +msg263396
2016-04-14 09:59:54martin.pantersetnosy: +martin.panter
messages: +msg263394
2016-04-14 09:16:05pitrousetnosy: +pitrou
messages: +msg263388
2016-04-14 08:06:10serhiy.storchakacreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp