Issue25961
Created on 2015-12-27 14:28 by serhiy.storchaka, last changed 2015-12-31 10:08 by python-dev. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| type_name_null.patch | serhiy.storchaka, 2015-12-27 17:52 | review | ||
| type_name_null_fix.patch | florin.papa, 2015-12-31 08:46 | review | ||
| Messages (7) | |||
|---|---|---|---|
| msg257076 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * | 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 bytes
But 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) * | 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() + 0
Traceback (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) | Date: 2015-12-30 19:42 | |
New changeset 29cc6b2f9d28 by Serhiy Storchaka in branch '2.7': Issue #25961: Disallowed null characters in the type name. https://hg.python.org/cpython/rev/29cc6b2f9d28 New changeset d2417971c934 by Serhiy Storchaka in branch '3.5': Issue #25961: Disallowed null characters in the type name. https://hg.python.org/cpython/rev/d2417971c934 New changeset 1ab7bcd4e176 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 in Objects/typeobject.c. Please see the attached patch. Regards, Florin Papa |
|||
| msg257251 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * | 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) | Date: 2015-12-31 10:08 | |
New changeset 57fea6f75ac2 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 | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2015-12-31 10:08:15 | python-dev | set | messages: + msg257252 |
| 2015-12-31 10:07:29 | serhiy.storchaka | set | messages: + msg257251 |
| 2015-12-31 08:46:27 | florin.papa | set | files:
+ type_name_null_fix.patch nosy: + florin.papa messages: + msg257250 |
| 2015-12-30 19:43:35 | serhiy.storchaka | set | status: open -> closed assignee: serhiy.storchaka resolution: fixed stage: patch review -> resolved |
| 2015-12-30 19:42:18 | python-dev | set | nosy:
+ python-dev messages: + msg257236 |
| 2015-12-29 14:39:49 | serhiy.storchaka | set | messages: + msg257191 |
| 2015-12-29 14:21:26 | ppperry | set | nosy:
+ ppperry messages: + msg257189 |
| 2015-12-27 17:52:11 | serhiy.storchaka | set | files:
+ type_name_null.patch keywords: + patch stage: needs patch -> patch review |
| 2015-12-27 14:28:00 | serhiy.storchaka | create | |