Commit 89d2488f authored by Stefan Behnel's avatar Stefan Behnel

The names of Cython's internal types (functions, generator, coroutine, etc.)...

The names of Cython's internal types (functions, generator, coroutine, etc.) are now prefixed with the shared module name, instead of making them look like homeless builtins.
See https://bugs.python.org/issue20204
See https://github.com/python/cpython/commit/490055a1673b524da2ebe2312f072aba2a826036
parent cbe43273
......@@ -711,6 +711,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
from .. import __version__
code.putln('#define CYTHON_ABI "%s"' % __version__.replace('.', '_'))
code.putln('#define __PYX_ABI_MODULE_NAME "_cython_" CYTHON_ABI')
code.putln('#define __PYX_TYPE_MODULE_PREFIX __PYX_ABI_MODULE_NAME "."')
code.putln('#define CYTHON_HEX_VERSION %s' % build_hex_version(__version__))
code.putln("#define CYTHON_FUTURE_DIVISION %d" % (
Future.division in env.context.future_directives))
......
......@@ -8,7 +8,7 @@ static PyTypeObject* __Pyx_FetchCommonTypeFromSpec(PyType_Spec *spec, PyObject *
/////////////// FetchCommonType ///////////////
static PyObject *__Pyx_FetchSharedCythonABIModule(void) {
PyObject *abi_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
PyObject *abi_module = PyImport_AddModule((char*) __PYX_ABI_MODULE_NAME);
if (!abi_module) return NULL;
Py_INCREF(abi_module);
return abi_module;
......@@ -126,7 +126,7 @@ static void* __Pyx_FetchCommonPointer(void* pointer, const char* name) {
PyObject* capsule = NULL;
void* value = NULL;
abi_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
abi_module = PyImport_AddModule((char*) __PYX_ABI_MODULE_NAME);
if (!abi_module) return NULL;
Py_INCREF(abi_module);
......
......@@ -1468,7 +1468,7 @@ static PyMethodDef __pyx_CoroutineAwait_methods[] = {
static PyTypeObject __pyx_CoroutineAwaitType_type = {
PyVarObject_HEAD_INIT(0, 0)
"coroutine_wrapper", /*tp_name*/
__PYX_TYPE_MODULE_PREFIX "coroutine_wrapper", /*tp_name*/
sizeof(__pyx_CoroutineAwaitObject), /*tp_basicsize*/
0, /*tp_itemsize*/
(destructor) __Pyx_CoroutineAwait_dealloc,/*tp_dealloc*/
......@@ -1616,7 +1616,7 @@ static __Pyx_PyAsyncMethodsStruct __pyx_Coroutine_as_async = {
static PyTypeObject __pyx_CoroutineType_type = {
PyVarObject_HEAD_INIT(0, 0)
"coroutine", /*tp_name*/
__PYX_TYPE_MODULE_PREFIX "coroutine", /*tp_name*/
sizeof(__pyx_CoroutineObject), /*tp_basicsize*/
0, /*tp_itemsize*/
(destructor) __Pyx_Coroutine_dealloc,/*tp_dealloc*/
......@@ -1732,7 +1732,7 @@ static int __pyx_IterableCoroutine_init(void);/*proto*/
static PyTypeObject __pyx_IterableCoroutineType_type = {
PyVarObject_HEAD_INIT(0, 0)
"iterable_coroutine", /*tp_name*/
__PYX_TYPE_MODULE_PREFIX "iterable_coroutine", /*tp_name*/
sizeof(__pyx_CoroutineObject), /*tp_basicsize*/
0, /*tp_itemsize*/
(destructor) __Pyx_Coroutine_dealloc,/*tp_dealloc*/
......@@ -1851,7 +1851,7 @@ static PyGetSetDef __pyx_Generator_getsets[] = {
static PyTypeObject __pyx_GeneratorType_type = {
PyVarObject_HEAD_INIT(0, 0)
"generator", /*tp_name*/
__PYX_TYPE_MODULE_PREFIX "generator", /*tp_name*/
sizeof(__pyx_CoroutineObject), /*tp_basicsize*/
0, /*tp_itemsize*/
(destructor) __Pyx_Coroutine_dealloc,/*tp_dealloc*/
......
......@@ -811,7 +811,7 @@ static PyType_Slot __pyx_CyFunctionType_slots[] = {
};
static PyType_Spec __pyx_CyFunctionType_spec = {
"cython_function_or_method",
__PYX_TYPE_MODULE_PREFIX "cython_function_or_method",
sizeof(__pyx_CyFunctionObject),
0,
// TODO: Support _Py_TPFLAGS_HAVE_VECTORCALL and _Py_TPFLAGS_HAVE_VECTORCALL
......@@ -821,7 +821,7 @@ static PyType_Spec __pyx_CyFunctionType_spec = {
#else
static PyTypeObject __pyx_CyFunctionType_type = {
PyVarObject_HEAD_INIT(0, 0)
"cython_function_or_method", /*tp_name*/
__PYX_TYPE_MODULE_PREFIX "cython_function_or_method", /*tp_name*/
sizeof(__pyx_CyFunctionObject), /*tp_basicsize*/
0, /*tp_itemsize*/
(destructor) __Pyx_CyFunction_dealloc, /*tp_dealloc*/
......@@ -1335,7 +1335,7 @@ static PyType_Slot __pyx_FusedFunctionType_slots[] = {
};
static PyType_Spec __pyx_FusedFunctionType_spec = {
"fused_cython_function",
__PYX_TYPE_MODULE_PREFIX "fused_cython_function",
sizeof(__pyx_FusedFunctionObject),
0,
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /*tp_flags*/
......@@ -1352,7 +1352,7 @@ static PyMappingMethods __pyx_FusedFunction_mapping_methods = {
static PyTypeObject __pyx_FusedFunctionType_type = {
PyVarObject_HEAD_INIT(0, 0)
"fused_cython_function", /*tp_name*/
__PYX_TYPE_MODULE_PREFIX "fused_cython_function", /*tp_name*/
sizeof(__pyx_FusedFunctionObject), /*tp_basicsize*/
0, /*tp_itemsize*/
(destructor) __pyx_FusedFunction_dealloc, /*tp_dealloc*/
......
......@@ -1648,7 +1648,7 @@ static void __Pyx_FastGilFuncInit(void);
#if CYTHON_FAST_GIL
#define __Pyx_FastGIL_ABI_module "_cython_" CYTHON_ABI
#define __Pyx_FastGIL_ABI_module __PYX_ABI_MODULE_NAME
#define __Pyx_FastGIL_PyCapsuleName "FastGilFuncs"
#define __Pyx_FastGIL_PyCapsule \
__Pyx_FastGIL_ABI_module "." __Pyx_FastGIL_PyCapsuleName
......
......@@ -31,7 +31,7 @@ print("importing...")
import a, b
print(type(a.funcA))
assert type(a.funcA).__name__ == 'cython_function_or_method'
assert type(a.funcA).__name__.endswith('cython_function_or_method')
assert type(a.funcA) is type(b.funcB)
assert a.funcA.func_globals is a.__dict__
......
......@@ -143,7 +143,7 @@ def run_cyfunction_check():
fused_cython_function
1
"""
print(type(opt_func).__name__)
print(type(opt_func).__name__.rsplit('.', 1)[-1])
print(__Pyx_CyFunction_Check(opt_func)) # should be True
def test_opt_func():
......
......@@ -109,7 +109,7 @@ class AsyncYield(object):
def run_async(coro):
#assert coro.__class__ is types.GeneratorType
assert coro.__class__.__name__ in ('coroutine', '_GeneratorWrapper'), coro.__class__.__name__
assert coro.__class__.__name__.rsplit('.', 1)[-1] in ('coroutine', '_GeneratorWrapper'), coro.__class__.__name__
buffer = []
result = None
......@@ -123,7 +123,7 @@ def run_async(coro):
def run_async__await__(coro):
assert coro.__class__.__name__ in ('coroutine', '_GeneratorWrapper'), coro.__class__.__name__
assert coro.__class__.__name__.rsplit('.', 1)[-1] in ('coroutine', '_GeneratorWrapper'), coro.__class__.__name__
aw = coro.__await__()
buffer = []
result = None
......@@ -895,7 +895,7 @@ class CoroutineTest(unittest.TestCase):
raise StopIteration
with silence_coro_gc():
self.assertRegex(repr(foo()), '^<coroutine object.* at 0x.*>$')
self.assertRegex(repr(foo()), '^<[^\s]*coroutine object.* at 0x.*>$')
def test_func_4(self):
async def foo():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment