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
871309c7
Commit
871309c7
authored
Mar 26, 2019
by
Inada Naoki
Committed by
Miss Islington (bot)
Mar 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-36433: fix confusing error messages in classmethoddescr_call (GH-12556)
https://bugs.python.org/issue36433
parent
b4d8f28a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
9 deletions
+23
-9
Lib/test/test_descr.py
Lib/test/test_descr.py
+18
-3
Misc/NEWS.d/next/Core and Builtins/2019-03-26-17-23-02.bpo-36433.-8XzZf.rst
...ore and Builtins/2019-03-26-17-23-02.bpo-36433.-8XzZf.rst
+1
-0
Objects/descrobject.c
Objects/descrobject.c
+4
-6
No files found.
Lib/test/test_descr.py
View file @
871309c7
...
...
@@ -1597,12 +1597,27 @@ order (MRO) for bases """
self
.
assertEqual
(
x2
,
SubSpam
)
self
.
assertEqual
(
a2
,
a1
)
self
.
assertEqual
(
d2
,
d1
)
with
self
.
assertRaises
(
TypeError
):
with
self
.
assertRaises
(
TypeError
)
as
cm
:
spam_cm
()
with
self
.
assertRaises
(
TypeError
):
self
.
assertEqual
(
str
(
cm
.
exception
),
"descriptor 'classmeth' of 'xxsubtype.spamlist' "
"object needs an argument"
)
with
self
.
assertRaises
(
TypeError
)
as
cm
:
spam_cm
(
spam
.
spamlist
())
with
self
.
assertRaises
(
TypeError
):
self
.
assertEqual
(
str
(
cm
.
exception
),
"descriptor 'classmeth' requires a type "
"but received a 'xxsubtype.spamlist' instance"
)
with
self
.
assertRaises
(
TypeError
)
as
cm
:
spam_cm
(
list
)
self
.
assertEqual
(
str
(
cm
.
exception
),
"descriptor 'classmeth' requires a subtype of 'xxsubtype.spamlist' "
"but received 'list'"
)
def
test_staticmethods
(
self
):
# Testing static methods...
...
...
Misc/NEWS.d/next/Core and Builtins/2019-03-26-17-23-02.bpo-36433.-8XzZf.rst
0 → 100644
View file @
871309c7
Fixed TypeError message in classmethoddescr_call.
Objects/descrobject.c
View file @
871309c7
...
...
@@ -315,20 +315,18 @@ classmethoddescr_call(PyMethodDescrObject *descr, PyObject *args,
if
(
!
PyType_Check
(
self
))
{
PyErr_Format
(
PyExc_TypeError
,
"descriptor '%V' requires a type "
"but received a '%.100s'"
,
"but received a '%.100s'
instance
"
,
descr_name
((
PyDescrObject
*
)
descr
),
"?"
,
PyDescr_TYPE
(
descr
)
->
tp_name
,
self
->
ob_type
->
tp_name
);
return
NULL
;
}
if
(
!
PyType_IsSubtype
((
PyTypeObject
*
)
self
,
PyDescr_TYPE
(
descr
)))
{
PyErr_Format
(
PyExc_TypeError
,
"descriptor '%V' "
"requires a subtype of '%.100s' "
"but received '%.100s"
,
"descriptor '%V' requires a subtype of '%.100s' "
"but received '%.100s'"
,
descr_name
((
PyDescrObject
*
)
descr
),
"?"
,
PyDescr_TYPE
(
descr
)
->
tp_name
,
self
->
ob_type
->
tp_name
);
((
PyTypeObject
*
)
self
)
->
tp_name
);
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