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: tp_del and tp_version_tag undocumented
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.8, Python 3.7, Python 3.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Alex.Leach, benjamin.peterson, book book, docs@python, gagern, georg.brandl, pitrou, ronaldoussoren, stutzbach
Priority: normal Keywords:

Created on 2009-01-13 17:54 by stutzbach, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (8)
msg79755 - (view) Author: Daniel Stutzbach (stutzbach) (Python committer) Date: 2009-01-13 17:54
The PyTypeObject field "tp_version_tag" (new in 2.6) isn't documented.

"tp_del" isn't documented either.  I'm not sure when it was added.
msg112148 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-07-31 12:23
I think the reason tp_del isn't documented is that, as we somehow learnt it with the new IO code, it isn't really meant for third-party types.
I would suggest checking with python-dev.

As for tp_version_tag, it's for internal use (it indicated whether the method cache is still fresh), I don't think extension authors should modify it.
msg180383 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2013-01-22 13:00
tp_cache and tp_weaklist are also for internal use only, but are documented.

One reason for documenting them is that users will run into them when running with a high enough warning level in GCC.
msg180474 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-01-23 16:59
> tp_cache and tp_weaklist are also for internal use only, but are
> documented.

Ok, so I guess tp_version_tag and tp_del should also be documented as "for internal use only".
msg187450 - (view) Author: Alex Leach (Alex.Leach) Date: 2013-04-20 18:32
I've just ran into tp_version_tag, when running the boost python testsuite and wondered what it was... Since upgrading to GCC 4.8, I've started to get a lot more warnings with Python extensions, e.g.:-

boost/python/opaque_pointer_converter.hpp:122:14: warning: missing initializer for member ‘_typeobject::tp_version_tag’ [-Wmissing-field-initializers]

In this instance the testsuite was made to compile with the '-Wextra' flag. The fix was pretty simple; add another zero to the opaque_pointer_convert struct.

I have used the following preprocessor macro to test whether or not to do this. Would this be a good way to test for the addition?

#if PY_VERSION_HEX >= 0x02060000
  0,    /* tp_version_tag */
#endif

Cheers,
Alex
msg316433 - (view) Author: book book (book book) Date: 2018-05-12 18:09
tp_del still undocumented.

In my opinion, tp_del corresponds to the __del__() method of classes, because there are no other variable correspondes to it, but methods using for creating(tp_new) and initializing(tp_init) an object are not.

Although __del__ method have some issue according to the offical document, but it is exist, so there must have a pointer to the function corresponding to it.
msg316434 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2018-05-12 18:12
The reason tp_del has remained undocumented is that it's now obsolete.  You should use tp_finalize instead:
https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_finalize

tp_finalize is roughly the C equivalent of __del__ (tp_del was something else, despite the name).
msg316435 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2018-05-12 18:13
Both tp_del and tp_version_tag are for internal use.  Besides, tp_del is obsolete as I mentioned above.  So I'm going to close the issue.
History
Date User Action Args
2022-04-11 14:56:44adminsetgithub: 49184
2018-05-12 18:13:26pitrousetstatus: open -> closed
resolution: not a bug
messages: + msg316435

stage: resolved
2018-05-12 18:12:40pitrousetmessages: + msg316434
versions: + Python 3.7, Python 3.8
2018-05-12 18:09:03book booksetnosy: + book book

messages: + msg316433
versions: + Python 3.6, - Python 2.6, Python 2.7, Python 3.2, Python 3.3, Python 3.4
2013-04-20 18:32:39Alex.Leachsetnosy: + Alex.Leach
messages: + msg187450
2013-01-23 16:59:21pitrousetmessages: + msg180474
2013-01-22 13:04:25ezio.melottisettype: enhancement
versions: + Python 3.3, Python 3.4, - Python 3.1
2013-01-22 13:00:40ronaldoussorensetnosy: + ronaldoussoren
messages: + msg180383
2011-05-19 08:25:09gagernsetnosy: + gagern
2010-07-31 12:24:20pitrousetnosy: + benjamin.peterson
2010-07-31 12:23:38pitrousetnosy: + pitrou
messages: + msg112148
2010-07-31 11:37:07BreamoreBoysetassignee: georg.brandl -> docs@python

nosy: + docs@python
versions: + Python 3.2, - Python 3.0
2009-01-13 17:54:44stutzbachcreate