Commit e0caff50 authored by scoder's avatar scoder Committed by GitHub

Merge pull request #1878 from rlamy/pypy3-fixes

More pypy3 fixes
parents 6213a172 52419f66
...@@ -74,7 +74,11 @@ static PyObject* __Pyx__Coroutine_Yield_From_Generic(__pyx_CoroutineObject *gen, ...@@ -74,7 +74,11 @@ static PyObject* __Pyx__Coroutine_Yield_From_Generic(__pyx_CoroutineObject *gen,
if (__Pyx_Coroutine_CheckExact(source_gen)) { if (__Pyx_Coroutine_CheckExact(source_gen)) {
retval = __Pyx_Generator_Next(source_gen); retval = __Pyx_Generator_Next(source_gen);
} else { } else {
#if CYTHON_USE_TYPE_SLOTS
retval = Py_TYPE(source_gen)->tp_iternext(source_gen); retval = Py_TYPE(source_gen)->tp_iternext(source_gen);
#else
retval = PyIter_Next(source_gen);
#endif
} }
if (retval) { if (retval) {
gen->yieldfrom = source_gen; gen->yieldfrom = source_gen;
......
...@@ -203,7 +203,7 @@ static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { ...@@ -203,7 +203,7 @@ static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
return __Pyx_PyObject_AsStringAndSize(o, &ignore); return __Pyx_PyObject_AsStringAndSize(o, &ignore);
} }
#if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
#if !CYTHON_PEP393_ENABLED #if !CYTHON_PEP393_ENABLED
static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
char* defenc_c; char* defenc_c;
...@@ -251,7 +251,7 @@ static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py ...@@ -251,7 +251,7 @@ static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py
// Py3.7 returns a "const char*" for unicode strings // Py3.7 returns a "const char*" for unicode strings
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
if ( if (
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
__Pyx_sys_getdefaultencoding_not_ascii && __Pyx_sys_getdefaultencoding_not_ascii &&
......
...@@ -26,7 +26,14 @@ run.datetime_pxd ...@@ -26,7 +26,14 @@ run.datetime_pxd
run.datetime_cimport run.datetime_cimport
run.datetime_members run.datetime_members
run.extern_builtins_T258 run.extern_builtins_T258
run.line_trace
run.line_profile_test
run.pstats_profile_test
run.longintrepr
# refcounting-specific tests # refcounting-specific tests
double_dealloc_T796 double_dealloc_T796
run.exceptionrefcount
run.capiimpl
run.refcount_in_meth
...@@ -54,6 +54,16 @@ except ImportError: ...@@ -54,6 +54,16 @@ except ImportError:
def __call__(self, *args, **kwargs): def __call__(self, *args, **kwargs):
return self._GeneratorWrapper(self._gen(*args, **kwargs)) return self._GeneratorWrapper(self._gen(*args, **kwargs))
try:
from sys import getrefcount
except ImportError:
from cpython.ref cimport PyObject
def getrefcount(obj):
gc.collect()
# PyPy needs to execute a bytecode to run the finalizers
exec('', {}, {})
return (<PyObject*>obj).ob_refcnt
# compiled exec() # compiled exec()
def exec(code_string, l, g): def exec(code_string, l, g):
...@@ -1867,7 +1877,7 @@ class CoroutineTest(unittest.TestCase): ...@@ -1867,7 +1877,7 @@ class CoroutineTest(unittest.TestCase):
def test_for_2(self): def test_for_2(self):
tup = (1, 2, 3) tup = (1, 2, 3)
refs_before = sys.getrefcount(tup) refs_before = getrefcount(tup)
async def foo(): async def foo():
async for i in tup: async for i in tup:
...@@ -1878,7 +1888,7 @@ class CoroutineTest(unittest.TestCase): ...@@ -1878,7 +1888,7 @@ class CoroutineTest(unittest.TestCase):
run_async(foo()) run_async(foo())
self.assertEqual(sys.getrefcount(tup), refs_before) self.assertEqual(getrefcount(tup), refs_before)
def test_for_3(self): def test_for_3(self):
class I(object): class I(object):
...@@ -1886,7 +1896,7 @@ class CoroutineTest(unittest.TestCase): ...@@ -1886,7 +1896,7 @@ class CoroutineTest(unittest.TestCase):
return self return self
aiter = I() aiter = I()
refs_before = sys.getrefcount(aiter) refs_before = getrefcount(aiter)
async def foo(): async def foo():
async for i in aiter: async for i in aiter:
...@@ -1898,7 +1908,7 @@ class CoroutineTest(unittest.TestCase): ...@@ -1898,7 +1908,7 @@ class CoroutineTest(unittest.TestCase):
run_async(foo()) run_async(foo())
self.assertEqual(sys.getrefcount(aiter), refs_before) self.assertEqual(getrefcount(aiter), refs_before)
def test_for_4(self): def test_for_4(self):
class I(object): class I(object):
...@@ -1909,7 +1919,7 @@ class CoroutineTest(unittest.TestCase): ...@@ -1909,7 +1919,7 @@ class CoroutineTest(unittest.TestCase):
return () return ()
aiter = I() aiter = I()
refs_before = sys.getrefcount(aiter) refs_before = getrefcount(aiter)
async def foo(): async def foo():
async for i in aiter: async for i in aiter:
...@@ -1921,7 +1931,7 @@ class CoroutineTest(unittest.TestCase): ...@@ -1921,7 +1931,7 @@ class CoroutineTest(unittest.TestCase):
run_async(foo()) run_async(foo())
self.assertEqual(sys.getrefcount(aiter), refs_before) self.assertEqual(getrefcount(aiter), refs_before)
def test_for_5(self): def test_for_5(self):
class I(object): class I(object):
...@@ -1971,8 +1981,8 @@ class CoroutineTest(unittest.TestCase): ...@@ -1971,8 +1981,8 @@ class CoroutineTest(unittest.TestCase):
manager = Manager() manager = Manager()
iterable = Iterable() iterable = Iterable()
mrefs_before = sys.getrefcount(manager) mrefs_before = getrefcount(manager)
irefs_before = sys.getrefcount(iterable) irefs_before = getrefcount(iterable)
async def main(): async def main():
nonlocal I nonlocal I
...@@ -1985,8 +1995,8 @@ class CoroutineTest(unittest.TestCase): ...@@ -1985,8 +1995,8 @@ class CoroutineTest(unittest.TestCase):
run_async(main()) run_async(main())
self.assertEqual(I, 111011) self.assertEqual(I, 111011)
self.assertEqual(sys.getrefcount(manager), mrefs_before) self.assertEqual(getrefcount(manager), mrefs_before)
self.assertEqual(sys.getrefcount(iterable), irefs_before) self.assertEqual(getrefcount(iterable), irefs_before)
############## ##############
......
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