Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue25961

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:Disallow the null character in type name
Type:behaviorStage:resolved
Components:Interpreter CoreVersions:Python 3.6, Python 3.5, Python 2.7
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To: serhiy.storchakaNosy List: florin.papa, ppperry, python-dev, serhiy.storchaka
Priority:normalKeywords:patch

Created on2015-12-27 14:28 byserhiy.storchaka, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
type_name_null.patchserhiy.storchaka,2015-12-27 17:52review
type_name_null_fix.patchflorin.papa,2015-12-31 08:46review
Messages (7)
msg257076 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2015-12-27 14:28
The null character is allowed in __name__ setter (but error message is a little confusing).>>> class A: pass... >>> A.__name__ = 'B\0'Traceback (most recent call last):  File "<stdin>", line 1, in <module>ValueError: __name__ must not contain null bytesBut is allowed in type constructor.>>> t = type('B\0C', (), {})>>> t<class '__main__.BC'>>>> t.__name__'B\x00C'
msg257189 -(view)Author: (ppperry)Date: 2015-12-29 14:21
Why are null bytes being excluded from type names in the first place?
msg257191 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2015-12-29 14:39
Because tp_name is a pointer to null-terminated C string and there is no way to distinguish the name containg the null byte from the name terminated by null byte. tp_name is used for example in error messages.>>> t = type('B\0C', (), {})>>> t.__name__'B\x00C'>>> t() + 0Traceback (most recent call last):  File "<stdin>", line 1, in <module>TypeError: unsupported operand type(s) for +: 'B' and 'int'
msg257236 -(view)Author: Roundup Robot (python-dev)(Python triager)Date: 2015-12-30 19:42
New changeset29cc6b2f9d28 by Serhiy Storchaka in branch '2.7':Issue#25961: Disallowed null characters in the type name.https://hg.python.org/cpython/rev/29cc6b2f9d28New changesetd2417971c934 by Serhiy Storchaka in branch '3.5':Issue#25961: Disallowed null characters in the type name.https://hg.python.org/cpython/rev/d2417971c934New changeset1ab7bcd4e176 by Serhiy Storchaka in branch 'default':Issue#25961: Disallowed null characters in the type name.https://hg.python.org/cpython/rev/1ab7bcd4e176
msg257250 -(view)Author: Florin Papa (florin.papa)*Date: 2015-12-31 08:46
Hi all,I fixed a compile error introduced in Python 2.7 by this issue. There is a jump made to an nonexistent label "error" in type_new function inObjects/typeobject.c. Please see the attached patch.Regards,Florin Papa
msg257251 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2015-12-31 10:07
Thank you Florin. How could I miss this?But your patch is not correct. It leads to double free and deallocating using non-initialized pointer. It also contains trailing spaces and incorrect indentation.
msg257252 -(view)Author: Roundup Robot (python-dev)(Python triager)Date: 2015-12-31 10:08
New changeset57fea6f75ac2 by Serhiy Storchaka in branch '2.7':Issue#25961: Fixed compilation error and a leak in type constructor.https://hg.python.org/cpython/rev/57fea6f75ac2
History
DateUserActionArgs
2022-04-11 14:58:25adminsetgithub: 70149
2015-12-31 10:08:15python-devsetmessages: +msg257252
2015-12-31 10:07:29serhiy.storchakasetmessages: +msg257251
2015-12-31 08:46:27florin.papasetfiles: +type_name_null_fix.patch
nosy: +florin.papa
messages: +msg257250

2015-12-30 19:43:35serhiy.storchakasetstatus: open -> closed
assignee:serhiy.storchaka
resolution: fixed
stage: patch review -> resolved
2015-12-30 19:42:18python-devsetnosy: +python-dev
messages: +msg257236
2015-12-29 14:39:49serhiy.storchakasetmessages: +msg257191
2015-12-29 14:21:26ppperrysetnosy: +ppperry
messages: +msg257189
2015-12-27 17:52:11serhiy.storchakasetfiles: +type_name_null.patch
keywords: +patch
stage: needs patch -> patch review
2015-12-27 14:28:00serhiy.storchakacreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp