Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
2a87dd4d
Commit
2a87dd4d
authored
Oct 07, 2016
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #18287: PyType_Ready() now checks that tp_name is not NULL.
Original patch by Niklas Koep.
parent
41868cfb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
2 deletions
+15
-2
Doc/c-api/typeobj.rst
Doc/c-api/typeobj.rst
+2
-1
Doc/extending/newtypes.rst
Doc/extending/newtypes.rst
+3
-1
Misc/ACKS
Misc/ACKS
+1
-0
Misc/NEWS
Misc/NEWS
+3
-0
Objects/typeobject.c
Objects/typeobject.c
+6
-0
No files found.
Doc/c-api/typeobj.rst
View file @
2a87dd4d
...
...
@@ -116,7 +116,8 @@ type objects) *must* have the :attr:`ob_size` field.
If no dot is present, the entire :c:member:`~PyTypeObject.tp_name` field is made accessible as the
:attr:`~definition.__name__` attribute, and the :attr:`__module__` attribute is undefined
(unless explicitly set in the dictionary, as explained above). This means your
type will be impossible to pickle.
type will be impossible to pickle. Additionally, it will not be listed in
module documentations created with pydoc.
This field is not inherited by subtypes.
...
...
Doc/extending/newtypes.rst
View file @
2a87dd4d
...
...
@@ -129,7 +129,9 @@ our objects and in some error messages, for example::
Note that the name is a dotted name that includes both the module name and the
name of the type within the module. The module in this case is :mod:`noddy` and
the type is :class:`Noddy`, so we set the type name to :class:`noddy.Noddy`. ::
the type is :class:`Noddy`, so we set the type name to :class:`noddy.Noddy`.
One side effect of using an undotted name is that the pydoc documentation tool
will not list the new type in the module documentation. ::
sizeof(noddy_NoddyObject), /* tp_basicsize */
...
...
Misc/ACKS
View file @
2a87dd4d
...
...
@@ -775,6 +775,7 @@ Jeff Knupp
Kubilay Kocak
Greg Kochanski
Manvisha Kodali
Niklas Koep
Damon Kohler
Marko Kohtala
Vajrasky Kok
...
...
Misc/NEWS
View file @
2a87dd4d
...
...
@@ -10,6 +10,9 @@ Release date: TBA
Core and Builtins
-----------------
- Issue #18287: PyType_Ready() now checks that tp_name is not NULL.
Original patch by Niklas Koep.
- Issue #24098: Fixed possible crash when AST is changed in process of
compiling it.
...
...
Objects/typeobject.c
View file @
2a87dd4d
...
...
@@ -4820,6 +4820,12 @@ PyType_Ready(PyTypeObject *type)
_Py_AddToAllObjects
((
PyObject
*
)
type
,
0
);
#endif
if
(
type
->
tp_name
==
NULL
)
{
PyErr_Format
(
PyExc_SystemError
,
"Type does not define the tp_name field."
);
goto
error
;
}
/* Initialize tp_base (defaults to BaseObject unless that's us) */
base
=
type
->
tp_base
;
if
(
base
==
NULL
&&
type
!=
&
PyBaseObject_Type
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment