pypy/module/cpyext/test/test_typeobject.py::AppTestSlots::()::test_multiple_inheritance3
self = <CallInfo when='call' exception: Subprocess failed with exit code 1:
Traceback (most recent call last):
File "d:\py...oft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.41.34120\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
>
func = <function <lambda> at 0x000001f1bfa1e728>, when = 'call'
def __init__(self, func, when):
#: context of invocation: one of "setup", "call",
#: "teardown", "memocollect"
self.when = when
self.start = time()
try:
> self.result = func()
..\_pytest\runner.py:150:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> return CallInfo(lambda: ihook(item=item, **kwds), when=when)
..\_pytest\runner.py:138:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <_HookCaller 'pytest_runtest_call'>
kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_multiple_inheritance3'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_multiple_inheritance3'>}
def __call__(self, **kwargs):
assert not self.is_historic()
> return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
..\_pytest\vendored_packages\pluggy.py:724:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <_pytest.config.PytestPluginManager object at 0x000001f1bbb5e8e0>
hook = <_HookCaller 'pytest_runtest_call'>, methods = []
kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_multiple_inheritance3'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_multiple_inheritance3'>}
def _hookexec(self, hook, methods, kwargs):
# called from all hookcaller instances.
# enable_tracing will set its own wrapping function at self._inner_hookexec
> return self._inner_hookexec(hook, methods, kwargs)
..\_pytest\vendored_packages\pluggy.py:338:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
hook = <_HookCaller 'pytest_runtest_call'>, methods = []
kwargs = {'__multicall__': <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_multiple_inheritance3'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>, 'item': <AppTestMethod 'test_multiple_inheritance3'>}
self._inner_hookexec = lambda hook, methods, kwargs: \
> _MultiCall(methods, kwargs, hook.spec_opts).execute()
..\_pytest\vendored_packages\pluggy.py:333:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_multiple_inheritance3'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>
def execute(self):
all_kwargs = self.kwargs
self.results = results = []
firstresult = self.specopts.get("firstresult")
while self.hook_impls:
hook_impl = self.hook_impls.pop()
args = [all_kwargs[argname] for argname in hook_impl.argnames]
if hook_impl.hookwrapper:
> return _wrapped_call(hook_impl.function(*args), self.execute)
..\_pytest\vendored_packages\pluggy.py:595:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
wrap_controller = <generator object pytest_runtest_call at 0x000001f1bf63e188>
func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...heritance3'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>>
def _wrapped_call(wrap_controller, func):
""" Wrap calling to a function with a generator which needs to yield
exactly once. The yield point will trigger calling the wrapped function
and return its _CallOutcome to the yield point. The generator then needs
to finish (raise StopIteration) in order for the wrapped call to complete.
"""
try:
next(wrap_controller) # first yield
except StopIteration:
_raise_wrapfail(wrap_controller, "did not yield")
call_outcome = _CallOutcome(func)
try:
wrap_controller.send(call_outcome)
_raise_wrapfail(wrap_controller, "has second yield")
except StopIteration:
pass
> return call_outcome.get_result()
..\_pytest\vendored_packages\pluggy.py:253:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0x000001f1c0f68060>
def get_result(self):
if self.excinfo is None:
return self.result
else:
ex = self.excinfo
if _py3:
raise ex[1].with_traceback(ex[2])
> _reraise(*ex) # noqa
..\_pytest\vendored_packages\pluggy.py:279:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <_pytest.vendored_packages.pluggy._CallOutcome instance at 0x000001f1c0f68060>
func = <bound method _MultiCall.execute of <_MultiCall 0 results, 0 meths, kwargs={'i...heritance3'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>>
def __init__(self, func):
try:
> self.result = func()
..\_pytest\vendored_packages\pluggy.py:264:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <_MultiCall 0 results, 0 meths, kwargs={'item': <AppTestMethod 'test_multiple_inheritance3'>, '__multicall__': <_MultiCall 0 results, 0 meths, kwargs={...}>}>
def execute(self):
all_kwargs = self.kwargs
self.results = results = []
firstresult = self.specopts.get("firstresult")
while self.hook_impls:
hook_impl = self.hook_impls.pop()
args = [all_kwargs[argname] for argname in hook_impl.argnames]
if hook_impl.hookwrapper:
return _wrapped_call(hook_impl.function(*args), self.execute)
> res = hook_impl.function(*args)
..\_pytest\vendored_packages\pluggy.py:596:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
item = <AppTestMethod 'test_multiple_inheritance3'>
def pytest_runtest_call(item):
try:
> item.runtest()
..\_pytest\runner.py:91:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <AppTestMethod 'test_multiple_inheritance3'>
def runtest(self):
target = self.obj
src = extract_docstring_if_empty_function(target.im_func)
space = target.im_self.space
if self.config.option.runappdirect:
appexec_definitions = self.parent.obj.__dict__
spaceconfig = getattr(self.parent.obj, 'spaceconfig', None)
usemodules = spaceconfig.get('usemodules') if spaceconfig else None
return run_with_python(self.config.option.python, src, usemodules,
> **appexec_definitions)
tool\pytest\apptest.py:341:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
python_ = 'd:\\pypy_stuff\\buildbot64\\slave\\pypy-c-jit-win-x86-64\\build\\pypy\\goal\\pypy3.11-c.exe'
target_ = <function test_multiple_inheritance3 at 0x000001f1c163a200>
usemodules = ['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', ...]
definitions = {'_check_type_object': <pypy.interpreter.gateway.interp2app object at 0x000001f1bf66f6a8>, 'compile_module': <bound me...1991ef8>>, 'here': u'd:\\pypy_stuff\\buildbot64\\slave\\pypy-c-jit-win-x86-64\\build\\pypy\\module\\cpyext\\test', ...}
defs = ['def w_compile_module(self, name,\n source_files=None, source_strings=None):\n from extbuild import get_sys...e=prologue,\n include_dirs=include_dirs, more_init=more_init,\n PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)', ...]
symbol = 'udir', value = u'd:\\systemtemp\\pytest\\usession-py3.11-1235'
code = <py._code.code.Code object at 0x000001f1c1991f30>
def run_with_python(python_, target_, usemodules, **definitions):
if python_ is None:
py.test.skip("Cannot find the default python3 interpreter to run with -A")
defs = []
for symbol, value in sorted(definitions.items()):
if isinstance(value, tuple) and isinstance(value[0], py.code.Source):
code, args = value
defs.append(str(code))
arg_repr = []
for arg in args:
if isinstance(arg, types.FunctionType):
arg_repr.append(arg.__name__)
elif isinstance(arg, types.MethodType):
arg_repr.append(arg.__name__)
else:
arg_repr.append(py3k_repr(arg))
args = ', '.join(arg_repr)
defs.append("self.%s = anonymous(%s)\n" % (symbol, args))
elif isinstance(value, types.MethodType):
# "def w_method(self)"
code = py.code.Code(value)
defs.append(str(code.source()))
defs.append("type(self).%s = %s\n" % (symbol, value.__name__))
elif isinstance(value, types.ModuleType):
name = value.__name__
defs.append("import %s; self.%s = %s\n" % (name, symbol, name))
elif isinstance(value, (str, unicode, int, long, float, list, tuple,
dict)) or value is None:
defs.append("self.%s = %s\n" % (symbol, py3k_repr(value)))
check_usemodules = ''
if usemodules:
usemodules = [_rename_module(name) for name in usemodules]
check_usemodules = """\
missing = set(%r).difference(sys.builtin_module_names)
if missing:
if not hasattr(sys, 'pypy_version_info'):
# They may be extension modules on CPython
name = None
for name in missing.copy():
if name in ['cpyext', '_cffi_backend', '_rawffi']:
missing.remove(name)
continue
try:
__import__(name)
except ImportError:
pass
else:
missing.remove(name)
del name
if missing:
sys.exit(81)
del missing""" % usemodules
source = list(py.code.Source(target_))
while source[0].startswith(('@py.test.mark.', '@pytest.mark.')):
source.pop(0)
source = source[1:]
pyfile = udir.join('src.py')
if isinstance(target_, str):
# Special case of a docstring; the function name is the first word.
target_name = target_.split('(', 1)[0]
else:
target_name = target_.__name__
with pyfile.open('w') as f:
f.write(helpers % (pypyroot, check_usemodules))
f.write('\n'.join(defs))
f.write('def %s():\n' % target_name)
f.write('\n'.join(source))
f.write("\ntry:\n %s()\n" % target_name)
f.write('finally:\n print("===aefwuiheawiu===")')
helper_dir = os.path.join(pypydir, 'tool', 'cpyext')
env = os.environ.copy()
env['PYTHONPATH'] = helper_dir
res, stdout, stderr = run_subprocess(
python_, [str(pyfile)], env=env)
print pyfile.read()
print "from", str(pyfile)
print >> sys.stdout, stdout
print >> sys.stderr, stderr
if res == 81:
py.test.skip('%r was not compiled w/ required usemodules: %r' %
(python_, usemodules))
elif res != 0:
raise AssertionError(
> "Subprocess failed with exit code %s:\n%s" % (res, stderr))
E AssertionError: Subprocess failed with exit code 1:
E Traceback (most recent call last):
E File "d:\pypy_stuff\buildbot64\slave\pypy-c-jit-win-x86-64\build\Lib\site-packages\setuptools\_distutils\spawn.py", line 87, in spawn
E subprocess.check_call(cmd, env=_inject_macos_ver(env))
E ^^^^^^^^^^
E File "d:\pypy_stuff\buildbot64\slave\pypy-c-jit-win-x86-64\build\lib-python\3\subprocess.py", line 413, in check_call
E raise CalledProcessError(retcode, cmd)
E subprocess.CalledProcessError: Command '['d:\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.41.34120\\bin\\HostX86\\x64\\cl.exe', '/we4013', '/std:c11', '/c', '/nologo', '/O2', '/W3', '/GL', '/DNDEBUG', '/MD', '-Id:\\pypy_stuff\\buildbot64\\slave\\pypy-c-jit-win-x86-64\\build\\include', '-Id:\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.41.34120\\include', '-Id:\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.41.34120\\ATLMFC\\include', '-Id:\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\VS\\include', '-IC:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.20348.0\\ucrt', '-IC:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.20348.0\\\\um', '-IC:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.20348.0\\\\shared', '-IC:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.20348.0\\\\winrt', '-IC:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.20348.0\\\\cppwinrt', '-Id:\\pypy_stuff\\buildbot64\\slave\\pypy-c-jit-win-x86-64\\build\\externals\\include', '/Tcsource_0.c', '/Fosource_0.obj']' returned non-zero exit status 2.
E
E The above exception was the direct cause of the following exception:
E
E Traceback (most recent call last):
E File "d:\pypy_stuff\buildbot64\slave\pypy-c-jit-win-x86-64\build\Lib\site-packages\setuptools\_distutils\compilers\C\msvc.py", line 460, in compile
E self.spawn(args)
E ^^^^^
E File "d:\pypy_stuff\buildbot64\slave\pypy-c-jit-win-x86-64\build\Lib\site-packages\setuptools\_distutils\compilers\C\msvc.py", line 563, in spawn
E return super().spawn(cmd, env=env)
E ^^^^^
E File "d:\pypy_stuff\buildbot64\slave\pypy-c-jit-win-x86-64\build\Lib\site-packages\setuptools\_distutils\compilers\C\base.py", line 1158, in spawn
E spawn(cmd, dry_run=self.dry_run, **kwargs)
E File "d:\pypy_stuff\buildbot64\slave\pypy-c-jit-win-x86-64\build\Lib\site-packages\setuptools\_distutils\spawn.py", line 93, in spawn
E raise DistutilsExecError(
E distutils.errors.DistutilsExecError: command 'd:\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.41.34120\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
E
E During handling of the above exception, another exception occurred:
E
E Traceback (most recent call last):
E File "d:\systemtemp\pytest\usession-py3.11-1235\src.py", line 313, in <module>
E test_multiple_inheritance3()
E File "d:\systemtemp\pytest\usession-py3.11-1235\src.py", line 121, in test_multiple_inheritance3
E module = self.import_extension('foo', [
E ^^^^^^^^^^^^^^^^
E File "d:\systemtemp\pytest\usession-py3.11-1235\src.py", line 95, in w_import_extension
E return sys_info.import_extension(
E ^^^^^^^^^^^^^^^^
E File "d:\pypy_stuff\buildbot64\slave\pypy-c-jit-win-x86-64\build\pypy\tool\cpyext\extbuild.py", line 96, in import_extension
E return self.import_module(
E ^^^^^^^^^^^^^
E File "d:\pypy_stuff\buildbot64\slave\pypy-c-jit-win-x86-64\build\pypy\tool\cpyext\extbuild.py", line 82, in import_module
E mod = self.compile_extension_module(
E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E File "d:\pypy_stuff\buildbot64\slave\pypy-c-jit-win-x86-64\build\pypy\tool\cpyext\extbuild.py", line 50, in compile_extension_module
E soname = c_compile(source_files, outputfilename=str(dirname / modname),
E ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E File "d:\pypy_stuff\buildbot64\slave\pypy-c-jit-win-x86-64\build\pypy\tool\cpyext\extbuild.py", line 197, in c_compile
E _build(
E File "d:\pypy_stuff\buildbot64\slave\pypy-c-jit-win-x86-64\build\pypy\tool\cpyext\extbuild.py", line 231, in _build
E res = compiler.compile([cfile.basename],
E ^^^^^^^
E File "d:\pypy_stuff\buildbot64\slave\pypy-c-jit-win-x86-64\build\Lib\site-packages\setuptools\_distutils\compilers\C\msvc.py", line 462, in compile
E raise CompileError(msg)
E distutils.compilers.C.errors.CompileError: command 'd:\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.41.34120\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
tool\pytest\apptest.py:239: AssertionError
---------- Captured stdout call ----------
# -*- encoding: utf-8 -*-
if 1:
import sys
sys.path.append('d:\\pypy_stuff\\buildbot64\\slave\\pypy-c-jit-win-x86-64\\build')
missing = set(['cpyext', '_thread', '_struct', 'array', 'itertools', 'time', 'binascii', 'mmap', '_signal', '_cffi_backend']).difference(sys.builtin_module_names)
if missing:
if not hasattr(sys, 'pypy_version_info'):
# They may be extension modules on CPython
name = None
for name in missing.copy():
if name in ['cpyext', '_cffi_backend', '_rawffi']:
missing.remove(name)
continue
try:
__import__(name)
except ImportError:
pass
else:
missing.remove(name)
del name
if missing:
sys.exit(81)
del missing
def skip(message):
print(message)
raise SystemExit(0)
__builtins__.skip = skip
__builtins__.py3k_skip = skip
class ExceptionWrapper:
pass
def raises(exc, *args, **kwargs):
if not args:
return RaisesContext(exc)
func = args[0]
args = args[1:]
import os
try:
if isinstance(func, str):
if func.startswith((' ', os.linesep, '\n')):
# it's probably an indented block, so we prefix if True:
# to avoid SyntaxError
func = "if True:\n" + func
frame = sys._getframe(1)
exec(func, frame.f_globals, frame.f_locals)
else:
func(*args, **kwargs)
except exc as e:
res = ExceptionWrapper()
res.value = e
res.traceback = e.__traceback__
return res
else:
raise AssertionError("DID NOT RAISE")
class RaisesContext(object):
def __init__(self, expected_exception):
self.expected_exception = expected_exception
self.excinfo = None
def __enter__(self):
return self
def __exit__(self, *tp):
__tracebackhide__ = True
if tp[0] is None:
raise AssertionError("DID NOT RAISE")
self.value = tp[1]
return issubclass(tp[0], self.expected_exception)
__builtins__.raises = raises
class Test:
pass
self = Test()
def w_compile_module(self, name,
source_files=None, source_strings=None):
from extbuild import get_sys_info_app
sys_info = get_sys_info_app(self.udir)
return sys_info.compile_extension_module(name,
source_files=source_files, source_strings=source_strings)
type(self).compile_module = w_compile_module
def w_debug_collect(self):
import gc
gc.collect()
gc.collect()
gc.collect()
type(self).debug_collect = w_debug_collect
self.here = 'd:\\pypy_stuff\\buildbot64\\slave\\pypy-c-jit-win-x86-64\\build\\pypy\\module\\cpyext\\test'
def w_import_extension(self, modname, functions, prologue="",
include_dirs=None, more_init="", PY_SSIZE_T_CLEAN=False):
from extbuild import get_sys_info_app
sys_info = get_sys_info_app(self.udir)
return sys_info.import_extension(
modname, functions, prologue=prologue,
include_dirs=include_dirs, more_init=more_init,
PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)
type(self).import_extension = w_import_extension
def w_import_module(self, name, init=None, body='', filename=None,
include_dirs=None, PY_SSIZE_T_CLEAN=False, use_imp=False):
from extbuild import get_sys_info_app
sys_info = get_sys_info_app(self.udir)
return sys_info.import_module(
name, init=init, body=body, filename=filename,
include_dirs=include_dirs,
PY_SSIZE_T_CLEAN=PY_SSIZE_T_CLEAN)
type(self).import_module = w_import_module
def w_load_module(self, mod, name):
from extbuild import get_sys_info_app
sys_info = get_sys_info_app(self.udir)
return sys_info.load_module(mod, name)
type(self).load_module = w_load_module
self.runappdirect = True
self.udir = 'd:\\systemtemp\\pytest\\usession-py3.11-1235'
def test_multiple_inheritance3():
module = self.import_extension('foo', [
("new_obj_small_basicsize", "METH_NOARGS",
'''
/* Simulate pybind11: instance struct is PyObject_HEAD + one ptr,
which is << sizeof(PyHeapTypeObject). */
typedef struct { PyObject_HEAD; void *extra; } SmallInst;
Py_ssize_t inst_size = (Py_ssize_t)sizeof(SmallInst);
PyTypeObject *B1, *B2, *B12;
B1 = (PyTypeObject*)PyType_Type.tp_alloc(&PyType_Type, 0);
B2 = (PyTypeObject*)PyType_Type.tp_alloc(&PyType_Type, 0);
B12 = (PyTypeObject*)PyType_Type.tp_alloc(&PyType_Type, 0);
PyObject *n1 = PyUnicode_FromString("B1");
PyObject *n2 = PyUnicode_FromString("B2");
PyObject *n12 = PyUnicode_FromString("B12");
B1->tp_name = "B1";
B2->tp_name = "B2";
B12->tp_name = "B12";
B1->tp_basicsize = inst_size;
B2->tp_basicsize = inst_size;
B12->tp_basicsize = inst_size;
((PyHeapTypeObject*)B1)->ht_name = n1;
((PyHeapTypeObject*)B2)->ht_name = n2;
((PyHeapTypeObject*)B12)->ht_name = n12;
((PyHeapTypeObject*)B1)->ht_qualname = n1;
((PyHeapTypeObject*)B2)->ht_qualname = n2;
((PyHeapTypeObject*)B12)->ht_qualname = n12;
B1->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE;
B2->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE;
B12->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE;
B12->tp_base = B1;
B12->tp_bases = PyTuple_Pack(2, B1, B2);
if (PyType_Ready(B1) < 0) return NULL;
if (PyType_Ready(B2) < 0) return NULL;
if (PyType_Ready(B12) < 0) return NULL;
PyObject *obj = PyObject_New(PyObject, B12);
return obj;
'''
),
("get_bases", "METH_NOARGS",
'''
/* Simulate two independent pybind11-style types: both have the
same tp_basicsize (larger than PyObject but smaller than
PyHeapTypeObject), both inherit from the same base. */
typedef struct { PyObject_HEAD; void *holder; } PybindInst;
Py_ssize_t inst_size = (Py_ssize_t)sizeof(PybindInst);
/* Shared object base (analogous to pybind11_object). */
PyTypeObject *ObjBase;
ObjBase = (PyTypeObject*)PyType_Type.tp_alloc(&PyType_Type, 0);
PyObject *nobj = PyUnicode_FromString("ObjBase");
ObjBase->tp_name = "ObjBase";
ObjBase->tp_basicsize = inst_size;
((PyHeapTypeObject*)ObjBase)->ht_name = nobj;
((PyHeapTypeObject*)ObjBase)->ht_qualname = nobj;
ObjBase->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE;
if (PyType_Ready(ObjBase) < 0) return NULL;
PyTypeObject *B1, *B2;
B1 = (PyTypeObject*)PyType_Type.tp_alloc(&PyType_Type, 0);
B2 = (PyTypeObject*)PyType_Type.tp_alloc(&PyType_Type, 0);
PyObject *n1 = PyUnicode_FromString("B1");
PyObject *n2 = PyUnicode_FromString("B2");
B1->tp_name = "B1";
B2->tp_name = "B2";
B1->tp_basicsize = inst_size;
B2->tp_basicsize = inst_size;
((PyHeapTypeObject*)B1)->ht_name = n1;
((PyHeapTypeObject*)B2)->ht_name = n2;
((PyHeapTypeObject*)B1)->ht_qualname = n1;
((PyHeapTypeObject*)B2)->ht_qualname = n2;
B1->tp_base = ObjBase; Py_INCREF(ObjBase);
B2->tp_base = ObjBase; Py_INCREF(ObjBase);
B1->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE;
B2->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE;
if (PyType_Ready(B1) < 0) return NULL;
if (PyType_Ready(B2) < 0) return NULL;
return PyTuple_Pack(2, B1, B2);
'''
),
("new_obj", "METH_NOARGS",
'''
PyObject *obj;
PyTypeObject *Base1, *Base2, *Base12;
Base1 = (PyTypeObject*)PyType_Type.tp_alloc(&PyType_Type, 0);
Base2 = (PyTypeObject*)PyType_Type.tp_alloc(&PyType_Type, 0);
Base12 = (PyTypeObject*)PyType_Type.tp_alloc(&PyType_Type, 0);
Base1->tp_name = "Base1";
Base2->tp_name = "Base2";
Base12->tp_name = "Base12";
Base1->tp_basicsize = sizeof(PyHeapTypeObject);
Base2->tp_basicsize = sizeof(PyHeapTypeObject);
Base12->tp_basicsize = sizeof(PyHeapTypeObject);
PyObject * dummyname = PyUnicode_FromString("dummy name");
((PyHeapTypeObject*)Base1)->ht_qualname = dummyname;
((PyHeapTypeObject*)Base2)->ht_qualname = dummyname;
((PyHeapTypeObject*)Base12)->ht_qualname = dummyname;
((PyHeapTypeObject*)Base1)->ht_name = PyUnicode_FromString("Base1");
((PyHeapTypeObject*)Base2)->ht_name = PyUnicode_FromString("Base2");
((PyHeapTypeObject*)Base12)->ht_name = PyUnicode_FromString("Base12");
Base1->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE;
Base2->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE;
Base12->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE;
Base12->tp_base = Base1;
Base12->tp_bases = PyTuple_Pack(2, Base1, Base2);
Base12->tp_doc = "The Base12 type or object";
if (PyType_Ready(Base1) < 0) return NULL;
if (PyType_Ready(Base2) < 0) return NULL;
if (PyType_Ready(Base12) < 0) return NULL;
obj = PyObject_New(PyObject, Base12);
return obj;
'''
),
("test_getslot", "METH_O",
'''
PyTypeObject *typ = (PyTypeObject *)PyObject_Type(args);
if (! PyType_HasFeature(typ, Py_TPFLAGS_HEAPTYPE) ) {
return PyLong_FromLong(-1);
}
void * tp_bases = PyType_GetSlot(typ, Py_tp_bases);
long eq = (tp_bases == (void*)typ->tp_bases);
return PyLong_FromLong(eq);
'''),
("test_tp_new", "METH_NOARGS",
'''
newfunc tp_new = PyType_GetSlot(&PyLong_Type, Py_tp_new);
if (PyLong_Type.tp_new != tp_new) {
PyErr_SetString(PyExc_AssertionError, "mismatch: tp_new of long");
return NULL;
}
Py_RETURN_NONE;
'''),
("test_nb_add", "METH_NOARGS",
'''
binaryfunc nb_add = PyType_GetSlot(&PyLong_Type, Py_nb_add);
if (PyLong_Type.tp_as_number->nb_add != nb_add) {
PyErr_SetString(PyExc_AssertionError, "mismatch: nb_add of long");
return NULL;
}
Py_RETURN_NONE;
'''),
("test_zero", "METH_NOARGS",
'''
binaryfunc nb_add = PyType_GetSlot(&PyLong_Type, 0);
if (nb_add != NULL) {
PyErr_SetString(PyExc_AssertionError,
"PyType_GetSlot should not succeed");
}
return NULL;
'''),
])
obj = module.new_obj()
assert 'Base12' in str(obj)
assert type(obj).__doc__ == "The Base12 type or object"
assert obj.__doc__ == "The Base12 type or object"
assert module.test_getslot(obj) == 1
module.test_tp_new()
module.test_nb_add()
with raises(SystemError):
module.test_zero()
# Regression test: two manually-allocated heap types whose tp_basicsize
# is smaller than sizeof(PyHeapTypeObject) (as pybind11 does) must be
# combinable in multiple inheritance when they share the same
# tp_basicsize, because there is no actual instance-layout conflict.
obj = module.new_obj_small_basicsize()
assert 'B12' in str(obj)
# Regression test: Python code must be able to create a class that
# inherits from two cpytype bases that share the same solid base
# (i.e. have equivalent layouts), as pybind11 does with Base1/Base2.
# The previous fix (issue 5481) only covered the case where the new
# type itself was a cpytype (created via PyType_Ready); this covers
# the Python-level "class MI1(B1, B2):" case.
B1, B2 = module.get_bases()
# This must not raise "instance layout conflicts in multiple inheritance"
class MI1(B1, B2):
pass
obj = MI1()
assert isinstance(obj, B1)
assert isinstance(obj, B2)
try:
test_multiple_inheritance3()
finally:
print("===aefwuiheawiu===")
from d:\systemtemp\pytest\usession-py3.11-1235\src.py
source_0.c
source_0.c(11): error C2059: syntax error: ';'
source_0.c(15): error C2040: 'B1': 'int' differs in levels of indirection from 'PyTypeObject *'
source_0.c(16): error C2040: 'B2': 'int' differs in levels of indirection from 'PyTypeObject *'
source_0.c(17): error C2040: 'B12': 'int' differs in levels of indirection from 'PyTypeObject *'
source_0.c(19): error C2099: initializer is not a constant
source_0.c(20): error C2099: initializer is not a constant
source_0.c(21): error C2099: initializer is not a constant
source_0.c(23): error C2143: syntax error: missing '{' before '->'
source_0.c(23): error C2059: syntax error: '->'
source_0.c(24): error C2143: syntax error: missing '{' before '->'
source_0.c(24): error C2059: syntax error: '->'
source_0.c(25): error C2143: syntax error: missing '{' before '->'
source_0.c(25): error C2059: syntax error: '->'
source_0.c(27): error C2143: syntax error: missing '{' before '->'
source_0.c(27): error C2059: syntax error: '->'
source_0.c(28): error C2143: syntax error: missing '{' before '->'
source_0.c(28): error C2059: syntax error: '->'
source_0.c(29): error C2143: syntax error: missing '{' before '->'
source_0.c(29): error C2059: syntax error: '->'
source_0.c(31): error C2059: syntax error: '<parameter-list>'
source_0.c(32): error C2059: syntax error: '<parameter-list>'
source_0.c(33): error C2059: syntax error: '<parameter-list>'
source_0.c(34): error C2059: syntax error: '<parameter-list>'
source_0.c(35): error C2059: syntax error: '<parameter-list>'
source_0.c(36): error C2059: syntax error: '<parameter-list>'
source_0.c(38): error C2143: syntax error: missing '{' before '->'
source_0.c(38): error C2059: syntax error: '->'
source_0.c(39): error C2143: syntax error: missing '{' before '->'
source_0.c(39): error C2059: syntax error: '->'
source_0.c(40): error C2143: syntax error: missing '{' before '->'
source_0.c(40): error C2059: syntax error: '->'
source_0.c(42): error C2143: syntax error: missing '{' before '->'
source_0.c(42): error C2059: syntax error: '->'
source_0.c(43): error C2143: syntax error: missing '{' before '->'
source_0.c(43): error C2059: syntax error: '->'
source_0.c(45): error C2059: syntax error: 'if'
source_0.c(46): error C2059: syntax error: 'if'
source_0.c(47): error C2059: syntax error: 'if'
source_0.c(49): error C2099: initializer is not a constant
source_0.c(50): error C2059: syntax error: 'return'
source_0.c(52): error C2059: syntax error: '}'
source_0.c(191): error C2065: 'foo_get_bases': undeclared identifier
source_0.c(191): warning C4312: 'type cast': conversion from 'int' to 'PyCFunction' of greater size
source_0.c(189): error C2099: initializer is not a constant
source_0.c(191): warning C4047: 'initializing': 'PyCFunction' differs in levels of indirection from 'int'
===aefwuiheawiu===
---------- Captured stderr call ----------
Traceback (most recent call last):
File "d:\pypy_stuff\buildbot64\slave\pypy-c-jit-win-x86-64\build\Lib\site-packages\setuptools\_distutils\spawn.py", line 87, in spawn
subprocess.check_call(cmd, env=_inject_macos_ver(env))
^^^^^^^^^^
File "d:\pypy_stuff\buildbot64\slave\pypy-c-jit-win-x86-64\build\lib-python\3\subprocess.py", line 413, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['d:\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.41.34120\\bin\\HostX86\\x64\\cl.exe', '/we4013', '/std:c11', '/c', '/nologo', '/O2', '/W3', '/GL', '/DNDEBUG', '/MD', '-Id:\\pypy_stuff\\buildbot64\\slave\\pypy-c-jit-win-x86-64\\build\\include', '-Id:\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.41.34120\\include', '-Id:\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.41.34120\\ATLMFC\\include', '-Id:\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\VS\\include', '-IC:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.20348.0\\ucrt', '-IC:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.20348.0\\\\um', '-IC:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.20348.0\\\\shared', '-IC:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.20348.0\\\\winrt', '-IC:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.20348.0\\\\cppwinrt', '-Id:\\pypy_stuff\\buildbot64\\slave\\pypy-c-jit-win-x86-64\\build\\externals\\include', '/Tcsource_0.c', '/Fosource_0.obj']' returned non-zero exit status 2.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "d:\pypy_stuff\buildbot64\slave\pypy-c-jit-win-x86-64\build\Lib\site-packages\setuptools\_distutils\compilers\C\msvc.py", line 460, in compile
self.spawn(args)
^^^^^
File "d:\pypy_stuff\buildbot64\slave\pypy-c-jit-win-x86-64\build\Lib\site-packages\setuptools\_distutils\compilers\C\msvc.py", line 563, in spawn
return super().spawn(cmd, env=env)
^^^^^
File "d:\pypy_stuff\buildbot64\slave\pypy-c-jit-win-x86-64\build\Lib\site-packages\setuptools\_distutils\compilers\C\base.py", line 1158, in spawn
spawn(cmd, dry_run=self.dry_run, **kwargs)
File "d:\pypy_stuff\buildbot64\slave\pypy-c-jit-win-x86-64\build\Lib\site-packages\setuptools\_distutils\spawn.py", line 93, in spawn
raise DistutilsExecError(
distutils.errors.DistutilsExecError: command 'd:\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.41.34120\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "d:\systemtemp\pytest\usession-py3.11-1235\src.py", line 313, in <module>
test_multiple_inheritance3()
File "d:\systemtemp\pytest\usession-py3.11-1235\src.py", line 121, in test_multiple_inheritance3
module = self.import_extension('foo', [
^^^^^^^^^^^^^^^^
File "d:\systemtemp\pytest\usession-py3.11-1235\src.py", line 95, in w_import_extension
return sys_info.import_extension(
^^^^^^^^^^^^^^^^
File "d:\pypy_stuff\buildbot64\slave\pypy-c-jit-win-x86-64\build\pypy\tool\cpyext\extbuild.py", line 96, in import_extension
return self.import_module(
^^^^^^^^^^^^^
File "d:\pypy_stuff\buildbot64\slave\pypy-c-jit-win-x86-64\build\pypy\tool\cpyext\extbuild.py", line 82, in import_module
mod = self.compile_extension_module(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "d:\pypy_stuff\buildbot64\slave\pypy-c-jit-win-x86-64\build\pypy\tool\cpyext\extbuild.py", line 50, in compile_extension_module
soname = c_compile(source_files, outputfilename=str(dirname / modname),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "d:\pypy_stuff\buildbot64\slave\pypy-c-jit-win-x86-64\build\pypy\tool\cpyext\extbuild.py", line 197, in c_compile
_build(
File "d:\pypy_stuff\buildbot64\slave\pypy-c-jit-win-x86-64\build\pypy\tool\cpyext\extbuild.py", line 231, in _build
res = compiler.compile([cfile.basename],
^^^^^^^
File "d:\pypy_stuff\buildbot64\slave\pypy-c-jit-win-x86-64\build\Lib\site-packages\setuptools\_distutils\compilers\C\msvc.py", line 462, in compile
raise CompileError(msg)
distutils.compilers.C.errors.CompileError: command 'd:\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.41.34120\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
builder: pypy-c-jit-win-x86-64 build #2532+
test: pypy/module/cpyext/test/test_typeobject.py::AppTestSlots::()::test_multiple_inheritance3