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
0bbdbddb
Commit
0bbdbddb
authored
Oct 02, 2010
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
type.__abstractmethods__ should raise an AttributeError #10006
parent
2247911d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
2 deletions
+14
-2
Lib/test/test_abc.py
Lib/test/test_abc.py
+7
-0
Misc/NEWS
Misc/NEWS
+2
-0
Objects/typeobject.c
Objects/typeobject.c
+5
-2
No files found.
Lib/test/test_abc.py
View file @
0bbdbddb
...
...
@@ -98,6 +98,13 @@ class TestABC(unittest.TestCase):
self
.
assertRaises
(
TypeError
,
F
)
# because bar is abstract now
self
.
assertTrue
(
isabstract
(
F
))
def
test_type_has_no_abstractmethods
(
self
):
# type pretends not to have __abstractmethods__.
self
.
assertRaises
(
AttributeError
,
getattr
,
type
,
"__abstractmethods__"
)
class
meta
(
type
):
pass
self
.
assertRaises
(
AttributeError
,
getattr
,
meta
,
"__abstractmethods__"
)
def
test_registration_basics
(
self
):
class
A
(
metaclass
=
abc
.
ABCMeta
):
pass
...
...
Misc/NEWS
View file @
0bbdbddb
...
...
@@ -10,6 +10,8 @@ What's New in Python 3.2 Alpha 3?
Core and Builtins
-----------------
- Issue #10006: type.__abstractmethods__ now raises an AttributeError.
- Issue #10003: Allow handling of SIGBREAK on Windows. Fixes a regression
introduced by issue #9324.
...
...
Objects/typeobject.c
View file @
0bbdbddb
...
...
@@ -320,8 +320,11 @@ type_set_module(PyTypeObject *type, PyObject *value, void *context)
static
PyObject
*
type_abstractmethods
(
PyTypeObject
*
type
,
void
*
context
)
{
PyObject
*
mod
=
PyDict_GetItemString
(
type
->
tp_dict
,
"__abstractmethods__"
);
PyObject
*
mod
=
NULL
;
/* type its self has an __abstractmethods__ descriptor (this). Don't
return that. */
if
(
type
!=
&
PyType_Type
)
mod
=
PyDict_GetItemString
(
type
->
tp_dict
,
"__abstractmethods__"
);
if
(
!
mod
)
{
PyErr_Format
(
PyExc_AttributeError
,
"__abstractmethods__"
);
return
NULL
;
...
...
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