[pypy-commit] pypy default: Make test_bytearrayobject.py CPython-compatible (with pytest -A).
devin.jeanpierre
pypy.commits at gmail.com
Mon Jun 20 21:59:13 EDT 2016
Author: Devin Jeanpierre <jeanpierreda at gmail.com>
Branch:
Changeset: r85297:cdcba39cd359
Date: 2016-06-20 18:40 -0700
http://bitbucket.org/pypy/pypy/changeset/cdcba39cd359/
Log: Make test_bytearrayobject.py CPython-compatible (with pytest -A).
The test asserted that PyByteArray_AsString would raise on CPython,
but this is not documented to happen. In fact it seems like it just
does potentially arbitrary memory unsafety if asserts are disabled.
Unsettling.
diff --git a/pypy/module/cpyext/test/test_bytearrayobject.py b/pypy/module/cpyext/test/test_bytearrayobject.py
--- a/pypy/module/cpyext/test/test_bytearrayobject.py
+++ b/pypy/module/cpyext/test/test_bytearrayobject.py
@@ -1,5 +1,7 @@
from pypy.module.cpyext.test.test_cpyext import AppTestCpythonExtensionBase
+import sys
+
class AppTestStringObject(AppTestCpythonExtensionBase):
def test_basic(self):
module = self.import_extension('foo', [
@@ -157,7 +159,9 @@
""")])
assert module.bytearray_from_string("huheduwe") == "huhe"
assert module.str_from_bytearray(bytearray('abc')) == 'abc'
- raises(ValueError, module.str_from_bytearray, 4.0)
+ if '__pypy__' in sys.builtin_module_names:
+ # CPython only makes an assert.
+ raises(ValueError, module.str_from_bytearray, 4.0)
ret = module.concat('abc', 'def')
assert ret == 'abcdef'
assert not isinstance(ret, str)
More information about the pypy-commit
mailing list