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
74a1deaa
Commit
74a1deaa
authored
May 28, 2008
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#2989: add PyType_Modified().
parent
88eeef35
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
12 deletions
+23
-12
Doc/c-api/type.rst
Doc/c-api/type.rst
+10
-1
Include/object.h
Include/object.h
+1
-0
Misc/NEWS
Misc/NEWS
+3
-1
Objects/typeobject.c
Objects/typeobject.c
+9
-10
No files found.
Doc/c-api/type.rst
View file @
74a1deaa
...
...
@@ -37,7 +37,16 @@ Type Objects
.. cfunction:: unsigned int PyType_ClearCache(void)
Clears the internal lookup cache. Return the current version tag.
Clear the internal lookup cache. Return the current version tag.
.. versionadded:: 2.6
.. cfunction:: void PyType_Modified(PyTypeObject *type)
Invalidate the internal lookup cache for the type and all of its
subtypes. This function must be called after any manual
modification of the attributes or base classes of the type.
.. versionadded:: 2.6
...
...
Include/object.h
View file @
74a1deaa
...
...
@@ -460,6 +460,7 @@ PyAPI_FUNC(PyObject *) PyType_GenericNew(PyTypeObject *,
PyObject
*
,
PyObject
*
);
PyAPI_FUNC
(
PyObject
*
)
_PyType_Lookup
(
PyTypeObject
*
,
PyObject
*
);
PyAPI_FUNC
(
unsigned
int
)
PyType_ClearCache
(
void
);
PyAPI_FUNC
(
void
)
PyType_Modified
(
PyTypeObject
*
);
/* Generic operations on objects */
PyAPI_FUNC
(
int
)
PyObject_Print
(
PyObject
*
,
FILE
*
,
int
);
...
...
Misc/NEWS
View file @
74a1deaa
...
...
@@ -239,7 +239,9 @@ Build
C API
-----
- The PyBytes functions have been renamed to PyByteArray
- Add ``PyType_Modified()`` as a public API to clear the type cache.
- The PyBytes functions have been renamed to PyByteArray.
- The PyString functions have been renamed to PyBytes. A batch of
defines were added so that the linker still sees the original
...
...
Objects/typeobject.c
View file @
74a1deaa
...
...
@@ -32,7 +32,6 @@ struct method_cache_entry {
static
struct
method_cache_entry
method_cache
[
1
<<
MCACHE_SIZE_EXP
];
static
unsigned
int
next_version_tag
=
0
;
static
void
type_modified
(
PyTypeObject
*
);
unsigned
int
PyType_ClearCache
(
void
)
...
...
@@ -47,12 +46,12 @@ PyType_ClearCache(void)
}
next_version_tag
=
0
;
/* mark all version tags as invalid */
type_m
odified
(
&
PyBaseObject_Type
);
PyType_M
odified
(
&
PyBaseObject_Type
);
return
cur_version_tag
;
}
static
void
type_m
odified
(
PyTypeObject
*
type
)
void
PyType_M
odified
(
PyTypeObject
*
type
)
{
/* Invalidate any cached data for the specified type and all
subclasses. This function is called after the base
...
...
@@ -86,7 +85,7 @@ type_modified(PyTypeObject *type)
ref
=
PyList_GET_ITEM
(
raw
,
i
);
ref
=
PyWeakref_GET_OBJECT
(
ref
);
if
(
ref
!=
Py_None
)
{
type_m
odified
((
PyTypeObject
*
)
ref
);
PyType_M
odified
((
PyTypeObject
*
)
ref
);
}
}
}
...
...
@@ -172,7 +171,7 @@ assign_version_tag(PyTypeObject *type)
Py_INCREF
(
Py_None
);
}
/* mark all version tags as invalid */
type_m
odified
(
&
PyBaseObject_Type
);
PyType_M
odified
(
&
PyBaseObject_Type
);
return
1
;
}
bases
=
type
->
tp_bases
;
...
...
@@ -300,7 +299,7 @@ type_set_module(PyTypeObject *type, PyObject *value, void *context)
return
-
1
;
}
type_m
odified
(
type
);
PyType_M
odified
(
type
);
return
PyDict_SetItemString
(
type
->
tp_dict
,
"__module__"
,
value
);
}
...
...
@@ -328,7 +327,7 @@ type_set_abstractmethods(PyTypeObject *type, PyObject *value, void *context)
int
res
=
PyDict_SetItemString
(
type
->
tp_dict
,
"__abstractmethods__"
,
value
);
if
(
res
==
0
)
{
type_m
odified
(
type
);
PyType_M
odified
(
type
);
if
(
value
&&
PyObject_IsTrue
(
value
))
{
type
->
tp_flags
|=
Py_TPFLAGS_IS_ABSTRACT
;
}
...
...
@@ -1621,7 +1620,7 @@ mro_internal(PyTypeObject *type)
from the custom MRO */
type_mro_modified
(
type
,
type
->
tp_bases
);
type_m
odified
(
type
);
PyType_M
odified
(
type
);
return
0
;
}
...
...
@@ -6092,7 +6091,7 @@ update_slot(PyTypeObject *type, PyObject *name)
update_subclasses() recursion below, but carefully:
they each have their own conditions on which to stop
recursing into subclasses. */
type_m
odified
(
type
);
PyType_M
odified
(
type
);
init_slotdefs
();
pp
=
ptrs
;
...
...
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