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: Interning string constants with null character
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.7, Python 3.6, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: benjamin.peterson, brett.cannon, georg.brandl, ncoghlan, python-dev, rhettinger, serhiy.storchaka, vstinner, yselivanov
Priority: normal Keywords: patch

Created on 2016-10-03 19:23 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
all_name_chars.patch serhiy.storchaka, 2016-10-03 19:23 review
Pull Requests
URL Status Linked Edit
PR 552 closed dstufft, 2017-03-31 16:36
Messages (6)
msg277994 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-10-03 19:23
Currently string constants are interned if they consist of ASCII word characters ([0-9A-Za-z_]). But strings are tested only to the first null character. This is not problem for names, since they can't include null characters, but string constants that contains ASCII non-word characters after the null character passes this test.

Proposed simple patch fixes the testing function all_name_chars().

Other question: shouldn't PyUnicode_IsIdentifier() be used in 3.x?
msg277997 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-10-03 19:37
all_name_chars.patch LGTM.
msg278042 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-10-04 14:31
Thanks Victor.
msg278043 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-10-04 14:35
I have no opinion on interning non-ASCII strings.
msg278047 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-10-04 15:25
New changeset 522adc2e082a by Serhiy Storchaka in branch '2.7':
Issue #28350: String constants with null character no longer interned.
https://hg.python.org/cpython/rev/522adc2e082a

New changeset d7ab3241aef2 by Serhiy Storchaka in branch '3.5':
Issue #28350: String constants with null character no longer interned.
https://hg.python.org/cpython/rev/d7ab3241aef2

New changeset 8585b4de4fc0 by Serhiy Storchaka in branch '3.6':
Issue #28350: String constants with null character no longer interned.
https://hg.python.org/cpython/rev/8585b4de4fc0

New changeset 563d523036c6 by Serhiy Storchaka in branch 'default':
Issue #28350: String constants with null character no longer interned.
https://hg.python.org/cpython/rev/563d523036c6
msg278049 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-10-04 15:27
Added tests and refactored all_name_chars().
History
Date User Action Args
2022-04-11 14:58:37adminsetgithub: 72536
2017-03-31 16:36:09dstufftsetpull_requests: + pull_request853
2016-10-04 15:27:43serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg278049

stage: patch review -> resolved
2016-10-04 15:25:19python-devsetnosy: + python-dev
messages: + msg278047
2016-10-04 14:35:29vstinnersetmessages: + msg278043
2016-10-04 14:31:53serhiy.storchakasetassignee: serhiy.storchaka
messages: + msg278042
2016-10-03 19:37:14vstinnersetnosy: + vstinner
messages: + msg277997
2016-10-03 19:23:36serhiy.storchakacreate