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
b2953fa3
Commit
b2953fa3
authored
Oct 04, 2018
by
Serhiy Storchaka
Committed by
GitHub
Oct 04, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-34739: Get rid of tp_getattro in xml.etree.ElementTree.XMLParser. (GH-9420)
Use tp_members and tp_getset instead.
parent
65ed12cb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
24 deletions
+19
-24
Modules/_elementtree.c
Modules/_elementtree.c
+19
-24
No files found.
Modules/_elementtree.c
View file @
b2953fa3
...
...
@@ -3685,30 +3685,25 @@ _elementtree_XMLParser__setevents_impl(XMLParserObject *self,
Py_RETURN_NONE
;
}
static
PyObject
*
xmlparser_getattro
(
XMLParserObject
*
self
,
PyObject
*
nameobj
)
{
if
(
PyUnicode_Check
(
nameobj
))
{
PyObject
*
res
;
if
(
_PyUnicode_EqualToASCIIString
(
nameobj
,
"entity"
))
res
=
self
->
entity
;
else
if
(
_PyUnicode_EqualToASCIIString
(
nameobj
,
"target"
))
res
=
self
->
target
;
else
if
(
_PyUnicode_EqualToASCIIString
(
nameobj
,
"version"
))
{
return
PyUnicode_FromFormat
(
"Expat %d.%d.%d"
,
XML_MAJOR_VERSION
,
XML_MINOR_VERSION
,
XML_MICRO_VERSION
);
}
else
goto
generic
;
static
PyMemberDef
xmlparser_members
[]
=
{
{
"entity"
,
T_OBJECT
,
offsetof
(
XMLParserObject
,
entity
),
READONLY
,
NULL
},
{
"target"
,
T_OBJECT
,
offsetof
(
XMLParserObject
,
target
),
READONLY
,
NULL
},
{
NULL
}
};
Py_INCREF
(
res
);
return
res
;
}
generic:
return
PyObject_GenericGetAttr
((
PyObject
*
)
self
,
nameobj
);
static
PyObject
*
xmlparser_version_getter
(
XMLParserObject
*
self
,
void
*
closure
)
{
return
PyUnicode_FromFormat
(
"Expat %d.%d.%d"
,
XML_MAJOR_VERSION
,
XML_MINOR_VERSION
,
XML_MICRO_VERSION
);
}
static
PyGetSetDef
xmlparser_getsetlist
[]
=
{
{
"version"
,
(
getter
)
xmlparser_version_getter
,
NULL
,
NULL
},
{
NULL
},
};
#include "clinic/_elementtree.c.h"
static
PyMethodDef
element_methods
[]
=
{
...
...
@@ -3890,7 +3885,7 @@ static PyTypeObject XMLParser_Type = {
0
,
/* tp_hash */
0
,
/* tp_call */
0
,
/* tp_str */
(
getattrofunc
)
xmlparser_getattro
,
/* tp_getattro */
0
,
/* tp_getattro */
0
,
/* tp_setattro */
0
,
/* tp_as_buffer */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_BASETYPE
|
Py_TPFLAGS_HAVE_GC
,
...
...
@@ -3903,8 +3898,8 @@ static PyTypeObject XMLParser_Type = {
0
,
/* tp_iter */
0
,
/* tp_iternext */
xmlparser_methods
,
/* tp_methods */
0
,
/* tp_members */
0
,
/* tp_getset */
xmlparser_members
,
/* tp_members */
xmlparser_getsetlist
,
/* tp_getset */
0
,
/* tp_base */
0
,
/* tp_dict */
0
,
/* tp_descr_get */
...
...
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