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
4c3acf2c
Commit
4c3acf2c
authored
Sep 01, 2012
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make super() internal errors RuntimeError instead of SystemError (closes #15839)
parent
69675401
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
7 deletions
+24
-7
Lib/test/test_super.py
Lib/test/test_super.py
+15
-0
Misc/NEWS
Misc/NEWS
+2
-0
Objects/typeobject.c
Objects/typeobject.c
+7
-7
No files found.
Lib/test/test_super.py
View file @
4c3acf2c
...
...
@@ -115,6 +115,21 @@ class TestSuper(unittest.TestCase):
return
__class__
self
.
assertIs
(
X
.
f
(),
X
)
def
test_obscure_super_errors
(
self
):
def
f
():
super
()
self
.
assertRaises
(
RuntimeError
,
f
)
def
f
(
x
):
del
x
super
()
self
.
assertRaises
(
RuntimeError
,
f
,
None
)
class
X
:
def
f
(
x
):
nonlocal
__class__
del
__class__
super
()
self
.
assertRaises
(
RuntimeError
,
X
().
f
)
def
test_main
():
support
.
run_unittest
(
TestSuper
)
...
...
Misc/NEWS
View file @
4c3acf2c
...
...
@@ -10,6 +10,8 @@ What's New in Python 3.3.1
Core and Builtins
-----------------
- Issue #15839: Convert SystemErrors in super() to RuntimeErrors.
- Issue #15801: Make sure mappings passed to '
%
' formatting are actually
subscriptable.
...
...
Objects/typeobject.c
View file @
4c3acf2c
...
...
@@ -6497,18 +6497,18 @@ super_init(PyObject *self, PyObject *args, PyObject *kwds)
PyCodeObject
*
co
=
f
->
f_code
;
Py_ssize_t
i
,
n
;
if
(
co
==
NULL
)
{
PyErr_SetString
(
PyExc_
System
Error
,
PyErr_SetString
(
PyExc_
Runtime
Error
,
"super(): no code object"
);
return
-
1
;
}
if
(
co
->
co_argcount
==
0
)
{
PyErr_SetString
(
PyExc_
System
Error
,
PyErr_SetString
(
PyExc_
Runtime
Error
,
"super(): no arguments"
);
return
-
1
;
}
obj
=
f
->
f_localsplus
[
0
];
if
(
obj
==
NULL
)
{
PyErr_SetString
(
PyExc_
System
Error
,
PyErr_SetString
(
PyExc_
Runtime
Error
,
"super(): arg[0] deleted"
);
return
-
1
;
}
...
...
@@ -6527,18 +6527,18 @@ super_init(PyObject *self, PyObject *args, PyObject *kwds)
PyTuple_GET_SIZE
(
co
->
co_cellvars
)
+
i
;
PyObject
*
cell
=
f
->
f_localsplus
[
index
];
if
(
cell
==
NULL
||
!
PyCell_Check
(
cell
))
{
PyErr_SetString
(
PyExc_
System
Error
,
PyErr_SetString
(
PyExc_
Runtime
Error
,
"super(): bad __class__ cell"
);
return
-
1
;
}
type
=
(
PyTypeObject
*
)
PyCell_GET
(
cell
);
if
(
type
==
NULL
)
{
PyErr_SetString
(
PyExc_
System
Error
,
PyErr_SetString
(
PyExc_
Runtime
Error
,
"super(): empty __class__ cell"
);
return
-
1
;
}
if
(
!
PyType_Check
(
type
))
{
PyErr_Format
(
PyExc_
System
Error
,
PyErr_Format
(
PyExc_
Runtime
Error
,
"super(): __class__ is not a type (%s)"
,
Py_TYPE
(
type
)
->
tp_name
);
return
-
1
;
...
...
@@ -6547,7 +6547,7 @@ super_init(PyObject *self, PyObject *args, PyObject *kwds)
}
}
if
(
type
==
NULL
)
{
PyErr_SetString
(
PyExc_
System
Error
,
PyErr_SetString
(
PyExc_
Runtime
Error
,
"super(): __class__ cell not found"
);
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