
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2016-04-14 08:06 byserhiy.storchaka, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| PyUnicode_FSDecoder-no-list.patch | serhiy.storchaka,2016-06-11 14:38 | review | ||
| PyUnicode_FSDecoder-deprecate-buffer.patch | serhiy.storchaka,2016-06-18 11:45 | review | ||
| Messages (9) | |||
|---|---|---|---|
| msg263378 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | 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)*![]() | Date: 2016-04-14 09:16 | |
I agree this doens't make sense. | |||
| msg263394 -(view) | Author: Martin Panter (martin.panter)*![]() | 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)*![]() | 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)*![]() | Date: 2016-04-18 21:36 | |
Seeissue26800 for reasoning to go with #4 | |||
| msg268213 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2016-06-11 14:38 | |
Proposed patch makes PyUnicode_FSDecoder() rejecting arbitrary iterables. | |||
| msg268795 -(view) | Author: Roundup Robot (python-dev)![]() | 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)*![]() | 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)![]() | 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 | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:29 | admin | set | github: 70941 |
| 2016-08-14 06:30:31 | serhiy.storchaka | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2016-08-06 20:29:49 | python-dev | set | messages: +msg272107 |
| 2016-06-18 11:45:35 | serhiy.storchaka | set | files: +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:41 | python-dev | set | nosy: +python-dev messages: +msg268795 |
| 2016-06-11 14:38:32 | serhiy.storchaka | set | files: +PyUnicode_FSDecoder-no-list.patch versions: + Python 3.5 messages: +msg268213 assignee:serhiy.storchaka keywords: +patch stage: patch review |
| 2016-04-18 21:36:11 | pjenvey | set | nosy: +pjenvey messages: +msg263695 |
| 2016-04-14 10:51:13 | serhiy.storchaka | set | nosy: +vstinner messages: +msg263396 |
| 2016-04-14 09:59:54 | martin.panter | set | nosy: +martin.panter messages: +msg263394 |
| 2016-04-14 09:16:05 | pitrou | set | nosy: +pitrou messages: +msg263388 |
| 2016-04-14 08:06:10 | serhiy.storchaka | create | |