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.

Title: _elementtree: missing PyType_Ready call
Type: behavior Stage: resolved
Components: Extension Modules, XML Versions: Python 3.3, Python 3.4
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ronaldoussoren Nosy List: christian.heimes, eli.bendersky, python-dev, ronaldoussoren
Priority: normal Keywords: patch

Created on 2013-07-17 12:54 by ronaldoussoren, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit
elementtree-missing-type-ready.txt ronaldoussoren, 2013-07-17 12:54 review
elementtree-missing-type-ready-with-forwards.txt ronaldoussoren, 2013-07-17 13:30 review
Messages (5)
msg193226 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2013-07-17 12:54
The _elementtree extension calls PyType_Ready for most, but not all, types defined in the extension. The attached patch calls PyType_Ready for the ElementIter_Type.
msg193227 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2013-07-17 13:16
Good catch!

ElementIter_Type has no prototype, too.

$ grep Type Modules/_elementtree.c  | grep static
static PyTypeObject Element_Type;
static PyTypeObject Element_Type = {
static PyTypeObject ElementIter_Type = {
static PyTypeObject TreeBuilder_Type;
static PyTypeObject TreeBuilder_Type = {
static PyTypeObject XMLParser_Type;
static PyTypeObject XMLParser_Type = {

How about you move the prototypes for all four types to the head of the file? For example the ssl.c module declares all types up front. It makes it more clear which types are defined by the module.
msg193228 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2013-07-17 13:30
It was a pretty easy catch, the _elementtree caused a crash while I was working on an implementation for PEP 447.  The missing call to PyType_Ready helped to make that implementation more robust :-)

I'm not entirely convinced that adding forward declarations for the type is really useful, but have added a patch that moves the forward declarations to the start of the file and adds one for the iter type.
msg193345 - (view) Author: Eli Bendersky (eli.bendersky) * (Python committer) Date: 2013-07-19 01:44
LGTM, thanks.
msg193351 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-07-19 09:14
New changeset cd4c9d4bd88f by Ronald Oussoren in branch '3.3':
#18480: Add missing PyType_Ready call to _elementtree extension

New changeset 7362722646f7 by Ronald Oussoren in branch 'default':
(3.3->default): #18480: Add missing PyType_Ready call to _elementtree extension
Date User Action Args
2022-04-11 14:57:48adminsetgithub: 62680
2013-07-19 09:14:53ronaldoussorensetkeywords: - needs review
status: open -> closed
resolution: fixed
stage: patch review -> resolved
2013-07-19 09:14:23python-devsetnosy: + python-dev
messages: + msg193351
2013-07-19 08:05:05ronaldoussorensetassignee: ronaldoussoren
2013-07-19 01:44:57eli.benderskysetmessages: + msg193345
2013-07-17 13:30:24ronaldoussorensetfiles: + elementtree-missing-type-ready-with-forwards.txt

messages: + msg193228
2013-07-17 13:20:32serhiy.storchakasetnosy: + eli.bendersky
2013-07-17 13:16:45christian.heimessetnosy: + christian.heimes
messages: + msg193227
2013-07-17 12:55:21ronaldoussorensetkeywords: + patch, needs review
2013-07-17 12:54:58ronaldoussorencreate