Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tp_del and tp_version_tag undocumented #49184

Closed
stutzbach mannequin opened this issue Jan 13, 2009 · 8 comments
Closed

tp_del and tp_version_tag undocumented #49184

stutzbach mannequin opened this issue Jan 13, 2009 · 8 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes docs Documentation in the Doc dir type-feature A feature request or enhancement

Comments

@stutzbach
Copy link
Mannequin

stutzbach mannequin commented Jan 13, 2009

BPO 4934
Nosy @birkenfeld, @ronaldoussoren, @pitrou, @benjaminp

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2018-05-12.18:13:26.429>
created_at = <Date 2009-01-13.17:54:44.691>
labels = ['3.8', 'type-feature', '3.7', 'invalid', 'docs']
title = 'tp_del and tp_version_tag undocumented'
updated_at = <Date 2018-05-12.18:13:26.428>
user = 'https://bugs.python.org/stutzbach'

bugs.python.org fields:

activity = <Date 2018-05-12.18:13:26.428>
actor = 'pitrou'
assignee = 'docs@python'
closed = True
closed_date = <Date 2018-05-12.18:13:26.429>
closer = 'pitrou'
components = ['Documentation']
creation = <Date 2009-01-13.17:54:44.691>
creator = 'stutzbach'
dependencies = []
files = []
hgrepos = []
issue_num = 4934
keywords = []
message_count = 8.0
messages = ['79755', '112148', '180383', '180474', '187450', '316433', '316434', '316435']
nosy_count = 9.0
nosy_names = ['georg.brandl', 'ronaldoussoren', 'gagern', 'pitrou', 'benjamin.peterson', 'stutzbach', 'docs@python', 'Alex.Leach', 'book book']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue4934'
versions = ['Python 3.6', 'Python 3.7', 'Python 3.8']

@stutzbach
Copy link
Mannequin Author

stutzbach mannequin commented Jan 13, 2009

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.

@stutzbach stutzbach mannequin assigned birkenfeld Jan 13, 2009
@stutzbach stutzbach mannequin added the docs Documentation in the Doc dir label Jan 13, 2009
@BreamoreBoy BreamoreBoy mannequin assigned docspython and unassigned birkenfeld Jul 31, 2010
@pitrou
Copy link
Member

pitrou commented Jul 31, 2010

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.

@ronaldoussoren
Copy link
Contributor

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.

@ezio-melotti ezio-melotti added the type-feature A feature request or enhancement label Jan 22, 2013
@pitrou
Copy link
Member

pitrou commented Jan 23, 2013

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".

@AlexLeach
Copy link
Mannequin

AlexLeach mannequin commented Apr 20, 2013

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

@bookbook
Copy link
Mannequin

bookbook mannequin commented May 12, 2018

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.

@pitrou
Copy link
Member

pitrou commented May 12, 2018

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).

@pitrou pitrou added 3.7 (EOL) end of life 3.8 only security fixes labels May 12, 2018
@pitrou
Copy link
Member

pitrou commented May 12, 2018

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.

@pitrou pitrou closed this as completed May 12, 2018
@pitrou pitrou added the invalid label May 12, 2018
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.7 (EOL) end of life 3.8 only security fixes docs Documentation in the Doc dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

4 participants