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
14db1b4a
Commit
14db1b4a
authored
Nov 06, 2013
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #19512: type_abstractmethods() and type_set_abstractmethods() now use an
identifier for the "__abstractmethods__" string
parent
9153f8d3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
5 deletions
+10
-5
Objects/typeobject.c
Objects/typeobject.c
+10
-5
No files found.
Objects/typeobject.c
View file @
14db1b4a
...
...
@@ -48,6 +48,7 @@ _Py_IDENTIFIER(__hash__);
_Py_IDENTIFIER
(
__module__
);
_Py_IDENTIFIER
(
__name__
);
_Py_IDENTIFIER
(
__new__
);
_Py_IDENTIFIER
(
__abstractmethods__
);
static
PyObject
*
slot_tp_new
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwds
);
...
...
@@ -383,9 +384,11 @@ type_abstractmethods(PyTypeObject *type, void *context)
/* type itself has an __abstractmethods__ descriptor (this). Don't return
that. */
if
(
type
!=
&
PyType_Type
)
mod
=
PyDict_GetItemString
(
type
->
tp_dict
,
"__abstractmethods__"
);
mod
=
_PyDict_GetItemId
(
type
->
tp_dict
,
&
PyId___abstractmethods__
);
if
(
!
mod
)
{
PyErr_SetString
(
PyExc_AttributeError
,
"__abstractmethods__"
);
PyObject
*
message
=
_PyUnicode_FromId
(
&
PyId___abstractmethods__
);
if
(
message
)
PyErr_SetObject
(
PyExc_AttributeError
,
message
);
return
NULL
;
}
Py_XINCREF
(
mod
);
...
...
@@ -404,13 +407,15 @@ type_set_abstractmethods(PyTypeObject *type, PyObject *value, void *context)
abstract
=
PyObject_IsTrue
(
value
);
if
(
abstract
<
0
)
return
-
1
;
res
=
PyDict_SetItemString
(
type
->
tp_dict
,
"__abstractmethods__"
,
value
);
res
=
_PyDict_SetItemId
(
type
->
tp_dict
,
&
PyId___abstractmethods__
,
value
);
}
else
{
abstract
=
0
;
res
=
PyDict_DelItemString
(
type
->
tp_dict
,
"__abstractmethods__"
);
res
=
_PyDict_DelItemId
(
type
->
tp_dict
,
&
PyId___abstractmethods__
);
if
(
res
&&
PyErr_ExceptionMatches
(
PyExc_KeyError
))
{
PyErr_SetString
(
PyExc_AttributeError
,
"__abstractmethods__"
);
PyObject
*
message
=
_PyUnicode_FromId
(
&
PyId___abstractmethods__
);
if
(
message
)
PyErr_SetObject
(
PyExc_AttributeError
,
message
);
return
-
1
;
}
}
...
...
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