[pypy-commit] pypy py3.3: NoneType can be constructed.
Author: Vasily Kuznetsov Branch: py3.3 Changeset: r72487:032296946827 Date: 2014-07-26 11:00 +0200 http://bitbucket.org/pypy/pypy/changeset/032296946827/ Log:NoneType can be constructed. diff --git a/pypy/module/__builtin__/test/test_construct_singletons.py b/pypy/module/__builtin__/test/test_construct_singletons.py new file mode 100644 --- /dev/null +++ b/pypy/module/__builtin__/test/test_construct_singletons.py @@ -0,0 +1,7 @@ +class AppTestConstructSingletons: + +def test_construct_singletons(self): +none_type = type(None) +assert none_type() is None +raises(TypeError, none_type, 1, 2) +raises(TypeError, none_type, a=1, b=2) diff --git a/pypy/objspace/std/nonetype.py b/pypy/objspace/std/nonetype.py --- a/pypy/objspace/std/nonetype.py +++ b/pypy/objspace/std/nonetype.py @@ -1,8 +1,15 @@ from pypy.objspace.std.stdtypedef import StdTypeDef +from pypy.interpreter import gateway +def descr__new__(space, w_type): +return space.w_None + # none_typedef = StdTypeDef("NoneType", +__new__ = gateway.interp2app(descr__new__) ) none_typedef.acceptable_as_base_class = False + + ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: Added missing log2 in math module.
Author: Arjun Naik Branch: py3.3 Changeset: r72489:342ebe4c4d7f Date: 2014-07-26 11:16 +0200 http://bitbucket.org/pypy/pypy/changeset/342ebe4c4d7f/ Log:Added missing log2 in math module. diff --git a/pypy/module/math/__init__.py b/pypy/module/math/__init__.py --- a/pypy/module/math/__init__.py +++ b/pypy/module/math/__init__.py @@ -23,6 +23,7 @@ 'frexp' : 'interp_math.frexp', 'degrees': 'interp_math.degrees', 'log': 'interp_math.log', + 'log2' : 'interp_math.log2', 'log10' : 'interp_math.log10', 'fmod' : 'interp_math.fmod', 'atan' : 'interp_math.atan', diff --git a/pypy/module/math/interp_math.py b/pypy/module/math/interp_math.py --- a/pypy/module/math/interp_math.py +++ b/pypy/module/math/interp_math.py @@ -228,6 +228,11 @@ return math1(space, math.log, w_base) return _log_any(space, w_x, base) +def log2(space, w_x): +"""log2(x) -> the base 2 logarithm of x. +""" +return _log_any(space, w_x, 2.0) + def log10(space, w_x): """log10(x) -> the base 10 logarithm of x. """ diff --git a/pypy/module/math/test/test_math.py b/pypy/module/math/test/test_math.py --- a/pypy/module/math/test/test_math.py +++ b/pypy/module/math/test/test_math.py @@ -148,6 +148,19 @@ raises(ValueError, math.log1p, -1) raises(ValueError, math.log1p, -100) +def test_log2(self): +import math +self.ftest(math.log2(0.125), -3) +self.ftest(math.log2(0.5), -1) +self.ftest(math.log2(4), 2) + +def test_log10(self): +import math +self.ftest(math.log10(0.1), -1) +self.ftest(math.log10(10), 1) +self.ftest(math.log10(100), 2) +self.ftest(math.log10(0.01), -2) + def test_acosh(self): import math self.ftest(math.acosh(1), 0) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: Added the missing log2 in the math module.
Author: Arjun Naik Branch: py3.3 Changeset: r72488:e54b7fe58ecf Date: 2014-07-26 10:41 +0200 http://bitbucket.org/pypy/pypy/changeset/e54b7fe58ecf/ Log:Added the missing log2 in the math module. diff --git a/pypy/module/math/__init__.py b/pypy/module/math/__init__.py --- a/pypy/module/math/__init__.py +++ b/pypy/module/math/__init__.py @@ -23,6 +23,7 @@ 'frexp' : 'interp_math.frexp', 'degrees': 'interp_math.degrees', 'log': 'interp_math.log', + 'log2' : 'interp_math.log2', 'log10' : 'interp_math.log10', 'fmod' : 'interp_math.fmod', 'atan' : 'interp_math.atan', diff --git a/pypy/module/math/interp_math.py b/pypy/module/math/interp_math.py --- a/pypy/module/math/interp_math.py +++ b/pypy/module/math/interp_math.py @@ -228,6 +228,11 @@ return math1(space, math.log, w_base) return _log_any(space, w_x, base) +def log2(space, w_x): +"""log2(x) -> the base 2 logarithm of x. +""" +return _log_any(space, w_x, 2.0) + def log10(space, w_x): """log10(x) -> the base 10 logarithm of x. """ diff --git a/pypy/module/math/test/test_math.py b/pypy/module/math/test/test_math.py --- a/pypy/module/math/test/test_math.py +++ b/pypy/module/math/test/test_math.py @@ -148,6 +148,19 @@ raises(ValueError, math.log1p, -1) raises(ValueError, math.log1p, -100) +def test_log2(self): +import math +self.ftest(math.log2(0.125), -3) +self.ftest(math.log2(0.5), -1) +self.ftest(math.log2(4), 2) + +def test_log10(self): +import math +self.ftest(math.log10(0.1), -1) +self.ftest(math.log10(10), 1) +self.ftest(math.log10(100), 2) +self.ftest(math.log10(0.01), -2) + def test_acosh(self): import math self.ftest(math.acosh(1), 0) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: fixing typo in range hash function
Author: Boglarka Vezer Branch: py3.3 Changeset: r72491:b8a56b701025 Date: 2014-07-26 11:26 +0200 http://bitbucket.org/pypy/pypy/changeset/b8a56b701025/ Log:fixing typo in range hash function diff --git a/pypy/module/__builtin__/functional.py b/pypy/module/__builtin__/functional.py --- a/pypy/module/__builtin__/functional.py +++ b/pypy/module/__builtin__/functional.py @@ -482,7 +482,7 @@ def descr_hash(self, space): if space.eq_w(self.w_length, space.wrap(0)): w_tup = space.newtuple([self.w_length, space.w_None, space.w_None]) -elif space.eq_w(self.w_length, space.wrap(0)): +elif space.eq_w(self.w_length, space.wrap(1)): w_tup = space.newtuple([self.w_length, self.w_start, space.w_None]) else: w_tup = space.newtuple([self.w_length, self.w_start, self.w_step]) diff --git a/pypy/module/__builtin__/test/test_functional.py b/pypy/module/__builtin__/test/test_functional.py --- a/pypy/module/__builtin__/test/test_functional.py +++ b/pypy/module/__builtin__/test/test_functional.py @@ -484,7 +484,7 @@ for a in test_ranges: for b in test_ranges: if a == b: -assert (hash(a), hash(b)) +assert hash(a) == hash(b) # Ranges are unequal to other types (even sequence types) assert (range(0) == ()) is False ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: __dir__ is allowed to return any iterable like in cpython3.
Author: Vasily Kuznetsov Branch: py3.3 Changeset: r72492:72a3a7810d5c Date: 2014-07-26 12:05 +0200 http://bitbucket.org/pypy/pypy/changeset/72a3a7810d5c/ Log:__dir__ is allowed to return any iterable like in cpython3. diff --git a/pypy/module/__builtin__/app_inspect.py b/pypy/module/__builtin__/app_inspect.py --- a/pypy/module/__builtin__/app_inspect.py +++ b/pypy/module/__builtin__/app_inspect.py @@ -52,11 +52,8 @@ dir_meth = lookup_special(obj, "__dir__") if dir_meth is not None: result = dir_meth() -if isinstance(result, tuple): -result = list(result) if not isinstance(result, list): -raise TypeError("__dir__() must return a list, not %r" % ( -type(result),)) +result = list(result) # Will throw TypeError if not iterable result.sort() return result elif isinstance(obj, types.ModuleType): diff --git a/pypy/module/__builtin__/test/test_dir.py b/pypy/module/__builtin__/test/test_dir.py --- a/pypy/module/__builtin__/test/test_dir.py +++ b/pypy/module/__builtin__/test/test_dir.py @@ -1,12 +1,26 @@ class AppTestDir: def test_dir_obj__dir__tuple(self): -"""When __dir__ method returns a tuple, python3 converts it to list.""" - +"""If __dir__ method returns a tuple, cpython3 converts it to list.""" class Foo(object): def __dir__(self): return ("b", "c", "a") - res = dir(Foo()) assert isinstance(res, list) assert res == ["a", "b", "c"] + +def test_dir_obj__dir__genexp(self): +"""Generator expression is also converted to list by cpython3.""" +class Foo(object): +def __dir__(self): +return (i for i in ["b", "c", "a"]) +res = dir(Foo()) +assert isinstance(res, list) +assert res == ["a", "b", "c"] + +def test_dir_obj__dir__noniter(self): +"""If result of __dir__ is not iterable, it's an error.""" +class Foo(object): +def __dir__(self): +return 42 +raises(TypeError, dir, Foo()) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: __dir__ is allowed to return a tuple (it's converted to list like in cpython3).
Author: Vasily Kuznetsov Branch: py3.3 Changeset: r72490:71501209fc12 Date: 2014-07-26 11:22 +0200 http://bitbucket.org/pypy/pypy/changeset/71501209fc12/ Log:__dir__ is allowed to return a tuple (it's converted to list like in cpython3). diff --git a/pypy/module/__builtin__/app_inspect.py b/pypy/module/__builtin__/app_inspect.py --- a/pypy/module/__builtin__/app_inspect.py +++ b/pypy/module/__builtin__/app_inspect.py @@ -52,6 +52,8 @@ dir_meth = lookup_special(obj, "__dir__") if dir_meth is not None: result = dir_meth() +if isinstance(result, tuple): +result = list(result) if not isinstance(result, list): raise TypeError("__dir__() must return a list, not %r" % ( type(result),)) diff --git a/pypy/module/__builtin__/test/test_dir.py b/pypy/module/__builtin__/test/test_dir.py new file mode 100644 --- /dev/null +++ b/pypy/module/__builtin__/test/test_dir.py @@ -0,0 +1,12 @@ +class AppTestDir: + +def test_dir_obj__dir__tuple(self): +"""When __dir__ method returns a tuple, python3 converts it to list.""" + +class Foo(object): +def __dir__(self): +return ("b", "c", "a") + +res = dir(Foo()) +assert isinstance(res, list) +assert res == ["a", "b", "c"] ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: fixing _csv lineterminator exception message
Author: Martin Matusiak Branch: py3.3 Changeset: r72494:cbfe89ead8c2 Date: 2014-07-26 12:12 +0200 http://bitbucket.org/pypy/pypy/changeset/cbfe89ead8c2/ Log:fixing _csv lineterminator exception message diff --git a/pypy/module/_csv/interp_csv.py b/pypy/module/_csv/interp_csv.py --- a/pypy/module/_csv/interp_csv.py +++ b/pypy/module/_csv/interp_csv.py @@ -34,10 +34,15 @@ return default return space.int_w(w_src) -def _get_str(space, w_src, default): +def _get_str(space, w_src, default, attrname): if w_src is None: return default -return space.unicode_w(w_src) +try: +return space.unicode_w(w_src) +except OperationError as e: +if e.match(space, space.w_TypeError): +raise oefmt(space.w_TypeError, '"%s" must be a string', attrname) +raise def _get_char(space, w_src, default, name): if w_src is None: @@ -91,7 +96,7 @@ dialect.delimiter = _get_char(space, w_delimiter, u',', 'delimiter') dialect.doublequote = _get_bool(space, w_doublequote, True) dialect.escapechar = _get_char(space, w_escapechar, u'\0', 'escapechar') -dialect.lineterminator = _get_str(space, w_lineterminator, u'\r\n') +dialect.lineterminator = _get_str(space, w_lineterminator, u'\r\n', 'lineterminator') dialect.quotechar = _get_char(space, w_quotechar, u'"', 'quotechar') tmp_quoting = _get_int(space, w_quoting, QUOTE_MINIMAL) dialect.skipinitialspace = _get_bool(space, w_skipinitialspace, False) diff --git a/pypy/module/_csv/test/test_dialect.py b/pypy/module/_csv/test/test_dialect.py --- a/pypy/module/_csv/test/test_dialect.py +++ b/pypy/module/_csv/test/test_dialect.py @@ -67,6 +67,9 @@ kwargs = {name: value} raises(TypeError, _csv.register_dialect, 'foo1', **kwargs) +exc_info = raises(TypeError, _csv.register_dialect, 'foo1', lineterminator=4) +assert exc_info.value.args[0] == '"lineterminator" must be a string' + def test_bool_arg(self): # boolean arguments take *any* object and use its truth-value import _csv ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: Merged pypy/pypy/py3.3 into py3.3
Author: Martin Matusiak Branch: py3.3 Changeset: r72495:61fd7b56f3ed Date: 2014-07-26 12:41 +0200 http://bitbucket.org/pypy/pypy/changeset/61fd7b56f3ed/ Log:Merged pypy/pypy/py3.3 into py3.3 diff --git a/pypy/module/__builtin__/app_inspect.py b/pypy/module/__builtin__/app_inspect.py --- a/pypy/module/__builtin__/app_inspect.py +++ b/pypy/module/__builtin__/app_inspect.py @@ -53,8 +53,7 @@ if dir_meth is not None: result = dir_meth() if not isinstance(result, list): -raise TypeError("__dir__() must return a list, not %r" % ( -type(result),)) +result = list(result) # Will throw TypeError if not iterable result.sort() return result elif isinstance(obj, types.ModuleType): diff --git a/pypy/module/__builtin__/functional.py b/pypy/module/__builtin__/functional.py --- a/pypy/module/__builtin__/functional.py +++ b/pypy/module/__builtin__/functional.py @@ -482,7 +482,7 @@ def descr_hash(self, space): if space.eq_w(self.w_length, space.wrap(0)): w_tup = space.newtuple([self.w_length, space.w_None, space.w_None]) -elif space.eq_w(self.w_length, space.wrap(0)): +elif space.eq_w(self.w_length, space.wrap(1)): w_tup = space.newtuple([self.w_length, self.w_start, space.w_None]) else: w_tup = space.newtuple([self.w_length, self.w_start, self.w_step]) diff --git a/pypy/module/__builtin__/test/test_construct_singletons.py b/pypy/module/__builtin__/test/test_construct_singletons.py new file mode 100644 --- /dev/null +++ b/pypy/module/__builtin__/test/test_construct_singletons.py @@ -0,0 +1,7 @@ +class AppTestConstructSingletons: + +def test_construct_singletons(self): +none_type = type(None) +assert none_type() is None +raises(TypeError, none_type, 1, 2) +raises(TypeError, none_type, a=1, b=2) diff --git a/pypy/module/__builtin__/test/test_dir.py b/pypy/module/__builtin__/test/test_dir.py new file mode 100644 --- /dev/null +++ b/pypy/module/__builtin__/test/test_dir.py @@ -0,0 +1,26 @@ +class AppTestDir: + +def test_dir_obj__dir__tuple(self): +"""If __dir__ method returns a tuple, cpython3 converts it to list.""" +class Foo(object): +def __dir__(self): +return ("b", "c", "a") +res = dir(Foo()) +assert isinstance(res, list) +assert res == ["a", "b", "c"] + +def test_dir_obj__dir__genexp(self): +"""Generator expression is also converted to list by cpython3.""" +class Foo(object): +def __dir__(self): +return (i for i in ["b", "c", "a"]) +res = dir(Foo()) +assert isinstance(res, list) +assert res == ["a", "b", "c"] + +def test_dir_obj__dir__noniter(self): +"""If result of __dir__ is not iterable, it's an error.""" +class Foo(object): +def __dir__(self): +return 42 +raises(TypeError, dir, Foo()) diff --git a/pypy/module/__builtin__/test/test_functional.py b/pypy/module/__builtin__/test/test_functional.py --- a/pypy/module/__builtin__/test/test_functional.py +++ b/pypy/module/__builtin__/test/test_functional.py @@ -484,7 +484,7 @@ for a in test_ranges: for b in test_ranges: if a == b: -assert (hash(a), hash(b)) +assert hash(a) == hash(b) # Ranges are unequal to other types (even sequence types) assert (range(0) == ()) is False diff --git a/pypy/module/math/__init__.py b/pypy/module/math/__init__.py --- a/pypy/module/math/__init__.py +++ b/pypy/module/math/__init__.py @@ -23,6 +23,7 @@ 'frexp' : 'interp_math.frexp', 'degrees': 'interp_math.degrees', 'log': 'interp_math.log', + 'log2' : 'interp_math.log2', 'log10' : 'interp_math.log10', 'fmod' : 'interp_math.fmod', 'atan' : 'interp_math.atan', diff --git a/pypy/module/math/interp_math.py b/pypy/module/math/interp_math.py --- a/pypy/module/math/interp_math.py +++ b/pypy/module/math/interp_math.py @@ -228,6 +228,11 @@ return math1(space, math.log, w_base) return _log_any(space, w_x, base) +def log2(space, w_x): +"""log2(x) -> the base 2 logarithm of x. +""" +return _log_any(space, w_x, 2.0) + def log10(space, w_x): """log10(x) -> the base 10 logarithm of x. """ diff --git a/pypy/module/math/test/test_math.py b/pypy/module/math/test/test_math.py --- a/pypy/module/math/test/test_math.py +++ b/pypy/module/math/test/test_math.py @@ -148,6 +148,19 @@ raises(ValueError, math.log1p, -1) raises(ValueError, math.log1p, -100) +def test_log2(self): +import math +self.ftest(math.log2(0.125), -3) +self.ftest(math.log2(0.5), -1) +self.ftest(math.log2(4), 2) + +def test_log10
[pypy-commit] pypy py3.3: patching cpython3 csv test as the exception message has bad grammar
Author: Martin Matusiak Branch: py3.3 Changeset: r72493:c94a608f5616 Date: 2014-07-26 11:11 +0200 http://bitbucket.org/pypy/pypy/changeset/c94a608f5616/ Log:patching cpython3 csv test as the exception message has bad grammar diff --git a/lib-python/3/test/test_csv.py b/lib-python/3/test/test_csv.py --- a/lib-python/3/test/test_csv.py +++ b/lib-python/3/test/test_csv.py @@ -766,8 +766,9 @@ mydialect.quotechar = "''" with self.assertRaises(csv.Error) as cm: mydialect() +# NOTE: Patched exception message since cpython uses bad grammar (cpython issue22076) self.assertEqual(str(cm.exception), - '"quotechar" must be an 1-character string') + '"quotechar" must be a 1-character string') mydialect.quotechar = 4 with self.assertRaises(csv.Error) as cm: @@ -789,14 +790,16 @@ mydialect.delimiter = ":::" with self.assertRaises(csv.Error) as cm: mydialect() +# NOTE: Patched exception message since cpython uses bad grammar (cpython issue22076) self.assertEqual(str(cm.exception), - '"delimiter" must be an 1-character string') + '"delimiter" must be a 1-character string') mydialect.delimiter = "" with self.assertRaises(csv.Error) as cm: mydialect() +# NOTE: Patched exception message since cpython uses bad grammar (cpython issue22076) self.assertEqual(str(cm.exception), - '"delimiter" must be an 1-character string') + '"delimiter" must be a 1-character string') mydialect.delimiter = b"," with self.assertRaises(csv.Error) as cm: ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] lang-smalltalk stmgc-c7: End image loading with \n
Author: Malte Swart Branch: stmgc-c7 Changeset: r946:a772ee2447d9 Date: 2014-07-26 13:05 +0200 http://bitbucket.org/pypy/lang-smalltalk/changeset/a772ee2447d9/ Log:End image loading with \n For better reading of further output, end image loading with \n. By this the ouput is separated by a new line. diff --git a/spyvm/squeakimage.py b/spyvm/squeakimage.py --- a/spyvm/squeakimage.py +++ b/spyvm/squeakimage.py @@ -231,6 +231,7 @@ self.init_w_objects() self.fillin_w_objects() self.synchronize_shadows() +os.write(2, "\n") def read_version(self): # 1 word version ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: _posixsubprocess is not optional anymore.
Author: Amaury Forgeot d'Arc Branch: py3.3 Changeset: r72496:2e4e787ecfa6 Date: 2014-07-26 13:22 +0200 http://bitbucket.org/pypy/pypy/changeset/2e4e787ecfa6/ Log:_posixsubprocess is not optional anymore. diff --git a/pypy/module/posix/test/test_posix2.py b/pypy/module/posix/test/test_posix2.py --- a/pypy/module/posix/test/test_posix2.py +++ b/pypy/module/posix/test/test_posix2.py @@ -17,7 +17,7 @@ usemodules = ['binascii', 'posix', 'signal', 'struct', 'rctime'] # py3k os.open uses subprocess, requiring the following per platform if os.name != 'nt': -usemodules += ['fcntl', 'select'] +usemodules += ['fcntl', 'select', '_posixsubprocess'] else: usemodules += ['_rawffi', 'thread'] mod.space = gettestobjspace(usemodules=usemodules) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Oops. If, during translation, we execute app-level code that contains a
Author: Armin Rigo Branch: Changeset: r72497:c97bfecbfc61 Date: 2014-07-26 13:54 +0200 http://bitbucket.org/pypy/pypy/changeset/c97bfecbfc61/ Log:Oops. If, during translation, we execute app-level code that contains a "continue" in a "try:" block, and if we're translating with "-Ojit", then crash. This case occurs in the py3.3 branch. diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py --- a/pypy/interpreter/pyopcode.py +++ b/pypy/interpreter/pyopcode.py @@ -200,7 +200,7 @@ elif opcode == opcodedesc.BREAK_LOOP.index: next_instr = self.BREAK_LOOP(oparg, next_instr) elif opcode == opcodedesc.CONTINUE_LOOP.index: -next_instr = self.CONTINUE_LOOP(oparg, next_instr) +return self.CONTINUE_LOOP(oparg, next_instr) elif opcode == opcodedesc.FOR_ITER.index: next_instr = self.FOR_ITER(oparg, next_instr) elif opcode == opcodedesc.JUMP_FORWARD.index: ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: Oops. If, during translation, we execute app-level code that contains a
Author: Armin Rigo Branch: py3.3 Changeset: r72498:5fbb8de72550 Date: 2014-07-26 13:54 +0200 http://bitbucket.org/pypy/pypy/changeset/5fbb8de72550/ Log:Oops. If, during translation, we execute app-level code that contains a "continue" in a "try:" block, and if we're translating with "-Ojit", then crash. This case occurs in the py3.3 branch. diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py --- a/pypy/interpreter/pyopcode.py +++ b/pypy/interpreter/pyopcode.py @@ -204,7 +204,7 @@ elif opcode == opcodedesc.BREAK_LOOP.index: next_instr = self.BREAK_LOOP(oparg, next_instr) elif opcode == opcodedesc.CONTINUE_LOOP.index: -next_instr = self.CONTINUE_LOOP(oparg, next_instr) +return self.CONTINUE_LOOP(oparg, next_instr) elif opcode == opcodedesc.FOR_ITER.index: next_instr = self.FOR_ITER(oparg, next_instr) elif opcode == opcodedesc.JUMP_FORWARD.index: ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: merge heads
Author: Armin Rigo Branch: py3.3 Changeset: r72500:38d2f98adca7 Date: 2014-07-26 13:57 +0200 http://bitbucket.org/pypy/pypy/changeset/38d2f98adca7/ Log:merge heads diff --git a/pypy/module/posix/test/test_posix2.py b/pypy/module/posix/test/test_posix2.py --- a/pypy/module/posix/test/test_posix2.py +++ b/pypy/module/posix/test/test_posix2.py @@ -17,7 +17,7 @@ usemodules = ['binascii', 'posix', 'signal', 'struct', 'rctime'] # py3k os.open uses subprocess, requiring the following per platform if os.name != 'nt': -usemodules += ['fcntl', 'select'] +usemodules += ['fcntl', 'select', '_posixsubprocess'] else: usemodules += ['_rawffi', 'thread'] mod.space = gettestobjspace(usemodules=usemodules) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: Remove unused return value
Author: Armin Rigo Branch: py3.3 Changeset: r72499:900ace194cd5 Date: 2014-07-26 13:56 +0200 http://bitbucket.org/pypy/pypy/changeset/900ace194cd5/ Log:Remove unused return value diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py --- a/pypy/interpreter/pyopcode.py +++ b/pypy/interpreter/pyopcode.py @@ -1022,7 +1022,6 @@ raise w_value = space.w_None self.pushvalue(w_value) -return next_instr else: # iter remains on stack, w_retval is value to be yielded. self.pushvalue(w_retval) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: creating the RTLD_* constants in the module posix
Author: Attila Gobi Branch: py3.3 Changeset: r72501:2e121b41a4c3 Date: 2014-07-26 13:47 +0200 http://bitbucket.org/pypy/pypy/changeset/2e121b41a4c3/ Log:creating the RTLD_* constants in the module posix diff --git a/pypy/module/posix/__init__.py b/pypy/module/posix/__init__.py --- a/pypy/module/posix/__init__.py +++ b/pypy/module/posix/__init__.py @@ -1,5 +1,6 @@ from pypy.interpreter.mixedmodule import MixedModule from rpython.rtyper.module.ll_os import RegisterOs +from rpython.rlib import rdynload import os exec 'import %s as posix' % os.name @@ -173,6 +174,12 @@ if hasattr(os, name): interpleveldefs[name] = 'interp_posix.' + name +for _name in ["RTLD_LAZY", "RTLD_NOW", "RTLD_GLOBAL", "RTLD_LOCAL", + "RTLD_NODELETE", "RTLD_NOLOAD", "RTLD_DEEPBIND"]: +if getattr(rdynload.cConfig, _name) is not None: +interpleveldefs[_name] = 'space.wrap(%d)' % ( +getattr(rdynload.cConfig, _name),) + # os.py uses this list to build os.supports_dir_fd() and os.supports_fd(). # Fill with e.g. HAVE_FCHDIR, when os.chdir() supports file descriptors. interpleveldefs['_have_functions'] = 'space.newlist([])' diff --git a/pypy/module/posix/test/test_posix2.py b/pypy/module/posix/test/test_posix2.py --- a/pypy/module/posix/test/test_posix2.py +++ b/pypy/module/posix/test/test_posix2.py @@ -1042,6 +1042,12 @@ # just ensure it returns something reasonable assert encoding is None or type(encoding) is str +def test_rtld_constants(self): +# check presence of major RTLD_* constants +self.posix.RTLD_LAZY +self.posix.RTLD_NOW +self.posix.RTLD_GLOBAL +self.posix.RTLD_LOCAL class AppTestEnvironment(object): def setup_class(cls): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: merge heads
Author: Armin Rigo Branch: py3.3 Changeset: r72502:2ff4e3b542b6 Date: 2014-07-26 13:59 +0200 http://bitbucket.org/pypy/pypy/changeset/2ff4e3b542b6/ Log:merge heads diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py --- a/pypy/interpreter/pyopcode.py +++ b/pypy/interpreter/pyopcode.py @@ -204,7 +204,7 @@ elif opcode == opcodedesc.BREAK_LOOP.index: next_instr = self.BREAK_LOOP(oparg, next_instr) elif opcode == opcodedesc.CONTINUE_LOOP.index: -next_instr = self.CONTINUE_LOOP(oparg, next_instr) +return self.CONTINUE_LOOP(oparg, next_instr) elif opcode == opcodedesc.FOR_ITER.index: next_instr = self.FOR_ITER(oparg, next_instr) elif opcode == opcodedesc.JUMP_FORWARD.index: @@ -1022,7 +1022,6 @@ raise w_value = space.w_None self.pushvalue(w_value) -return next_instr else: # iter remains on stack, w_retval is value to be yielded. self.pushvalue(w_retval) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy improve-docs: hg merge default
Author: Manuel Jacob Branch: improve-docs Changeset: r72503:9ca2657fe663 Date: 2014-07-26 14:49 +0200 http://bitbucket.org/pypy/pypy/changeset/9ca2657fe663/ Log:hg merge default diff too long, truncating to 2000 out of 33446 lines diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -10,3 +10,7 @@ 20e51c4389ed4469b66bb9d6289ce0ecfc82c4b9 release-2.3.0 release-2.3.0 394146e9bb673514c61f0150ab2013ccf78e8de7 release-2.3 +32f35069a16d819b58c1b6efb17c44e3e53397b2 release-2.2=3.1 +32f35069a16d819b58c1b6efb17c44e3e53397b2 release-2.3.1 +32f35069a16d819b58c1b6efb17c44e3e53397b2 release-2.2=3.1 + release-2.2=3.1 diff --git a/LICENSE b/LICENSE --- a/LICENSE +++ b/LICENSE @@ -128,6 +128,7 @@ Stian Andreassen Laurence Tratt Wanja Saatkamp +Ivan Sichmann Freitas Gerald Klix Mike Blume Oscar Nierstrasz @@ -212,7 +213,9 @@ Alejandro J. Cura Jacob Oscarson Travis Francis Athougies +Ryan Gonzalez Kristjan Valur Jonsson +Sebastian Pawluś Neil Blakey-Milner anatoly techtonik Lutz Paelike @@ -245,6 +248,7 @@ Michael Hudson-Doyle Anders Sigfridsson Yasir Suhail +rafalgalczyn...@gmail.com Floris Bruynooghe Laurens Van Houtven Akira Li @@ -274,6 +278,8 @@ Zooko Wilcox-O Hearn Tomer Chachamu Christopher Groskopf +Asmo Soinio +Stefan Marr jiaaro opassembler.py Antony Lee diff --git a/lib-python/2.7/ctypes/__init__.py b/lib-python/2.7/ctypes/__init__.py --- a/lib-python/2.7/ctypes/__init__.py +++ b/lib-python/2.7/ctypes/__init__.py @@ -389,12 +389,13 @@ func.__name__ = name_or_ordinal return func -class PyDLL(CDLL): -"""This class represents the Python library itself. It allows to -access Python API functions. The GIL is not released, and -Python exceptions are handled correctly. -""" -_func_flags_ = _FUNCFLAG_CDECL | _FUNCFLAG_PYTHONAPI +# Not in PyPy +#class PyDLL(CDLL): +#"""This class represents the Python library itself. It allows to +#access Python API functions. The GIL is not released, and +#Python exceptions are handled correctly. +#""" +#_func_flags_ = _FUNCFLAG_CDECL | _FUNCFLAG_PYTHONAPI if _os.name in ("nt", "ce"): @@ -447,15 +448,8 @@ return self._dlltype(name) cdll = LibraryLoader(CDLL) -pydll = LibraryLoader(PyDLL) - -if _os.name in ("nt", "ce"): -pythonapi = PyDLL("python dll", None, _sys.dllhandle) -elif _sys.platform == "cygwin": -pythonapi = PyDLL("libpython%d.%d.dll" % _sys.version_info[:2]) -else: -pythonapi = PyDLL(None) - +# not on PyPy +#pydll = LibraryLoader(PyDLL) if _os.name in ("nt", "ce"): windll = LibraryLoader(WinDLL) diff --git a/lib-python/2.7/ctypes/test/test_values.py b/lib-python/2.7/ctypes/test/test_values.py --- a/lib-python/2.7/ctypes/test/test_values.py +++ b/lib-python/2.7/ctypes/test/test_values.py @@ -4,6 +4,7 @@ import unittest from ctypes import * +from ctypes.test import xfail import _ctypes_test @@ -23,7 +24,8 @@ class Win_ValuesTestCase(unittest.TestCase): """This test only works when python itself is a dll/shared library""" - + +@xfail def test_optimizeflag(self): # This test accesses the Py_OptimizeFlag intger, which is # exported by the Python dll. @@ -40,6 +42,7 @@ else: self.assertEqual(opt, 2) +@xfail def test_frozentable(self): # Python exports a PyImport_FrozenModules symbol. This is a # pointer to an array of struct _frozen entries. The end of the @@ -75,6 +78,7 @@ from ctypes import _pointer_type_cache del _pointer_type_cache[struct_frozen] +@xfail def test_undefined(self): self.assertRaises(ValueError, c_int.in_dll, pydll, "Undefined_Symbol") diff --git a/lib-python/2.7/imputil.py b/lib-python/2.7/imputil.py --- a/lib-python/2.7/imputil.py +++ b/lib-python/2.7/imputil.py @@ -422,7 +422,8 @@ saved back to the filesystem for future imports. The source file's modification timestamp must be provided as a Long value. """ -codestring = open(pathname, 'rU').read() +with open(pathname, 'rU') as fp: +codestring = fp.read() if codestring and codestring[-1] != '\n': codestring = codestring + '\n' code = __builtin__.compile(codestring, pathname, 'exec') @@ -603,8 +604,8 @@ self.desc = desc def import_file(self, filename, finfo, fqname): -fp = open(filename, self.desc[1]) -module = imp.load_module(fqname, fp, filename, self.desc) +with open(filename, self.desc[1]) as fp: +module = imp.load_module(fqname, fp, filename, self.desc) module.__file__ = filename return 0, module, { } diff --git a/lib-python/2.7/mod
[pypy-commit] pypy py3.3: Fix zlib's test_decompress_eof.
Author: Valentina Mukhamedzhanova Branch: py3.3 Changeset: r72504:c22750fbe7ad Date: 2014-07-26 14:46 +0200 http://bitbucket.org/pypy/pypy/changeset/c22750fbe7ad/ Log:Fix zlib's test_decompress_eof. diff --git a/pypy/module/zlib/interp_zlib.py b/pypy/module/zlib/interp_zlib.py --- a/pypy/module/zlib/interp_zlib.py +++ b/pypy/module/zlib/interp_zlib.py @@ -1,7 +1,7 @@ import sys from pypy.interpreter.gateway import interp2app, unwrap_spec from pypy.interpreter.baseobjspace import W_Root -from pypy.interpreter.typedef import TypeDef, interp_attrproperty_bytes +from pypy.interpreter.typedef import TypeDef, interp_attrproperty_bytes, interp_attrproperty from pypy.interpreter.error import OperationError, oefmt from rpython.rlib.rarithmetic import intmask, r_uint from rpython.rlib.objectmodel import keepalive_until_here @@ -231,6 +231,7 @@ ZLibObject.__init__(self, space) self.unused_data = '' self.unconsumed_tail = '' +self.eof = False try: self.stream = rzlib.inflateInit(wbits) except rzlib.RZlibError, e: @@ -238,7 +239,7 @@ except ValueError: raise OperationError(space.w_ValueError, space.wrap("Invalid initialization option")) - + def __del__(self): """Automatically free the resources used by the stream.""" if self.stream: @@ -280,6 +281,7 @@ raise zlib_error(space, e.msg) string, finished, unused_len = result +self.eof = finished self._save_unconsumed_input(data, finished, unused_len) return space.wrapbytes(string) @@ -327,6 +329,7 @@ flush = interp2app(Decompress.flush), unused_data = interp_attrproperty_bytes('unused_data', Decompress), unconsumed_tail = interp_attrproperty_bytes('unconsumed_tail', Decompress), +eof = interp_attrproperty('eof', Decompress), __doc__ = """decompressobj([wbits]) -- Return a decompressor object. Optional arg wbits is the window buffer size. diff --git a/pypy/module/zlib/test/test_zlib.py b/pypy/module/zlib/test/test_zlib.py --- a/pypy/module/zlib/test/test_zlib.py +++ b/pypy/module/zlib/test/test_zlib.py @@ -166,6 +166,18 @@ dco = zlib.decompressobj() assert dco.flush() == b"" +def test_decompress_eof(self): +import zlib +x = b'x\x9cK\xcb\xcf\x07\x00\x02\x82\x01E' # 'foo' +dco = zlib.decompressobj() +assert dco.eof == False +dco.decompress(x[:-5]) +assert dco.eof == False +dco.decompress(x[-5:]) +assert dco.eof == True +dco.flush() +assert dco.eof == True + def test_decompress_incomplete_stream(self): import zlib # This is 'foo', deflated ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: Merge heads.
Author: Valentina Mukhamedzhanova Branch: py3.3 Changeset: r72505:4bba41190d41 Date: 2014-07-26 14:48 +0200 http://bitbucket.org/pypy/pypy/changeset/4bba41190d41/ Log:Merge heads. diff --git a/lib-python/3/json/__init__.py b/lib-python/3/json/__init__.py --- a/lib-python/3/json/__init__.py +++ b/lib-python/3/json/__init__.py @@ -104,6 +104,12 @@ __author__ = 'Bob Ippolito ' +try: +# PyPy speedup, the interface is different than CPython's _json +import _pypyjson +except ImportError: +_pypyjson = None + from .decoder import JSONDecoder from .encoder import JSONEncoder @@ -313,7 +319,7 @@ if (cls is None and object_hook is None and parse_int is None and parse_float is None and parse_constant is None and object_pairs_hook is None and not kw): -return _default_decoder.decode(s) +return _pypyjson.loads(s) if _pypyjson else _default_decoder.decode(s) if cls is None: cls = JSONDecoder if object_hook is not None: diff --git a/lib-python/3/test/test_csv.py b/lib-python/3/test/test_csv.py --- a/lib-python/3/test/test_csv.py +++ b/lib-python/3/test/test_csv.py @@ -766,8 +766,9 @@ mydialect.quotechar = "''" with self.assertRaises(csv.Error) as cm: mydialect() +# NOTE: Patched exception message since cpython uses bad grammar (cpython issue22076) self.assertEqual(str(cm.exception), - '"quotechar" must be an 1-character string') + '"quotechar" must be a 1-character string') mydialect.quotechar = 4 with self.assertRaises(csv.Error) as cm: @@ -789,14 +790,16 @@ mydialect.delimiter = ":::" with self.assertRaises(csv.Error) as cm: mydialect() +# NOTE: Patched exception message since cpython uses bad grammar (cpython issue22076) self.assertEqual(str(cm.exception), - '"delimiter" must be an 1-character string') + '"delimiter" must be a 1-character string') mydialect.delimiter = "" with self.assertRaises(csv.Error) as cm: mydialect() +# NOTE: Patched exception message since cpython uses bad grammar (cpython issue22076) self.assertEqual(str(cm.exception), - '"delimiter" must be an 1-character string') + '"delimiter" must be a 1-character string') mydialect.delimiter = b"," with self.assertRaises(csv.Error) as cm: diff --git a/lib-python/stdlib-version.txt b/lib-python/stdlib-version.txt --- a/lib-python/stdlib-version.txt +++ b/lib-python/stdlib-version.txt @@ -6,4 +6,4 @@ 2.7:: 3a1db0d2747e (2.7) v2.7.6 3:: -cef745775b65 (3.2) v3.2.5 +62cf4e77f785 (3.3) v3.3.5 diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py --- a/pypy/interpreter/pyopcode.py +++ b/pypy/interpreter/pyopcode.py @@ -204,7 +204,7 @@ elif opcode == opcodedesc.BREAK_LOOP.index: next_instr = self.BREAK_LOOP(oparg, next_instr) elif opcode == opcodedesc.CONTINUE_LOOP.index: -next_instr = self.CONTINUE_LOOP(oparg, next_instr) +return self.CONTINUE_LOOP(oparg, next_instr) elif opcode == opcodedesc.FOR_ITER.index: next_instr = self.FOR_ITER(oparg, next_instr) elif opcode == opcodedesc.JUMP_FORWARD.index: @@ -1022,7 +1022,6 @@ raise w_value = space.w_None self.pushvalue(w_value) -return next_instr else: # iter remains on stack, w_retval is value to be yielded. self.pushvalue(w_retval) diff --git a/pypy/interpreter/test/test_generator.py b/pypy/interpreter/test/test_generator.py --- a/pypy/interpreter/test/test_generator.py +++ b/pypy/interpreter/test/test_generator.py @@ -307,13 +307,13 @@ w_co = space.appexec([], '''(): def g(x): yield x + 5 -return g.func_code +return g.__code__ ''') assert should_not_inline(w_co) == False w_co = space.appexec([], '''(): def g(x): yield x + 5 yield x + 6 -return g.func_code +return g.__code__ ''') assert should_not_inline(w_co) == True diff --git a/pypy/module/__builtin__/app_inspect.py b/pypy/module/__builtin__/app_inspect.py --- a/pypy/module/__builtin__/app_inspect.py +++ b/pypy/module/__builtin__/app_inspect.py @@ -53,8 +53,7 @@ if dir_meth is not None: result = dir_meth() if not isinstance(result, list): -raise TypeError("__dir__() must return a list, not %r" % ( -type(result),)) +result = list(result) # Will throw TypeError if not iterable result.sort() return result elif isinstance(obj, types.ModuleType): diff --git a/pypy/module/__builtin
[pypy-commit] pypy py3.3: Merged in numerodix/pypy/py3.3 (pull request #249)
Author: Armin Rigo Branch: py3.3 Changeset: r72507:a85920372113 Date: 2014-07-26 15:07 +0200 http://bitbucket.org/pypy/pypy/changeset/a85920372113/ Log:Merged in numerodix/pypy/py3.3 (pull request #249) Removing sys.flags.division_warning (removed in 3.3) diff --git a/pypy/interpreter/app_main.py b/pypy/interpreter/app_main.py --- a/pypy/interpreter/app_main.py +++ b/pypy/interpreter/app_main.py @@ -317,7 +317,6 @@ # Order is significant! sys_flags = ( "debug", -"division_warning", "inspect", "interactive", "optimize", diff --git a/pypy/module/sys/app.py b/pypy/module/sys/app.py --- a/pypy/module/sys/app.py +++ b/pypy/module/sys/app.py @@ -94,20 +94,19 @@ name = "sys.flags" debug = structseqfield(0) -division_warning = structseqfield(1) -inspect = structseqfield(2) -interactive = structseqfield(3) -optimize = structseqfield(4) -dont_write_bytecode = structseqfield(5) -no_user_site = structseqfield(6) -no_site = structseqfield(7) -ignore_environment = structseqfield(8) -verbose = structseqfield(9) -bytes_warning = structseqfield(10) -quiet = structseqfield(11) -hash_randomization = structseqfield(12) +inspect = structseqfield(1) +interactive = structseqfield(2) +optimize = structseqfield(3) +dont_write_bytecode = structseqfield(4) +no_user_site = structseqfield(5) +no_site = structseqfield(6) +ignore_environment = structseqfield(7) +verbose = structseqfield(8) +bytes_warning = structseqfield(9) +quiet = structseqfield(10) +hash_randomization = structseqfield(11) -null_sysflags = sysflags((0,)*13) +null_sysflags = sysflags((0,)*12) null__xoptions = {} ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: Removing sys.flags.division_warning (removed in 3.3)
Author: Martin Matusiak Branch: py3.3 Changeset: r72506:d4642496139c Date: 2014-07-26 15:02 +0200 http://bitbucket.org/pypy/pypy/changeset/d4642496139c/ Log:Removing sys.flags.division_warning (removed in 3.3) diff --git a/pypy/interpreter/app_main.py b/pypy/interpreter/app_main.py --- a/pypy/interpreter/app_main.py +++ b/pypy/interpreter/app_main.py @@ -317,7 +317,6 @@ # Order is significant! sys_flags = ( "debug", -"division_warning", "inspect", "interactive", "optimize", diff --git a/pypy/module/sys/app.py b/pypy/module/sys/app.py --- a/pypy/module/sys/app.py +++ b/pypy/module/sys/app.py @@ -94,20 +94,19 @@ name = "sys.flags" debug = structseqfield(0) -division_warning = structseqfield(1) -inspect = structseqfield(2) -interactive = structseqfield(3) -optimize = structseqfield(4) -dont_write_bytecode = structseqfield(5) -no_user_site = structseqfield(6) -no_site = structseqfield(7) -ignore_environment = structseqfield(8) -verbose = structseqfield(9) -bytes_warning = structseqfield(10) -quiet = structseqfield(11) -hash_randomization = structseqfield(12) +inspect = structseqfield(1) +interactive = structseqfield(2) +optimize = structseqfield(3) +dont_write_bytecode = structseqfield(4) +no_user_site = structseqfield(5) +no_site = structseqfield(6) +ignore_environment = structseqfield(7) +verbose = structseqfield(8) +bytes_warning = structseqfield(9) +quiet = structseqfield(10) +hash_randomization = structseqfield(11) -null_sysflags = sysflags((0,)*13) +null_sysflags = sysflags((0,)*12) null__xoptions = {} ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy improve-docs: RPython docs: Use read the docs theme locally if available (copied from PyPy docs configuration).
Author: Manuel Jacob Branch: improve-docs Changeset: r72508:8e884ef6d1d1 Date: 2014-07-26 15:17 +0200 http://bitbucket.org/pypy/pypy/changeset/8e884ef6d1d1/ Log:RPython docs: Use read the docs theme locally if available (copied from PyPy docs configuration). diff --git a/rpython/doc/conf.py b/rpython/doc/conf.py --- a/rpython/doc/conf.py +++ b/rpython/doc/conf.py @@ -18,6 +18,24 @@ # documentation root, use os.path.abspath to make it absolute, like shown here. #sys.path.insert(0, os.path.abspath('.')) + +# -- Read The Docs theme config + +# on_rtd is whether we are on readthedocs.org, this line of code grabbed from docs.readthedocs.org +on_rtd = os.environ.get('READTHEDOCS', None) == 'True' + +if not on_rtd: # only import and set the theme if we're building docs locally +try: +import sphinx_rtd_theme +html_theme = 'sphinx_rtd_theme' +html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] +except ImportError: +print('sphinx_rtd_theme is not installed') +html_theme = 'default' + +# otherwise, readthedocs.org uses their theme by default, so no need to specify it + + # -- General configuration - # If your documentation needs a minimal Sphinx version, state it here. @@ -91,7 +109,7 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -html_theme = 'default' +#html_theme = 'default' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: merge heads
Author: Armin Rigo Branch: py3.3 Changeset: r72510:4e00d712484e Date: 2014-07-26 15:27 +0200 http://bitbucket.org/pypy/pypy/changeset/4e00d712484e/ Log:merge heads diff --git a/pypy/module/zlib/test/test_zlib.py b/pypy/module/zlib/test/test_zlib.py --- a/pypy/module/zlib/test/test_zlib.py +++ b/pypy/module/zlib/test/test_zlib.py @@ -177,6 +177,16 @@ assert dco.eof == True dco.flush() assert dco.eof == True + +def test_decompress_eof_incomplete_stream(self): +import zlib +x = b'x\x9cK\xcb\xcf\x07\x00\x02\x82\x01E' # 'foo' +dco = zlib.decompressobj() +assert dco.eof == False +dco.decompress(x[:-5]) +assert dco.eof == False +dco.flush() +assert dco.eof == False def test_decompress_incomplete_stream(self): import zlib ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: Add test_decompress_eof_incomplete_stream to test_zlib.py.
Author: Valentina Mukhamedzhanova Branch: py3.3 Changeset: r72509:2b2441e85ee2 Date: 2014-07-26 15:14 +0200 http://bitbucket.org/pypy/pypy/changeset/2b2441e85ee2/ Log:Add test_decompress_eof_incomplete_stream to test_zlib.py. diff --git a/pypy/module/zlib/test/test_zlib.py b/pypy/module/zlib/test/test_zlib.py --- a/pypy/module/zlib/test/test_zlib.py +++ b/pypy/module/zlib/test/test_zlib.py @@ -177,6 +177,16 @@ assert dco.eof == True dco.flush() assert dco.eof == True + +def test_decompress_eof_incomplete_stream(self): +import zlib +x = b'x\x9cK\xcb\xcf\x07\x00\x02\x82\x01E' # 'foo' +dco = zlib.decompressobj() +assert dco.eof == False +dco.decompress(x[:-5]) +assert dco.eof == False +dco.flush() +assert dco.eof == False def test_decompress_incomplete_stream(self): import zlib ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Remove these old comments
Author: Armin Rigo Branch: Changeset: r72511:e65dfce91ce5 Date: 2014-07-26 15:34 +0200 http://bitbucket.org/pypy/pypy/changeset/e65dfce91ce5/ Log:Remove these old comments diff --git a/pypy/objspace/std/iterobject.py b/pypy/objspace/std/iterobject.py --- a/pypy/objspace/std/iterobject.py +++ b/pypy/objspace/std/iterobject.py @@ -30,10 +30,6 @@ raise NotImplementedError def descr_reduce(self, space): -""" -XXX to do: remove this __reduce__ method and do -a registration with copy_reg, instead. -""" from pypy.interpreter.mixedmodule import MixedModule w_mod = space.getbuiltinmodule('_pickle_support') mod = space.interp_w(MixedModule, w_mod) @@ -125,10 +121,6 @@ self.index = space.int_w(self.w_len) + index def descr_reduce(self, space): -""" -XXX to do: remove this __reduce__ method and do -a registration with copy_reg, instead. -""" from pypy.interpreter.mixedmodule import MixedModule w_mod = space.getbuiltinmodule('_pickle_support') mod = space.interp_w(MixedModule, w_mod) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: Fixed pickling of iterators produced by filter(func, iter).
Author: Vasily Kuznetsov Branch: py3.3 Changeset: r72512:6aecbffc27c8 Date: 2014-07-26 15:32 +0200 http://bitbucket.org/pypy/pypy/changeset/6aecbffc27c8/ Log:Fixed pickling of iterators produced by filter(func, iter). diff --git a/pypy/module/__builtin__/functional.py b/pypy/module/__builtin__/functional.py --- a/pypy/module/__builtin__/functional.py +++ b/pypy/module/__builtin__/functional.py @@ -711,6 +711,13 @@ if pred ^ self.reverse: return w_obj +def descr_reduce(self, space): +w_filter = space.getattr(space.getbuiltinmodule('builtins'), +space.wrap('filter')) +args = [space.w_None if self.no_predicate else self.w_predicate, +self.iterable] +return space.newtuple([w_filter, space.newtuple(args)]) + def W_Filter___new__(space, w_subtype, w_predicate, w_iterable): r = space.allocate_instance(W_Filter, w_subtype) @@ -722,6 +729,7 @@ __new__ = interp2app(W_Filter___new__), __iter__ = interp2app(W_Filter.iter_w), __next__ = interp2app(W_Filter.next_w), +__reduce__ = interp2app(W_Filter.descr_reduce), __doc__ = """\ Return an iterator yielding those items of iterable for which function(item) is true. If function is None, return the items that are true.""") diff --git a/pypy/module/__builtin__/test/test_filter_pickle.py b/pypy/module/__builtin__/test/test_filter_pickle.py new file mode 100644 --- /dev/null +++ b/pypy/module/__builtin__/test/test_filter_pickle.py @@ -0,0 +1,72 @@ +class AppTestFilterPickle: + +def test_filter_unpickle(self): +"""Test just the unpickling.""" +import pickle + +# This is filter(None, 'abc') pickled with cpython +dump = b'\x80\x03cbuiltins\nfilter\nq\x00Ncbuiltins\niter\nq\x01X\x03'\ + b'\x00\x00\x00abcq\x02\x85q\x03Rq\x04K\x00b\x86q\x05Rq\x06.' +t = pickle.loads(dump) +assert list(t) == ['a', 'b', 'c'] + +def test_iterator_pickle(self): +"""Pickle and unpickle just a simple iterator.""" +import pickle + +i0 = iter("abc") +i1 = iter("abc") + +d = pickle.dumps(i1) +i1 = pickle.loads(d) + +assert list(i0) == list(i1) + +def test_reduce_ex(self): +"" +f0 = filter(None, "abc") +f1 = filter(None, "abc") + +print(f0) +r = f1.__reduce_ex__(3) +# __reduce_ex__ doesn't return any arguments to the filter, so the next +# line will fail with TypeError. +f1 = r[0](*r[1]) + +assert list(f0) == list(f1) + +def test_nonfilter_pickle(self): +"""Pickle and unpickle a filter with no filtering.""" +import pickle + +f0 = filter(None, "abc") +d = pickle.dumps(f0) +f1 = pickle.loads(d) + +def test_filter_pickle(self): +"""Clone of the original test.""" +import pickle + +def check_iter_pickle(it, seq): +itorg = it +d = pickle.dumps(it) +it = pickle.loads(d) +assert type(itorg) == type(it) +assert list(it) == seq + +#test the iterator after dropping one from it +it = pickle.loads(d) +try: +next(it) +except StopIteration: +return +d = pickle.dumps(it) +it = pickle.loads(d) +assert list(it) == seq[1:] + +# We use ord instead of filter_char because the filter function has to +# be defined in the global scope for the picking to work and we can't +# do it from this test. +f1 = filter(ord, "abcdeabcde") +f2 = filter(ord, "abcdeabcde") +check_iter_pickle(f1, list(f2)) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: merge heads
Author: Armin Rigo Branch: py3.3 Changeset: r72513:b14679e8321d Date: 2014-07-26 15:35 +0200 http://bitbucket.org/pypy/pypy/changeset/b14679e8321d/ Log:merge heads diff --git a/pypy/module/__builtin__/functional.py b/pypy/module/__builtin__/functional.py --- a/pypy/module/__builtin__/functional.py +++ b/pypy/module/__builtin__/functional.py @@ -711,6 +711,13 @@ if pred ^ self.reverse: return w_obj +def descr_reduce(self, space): +w_filter = space.getattr(space.getbuiltinmodule('builtins'), +space.wrap('filter')) +args = [space.w_None if self.no_predicate else self.w_predicate, +self.iterable] +return space.newtuple([w_filter, space.newtuple(args)]) + def W_Filter___new__(space, w_subtype, w_predicate, w_iterable): r = space.allocate_instance(W_Filter, w_subtype) @@ -722,6 +729,7 @@ __new__ = interp2app(W_Filter___new__), __iter__ = interp2app(W_Filter.iter_w), __next__ = interp2app(W_Filter.next_w), +__reduce__ = interp2app(W_Filter.descr_reduce), __doc__ = """\ Return an iterator yielding those items of iterable for which function(item) is true. If function is None, return the items that are true.""") diff --git a/pypy/module/__builtin__/test/test_filter_pickle.py b/pypy/module/__builtin__/test/test_filter_pickle.py new file mode 100644 --- /dev/null +++ b/pypy/module/__builtin__/test/test_filter_pickle.py @@ -0,0 +1,72 @@ +class AppTestFilterPickle: + +def test_filter_unpickle(self): +"""Test just the unpickling.""" +import pickle + +# This is filter(None, 'abc') pickled with cpython +dump = b'\x80\x03cbuiltins\nfilter\nq\x00Ncbuiltins\niter\nq\x01X\x03'\ + b'\x00\x00\x00abcq\x02\x85q\x03Rq\x04K\x00b\x86q\x05Rq\x06.' +t = pickle.loads(dump) +assert list(t) == ['a', 'b', 'c'] + +def test_iterator_pickle(self): +"""Pickle and unpickle just a simple iterator.""" +import pickle + +i0 = iter("abc") +i1 = iter("abc") + +d = pickle.dumps(i1) +i1 = pickle.loads(d) + +assert list(i0) == list(i1) + +def test_reduce_ex(self): +"" +f0 = filter(None, "abc") +f1 = filter(None, "abc") + +print(f0) +r = f1.__reduce_ex__(3) +# __reduce_ex__ doesn't return any arguments to the filter, so the next +# line will fail with TypeError. +f1 = r[0](*r[1]) + +assert list(f0) == list(f1) + +def test_nonfilter_pickle(self): +"""Pickle and unpickle a filter with no filtering.""" +import pickle + +f0 = filter(None, "abc") +d = pickle.dumps(f0) +f1 = pickle.loads(d) + +def test_filter_pickle(self): +"""Clone of the original test.""" +import pickle + +def check_iter_pickle(it, seq): +itorg = it +d = pickle.dumps(it) +it = pickle.loads(d) +assert type(itorg) == type(it) +assert list(it) == seq + +#test the iterator after dropping one from it +it = pickle.loads(d) +try: +next(it) +except StopIteration: +return +d = pickle.dumps(it) +it = pickle.loads(d) +assert list(it) == seq[1:] + +# We use ord instead of filter_char because the filter function has to +# be defined in the global scope for the picking to work and we can't +# do it from this test. +f1 = filter(ord, "abcdeabcde") +f2 = filter(ord, "abcdeabcde") +check_iter_pickle(f1, list(f2)) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: Merge
Author: Arjun Naik Branch: py3.3 Changeset: r72515:2c99b4f912ad Date: 2014-07-26 15:52 +0200 http://bitbucket.org/pypy/pypy/changeset/2c99b4f912ad/ Log:Merge diff --git a/pypy/interpreter/app_main.py b/pypy/interpreter/app_main.py --- a/pypy/interpreter/app_main.py +++ b/pypy/interpreter/app_main.py @@ -317,7 +317,6 @@ # Order is significant! sys_flags = ( "debug", -"division_warning", "inspect", "interactive", "optimize", diff --git a/pypy/module/__builtin__/functional.py b/pypy/module/__builtin__/functional.py --- a/pypy/module/__builtin__/functional.py +++ b/pypy/module/__builtin__/functional.py @@ -711,6 +711,13 @@ if pred ^ self.reverse: return w_obj +def descr_reduce(self, space): +w_filter = space.getattr(space.getbuiltinmodule('builtins'), +space.wrap('filter')) +args = [space.w_None if self.no_predicate else self.w_predicate, +self.iterable] +return space.newtuple([w_filter, space.newtuple(args)]) + def W_Filter___new__(space, w_subtype, w_predicate, w_iterable): r = space.allocate_instance(W_Filter, w_subtype) @@ -722,6 +729,7 @@ __new__ = interp2app(W_Filter___new__), __iter__ = interp2app(W_Filter.iter_w), __next__ = interp2app(W_Filter.next_w), +__reduce__ = interp2app(W_Filter.descr_reduce), __doc__ = """\ Return an iterator yielding those items of iterable for which function(item) is true. If function is None, return the items that are true.""") diff --git a/pypy/module/__builtin__/test/test_filter_pickle.py b/pypy/module/__builtin__/test/test_filter_pickle.py new file mode 100644 --- /dev/null +++ b/pypy/module/__builtin__/test/test_filter_pickle.py @@ -0,0 +1,72 @@ +class AppTestFilterPickle: + +def test_filter_unpickle(self): +"""Test just the unpickling.""" +import pickle + +# This is filter(None, 'abc') pickled with cpython +dump = b'\x80\x03cbuiltins\nfilter\nq\x00Ncbuiltins\niter\nq\x01X\x03'\ + b'\x00\x00\x00abcq\x02\x85q\x03Rq\x04K\x00b\x86q\x05Rq\x06.' +t = pickle.loads(dump) +assert list(t) == ['a', 'b', 'c'] + +def test_iterator_pickle(self): +"""Pickle and unpickle just a simple iterator.""" +import pickle + +i0 = iter("abc") +i1 = iter("abc") + +d = pickle.dumps(i1) +i1 = pickle.loads(d) + +assert list(i0) == list(i1) + +def test_reduce_ex(self): +"" +f0 = filter(None, "abc") +f1 = filter(None, "abc") + +print(f0) +r = f1.__reduce_ex__(3) +# __reduce_ex__ doesn't return any arguments to the filter, so the next +# line will fail with TypeError. +f1 = r[0](*r[1]) + +assert list(f0) == list(f1) + +def test_nonfilter_pickle(self): +"""Pickle and unpickle a filter with no filtering.""" +import pickle + +f0 = filter(None, "abc") +d = pickle.dumps(f0) +f1 = pickle.loads(d) + +def test_filter_pickle(self): +"""Clone of the original test.""" +import pickle + +def check_iter_pickle(it, seq): +itorg = it +d = pickle.dumps(it) +it = pickle.loads(d) +assert type(itorg) == type(it) +assert list(it) == seq + +#test the iterator after dropping one from it +it = pickle.loads(d) +try: +next(it) +except StopIteration: +return +d = pickle.dumps(it) +it = pickle.loads(d) +assert list(it) == seq[1:] + +# We use ord instead of filter_char because the filter function has to +# be defined in the global scope for the picking to work and we can't +# do it from this test. +f1 = filter(ord, "abcdeabcde") +f2 = filter(ord, "abcdeabcde") +check_iter_pickle(f1, list(f2)) diff --git a/pypy/module/sys/app.py b/pypy/module/sys/app.py --- a/pypy/module/sys/app.py +++ b/pypy/module/sys/app.py @@ -94,20 +94,19 @@ name = "sys.flags" debug = structseqfield(0) -division_warning = structseqfield(1) -inspect = structseqfield(2) -interactive = structseqfield(3) -optimize = structseqfield(4) -dont_write_bytecode = structseqfield(5) -no_user_site = structseqfield(6) -no_site = structseqfield(7) -ignore_environment = structseqfield(8) -verbose = structseqfield(9) -bytes_warning = structseqfield(10) -quiet = structseqfield(11) -hash_randomization = structseqfield(12) +inspect = structseqfield(1) +interactive = structseqfield(2) +optimize = structseqfield(3) +dont_write_bytecode = structseqfield(4) +no_user_site = structseqfield(5) +no_site = structseqfield(6) +ignore_environment = structseqfield(7) +verbose = structseqfield(8) +bytes_warning = structseqfield(
[pypy-commit] pypy py3.3: Changed the _get_inttime() to raise OverflowError.
Author: Arjun Naik Branch: py3.3 Changeset: r72514:8ccff189b82f Date: 2014-07-26 15:11 +0200 http://bitbucket.org/pypy/pypy/changeset/8ccff189b82f/ Log:Changed the _get_inttime() to raise OverflowError. diff --git a/pypy/module/rctime/interp_time.py b/pypy/module/rctime/interp_time.py --- a/pypy/module/rctime/interp_time.py +++ b/pypy/module/rctime/interp_time.py @@ -364,7 +364,7 @@ # input doesn't fit in a time_t; call it an error. diff = seconds - rffi.cast(lltype.Float, t) if diff <= -1.0 or diff >= 1.0: -raise OperationError(space.w_ValueError, +raise OperationError(space.w_OverflowError, space.wrap("timestamp out of range for platform time_t")) return t diff --git a/pypy/module/rctime/test/test_rctime.py b/pypy/module/rctime/test/test_rctime.py --- a/pypy/module/rctime/test/test_rctime.py +++ b/pypy/module/rctime/test/test_rctime.py @@ -42,7 +42,7 @@ res = rctime.ctime(0) assert isinstance(res, str) rctime.ctime(rctime.time()) -raises(ValueError, rctime.ctime, 1E200) +raises(OverflowError, rctime.ctime, 1E200) raises(OverflowError, rctime.ctime, 10**900) for year in [-100, 100, 1000, 2000, 1]: try: @@ -68,8 +68,8 @@ assert 0 <= (t1 - t0) < 1.2 t = rctime.time() assert rctime.gmtime(t) == rctime.gmtime(t) -raises(ValueError, rctime.gmtime, 2**64) -raises(ValueError, rctime.gmtime, -2**64) +raises(OverflowError, rctime.gmtime, 2**64) +raises(OverflowError, rctime.gmtime, -2**64) def test_localtime(self): import time as rctime ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: Fixed pickling of iterators produced by map(func, iter, ...).
Author: Vasily Kuznetsov Branch: py3.3 Changeset: r72516:b30c4330c8b3 Date: 2014-07-26 15:57 +0200 http://bitbucket.org/pypy/pypy/changeset/b30c4330c8b3/ Log:Fixed pickling of iterators produced by map(func, iter, ...). diff --git a/pypy/module/__builtin__/functional.py b/pypy/module/__builtin__/functional.py --- a/pypy/module/__builtin__/functional.py +++ b/pypy/module/__builtin__/functional.py @@ -667,6 +667,12 @@ # the loop is out of the way of the JIT return [self.space.next(w_elem) for w_elem in self.iterators_w] +def descr_reduce(self, space): +w_map = space.getattr(space.getbuiltinmodule('builtins'), +space.wrap('map')) +args = [self.w_fun] + self.iterators_w +return space.newtuple([w_map, space.newtuple(args)]) + def W_Map___new__(space, w_subtype, w_fun, args_w): if len(args_w) == 0: @@ -681,6 +687,7 @@ __new__ = interp2app(W_Map___new__), __iter__ = interp2app(W_Map.iter_w), __next__ = interp2app(W_Map.next_w), +__reduce__ = interp2app(W_Map.descr_reduce), __doc__ = """\ Make an iterator that computes the function using arguments from each of the iterables. Stops when the shortest iterable is exhausted.""") diff --git a/pypy/module/__builtin__/test/test_map_pickle.py b/pypy/module/__builtin__/test/test_map_pickle.py new file mode 100644 --- /dev/null +++ b/pypy/module/__builtin__/test/test_map_pickle.py @@ -0,0 +1,28 @@ +class AppTestMapPickle: + +def test_map_pickle(self): +"""Pickle a map with one sequence.""" +import pickle + +def pickle_unpickle(obj): +d = pickle.dumps(obj) +return pickle.loads(d) + +m1 = map(ord, "Is this the real life?") +m1_ = pickle_unpickle(m1) + +assert list(m1) == list(m1_) + +def test_map2_pickle(self): +"""Pickle a map with multiple sequences.""" +import pickle + +def pickle_unpickle(obj): +d = pickle.dumps(obj) +return pickle.loads(d) + +m1 = map(max, "abc", "def") +m1_ = pickle_unpickle(m1) + +assert list(m1) == list(m1_) + ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: Added a test for the situation when one of the iterators given to map has been already advanced (suggested by Armin Rigo).
Author: Vasily Kuznetsov Branch: py3.3 Changeset: r72517:88e3c7e587b4 Date: 2014-07-26 16:05 +0200 http://bitbucket.org/pypy/pypy/changeset/88e3c7e587b4/ Log:Added a test for the situation when one of the iterators given to map has been already advanced (suggested by Armin Rigo). diff --git a/pypy/module/__builtin__/test/test_map_pickle.py b/pypy/module/__builtin__/test/test_map_pickle.py --- a/pypy/module/__builtin__/test/test_map_pickle.py +++ b/pypy/module/__builtin__/test/test_map_pickle.py @@ -26,3 +26,19 @@ assert list(m1) == list(m1_) +def test_map2_adv_pickle(self): +"""If some iterator was advanced, the pickling preserves it.""" +import pickle + +def pickle_unpickle(obj): +d = pickle.dumps(obj) +return pickle.loads(d) + +s1 = iter("abc") +s2 = iter("defg") +next(s2) + +m1 = map(max, s1, s2) +m1_ = pickle_unpickle(m1) + +assert list(m1) == list(m1_) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy improve-docs: RPython docs: Delete contents.rst and move toctree to index.rst.
Author: Manuel Jacob Branch: improve-docs Changeset: r72518:e8bf18c22cdb Date: 2014-07-26 15:23 +0200 http://bitbucket.org/pypy/pypy/changeset/e8bf18c22cdb/ Log:RPython docs: Delete contents.rst and move toctree to index.rst. diff --git a/rpython/doc/contents.rst b/rpython/doc/contents.rst deleted file mode 100644 --- a/rpython/doc/contents.rst +++ /dev/null @@ -1,19 +0,0 @@ -Table of Contents -=== - -Contents: - -.. toctree:: - :maxdepth: 2 - - getting-started - faq - rpython - rlib - rffi - translation - rtyper - garbage_collection - cli-backend - windows - diff --git a/rpython/doc/index.rst b/rpython/doc/index.rst --- a/rpython/doc/index.rst +++ b/rpython/doc/index.rst @@ -1,7 +1,23 @@ Welcome to RPython's documentation! === -* :doc:`contents` +Table of Contents +- + +.. toctree:: + :maxdepth: 1 + + getting-started + faq + rpython + rlib + rffi + translation + rtyper + garbage_collection + cli-backend + windows + Indices and tables == @@ -9,4 +25,3 @@ * :ref:`genindex` * :ref:`modindex` * :ref:`search` - ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy improve-docs: Rename title of rpython.rst from "RPython" to "RPython Language".
Author: Manuel Jacob Branch: improve-docs Changeset: r72519:79f23ae997e3 Date: 2014-07-26 16:10 +0200 http://bitbucket.org/pypy/pypy/changeset/79f23ae997e3/ Log:Rename title of rpython.rst from "RPython" to "RPython Language". diff --git a/rpython/doc/rpython.rst b/rpython/doc/rpython.rst --- a/rpython/doc/rpython.rst +++ b/rpython/doc/rpython.rst @@ -1,8 +1,8 @@ -RPython -=== +RPython Language + -RPython Definition --- +Definition +-- RPython is a restricted subset of Python that is amenable to static analysis. Although there are additions to the language and some things might surprisingly ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy gc-incminimark-pinning: wip: implement use case "old object points to pinned object".
Author: Gregor Wegberg Branch: gc-incminimark-pinning Changeset: r72522:754f9578ee1a Date: 2014-07-02 15:15 +0200 http://bitbucket.org/pypy/pypy/changeset/754f9578ee1a/ Log:wip: implement use case "old object points to pinned object". This is very much a work in progress commit. Still a lot to check, refactor and document. diff --git a/rpython/memory/gc/incminimark.py b/rpython/memory/gc/incminimark.py --- a/rpython/memory/gc/incminimark.py +++ b/rpython/memory/gc/incminimark.py @@ -380,6 +380,8 @@ # Counter tracking how many pinned objects currently reside inside # the nursery. self.pinned_objects_in_nursery = 0 +# TTT XXX +self.pinned_objects_keep_alive = self.AddressStack() # # Allocate a nursery. In case of auto_nursery_size, start by # allocating a very small nursery, enough to do things like look @@ -1601,6 +1603,15 @@ # them or make them old. if self.young_rawmalloced_objects: self.free_young_rawmalloced_objects() + +# +# In case we have to keep some pinned objects alive, add them +# to 'surviving_pinned_objects'. Such a case comes up if an old +# object references a pinned young one (pinned object inside +# the nursery). See '_trace_drag_out' for more details. +if self.pinned_objects_keep_alive.non_empty(): +self.pinned_objects_keep_alive.foreach( +self._populate_to_surviving_pinned_objects, None) # # All live nursery objects are out of the nursery or pinned inside # the nursery. Create nursery barriers to protect the pinned object, @@ -1620,6 +1631,7 @@ # clear the arena between the last pinned object (or arena start) # and the pinned object pinned_obj_size = llarena.getfakearenaaddress(cur) - prev +debug_print("before A") llarena.arena_reset(prev, pinned_obj_size, 2) # # clean up object's flags @@ -1634,6 +1646,7 @@ (size_gc_header + self.get_size(obj)) # # reset everything after the last pinned object till the end of the arena +debug_print("before B") llarena.arena_reset(prev, self.nursery_real_top - prev, 0) # # We assume that there are only a few pinned objects. Therefore, if there @@ -1644,6 +1657,7 @@ if prev - self.nursery >= self.nursery_cleanup: nursery_barriers.append(prev) else: +debug_print("before C") llarena.arena_reset(prev, self.nursery_cleanup, 2) nursery_barriers.append(prev + self.nursery_cleanup) # @@ -1665,6 +1679,12 @@ # debug_stop("gc-minor") +def _populate_to_surviving_pinned_objects(self, obj, ignored): +self.surviving_pinned_objects.append(obj) +# we have to update the counter each time, because it was set to 0 +# at the start of the *minor* collection. The 'obj' survives +# *major* collections and therefore also multiple minor collections. +self.pinned_objects_in_nursery += 1 def collect_roots_in_nursery(self): # we don't need to trace prebuilt GcStructs during a minor collect: @@ -1676,6 +1696,7 @@ callback = IncrementalMiniMarkGC._trace_drag_out1_marking_phase else: callback = IncrementalMiniMarkGC._trace_drag_out1 +# self.root_walker.walk_roots( callback, # stack roots callback, # static in prebuilt non-gc @@ -1772,7 +1793,7 @@ """obj must not be in the nursery. This copies all the young objects it references out of the nursery. """ -self.trace(obj, self._trace_drag_out, None) +self.trace(obj, self._trace_drag_out, obj) def trace_and_drag_out_of_nursery_partial(self, obj, start, stop): """Like trace_and_drag_out_of_nursery(), but limited to the array @@ -1801,13 +1822,18 @@ if not self.header(obj).tid & GCFLAG_VISITED: self.more_objects_to_trace.append(obj) -def _trace_drag_out(self, root, ignored): +def _trace_drag_out(self, root, parent): +# 'parent' is only set if we visit a pinned objects that is referenced +# by an other object. This is used to handle pinned object specially in +# such a case. obj = root.address[0] #print '_trace_drag_out(%x: %r)' % (hash(obj.ptr._obj), obj) +debug_print('_trace_drag_out(%x: %r)' % (hash(obj.ptr._obj), obj)) # # If 'obj' is not in the nursery, nothing to change -- expect # that we must set GCFLAG_VISITED_RMY on young raw-malloced objects. if not self.is_in_nursery(obj): +debug_print("\tnot in nursery") # cache usage trade-off: I think that it is a better idea to # check if 'obj' is in young_raw
[pypy-commit] pypy gc-incminimark-pinning: extend and enable test cases for still missing feature
Author: Gregor Wegberg Branch: gc-incminimark-pinning Changeset: r72520:e2b83c3965c0 Date: 2014-07-02 14:15 +0200 http://bitbucket.org/pypy/pypy/changeset/e2b83c3965c0/ Log:extend and enable test cases for still missing feature diff --git a/rpython/memory/gc/test/test_object_pinning.py b/rpython/memory/gc/test/test_object_pinning.py --- a/rpython/memory/gc/test/test_object_pinning.py +++ b/rpython/memory/gc/test/test_object_pinning.py @@ -76,25 +76,69 @@ ptr_old = self.stackroots[0] assert ptr_old.someInt == 100 -@py.test.mark.xfail(reason="Not implemented yet", run=False) -def test_pin_referenced_from_stackroot(self): -# XXX most likely somehow connected with `old_objects_pointing_to_young` -# (groggi) +def test_pin_referenced_from_stackroot_young(self): +# +# create both objects and reference the pinned one +# from the one that will be moved out of the +# nursery. root_ptr = self.malloc(S) next_ptr = self.malloc(S) self.write(root_ptr, 'next', next_ptr) self.stackroots.append(root_ptr) +# next_ptr.someInt = 100 - +root_ptr.someInt = 999 +# next_adr = llmemory.cast_ptr_to_adr(next_ptr) assert self.gc.pin(next_adr) +# +# in this step the 'root_ptr' object will be +# outside the nursery, pointing to the still +# young (because it's pinned) 'next_ptr'. +self.gc.collect() +# +root_ptr = self.stackroots[0] +assert not self.gc.is_in_nursery(llmemory.cast_ptr_to_adr(root_ptr)) +assert self.gc.is_in_nursery(next_adr) +assert next_ptr.someInt == 100 +assert root_ptr.next == next_ptr +# +# now we remove the reference to the pinned object and do a collect +# to check if the pinned object was removed from nursery. +self.write(root_ptr, 'next', lltype.nullptr(S)) +self.gc.collect() +try: +# should fail as this was the pinned object that is now collected +next_ptr.someInt = 0 +except RuntimeError as ex: +assert "freed" in str(ex) +def test_old_points_to_pinned(self): +# Test if we handle the case that an old object can point +# to a pinned object and keeps the pinned object alive by +# that. +# +# create the old object that will point to a pinned object +old_ptr = self.malloc(S) +old_ptr.someInt = 999 +self.stackroots.append(old_ptr) self.gc.collect() - -assert self.gc.is_in_nursery(adr) -assert next_ptr.someInt == 100 -root_ptr = self.stackroots[0] -assert root_ptr.next == next_ptr +assert not self.gc.is_in_nursery(llmemory.cast_ptr_to_adr(self.stackroots[0])) +# +# create the young pinned object and attach it to the old object +pinned_ptr = self.malloc(S) +pinned_ptr.someInt = 6 +assert self.gc.pin(llmemory.cast_ptr_to_adr(pinned_ptr)) +self.write(self.stackroots[0], 'next', pinned_ptr) +# +# let's check if everything stays in place before/after a collection +assert self.gc.is_in_nursery(llmemory.cast_ptr_to_adr(pinned_ptr)) +self.gc.collect() +assert self.gc.is_in_nursery(llmemory.cast_ptr_to_adr(pinned_ptr)) +# +self.stackroots[0].next.someInt = 100 +self.gc.collect() +assert self.stackroots[0].next.someInt == 100 def test_pin_old(self): ptr = self.malloc(S) @@ -109,22 +153,24 @@ # ^^^ should not be possible, struct is already old and won't # move. -def test_old_points_to_pinned(self): +def test_groggi(self): # Test if we handle the case that an old object can point # to a pinned object and keeps the pinned object alive by # that. # +# create the young pinned object and attach it to the old object +pinned_ptr = self.malloc(S) +pinned_ptr.someInt = 6 +assert self.gc.pin(llmemory.cast_ptr_to_adr(pinned_ptr)) +# # create the old object that will point to a pinned object old_ptr = self.malloc(S) +old_ptr.someInt = 999 self.stackroots.append(old_ptr) +self.write(self.stackroots[0], 'next', pinned_ptr) self.gc.collect() assert not self.gc.is_in_nursery(llmemory.cast_ptr_to_adr(self.stackroots[0])) # -# create the young pinned object and attach it to the old object -pinned_ptr = self.malloc(S) -assert self.gc.pin(llmemory.cast_ptr_to_adr(pinned_ptr)) -self.write(self.stackroots[0], 'next', pinned_ptr) -# # let's check if everything stays in place before/after a collection assert self.gc.is_in_nursery(llmemory.cast_ptr_to_adr(pinned_ptr)) self.gc.collect() _
[pypy-commit] pypy gc-incminimark-pinning: ups. remove test used to play around
Author: Gregor Wegberg Branch: gc-incminimark-pinning Changeset: r72521:3fca2532c67d Date: 2014-07-02 14:43 +0200 http://bitbucket.org/pypy/pypy/changeset/3fca2532c67d/ Log:ups. remove test used to play around diff --git a/rpython/memory/gc/test/test_object_pinning.py b/rpython/memory/gc/test/test_object_pinning.py --- a/rpython/memory/gc/test/test_object_pinning.py +++ b/rpython/memory/gc/test/test_object_pinning.py @@ -153,33 +153,6 @@ # ^^^ should not be possible, struct is already old and won't # move. -def test_groggi(self): -# Test if we handle the case that an old object can point -# to a pinned object and keeps the pinned object alive by -# that. -# -# create the young pinned object and attach it to the old object -pinned_ptr = self.malloc(S) -pinned_ptr.someInt = 6 -assert self.gc.pin(llmemory.cast_ptr_to_adr(pinned_ptr)) -# -# create the old object that will point to a pinned object -old_ptr = self.malloc(S) -old_ptr.someInt = 999 -self.stackroots.append(old_ptr) -self.write(self.stackroots[0], 'next', pinned_ptr) -self.gc.collect() -assert not self.gc.is_in_nursery(llmemory.cast_ptr_to_adr(self.stackroots[0])) -# -# let's check if everything stays in place before/after a collection -assert self.gc.is_in_nursery(llmemory.cast_ptr_to_adr(pinned_ptr)) -self.gc.collect() -assert self.gc.is_in_nursery(llmemory.cast_ptr_to_adr(pinned_ptr)) -# -self.stackroots[0].next.someInt = 100 -self.gc.collect() -assert self.stackroots[0].next.someInt == 100 - def test_pin_malloc_pin(self): first_ptr = self.malloc(S) first_ptr.someInt = 101 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy gc-incminimark-pinning: revert 754f9578ee1aee71b29f8a4ea6b23a60f89be3c3
Author: Gregor Wegberg Branch: gc-incminimark-pinning Changeset: r72528:cd9ec650486f Date: 2014-07-13 14:25 +0200 http://bitbucket.org/pypy/pypy/changeset/cd9ec650486f/ Log:revert 754f9578ee1aee71b29f8a4ea6b23a60f89be3c3 time to think first and implement afterwards diff --git a/rpython/memory/gc/incminimark.py b/rpython/memory/gc/incminimark.py --- a/rpython/memory/gc/incminimark.py +++ b/rpython/memory/gc/incminimark.py @@ -380,8 +380,6 @@ # Counter tracking how many pinned objects currently reside inside # the nursery. self.pinned_objects_in_nursery = 0 -# TTT XXX -self.pinned_objects_keep_alive = self.AddressStack() # # Allocate a nursery. In case of auto_nursery_size, start by # allocating a very small nursery, enough to do things like look @@ -1603,15 +1601,6 @@ # them or make them old. if self.young_rawmalloced_objects: self.free_young_rawmalloced_objects() - -# -# In case we have to keep some pinned objects alive, add them -# to 'surviving_pinned_objects'. Such a case comes up if an old -# object references a pinned young one (pinned object inside -# the nursery). See '_trace_drag_out' for more details. -if self.pinned_objects_keep_alive.non_empty(): -self.pinned_objects_keep_alive.foreach( -self._populate_to_surviving_pinned_objects, None) # # All live nursery objects are out of the nursery or pinned inside # the nursery. Create nursery barriers to protect the pinned object, @@ -1631,7 +1620,6 @@ # clear the arena between the last pinned object (or arena start) # and the pinned object pinned_obj_size = llarena.getfakearenaaddress(cur) - prev -debug_print("before A") llarena.arena_reset(prev, pinned_obj_size, 2) # # clean up object's flags @@ -1646,7 +1634,6 @@ (size_gc_header + self.get_size(obj)) # # reset everything after the last pinned object till the end of the arena -debug_print("before B") llarena.arena_reset(prev, self.nursery_real_top - prev, 0) # # We assume that there are only a few pinned objects. Therefore, if there @@ -1657,7 +1644,6 @@ if prev - self.nursery >= self.nursery_cleanup: nursery_barriers.append(prev) else: -debug_print("before C") llarena.arena_reset(prev, self.nursery_cleanup, 2) nursery_barriers.append(prev + self.nursery_cleanup) # @@ -1679,12 +1665,6 @@ # debug_stop("gc-minor") -def _populate_to_surviving_pinned_objects(self, obj, ignored): -self.surviving_pinned_objects.append(obj) -# we have to update the counter each time, because it was set to 0 -# at the start of the *minor* collection. The 'obj' survives -# *major* collections and therefore also multiple minor collections. -self.pinned_objects_in_nursery += 1 def collect_roots_in_nursery(self): # we don't need to trace prebuilt GcStructs during a minor collect: @@ -1696,7 +1676,6 @@ callback = IncrementalMiniMarkGC._trace_drag_out1_marking_phase else: callback = IncrementalMiniMarkGC._trace_drag_out1 -# self.root_walker.walk_roots( callback, # stack roots callback, # static in prebuilt non-gc @@ -1793,7 +1772,7 @@ """obj must not be in the nursery. This copies all the young objects it references out of the nursery. """ -self.trace(obj, self._trace_drag_out, obj) +self.trace(obj, self._trace_drag_out, None) def trace_and_drag_out_of_nursery_partial(self, obj, start, stop): """Like trace_and_drag_out_of_nursery(), but limited to the array @@ -1822,18 +1801,13 @@ if not self.header(obj).tid & GCFLAG_VISITED: self.more_objects_to_trace.append(obj) -def _trace_drag_out(self, root, parent): -# 'parent' is only set if we visit a pinned objects that is referenced -# by an other object. This is used to handle pinned object specially in -# such a case. +def _trace_drag_out(self, root, ignored): obj = root.address[0] #print '_trace_drag_out(%x: %r)' % (hash(obj.ptr._obj), obj) -debug_print('_trace_drag_out(%x: %r)' % (hash(obj.ptr._obj), obj)) # # If 'obj' is not in the nursery, nothing to change -- expect # that we must set GCFLAG_VISITED_RMY on young raw-malloced objects. if not self.is_in_nursery(obj): -debug_print("\tnot in nursery") # cache usage trade-off: I think that it is a better idea to # check if 'obj' is in young_rawmalloced_objects with an access # to this (small) dict
[pypy-commit] pypy gc-incminimark-pinning: modify tests for new pinning implementation
Author: Gregor Wegberg Branch: gc-incminimark-pinning Changeset: r72523:0bbc22db2b13 Date: 2014-07-13 12:42 +0200 http://bitbucket.org/pypy/pypy/changeset/0bbc22db2b13/ Log:modify tests for new pinning implementation pinned objects will stay inside the nursery as long as a major collection diff --git a/rpython/memory/gc/test/test_object_pinning.py b/rpython/memory/gc/test/test_object_pinning.py --- a/rpython/memory/gc/test/test_object_pinning.py +++ b/rpython/memory/gc/test/test_object_pinning.py @@ -46,7 +46,8 @@ class TestIncminimark(PinningGCTest): from rpython.memory.gc.incminimark import IncrementalMiniMarkGC as GCClass -def test_simple_pin(self): +def test_simple_pin_stack(self): +# create object, pin it and point from stackroots to it ptr = self.malloc(S) ptr.someInt = 100 self.stackroots.append(ptr) @@ -59,26 +60,33 @@ assert self.gc.is_in_nursery(adr) assert ptr.someInt == 100 -def test_simple_pin_unpin(self): +def test_simple_pin_unpin_stack(self): ptr = self.malloc(S) ptr.someInt = 100 + self.stackroots.append(ptr) + adr = llmemory.cast_ptr_to_adr(ptr) -# check if pin worked assert self.gc.pin(adr) + self.gc.collect() + assert self.gc.is_in_nursery(adr) assert ptr.someInt == 100 + # unpin and check if object is gone from nursery self.gc.unpin(adr) self.gc.collect() py.test.raises(RuntimeError, 'ptr.someInt') + +# check if we object is still accessible ptr_old = self.stackroots[0] +assert not self.gc.is_in_nursery(llmemory.cast_ptr_to_adr(ptr_old)) assert ptr_old.someInt == 100 def test_pin_referenced_from_stackroot_young(self): # -# create both objects and reference the pinned one +# create two objects and reference the pinned one # from the one that will be moved out of the # nursery. root_ptr = self.malloc(S) @@ -114,7 +122,7 @@ assert "freed" in str(ex) def test_old_points_to_pinned(self): -# Test if we handle the case that an old object can point +# Test if we handle the case that an already old object can point # to a pinned object and keeps the pinned object alive by # that. # @@ -123,7 +131,8 @@ old_ptr.someInt = 999 self.stackroots.append(old_ptr) self.gc.collect() -assert not self.gc.is_in_nursery(llmemory.cast_ptr_to_adr(self.stackroots[0])) +assert not self.gc.is_in_nursery( +llmemory.cast_ptr_to_adr(self.stackroots[0])) # # create the young pinned object and attach it to the old object pinned_ptr = self.malloc(S) @@ -178,11 +187,11 @@ ptr.someInt = 100 assert self.gc.pin(adr) self.gc.id(ptr) # allocate shadow -self.gc.minor_collection() +self.gc.collect() assert self.gc.is_in_nursery(adr) assert ptr.someInt == 100 self.gc.unpin(adr) -self.gc.minor_collection() # move to shadow +self.gc.collect() # move to shadow adr = llmemory.cast_ptr_to_adr(self.stackroots[0]) assert not self.gc.is_in_nursery(adr) @@ -193,11 +202,11 @@ ptr.someInt = 100 assert self.gc.pin(adr) self.gc.identityhash(ptr) # allocate shadow -self.gc.minor_collection() +self.gc.collect() assert self.gc.is_in_nursery(adr) assert ptr.someInt == 100 self.gc.unpin(adr) -self.gc.minor_collection() # move to shadow +self.gc.collect() # move to shadow adr = llmemory.cast_ptr_to_adr(self.stackroots[0]) assert not self.gc.is_in_nursery(adr) @@ -270,7 +279,7 @@ # +- nursery_free # +- nursery_top # -self.gc.minor_collection() +self.gc.collect() assert self.gc.nursery_free == self.gc.nursery_top assert self.gc.nursery_top == self.gc.nursery @@ -311,7 +320,7 @@ # +- nursery_free # self.gc.unpin(adr1) -self.gc.minor_collection() +self.gc.collect() assert self.gc.nursery_free == self.gc.nursery assert self.gc.nursery_top > self.gc.nursery_free @@ -353,7 +362,7 @@ # self.gc.unpin(adr1) self.gc.unpin(adr2) -self.gc.minor_collection() +self.gc.collect() assert self.gc.nursery_free == self.gc.nursery assert self.gc.nursery_free < self.gc.nursery_top @@ -413,7 +422,7 @@ self.gc.unpin(adr1) self.gc.unpin(adr2) self.gc.unpin(adr3) -self.gc.minor_collection() +self.gc.collect() assert self.gc.nursery_free == self.gc.nursery # the following assert is important: make sure that @@ -438,7 +447,7 @@
[pypy-commit] pypy gc-incminimark-pinning: Backout changeset 754f9578ee1aee71b29f8a4ea6b23a60f89be3c3
Author: Gregor Wegberg Branch: gc-incminimark-pinning Changeset: r72527:a4e98d2f48ff Date: 2014-07-13 14:23 +0200 http://bitbucket.org/pypy/pypy/changeset/a4e98d2f48ff/ Log:Backout changeset 754f9578ee1aee71b29f8a4ea6b23a60f89be3c3 diff --git a/rpython/memory/gc/incminimark.py b/rpython/memory/gc/incminimark.py --- a/rpython/memory/gc/incminimark.py +++ b/rpython/memory/gc/incminimark.py @@ -380,8 +380,6 @@ # Counter tracking how many pinned objects currently reside inside # the nursery. self.pinned_objects_in_nursery = 0 -# TTT XXX -self.pinned_objects_keep_alive = self.AddressStack() # # Allocate a nursery. In case of auto_nursery_size, start by # allocating a very small nursery, enough to do things like look @@ -1603,15 +1601,6 @@ # them or make them old. if self.young_rawmalloced_objects: self.free_young_rawmalloced_objects() - -# -# In case we have to keep some pinned objects alive, add them -# to 'surviving_pinned_objects'. Such a case comes up if an old -# object references a pinned young one (pinned object inside -# the nursery). See '_trace_drag_out' for more details. -if self.pinned_objects_keep_alive.non_empty(): -self.pinned_objects_keep_alive.foreach( -self._populate_to_surviving_pinned_objects, None) # # All live nursery objects are out of the nursery or pinned inside # the nursery. Create nursery barriers to protect the pinned object, @@ -1631,7 +1620,6 @@ # clear the arena between the last pinned object (or arena start) # and the pinned object pinned_obj_size = llarena.getfakearenaaddress(cur) - prev -debug_print("before A") llarena.arena_reset(prev, pinned_obj_size, 2) # # clean up object's flags @@ -1646,7 +1634,6 @@ (size_gc_header + self.get_size(obj)) # # reset everything after the last pinned object till the end of the arena -debug_print("before B") llarena.arena_reset(prev, self.nursery_real_top - prev, 0) # # We assume that there are only a few pinned objects. Therefore, if there @@ -1657,7 +1644,6 @@ if prev - self.nursery >= self.nursery_cleanup: nursery_barriers.append(prev) else: -debug_print("before C") llarena.arena_reset(prev, self.nursery_cleanup, 2) nursery_barriers.append(prev + self.nursery_cleanup) # @@ -1679,12 +1665,6 @@ # debug_stop("gc-minor") -def _populate_to_surviving_pinned_objects(self, obj, ignored): -self.surviving_pinned_objects.append(obj) -# we have to update the counter each time, because it was set to 0 -# at the start of the *minor* collection. The 'obj' survives -# *major* collections and therefore also multiple minor collections. -self.pinned_objects_in_nursery += 1 def collect_roots_in_nursery(self): # we don't need to trace prebuilt GcStructs during a minor collect: @@ -1696,7 +1676,6 @@ callback = IncrementalMiniMarkGC._trace_drag_out1_marking_phase else: callback = IncrementalMiniMarkGC._trace_drag_out1 -# self.root_walker.walk_roots( callback, # stack roots callback, # static in prebuilt non-gc @@ -1793,7 +1772,7 @@ """obj must not be in the nursery. This copies all the young objects it references out of the nursery. """ -self.trace(obj, self._trace_drag_out, obj) +self.trace(obj, self._trace_drag_out, None) def trace_and_drag_out_of_nursery_partial(self, obj, start, stop): """Like trace_and_drag_out_of_nursery(), but limited to the array @@ -1822,18 +1801,13 @@ if not self.header(obj).tid & GCFLAG_VISITED: self.more_objects_to_trace.append(obj) -def _trace_drag_out(self, root, parent): -# 'parent' is only set if we visit a pinned objects that is referenced -# by an other object. This is used to handle pinned object specially in -# such a case. +def _trace_drag_out(self, root, ignored): obj = root.address[0] #print '_trace_drag_out(%x: %r)' % (hash(obj.ptr._obj), obj) -debug_print('_trace_drag_out(%x: %r)' % (hash(obj.ptr._obj), obj)) # # If 'obj' is not in the nursery, nothing to change -- expect # that we must set GCFLAG_VISITED_RMY on young raw-malloced objects. if not self.is_in_nursery(obj): -debug_print("\tnot in nursery") # cache usage trade-off: I think that it is a better idea to # check if 'obj' is in young_rawmalloced_objects with an access # to this (small) dictionary, rather than risk a lot of cache @@
[pypy-commit] pypy gc-incminimark-pinning: generalize previously added test and use it to get two tests
Author: Gregor Wegberg Branch: gc-incminimark-pinning Changeset: r72525:4aa9c7ae56dd Date: 2014-07-13 13:13 +0200 http://bitbucket.org/pypy/pypy/changeset/4aa9c7ae56dd/ Log:generalize previously added test and use it to get two tests previouse test added in 513744aa7a905300b7389cd1c3724c0150762ee4 diff --git a/rpython/memory/gc/test/test_object_pinning.py b/rpython/memory/gc/test/test_object_pinning.py --- a/rpython/memory/gc/test/test_object_pinning.py +++ b/rpython/memory/gc/test/test_object_pinning.py @@ -149,22 +149,25 @@ self.gc.collect() assert self.stackroots[0].next.someInt == 100 -def test_old_and_stackroots_point_to_pinned(self): +def not_pinned_and_stackroots_point_to_pinned(self, make_old): # In this test case we point to a pinned object from an old object # *and* from the stackroots -old_ptr = self.malloc(S) -old_ptr.someInt = 999 -self.stackroots.append(old_ptr) -self.gc.collect() # old_ptr is now old -old_ptr = self.stackroots[0] -assert not self.gc.is_in_nursery(llmemory.cast_ptr_to_adr(old_ptr)) +obj_ptr = self.malloc(S) +obj_ptr.someInt = 999 +self.stackroots.append(obj_ptr) +if make_old: +self.gc.collect() # old_ptr is now old +obj_ptr = self.stackroots[0] +assert not self.gc.is_in_nursery(llmemory.cast_ptr_to_adr(obj_ptr)) +else: +assert self.gc.is_in_nursery(llmemory.cast_ptr_to_adr(obj_ptr)) pinned_ptr = self.malloc(S) pinned_ptr.someInt = 111 assert self.gc.pin(llmemory.cast_ptr_to_adr(pinned_ptr)) self.stackroots.append(pinned_ptr) -self.write(old_ptr, 'next', pinned_ptr) +self.write(obj_ptr, 'next', pinned_ptr) self.gc.collect() # done with preparation. do some basic checks @@ -172,6 +175,12 @@ assert pinned_ptr.someInt == 111 assert self.stackroots[0].next == pinned_ptr +def test_old_and_stackroots_point_to_pinned(self): +self.not_pinned_and_stackroots_point_to_pinned(make_old=True) + +def test_young_and_stackroots_point_to_pinned(self): +self.not_pinned_and_stackroots_point_to_pinned(make_old=False) + def test_pin_old(self): ptr = self.malloc(S) ptr.someInt = 100 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy gc-incminimark-pinning: generalize tests. tests pinning for minor collections and major ones now
Author: Gregor Wegberg Branch: gc-incminimark-pinning Changeset: r72529:daf002afa713 Date: 2014-07-13 14:52 +0200 http://bitbucket.org/pypy/pypy/changeset/daf002afa713/ Log:generalize tests. tests pinning for minor collections and major ones now diff --git a/rpython/memory/gc/test/test_object_pinning.py b/rpython/memory/gc/test/test_object_pinning.py --- a/rpython/memory/gc/test/test_object_pinning.py +++ b/rpython/memory/gc/test/test_object_pinning.py @@ -46,7 +46,7 @@ class TestIncminimark(PinningGCTest): from rpython.memory.gc.incminimark import IncrementalMiniMarkGC as GCClass -def test_simple_pin_stack(self): +def simple_pin_stack(self, collect_func): # create object, pin it and point from stackroots to it ptr = self.malloc(S) ptr.someInt = 100 @@ -55,12 +55,18 @@ adr = llmemory.cast_ptr_to_adr(ptr) assert self.gc.pin(adr) -self.gc.collect() +collect_func() assert self.gc.is_in_nursery(adr) assert ptr.someInt == 100 -def test_simple_pin_unpin_stack(self): +def test_simple_pin_stack_full_collect(self): +self.simple_pin_stack(self.gc.collect) + +def test_simple_pin_stack_minor_collect(self): +self.simple_pin_stack(self.gc.minor_collection) + +def simple_pin_unpin_stack(self, collect_func): ptr = self.malloc(S) ptr.someInt = 100 @@ -69,14 +75,14 @@ adr = llmemory.cast_ptr_to_adr(ptr) assert self.gc.pin(adr) -self.gc.collect() +collect_func() assert self.gc.is_in_nursery(adr) assert ptr.someInt == 100 # unpin and check if object is gone from nursery self.gc.unpin(adr) -self.gc.collect() +collect_func() py.test.raises(RuntimeError, 'ptr.someInt') # check if we object is still accessible @@ -84,6 +90,12 @@ assert not self.gc.is_in_nursery(llmemory.cast_ptr_to_adr(ptr_old)) assert ptr_old.someInt == 100 +def test_simple_pin_unpin_stack_full_collect(self): +self.simple_pin_unpin_stack(self.gc.collect) + +def test_simple_pin_unpin_stack_minor_collect(self): +self.simple_pin_unpin_stack(self.gc.minor_collection) + def test_pin_referenced_from_stackroot_young(self): # # create two objects and reference the pinned one @@ -150,7 +162,7 @@ assert self.stackroots[0].next.someInt == 100 def not_pinned_and_stackroots_point_to_pinned(self, make_old): -# In this test case we point to a pinned object from an old object +# In this test case we point to a pinned object from an (old) object # *and* from the stackroots obj_ptr = self.malloc(S) obj_ptr.someInt = 999 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy gc-incminimark-pinning: add test to make sure not referenced pinned objects are collected
Author: Gregor Wegberg Branch: gc-incminimark-pinning Changeset: r72531:1f3c0f2801cb Date: 2014-07-26 15:48 +0200 http://bitbucket.org/pypy/pypy/changeset/1f3c0f2801cb/ Log:add test to make sure not referenced pinned objects are collected Basically we have an old object pointing to a young pinned one. The moment the old object is not used anymore (not referenced from stack) the GC should not only collect the old object but also the still pinned one. diff --git a/rpython/memory/gc/test/test_object_pinning.py b/rpython/memory/gc/test/test_object_pinning.py --- a/rpython/memory/gc/test/test_object_pinning.py +++ b/rpython/memory/gc/test/test_object_pinning.py @@ -96,6 +96,29 @@ def test_simple_pin_unpin_stack_minor_collect(self): self.simple_pin_unpin_stack(self.gc.minor_collection) +def test_pinned_obj_collected_after_old_object_collected(self): +root_ptr = self.malloc(S) +root_ptr.someInt = 999 +self.stackroots.append(root_ptr) +self.gc.collect() + +root_ptr = self.stackroots[0] +next_ptr = self.malloc(S) +next_ptr.someInt = 111 +assert self.gc.pin(llmemory.cast_ptr_to_adr(next_ptr)) +self.write(root_ptr, 'next', next_ptr) +self.gc.collect() +# check still alive +assert self.gc.is_in_nursery(llmemory.cast_ptr_to_adr(root_ptr.next)) +self.stackroots.remove(root_ptr) +self.gc.collect() +# root_ptr was collected and therefore also the pinned object should +# be gone +try: +next_ptr.someInt = 101 +except RuntimeError as ex: +assert "freed" in str(ex) + def test_pin_referenced_from_stackroot_young(self): # # create two objects and reference the pinned one ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy gc-incminimark-pinning: additional test to cover more cases of referencing a pinned object
Author: Gregor Wegberg Branch: gc-incminimark-pinning Changeset: r72524:513744aa7a90 Date: 2014-07-13 13:05 +0200 http://bitbucket.org/pypy/pypy/changeset/513744aa7a90/ Log:additional test to cover more cases of referencing a pinned object diff --git a/rpython/memory/gc/test/test_object_pinning.py b/rpython/memory/gc/test/test_object_pinning.py --- a/rpython/memory/gc/test/test_object_pinning.py +++ b/rpython/memory/gc/test/test_object_pinning.py @@ -149,6 +149,29 @@ self.gc.collect() assert self.stackroots[0].next.someInt == 100 +def test_old_and_stackroots_point_to_pinned(self): +# In this test case we point to a pinned object from an old object +# *and* from the stackroots +old_ptr = self.malloc(S) +old_ptr.someInt = 999 +self.stackroots.append(old_ptr) +self.gc.collect() # old_ptr is now old +old_ptr = self.stackroots[0] +assert not self.gc.is_in_nursery(llmemory.cast_ptr_to_adr(old_ptr)) + +pinned_ptr = self.malloc(S) +pinned_ptr.someInt = 111 +assert self.gc.pin(llmemory.cast_ptr_to_adr(pinned_ptr)) + +self.stackroots.append(pinned_ptr) +self.write(old_ptr, 'next', pinned_ptr) + +self.gc.collect() +# done with preparation. do some basic checks +assert self.gc.is_in_nursery(llmemory.cast_ptr_to_adr(pinned_ptr)) +assert pinned_ptr.someInt == 111 +assert self.stackroots[0].next == pinned_ptr + def test_pin_old(self): ptr = self.malloc(S) ptr.someInt = 100 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy gc-incminimark-pinning: shadow tests now tested with minor and full major collections.
Author: Gregor Wegberg Branch: gc-incminimark-pinning Changeset: r72530:2b62d7537a85 Date: 2014-07-26 15:46 +0200 http://bitbucket.org/pypy/pypy/changeset/2b62d7537a85/ Log:shadow tests now tested with minor and full major collections. diff --git a/rpython/memory/gc/test/test_object_pinning.py b/rpython/memory/gc/test/test_object_pinning.py --- a/rpython/memory/gc/test/test_object_pinning.py +++ b/rpython/memory/gc/test/test_object_pinning.py @@ -224,36 +224,48 @@ assert first_ptr.someInt == 101 assert second_ptr.someInt == 102 -def test_pin_shadow_1(self): +def pin_shadow_1(self, collect_func): ptr = self.malloc(S) adr = llmemory.cast_ptr_to_adr(ptr) self.stackroots.append(ptr) ptr.someInt = 100 assert self.gc.pin(adr) self.gc.id(ptr) # allocate shadow -self.gc.collect() +collect_func() assert self.gc.is_in_nursery(adr) assert ptr.someInt == 100 self.gc.unpin(adr) -self.gc.collect() # move to shadow +collect_func() # move to shadow adr = llmemory.cast_ptr_to_adr(self.stackroots[0]) assert not self.gc.is_in_nursery(adr) -def test_pin_shadow_2(self): +def test_pin_shadow_1_minor(self): +self.pin_shadow_1(self.gc.minor_collection) + +def test_pin_shadow_1_full(self): +self.pin_shadow_1(self.gc.collect) + +def pin_shadow_2(self, collect_func): ptr = self.malloc(S) adr = llmemory.cast_ptr_to_adr(ptr) self.stackroots.append(ptr) ptr.someInt = 100 assert self.gc.pin(adr) self.gc.identityhash(ptr) # allocate shadow -self.gc.collect() +collect_func() assert self.gc.is_in_nursery(adr) assert ptr.someInt == 100 self.gc.unpin(adr) -self.gc.collect() # move to shadow +collect_func() # move to shadow adr = llmemory.cast_ptr_to_adr(self.stackroots[0]) assert not self.gc.is_in_nursery(adr) +def test_pin_shadow_2_minor(self): +self.pin_shadow_2(self.gc.minor_collection) + +def test_pin_shadow_2_full(self): +self.pin_shadow_2(self.gc.collect) + def test_pin_nursery_top_scenario1(self): ptr1 = self.malloc(S) adr1 = llmemory.cast_ptr_to_adr(ptr1) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy gc-incminimark-pinning: unnecessary comment removed
Author: Gregor Wegberg Branch: gc-incminimark-pinning Changeset: r72526:5868377b4b39 Date: 2014-07-13 13:48 +0200 http://bitbucket.org/pypy/pypy/changeset/5868377b4b39/ Log:unnecessary comment removed diff --git a/rpython/memory/gc/test/test_object_pinning.py b/rpython/memory/gc/test/test_object_pinning.py --- a/rpython/memory/gc/test/test_object_pinning.py +++ b/rpython/memory/gc/test/test_object_pinning.py @@ -156,7 +156,7 @@ obj_ptr.someInt = 999 self.stackroots.append(obj_ptr) if make_old: -self.gc.collect() # old_ptr is now old +self.gc.collect() obj_ptr = self.stackroots[0] assert not self.gc.is_in_nursery(llmemory.cast_ptr_to_adr(obj_ptr)) else: ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy gc-incminimark-pinning: add XXX todo item reminding to add more object pinning related tests
Author: Gregor Wegberg Branch: gc-incminimark-pinning Changeset: r72532:e02894d635ae Date: 2014-07-26 15:49 +0200 http://bitbucket.org/pypy/pypy/changeset/e02894d635ae/ Log:add XXX todo item reminding to add more object pinning related tests diff --git a/rpython/memory/gc/test/test_object_pinning.py b/rpython/memory/gc/test/test_object_pinning.py --- a/rpython/memory/gc/test/test_object_pinning.py +++ b/rpython/memory/gc/test/test_object_pinning.py @@ -119,6 +119,10 @@ except RuntimeError as ex: assert "freed" in str(ex) +# XXX more tests like the one above. Make list of all possible cases and +# write tests for each one. Also: minor/full major collection tests maybe +# needed + def test_pin_referenced_from_stackroot_young(self): # # create two objects and reference the pinned one ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy gc-incminimark-pinning: (wip) add handling for pinned objects referenced by old ones.
Author: Gregor Wegberg Branch: gc-incminimark-pinning Changeset: r72533:cb701ab5f828 Date: 2014-07-26 16:46 +0200 http://bitbucket.org/pypy/pypy/changeset/cb701ab5f828/ Log:(wip) add handling for pinned objects referenced by old ones. The added AddressStack keeps track of old objects which point to young pinned objects. This way if a pinned object is only referenced from an old object, it isn't collected as before. This is a work in progress. For now test_object_pinning.py tests pass. However, there is still a lot to be tested and double checked (see XXX). In addition some refactoring & additional comments are in order after we make sure it works as expected. For now this changes stop pypy from being translated. diff --git a/rpython/memory/gc/incminimark.py b/rpython/memory/gc/incminimark.py --- a/rpython/memory/gc/incminimark.py +++ b/rpython/memory/gc/incminimark.py @@ -381,6 +381,14 @@ # the nursery. self.pinned_objects_in_nursery = 0 # +# Keeps track of objects pointing to pinned objects. These objects +# must be revisited every minor collection. Without this list +# any old object inside this list would only be visited in case a +# write barrier was triggered, which would result in not visiting +# the young pinned object and would therefore result in removing +# the pinned object. +self.old_objects_pointing_to_pinned = self.AddressStack() +# # Allocate a nursery. In case of auto_nursery_size, start by # allocating a very small nursery, enough to do things like look # up the env var, which requires the GC; and then really @@ -1502,6 +1510,10 @@ obj = obj + self.gcheaderbuilder.size_gc_header shadow = self.nursery_objects_shadows.get(obj) if shadow != NULL: +# visit shadow to keep it alive +# XXX seems like it is save to set GCFLAG_VISITED, however +# should be double checked +self.header(shadow).tid |= GCFLAG_VISITED new_shadow_object_dict.setitem(obj, shadow) # -- @@ -1554,6 +1566,13 @@ self.nursery_surviving_size = 0 self.collect_roots_in_nursery() # +# visit all objects that are known for pointing to pinned +# objects. This way we populate 'surviving_pinned_objects' +# with pinned object that are (only) visible from an old +# object. +self.old_objects_pointing_to_pinned.foreach( +self._visit_old_objects_pointing_to_pinned, None) +# while True: # If we are using card marking, do a partial trace of the arrays # that are flagged with GCFLAG_CARDS_SET. @@ -1665,6 +1684,8 @@ # debug_stop("gc-minor") +def _visit_old_objects_pointing_to_pinned(self, obj, ignore): +self.trace(obj, self._trace_drag_out, None) def collect_roots_in_nursery(self): # we don't need to trace prebuilt GcStructs during a minor collect: @@ -1772,7 +1793,7 @@ """obj must not be in the nursery. This copies all the young objects it references out of the nursery. """ -self.trace(obj, self._trace_drag_out, None) +self.trace(obj, self._trace_drag_out, obj) def trace_and_drag_out_of_nursery_partial(self, obj, start, stop): """Like trace_and_drag_out_of_nursery(), but limited to the array @@ -1801,7 +1822,7 @@ if not self.header(obj).tid & GCFLAG_VISITED: self.more_objects_to_trace.append(obj) -def _trace_drag_out(self, root, ignored): +def _trace_drag_out(self, root, parent): obj = root.address[0] #print '_trace_drag_out(%x: %r)' % (hash(obj.ptr._obj), obj) # @@ -1842,8 +1863,11 @@ # already visited and keeping track of the object return hdr.tid |= GCFLAG_VISITED +# +if parent: +self.old_objects_pointing_to_pinned.append(parent) +# # XXX add additional checks for unsupported pinned objects (groggi) -# XXX implement unsupported object types with pinning ll_assert(not self.header(obj).tid & GCFLAG_HAS_CARDS, "pinned object with GCFLAG_HAS_CARDS not supported") self.surviving_pinned_objects.append( @@ -2073,6 +2097,15 @@ #END MARKING elif self.gc_state == STATE_SWEEPING: # +# get rid of objects pointing to pinned objects that were not +# visited +new_old_objects_pointing_to_pinned = self.AddressStack() +self.old_objects_pointing_to_pinned.foreach( +self._sweep_old_objects_pointing_to_pinned, +new_old_objects_pointing_to_pinned) +self.old_objects_pointing_to_pinned.delet
[pypy-commit] pypy py3.3: Pickling of iterators produced by zip(seq, ...).
Author: Vasily Kuznetsov Branch: py3.3 Changeset: r72535:1f1711d14798 Date: 2014-07-26 16:38 +0200 http://bitbucket.org/pypy/pypy/changeset/1f1711d14798/ Log:Pickling of iterators produced by zip(seq, ...). diff --git a/pypy/module/__builtin__/functional.py b/pypy/module/__builtin__/functional.py --- a/pypy/module/__builtin__/functional.py +++ b/pypy/module/__builtin__/functional.py @@ -753,6 +753,12 @@ raise OperationError(self.space.w_StopIteration, self.space.w_None) return W_Map.next_w(self) +def descr_reduce(self, space): +w_zip = space.getattr(space.getbuiltinmodule('builtins'), +space.wrap('zip')) +return space.newtuple([w_zip, space.newtuple(self.iterators_w)]) + + def W_Zip___new__(space, w_subtype, args_w): r = space.allocate_instance(W_Zip, w_subtype) r.__init__(space, None, args_w) @@ -763,6 +769,7 @@ __new__ = interp2app(W_Zip___new__), __iter__ = interp2app(W_Zip.iter_w), __next__ = interp2app(W_Zip.next_w), +__reduce__ = interp2app(W_Zip.descr_reduce), __doc__ = """\ Return a zip object whose .__next__() method returns a tuple where the i-th element comes from the i-th iterable argument. The .__next__() diff --git a/pypy/module/__builtin__/test/test_zip_pickle.py b/pypy/module/__builtin__/test/test_zip_pickle.py new file mode 100644 --- /dev/null +++ b/pypy/module/__builtin__/test/test_zip_pickle.py @@ -0,0 +1,14 @@ +class AppTestZipPickle: + +def test_zip_pickle(self): +import pickle + +def pickle_unpickle(obj): +d = pickle.dumps(obj) +return pickle.loads(d) + +z1 = zip([1, 2, 3], [4, 5, 6]) +z1_ = pickle_unpickle(z1) +l1, l1_ = list(z1), list(z1_) + +assert l1 == l1_ ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: Additional checks related to pickling of zip iterators.
Author: Vasily Kuznetsov Branch: py3.3 Changeset: r72536:d26183fe9a2b Date: 2014-07-26 16:43 +0200 http://bitbucket.org/pypy/pypy/changeset/d26183fe9a2b/ Log:Additional checks related to pickling of zip iterators. diff --git a/pypy/module/__builtin__/test/test_zip_pickle.py b/pypy/module/__builtin__/test/test_zip_pickle.py --- a/pypy/module/__builtin__/test/test_zip_pickle.py +++ b/pypy/module/__builtin__/test/test_zip_pickle.py @@ -3,12 +3,16 @@ def test_zip_pickle(self): import pickle -def pickle_unpickle(obj): -d = pickle.dumps(obj) -return pickle.loads(d) +def check_pickle_unpickle(itr): +d = pickle.dumps(itr) +itr_ = pickle.loads(d) +lst, lst_ = list(itr), list(itr_) +assert lst == lst_ -z1 = zip([1, 2, 3], [4, 5, 6]) -z1_ = pickle_unpickle(z1) -l1, l1_ = list(z1), list(z1_) +check_pickle_unpickle(zip([1, 2, 3], [4, 5, 6])) +check_pickle_unpickle(zip()) -assert l1 == l1_ +a = iter("abc") +b = iter("cdef") +next(b) +check_pickle_unpickle(zip(a, b)) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: Fixed test_construct_singletons for Ellipsis and NotImplemented as well, so now ellipsis and NotImplementedType can be constructed.
Author: Vasily Kuznetsov Branch: py3.3 Changeset: r72534:1c542d770ddb Date: 2014-07-26 16:25 +0200 http://bitbucket.org/pypy/pypy/changeset/1c542d770ddb/ Log:Fixed test_construct_singletons for Ellipsis and NotImplemented as well, so now ellipsis and NotImplementedType can be constructed. diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py --- a/pypy/interpreter/typedef.py +++ b/pypy/interpreter/typedef.py @@ -950,11 +950,13 @@ Cell.typedef.acceptable_as_base_class = False Ellipsis.typedef = TypeDef("Ellipsis", +__new__ = interp2app(lambda space, w_type: space.w_Ellipsis), __repr__ = interp2app(Ellipsis.descr__repr__), ) Ellipsis.typedef.acceptable_as_base_class = False NotImplemented.typedef = TypeDef("NotImplemented", +__new__ = interp2app(lambda space, w_type: space.w_NotImplemented), __repr__ = interp2app(NotImplemented.descr__repr__), ) NotImplemented.typedef.acceptable_as_base_class = False diff --git a/pypy/module/__builtin__/test/test_construct_singletons.py b/pypy/module/__builtin__/test/test_construct_singletons.py --- a/pypy/module/__builtin__/test/test_construct_singletons.py +++ b/pypy/module/__builtin__/test/test_construct_singletons.py @@ -1,7 +1,8 @@ class AppTestConstructSingletons: def test_construct_singletons(self): -none_type = type(None) -assert none_type() is None -raises(TypeError, none_type, 1, 2) -raises(TypeError, none_type, a=1, b=2) +for const in None, Ellipsis, NotImplemented: +const_type = type(const) +assert const_type() is const +raises(TypeError, const_type, 1, 2) +raises(TypeError, const_type, a=1, b=2) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: Refuse to sum bytes or bytearrays like cpython3 sum.
Author: Vasily Kuznetsov Branch: py3.3 Changeset: r72537:c4be82e0fa27 Date: 2014-07-26 18:08 +0200 http://bitbucket.org/pypy/pypy/changeset/c4be82e0fa27/ Log:Refuse to sum bytes or bytearrays like cpython3 sum. diff --git a/pypy/module/__builtin__/app_functional.py b/pypy/module/__builtin__/app_functional.py --- a/pypy/module/__builtin__/app_functional.py +++ b/pypy/module/__builtin__/app_functional.py @@ -37,6 +37,10 @@ empty, returns start.""" if isinstance(start, str): raise TypeError("sum() can't sum strings [use ''.join(seq) instead]") +if isinstance(start, bytes): +raise TypeError("sum() can't sum bytes [use b''.join(seq) instead]") +if isinstance(start, bytearray): +raise TypeError("sum() can't sum bytearray [use b''.join(seq) instead]") last = start for x in sequence: # Very intentionally *not* +=, that would have different semantics if diff --git a/pypy/module/__builtin__/test/test_sum.py b/pypy/module/__builtin__/test/test_sum.py new file mode 100644 --- /dev/null +++ b/pypy/module/__builtin__/test/test_sum.py @@ -0,0 +1,9 @@ +class AppTestSum: + +def test_sum(self): +raises(TypeError, sum, [b'a', b'c'], b'') +raises(TypeError, sum, [bytearray(b'a'), bytearray(b'b')], +bytearray(b'')) +raises(TypeError, sum, [[1], [2], [3]]) +raises(TypeError, sum, [{2:3}]) +raises(TypeError, sum, [{2:3}]*2, {2:3}) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: missing import
Author: Philip Jenvey Branch: py3.3 Changeset: r72539:6a34ba3e09b7 Date: 2014-07-26 12:27 -0700 http://bitbucket.org/pypy/pypy/changeset/6a34ba3e09b7/ Log:missing import diff --git a/lib-python/3/test/pickletester.py b/lib-python/3/test/pickletester.py --- a/lib-python/3/test/pickletester.py +++ b/lib-python/3/test/pickletester.py @@ -9,7 +9,7 @@ from test.support import ( TestFailed, TESTFN, run_with_locale, no_tracing, -_2G, _4G, bigmemtest, +_2G, _4G, bigmemtest, check_impl_detail ) from pickle import bytes_types ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: skip new GIL API test
Author: Philip Jenvey Branch: py3.3 Changeset: r72541:3224b56f5c8e Date: 2014-07-26 12:36 -0700 http://bitbucket.org/pypy/pypy/changeset/3224b56f5c8e/ Log:skip new GIL API test diff --git a/lib-python/3/test/test_sys.py b/lib-python/3/test/test_sys.py --- a/lib-python/3/test/test_sys.py +++ b/lib-python/3/test/test_sys.py @@ -169,7 +169,8 @@ sys.setcheckinterval(n) self.assertEqual(sys.getcheckinterval(), n) -@unittest.skipUnless(threading, 'Threading required for this test.') +@unittest.skipUnless(hasattr(sys, 'getswitchinterval') and threading, + 'New GIL & threading required for this test.') def test_switchinterval(self): self.assertRaises(TypeError, sys.setswitchinterval) self.assertRaises(TypeError, sys.setswitchinterval, "a") ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: clarify
Author: Philip Jenvey Branch: py3.3 Changeset: r72543:d8277de0ae4e Date: 2014-07-26 12:40 -0700 http://bitbucket.org/pypy/pypy/changeset/d8277de0ae4e/ Log:clarify diff --git a/lib-python/3/test/test_cmd_line.py b/lib-python/3/test/test_cmd_line.py --- a/lib-python/3/test/test_cmd_line.py +++ b/lib-python/3/test/test_cmd_line.py @@ -341,7 +341,7 @@ def test_hash_randomization(self): # Verify that -R enables hash randomization: self.verify_valid_flag('-R') -if test.support.check_impl_detail(cpython=False): +if test.support.check_impl_detail(pypy=True): # PyPy doesn't support hash randomization return hashes = [] ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: __basic/itemsize__ are impl details
Author: Philip Jenvey Branch: py3.3 Changeset: r72542:4f1d9525b86f Date: 2014-07-26 12:40 -0700 http://bitbucket.org/pypy/pypy/changeset/4f1d9525b86f/ Log:__basic/itemsize__ are impl details diff --git a/lib-python/3/test/test_types.py b/lib-python/3/test/test_types.py --- a/lib-python/3/test/test_types.py +++ b/lib-python/3/test/test_types.py @@ -1,6 +1,6 @@ # Python test set -- part 6, built-in types -from test.support import run_unittest, run_with_locale +from test.support import run_unittest, run_with_locale, impl_detail import collections import locale import sys @@ -566,6 +566,7 @@ for code in 'xXobns': self.assertRaises(ValueError, format, 0, ',' + code) +@impl_detail def test_internal_sizes(self): self.assertGreater(object.__basicsize__, 0) self.assertGreater(tuple.__itemsize__, 0) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: testing of __del__ needs a gc_collect
Author: Philip Jenvey Branch: py3.3 Changeset: r72540:48d61dbba1ff Date: 2014-07-26 12:30 -0700 http://bitbucket.org/pypy/pypy/changeset/48d61dbba1ff/ Log:testing of __del__ needs a gc_collect diff --git a/lib-python/3/test/test_scope.py b/lib-python/3/test/test_scope.py --- a/lib-python/3/test/test_scope.py +++ b/lib-python/3/test/test_scope.py @@ -1,7 +1,8 @@ import unittest import weakref -from test.support import check_syntax_error, cpython_only, run_unittest +from test.support import ( +check_syntax_error, cpython_only, run_unittest, gc_collect) class ScopeTests(unittest.TestCase): @@ -422,6 +423,7 @@ for i in range(100): f1() +gc_collect() self.assertEqual(Foo.count, 0) def testClassAndGlobal(self): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: skip hash randomization test
Author: Philip Jenvey Branch: py3.3 Changeset: r72538:a2f29529053a Date: 2014-07-26 12:27 -0700 http://bitbucket.org/pypy/pypy/changeset/a2f29529053a/ Log:skip hash randomization test diff --git a/lib-python/3/test/test_cmd_line.py b/lib-python/3/test/test_cmd_line.py --- a/lib-python/3/test/test_cmd_line.py +++ b/lib-python/3/test/test_cmd_line.py @@ -341,6 +341,9 @@ def test_hash_randomization(self): # Verify that -R enables hash randomization: self.verify_valid_flag('-R') +if test.support.check_impl_detail(cpython=False): +# PyPy doesn't support hash randomization +return hashes = [] for i in range(2): code = 'print(hash("spam"))' ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy gc-incminimark-pinning: incminimark can be translated now
Author: Gregor Wegberg Branch: gc-incminimark-pinning Changeset: r72544:f03b71e80cc6 Date: 2014-07-26 20:11 +0200 http://bitbucket.org/pypy/pypy/changeset/f03b71e80cc6/ Log:incminimark can be translated now diff --git a/rpython/memory/gc/incminimark.py b/rpython/memory/gc/incminimark.py --- a/rpython/memory/gc/incminimark.py +++ b/rpython/memory/gc/incminimark.py @@ -1685,7 +1685,7 @@ debug_stop("gc-minor") def _visit_old_objects_pointing_to_pinned(self, obj, ignore): -self.trace(obj, self._trace_drag_out, None) +self.trace(obj, self._trace_drag_out, NULL) def collect_roots_in_nursery(self): # we don't need to trace prebuilt GcStructs during a minor collect: @@ -1802,14 +1802,14 @@ ll_assert(start < stop, "empty or negative range " "in trace_and_drag_out_of_nursery_partial()") #print 'trace_partial:', start, stop, '\t', obj -self.trace_partial(obj, start, stop, self._trace_drag_out, None) +self.trace_partial(obj, start, stop, self._trace_drag_out, NULL) def _trace_drag_out1(self, root): -self._trace_drag_out(root, None) +self._trace_drag_out(root, NULL) def _trace_drag_out1_marking_phase(self, root): -self._trace_drag_out(root, None) +self._trace_drag_out(root, NULL) # # We are in the MARKING state: we must also record this object # if it was young. Don't bother with old objects in general, @@ -1864,7 +1864,7 @@ return hdr.tid |= GCFLAG_VISITED # -if parent: +if parent != NULL: self.old_objects_pointing_to_pinned.append(parent) # # XXX add additional checks for unsupported pinned objects (groggi) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy gc-incminimark-pinning: 'NULL' -> 'llmemory.NULL'. Make it consistent. Use explicit version
Author: Gregor Wegberg Branch: gc-incminimark-pinning Changeset: r72545:4a4fffb737e5 Date: 2014-07-26 20:44 +0200 http://bitbucket.org/pypy/pypy/changeset/4a4fffb737e5/ Log:'NULL' -> 'llmemory.NULL'. Make it consistent. Use explicit version diff --git a/rpython/memory/gc/incminimark.py b/rpython/memory/gc/incminimark.py --- a/rpython/memory/gc/incminimark.py +++ b/rpython/memory/gc/incminimark.py @@ -82,7 +82,6 @@ # XXX update doc string to contain object pinning (groggi) WORD = LONG_BIT // 8 -NULL = llmemory.NULL first_gcflag = 1 << (LONG_BIT//2) @@ -302,10 +301,10 @@ # it gives a lower bound on the allowed size of the nursery. self.nonlarge_max = large_object - 1 # -self.nursery = NULL -self.nursery_free = NULL -self.nursery_top = NULL -self.nursery_real_top = NULL +self.nursery = llmemory.NULL +self.nursery_free = llmemory.NULL +self.nursery_top = llmemory.NULL +self.nursery_real_top = llmemory.NULL self.debug_tiny_nursery = -1 self.debug_rotating_nurseries = lltype.nullptr(NURSARRAY) self.extra_threshold = 0 @@ -1509,7 +1508,7 @@ # dict of shadows. obj = obj + self.gcheaderbuilder.size_gc_header shadow = self.nursery_objects_shadows.get(obj) -if shadow != NULL: +if shadow != llmemory.NULL: # visit shadow to keep it alive # XXX seems like it is save to set GCFLAG_VISITED, however # should be double checked @@ -1685,7 +1684,7 @@ debug_stop("gc-minor") def _visit_old_objects_pointing_to_pinned(self, obj, ignore): -self.trace(obj, self._trace_drag_out, NULL) +self.trace(obj, self._trace_drag_out, llmemory.NULL) def collect_roots_in_nursery(self): # we don't need to trace prebuilt GcStructs during a minor collect: @@ -1802,14 +1801,14 @@ ll_assert(start < stop, "empty or negative range " "in trace_and_drag_out_of_nursery_partial()") #print 'trace_partial:', start, stop, '\t', obj -self.trace_partial(obj, start, stop, self._trace_drag_out, NULL) +self.trace_partial(obj, start, stop, self._trace_drag_out, llmemory.NULL) def _trace_drag_out1(self, root): -self._trace_drag_out(root, NULL) +self._trace_drag_out(root, llmemory.NULL) def _trace_drag_out1_marking_phase(self, root): -self._trace_drag_out(root, NULL) +self._trace_drag_out(root, llmemory.NULL) # # We are in the MARKING state: we must also record this object # if it was young. Don't bother with old objects in general, @@ -1864,7 +1863,7 @@ return hdr.tid |= GCFLAG_VISITED # -if parent != NULL: +if parent != llmemory.NULL: self.old_objects_pointing_to_pinned.append(parent) # # XXX add additional checks for unsupported pinned objects (groggi) @@ -1877,7 +1876,7 @@ else: # First visit to an object that has already a shadow. newobj = self.nursery_objects_shadows.get(obj) -ll_assert(newobj != NULL, "GCFLAG_HAS_SHADOW but no shadow found") +ll_assert(newobj != llmemory.NULL, "GCFLAG_HAS_SHADOW but no shadow found") newhdr = newobj - size_gc_header # # Remove the flag GCFLAG_HAS_SHADOW, so that it doesn't get @@ -2352,7 +2351,7 @@ # collection if self.header(obj).tid & GCFLAG_HAS_SHADOW: shadow = self.nursery_objects_shadows.get(obj) -ll_assert(shadow != NULL, +ll_assert(shadow != llmemory.NULL, "GCFLAG_HAS_SHADOW but no shadow found") else: shadow = self._allocate_shadow(obj) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: reapply workarounds from py3k branch
Author: Philip Jenvey Branch: py3.3 Changeset: r72546:9b1c5ecf653b Date: 2014-07-26 13:20 -0700 http://bitbucket.org/pypy/pypy/changeset/9b1c5ecf653b/ Log:reapply workarounds from py3k branch diff --git a/lib-python/3/test/test_pydoc.py b/lib-python/3/test/test_pydoc.py --- a/lib-python/3/test/test_pydoc.py +++ b/lib-python/3/test/test_pydoc.py @@ -18,7 +18,7 @@ from collections import namedtuple from test.script_helper import assert_python_ok from test.support import ( -TESTFN, rmtree, +TESTFN, rmtree, check_impl_detail, reap_children, reap_threads, captured_output, captured_stdout, captured_stderr, unlink ) @@ -105,7 +105,23 @@ expected_text_data_docstrings = tuple('\n | ' + s if s else '' for s in expected_data_docstrings) -expected_html_pattern = """ +if check_impl_detail(pypy=True): +# pydoc_mod.__builtins__ is always a module on PyPy (but a dict on +# CPython), hence an extra 'Modules' section +module_section = """ + + + +Modules + + +builtins + +""" +else: +module_section = "" + +expected_html_pattern = (""" @@ -113,7 +129,7 @@ >indexhref="file:%s">%s%s This is a test module for test_pydoc - +""" + module_section + """\ @@ -201,7 +217,7 @@ \x20\x20\x20\x20 Nobody -""".strip() # ' <- emacs turd +""").strip() # ' <- emacs turd expected_html_data_docstrings = tuple(s.replace(' ', ' ') for s in expected_data_docstrings) @@ -433,6 +449,8 @@ # What we expect to get back: everything on object... expected = dict(vars(object)) +# __new__'s descriptor can be a staticmethod on PyPy +expected['__new__'] = object.__new__ # ...plus our unbound method... expected['method_returning_true'] = TestClass.method_returning_true # ...but not the non-methods on object. ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: restore the sysconfig_pypy usage
Author: Philip Jenvey Branch: py3.3 Changeset: r72547:cfa2d06ed493 Date: 2014-07-26 14:05 -0700 http://bitbucket.org/pypy/pypy/changeset/cfa2d06ed493/ Log:restore the sysconfig_pypy usage diff --git a/lib-python/3/distutils/sysconfig.py b/lib-python/3/distutils/sysconfig.py --- a/lib-python/3/distutils/sysconfig.py +++ b/lib-python/3/distutils/sysconfig.py @@ -9,589 +9,17 @@ Email: """ -import os -import re import sys -from .errors import DistutilsPlatformError -# These are needed in a couple of spots, so just compute them once. -PREFIX = os.path.normpath(sys.prefix) -EXEC_PREFIX = os.path.normpath(sys.exec_prefix) -BASE_PREFIX = os.path.normpath(sys.base_prefix) -BASE_EXEC_PREFIX = os.path.normpath(sys.base_exec_prefix) +# The content of this file is redirected from +# sysconfig_cpython or sysconfig_pypy. -# Path to the base directory of the project. On Windows the binary may -# live in project/PCBuild9. If we're dealing with an x64 Windows build, -# it'll live in project/PCbuild/amd64. -# set for cross builds -if "_PYTHON_PROJECT_BASE" in os.environ: -project_base = os.path.abspath(os.environ["_PYTHON_PROJECT_BASE"]) +if '__pypy__' in sys.builtin_module_names: +from distutils.sysconfig_pypy import * +from distutils.sysconfig_pypy import _config_vars # needed by setuptools +from distutils.sysconfig_pypy import _variable_rx # read_setup_file() else: -project_base = os.path.dirname(os.path.abspath(sys.executable)) -if os.name == "nt" and "pcbuild" in project_base[-8:].lower(): -project_base = os.path.abspath(os.path.join(project_base, os.path.pardir)) -# PC/VS7.1 -if os.name == "nt" and "\\pc\\v" in project_base[-10:].lower(): -project_base = os.path.abspath(os.path.join(project_base, os.path.pardir, -os.path.pardir)) -# PC/AMD64 -if os.name == "nt" and "\\pcbuild\\amd64" in project_base[-14:].lower(): -project_base = os.path.abspath(os.path.join(project_base, os.path.pardir, -os.path.pardir)) - -# python_build: (Boolean) if true, we're either building Python or -# building an extension with an un-installed Python, so we use -# different (hard-wired) directories. -# Setup.local is available for Makefile builds including VPATH builds, -# Setup.dist is available on Windows -def _is_python_source_dir(d): -for fn in ("Setup.dist", "Setup.local"): -if os.path.isfile(os.path.join(d, "Modules", fn)): -return True -return False -_sys_home = getattr(sys, '_home', None) -if _sys_home and os.name == 'nt' and \ -_sys_home.lower().endswith(('pcbuild', 'pcbuild\\amd64')): -_sys_home = os.path.dirname(_sys_home) -if _sys_home.endswith('pcbuild'): # must be amd64 -_sys_home = os.path.dirname(_sys_home) -def _python_build(): -if _sys_home: -return _is_python_source_dir(_sys_home) -return _is_python_source_dir(project_base) -python_build = _python_build() - -# Calculate the build qualifier flags if they are defined. Adding the flags -# to the include and lib directories only makes sense for an installation, not -# an in-source build. -build_flags = '' -try: -if not python_build: -build_flags = sys.abiflags -except AttributeError: -# It's not a configure-based build, so the sys module doesn't have -# this attribute, which is fine. -pass - -def get_python_version(): -"""Return a string containing the major and minor Python version, -leaving off the patchlevel. Sample return values could be '1.5' -or '2.2'. -""" -return sys.version[:3] - - -def get_python_inc(plat_specific=0, prefix=None): -"""Return the directory containing installed Python header files. - -If 'plat_specific' is false (the default), this is the path to the -non-platform-specific header files, i.e. Python.h and so on; -otherwise, this is the path to platform-specific header files -(namely pyconfig.h). - -If 'prefix' is supplied, use it instead of sys.base_prefix or -sys.base_exec_prefix -- i.e., ignore 'plat_specific'. -""" -if prefix is None: -prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX -if os.name == "posix": -if python_build: -# Assume the executable is in the build directory. The -# pyconfig.h file should be in the same directory. Since -# the build directory may not be the source directory, we -# must use "srcdir" from the makefile to find the "Include" -# directory. -base = _sys_home or project_base -if plat_specific: -return base -if _sys_home: -incdir = os.path.join(_sys_home, get_config_var('AST_H_DIR')) -else: -incdir = os.path.join(get_config_var('srcdir'), 'Include') -return os.path.normpath(incdir) -python_dir = 'python' + get_python_versio
[pypy-commit] pypy py3.3: reapply PyPy workarounds to fix build_ext
Author: Philip Jenvey Branch: py3.3 Changeset: r72548:f43f86638f34 Date: 2014-07-26 14:06 -0700 http://bitbucket.org/pypy/pypy/changeset/f43f86638f34/ Log:reapply PyPy workarounds to fix build_ext diff --git a/lib-python/3/distutils/command/build_ext.py b/lib-python/3/distutils/command/build_ext.py --- a/lib-python/3/distutils/command/build_ext.py +++ b/lib-python/3/distutils/command/build_ext.py @@ -4,11 +4,10 @@ modules (currently limited to C extensions, should accommodate C++ extensions ASAP).""" -import sys, os, re +import sys, os, re, imp from distutils.core import Command from distutils.errors import * from distutils.sysconfig import customize_compiler, get_python_version -from distutils.sysconfig import get_config_h_filename from distutils.dep_util import newer_group from distutils.extension import Extension from distutils.util import get_platform @@ -36,6 +35,11 @@ from distutils.ccompiler import show_compilers show_compilers() +def _get_c_extension_suffix(): +for ext, mod, typ in imp.get_suffixes(): +if typ == imp.C_EXTENSION: +return ext + class build_ext(Command): @@ -204,11 +208,16 @@ # Append the source distribution include and library directories, # this allows distutils on windows to work in the source tree -self.include_dirs.append(os.path.dirname(get_config_h_filename())) +if 0: +# pypy has no config_h_filename directory + self.include_dirs.append(os.path.dirname(get_config_h_filename())) _sys_home = getattr(sys, '_home', None) if _sys_home: self.library_dirs.append(_sys_home) -if MSVC_VERSION >= 9: +if 1: +# pypy has no PCBuild directory +pass +elif MSVC_VERSION >= 9: # Use the .lib files for the correct architecture if self.plat_name == 'win32': suffix = '' @@ -675,10 +684,18 @@ # OS/2 has an 8 character module (extension) limit :-( if os.name == "os2": ext_path[len(ext_path) - 1] = ext_path[len(ext_path) - 1][:8] +# PyPy tweak: first try to get the C extension suffix from +# 'imp'. If it fails we fall back to the 'SO' config var, like +# the previous version of this code did. This should work for +# CPython too. The point is that on PyPy with cpyext, the +# config var 'SO' is just ".so" but we want to return +# ".pypy-VERSION.so" instead. +ext_suffix = _get_c_extension_suffix() +if ext_suffix is None: +ext_suffix = get_config_var('EXT_SUFFIX') # fall-back # extensions in debug_mode are named 'module_d.pyd' under windows -ext_suffix = get_config_var('EXT_SUFFIX') if os.name == 'nt' and self.debug: -return os.path.join(*ext_path) + '_d' + ext_suffix +ext_suffix = '_d.pyd' return os.path.join(*ext_path) + ext_suffix def get_export_symbols(self, ext): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: fix function identifier clashing breaking translation
Author: Philip Jenvey Branch: py3.3 Changeset: r72549:e6da813670d7 Date: 2014-07-26 14:40 -0700 http://bitbucket.org/pypy/pypy/changeset/e6da813670d7/ Log:fix function identifier clashing breaking translation diff --git a/pypy/interpreter/special.py b/pypy/interpreter/special.py --- a/pypy/interpreter/special.py +++ b/pypy/interpreter/special.py @@ -2,10 +2,20 @@ class Ellipsis(W_Root): + +@staticmethod +def descr_new_ellipsis(space, w_type): +return space.w_Ellipsis + def descr__repr__(self, space): return space.wrap('Ellipsis') class NotImplemented(W_Root): + +@staticmethod +def descr_new_notimplemented(space, w_type): +return space.w_NotImplemented + def descr__repr__(self, space): return space.wrap('NotImplemented') diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py --- a/pypy/interpreter/typedef.py +++ b/pypy/interpreter/typedef.py @@ -950,13 +950,13 @@ Cell.typedef.acceptable_as_base_class = False Ellipsis.typedef = TypeDef("Ellipsis", -__new__ = interp2app(lambda space, w_type: space.w_Ellipsis), +__new__ = interp2app(Ellipsis.descr_new_ellipsis), __repr__ = interp2app(Ellipsis.descr__repr__), ) Ellipsis.typedef.acceptable_as_base_class = False NotImplemented.typedef = TypeDef("NotImplemented", -__new__ = interp2app(lambda space, w_type: space.w_NotImplemented), +__new__ = interp2app(NotImplemented.descr_new_notimplemented), __repr__ = interp2app(NotImplemented.descr__repr__), ) NotImplemented.typedef.acceptable_as_base_class = False ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit