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
a8b27e62
Commit
a8b27e62
authored
Jun 24, 2019
by
Jeroen Demeyer
Committed by
Petr Viktorin
Jun 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-36974: inherit tp_vectorcall_offset unconditionally (GH-13858)
parent
47fbc4e4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
7 deletions
+18
-7
Lib/test/test_call.py
Lib/test/test_call.py
+9
-0
Misc/NEWS.d/next/Core and Builtins/2019-06-06-11-00-55.bpo-36974.wdzzym.rst
...ore and Builtins/2019-06-06-11-00-55.bpo-36974.wdzzym.rst
+2
-0
Objects/call.c
Objects/call.c
+1
-1
Objects/typeobject.c
Objects/typeobject.c
+6
-6
No files found.
Lib/test/test_call.py
View file @
a8b27e62
...
...
@@ -577,9 +577,18 @@ class TestPEP590(unittest.TestCase):
def __call__(self, n):
return 'new'
class SuperBase:
def __call__(self, *args):
return super().__call__(*args)
class MethodDescriptorSuper(SuperBase, _testcapi.MethodDescriptorBase):
def __call__(self, *args):
return super().__call__(*args)
calls += [
(MethodDescriptorHeap(), (0,), {}, True),
(MethodDescriptorOverridden(), (0,), {}, 'new'),
(MethodDescriptorSuper(), (0,), {}, True),
]
for (func, args, kwargs, expected) in calls:
...
...
Misc/NEWS.d/next/Core and Builtins/2019-06-06-11-00-55.bpo-36974.wdzzym.rst
0 → 100644
View file @
a8b27e62
The slot ``tp_vectorcall_offset`` is inherited unconditionally to support
``super().__call__()`` when the base class uses vectorcall.
Objects/call.c
View file @
a8b27e62
...
...
@@ -184,7 +184,7 @@ PyVectorcall_Call(PyObject *callable, PyObject *tuple, PyObject *kwargs)
/* get vectorcallfunc as in _PyVectorcall_Function, but without
* the _Py_TPFLAGS_HAVE_VECTORCALL check */
Py_ssize_t
offset
=
Py_TYPE
(
callable
)
->
tp_vectorcall_offset
;
if
(
(
offset
<=
0
)
||
(
!
Py_TYPE
(
callable
)
->
tp_call
)
)
{
if
(
offset
<=
0
)
{
PyErr_Format
(
PyExc_TypeError
,
"'%.200s' object does not support vectorcall"
,
Py_TYPE
(
callable
)
->
tp_name
);
return
NULL
;
...
...
Objects/typeobject.c
View file @
a8b27e62
...
...
@@ -5153,15 +5153,15 @@ inherit_slots(PyTypeObject *type, PyTypeObject *base)
COPYSLOT
(
tp_repr
);
/* tp_hash see tp_richcompare */
{
/* Inherit tp_vectorcall_offset only if tp_call is not overridden */
if
(
!
type
->
tp_call
)
{
COPYSLOT
(
tp_vectorcall_offset
);
}
/* Inherit_Py_TPFLAGS_HAVE_VECTORCALL for non-heap types
/* Always inherit tp_vectorcall_offset to support PyVectorcall_Call().
* If _Py_TPFLAGS_HAVE_VECTORCALL is not inherited, then vectorcall
* won't be used automatically. */
COPYSLOT
(
tp_vectorcall_offset
);
/* Inherit _Py_TPFLAGS_HAVE_VECTORCALL for non-heap types
* if tp_call is not overridden */
if
(
!
type
->
tp_call
&&
(
base
->
tp_flags
&
_Py_TPFLAGS_HAVE_VECTORCALL
)
&&
!
(
type
->
tp_flags
&
_Py_TPFLAGS_HAVE_VECTORCALL
)
&&
!
(
type
->
tp_flags
&
Py_TPFLAGS_HEAPTYPE
))
{
type
->
tp_flags
|=
_Py_TPFLAGS_HAVE_VECTORCALL
;
...
...
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