Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update capi_version for mypyc tests to 3.8 #18341

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mypyc/lib-rt/pythonsupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ update_bases(PyObject *bases)
}
continue;
}
new_base = _PyObject_Vectorcall(meth, stack, 1, NULL);
new_base = PyObject_Vectorcall(meth, stack, 1, NULL);
Py_DECREF(meth);
if (!new_base) {
goto error;
Expand Down Expand Up @@ -118,7 +118,7 @@ init_subclass(PyTypeObject *type, PyObject *kwds)
PyObject *super, *func, *result;
PyObject *args[2] = {(PyObject *)type, (PyObject *)type};

super = _PyObject_Vectorcall((PyObject *)&PySuper_Type, args, 2, NULL);
super = PyObject_Vectorcall((PyObject *)&PySuper_Type, args, 2, NULL);
if (super == NULL) {
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion mypyc/primitives/generic_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@
object_rprimitive,
], # Keyword arg names tuple (or NULL)
return_type=object_rprimitive,
c_function_name="_PyObject_Vectorcall",
c_function_name="PyObject_Vectorcall",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PyObject_Vectorcall is available unconditionally from pythoncapi_compat.h. Included the underscore removal here so I wouldn't have to do another big PR just for that.

// gh-105922 added PyObject_Vectorcall() to Python 3.9.0a4
#if PY_VERSION_HEX < 0x030900A4
static inline PyObject*
PyObject_Vectorcall(PyObject *callable, PyObject *const *args,
size_t nargsf, PyObject *kwnames)
{
#if PY_VERSION_HEX >= 0x030800B1 && !defined(PYPY_VERSION)
// bpo-36974 added _PyObject_Vectorcall() to Python 3.8.0b1
return _PyObject_Vectorcall(callable, args, nargsf, kwnames);

error_kind=ERR_MAGIC,
)

Expand Down
104 changes: 63 additions & 41 deletions mypyc/test-data/exceptions.test
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,20 @@ def g():
r5 :: str
r6 :: object
r7 :: str
r8, r9 :: object
r10 :: bit
r11 :: None
r8 :: object
r9 :: object[1]
r10 :: object_ptr
r11 :: object
r12 :: bit
r13 :: None
L0:
L1:
r0 = builtins :: module
r1 = 'object'
r2 = CPyObject_GetAttr(r0, r1)
if is_error(r2) goto L3 (error at g:3) else goto L2
L2:
r3 = PyObject_CallFunctionObjArgs(r2, 0)
r3 = PyObject_Vectorcall(r2, 0, 0, 0)
dec_ref r2
if is_error(r3) goto L3 (error at g:3) else goto L10
L3:
Expand All @@ -184,30 +187,32 @@ L3:
r8 = CPyObject_GetAttr(r6, r7)
if is_error(r8) goto L6 (error at g:5) else goto L4
L4:
r9 = PyObject_CallFunctionObjArgs(r8, r5, 0)
r9 = [r5]
r10 = load_address r9
r11 = PyObject_Vectorcall(r8, r10, 1, 0)
dec_ref r8
if is_error(r9) goto L6 (error at g:5) else goto L11
if is_error(r11) goto L6 (error at g:5) else goto L11
L5:
CPy_RestoreExcInfo(r4)
dec_ref r4
goto L8
L6:
CPy_RestoreExcInfo(r4)
dec_ref r4
r10 = CPy_KeepPropagating()
if not r10 goto L9 else goto L7 :: bool
r12 = CPy_KeepPropagating()
if not r12 goto L9 else goto L7 :: bool
L7:
unreachable
L8:
return 1
L9:
r11 = <error> :: None
return r11
r13 = <error> :: None
return r13
L10:
dec_ref r3
goto L8
L11:
dec_ref r9
dec_ref r11
goto L5

[case testGenopsTryFinally]
Expand All @@ -229,17 +234,20 @@ def a():
r10 :: str
r11 :: object
r12 :: str
r13, r14 :: object
r15 :: bit
r16 :: str
r13 :: object
r14 :: object[1]
r15 :: object_ptr
r16 :: object
r17 :: bit
r18 :: str
L0:
L1:
r0 = builtins :: module
r1 = 'print'
r2 = CPyObject_GetAttr(r0, r1)
if is_error(r2) goto L5 (error at a:3) else goto L2
L2:
r3 = PyObject_CallFunctionObjArgs(r2, 0)
r3 = PyObject_Vectorcall(r2, 0, 0, 0)
dec_ref r2
if is_error(r3) goto L5 (error at a:3) else goto L19
L3:
Expand All @@ -262,9 +270,11 @@ L6:
r13 = CPyObject_GetAttr(r11, r12)
if is_error(r13) goto L20 (error at a:6) else goto L7
L7:
r14 = PyObject_CallFunctionObjArgs(r13, r10, 0)
r14 = [r10]
r15 = load_address r14
r16 = PyObject_Vectorcall(r13, r15, 1, 0)
dec_ref r13
if is_error(r14) goto L20 (error at a:6) else goto L21
if is_error(r16) goto L20 (error at a:6) else goto L21
L8:
if is_error(r7) goto L11 else goto L22
L9:
Expand All @@ -282,23 +292,23 @@ L14:
CPy_RestoreExcInfo(r7)
xdec_ref r7
L15:
r15 = CPy_KeepPropagating()
if not r15 goto L18 else goto L16 :: bool
r17 = CPy_KeepPropagating()
if not r17 goto L18 else goto L16 :: bool
L16:
unreachable
L17:
unreachable
L18:
r16 = <error> :: str
return r16
r18 = <error> :: str
return r18
L19:
dec_ref r3
goto L3
L20:
xdec_ref r5
goto L13
L21:
dec_ref r14
dec_ref r16
goto L8
L22:
xdec_ref r5
Expand Down Expand Up @@ -446,59 +456,71 @@ def f(b):
r6 :: str
r7 :: object
r8 :: bool
r9 :: object
r10 :: None
r9 :: object[1]
r10 :: object_ptr
r11 :: object
r12 :: bool
r13 :: None
L0:
r0 = <error> :: str
v = r0
r1 = 'a'
inc_ref r1
u = r1
L1:
if b goto L10 else goto L11 :: bool
if b goto L13 else goto L14 :: bool
L2:
r2 = 'b'
inc_ref r2
v = r2
r3 = v == u
r4 = r3 ^ 1
if r4 goto L11 else goto L1 :: bool
if r4 goto L14 else goto L1 :: bool
L3:
r5 = builtins :: module
r6 = 'print'
r7 = CPyObject_GetAttr(r5, r6)
if is_error(r7) goto L12 (error at f:7) else goto L4
if is_error(r7) goto L15 (error at f:7) else goto L4
L4:
if is_error(v) goto L13 else goto L7
if is_error(v) goto L16 else goto L7
L5:
r8 = raise UnboundLocalError('local variable "v" referenced before assignment')
if not r8 goto L9 (error at f:7) else goto L6 :: bool
if not r8 goto L12 (error at f:-1) else goto L6 :: bool
L6:
unreachable
L7:
r9 = PyObject_CallFunctionObjArgs(r7, v, 0)
r9 = [v]
r10 = load_address r9
r11 = PyObject_Vectorcall(r7, r10, 1, 0)
dec_ref r7
xdec_ref v
if is_error(r9) goto L9 (error at f:7) else goto L14
if is_error(r11) goto L15 (error at f:7) else goto L17
L8:
return 1
if is_error(v) goto L9 else goto L11
L9:
r10 = <error> :: None
return r10
r12 = raise UnboundLocalError('local variable "v" referenced before assignment')
if not r12 goto L12 (error at f:-1) else goto L10 :: bool
L10:
unreachable
L11:
xdec_ref v
return 1
L12:
r13 = <error> :: None
return r13
L13:
xdec_ref v
goto L2
L11:
L14:
dec_ref u
goto L3
L12:
L15:
xdec_ref v
goto L9
L13:
goto L12
L16:
dec_ref r7
goto L5
L14:
dec_ref r9
L17:
dec_ref r11
goto L8

[case testExceptionWithOverlappingErrorValue]
Expand Down
Loading
Loading