[pypy-commit] pypy default: oops
Author: Maciej Fijalkowski Branch: Changeset: r74199:391cb686bad8 Date: 2014-10-25 10:18 +0200 http://bitbucket.org/pypy/pypy/changeset/391cb686bad8/ Log:oops diff --git a/pypy/tool/release/package.py b/pypy/tool/release/package.py --- a/pypy/tool/release/package.py +++ b/pypy/tool/release/package.py @@ -162,7 +162,7 @@ binaries = [(pypy_c, rename_pypy_c)] libpypy_c = basedir.join('pypy', 'goal', 'libpypy-c.so') if libpypy_c.check(): -binaries.append('libpypy-c.so') +binaries.append(('libpypy-c.so', 'libpypy-c.so')) # builddir = options.builddir pypydir = builddir.ensure(name, dir=True) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: merge
Author: Maciej Fijalkowski Branch: Changeset: r74200:81ceb87833b9 Date: 2014-10-25 10:19 +0200 http://bitbucket.org/pypy/pypy/changeset/81ceb87833b9/ Log:merge diff too long, truncating to 2000 out of 22654 lines diff --git a/.hgignore b/.hgignore --- a/.hgignore +++ b/.hgignore @@ -89,6 +89,7 @@ ^pypy/doc/image/lattice3\.png$ ^pypy/doc/image/stackless_informal\.png$ ^pypy/doc/image/parsing_example.+\.png$ +^rpython/doc/_build/.*$ ^pypy/module/test_lib_pypy/ctypes_tests/_ctypes_test\.o$ ^compiled ^.git/ diff --git a/README.rst b/README.rst --- a/README.rst +++ b/README.rst @@ -23,6 +23,7 @@ the pypy-dev team + Building diff --git a/ctypes_configure/doc/configure.txt b/ctypes_configure/doc/configure.txt --- a/ctypes_configure/doc/configure.txt +++ b/ctypes_configure/doc/configure.txt @@ -19,6 +19,4 @@ usage = -`sample.py`_ explains in details how to use it. - -.. _`sample.py`: http://codespeak.net/svn/pypy/dist/ctypes_configure/doc/sample.py +:source:`sample.py ` explains in details how to use it. diff --git a/pypy/doc/TODO b/pypy/doc/TODO new file mode 100644 --- /dev/null +++ b/pypy/doc/TODO @@ -0,0 +1,40 @@ +Documentation TODO +== + +General +--- + +* architecture documents don't really show the separation between PyPy and + RPython + * architecture.rst is duplicate (both pypy and rpython) +* Consider moving information from pypy/doc/{build,windows}.rst to rpython/doc + + +Cleanup +~~~ + +* remove documentation on removed features + * various object spaces +* update / remove dead links + + +Meta + + +* work on configuration/options documentation generation + + +PyPy + + +* Update coding guide +* Move links from project-documentation.rst to index.rst and consider killing + it. + + +RPython +--- + +* make translation.rst a high-level overview and move details in their own + documents +* redo various outdated pictures in translation.rst diff --git a/pypy/doc/__pypy__-module.rst b/pypy/doc/__pypy__-module.rst --- a/pypy/doc/__pypy__-module.rst +++ b/pypy/doc/__pypy__-module.rst @@ -1,20 +1,17 @@ - .. comment: this document is very incomplete, should we generate it automatically? -=== The ``__pypy__`` module === The ``__pypy__`` module is the main entry point to special features provided -by PyPy's standard interpreter. Its content depends on `configuration options`_ -which may add new functionality and functions whose existence or non-existence -indicates the presence of such features. +by PyPy's standard interpreter. Its content depends on :doc:`configuration options ` +which may add new functionality and functions whose existence or non-existence +indicates the presence of such features. -.. _`configuration options`: config/index.html Generally available functionality -= +- - ``internal_repr(obj)``: return the interpreter-level representation of an object. @@ -22,28 +19,22 @@ It works like a simplified array of characters (actually, depending on the configuration the ``array`` module internally uses this). + Transparent Proxy Functionality -=== +--- -If `transparent proxies`_ are enabled (with :config:`objspace.std.withtproxy`) +If :ref:`transparent proxies ` are enabled (with :config:`objspace.std.withtproxy`) the following functions are put into ``__pypy__``: - ``tproxy(typ, controller)``: Return something that looks like it is of type typ. Its behaviour is completely controlled by the controller. See the docs - about `transparent proxies`_ for detail. - + about :ref:`transparent proxies ` for detail. - ``get_tproxy_controller(obj)``: If obj is really a transparent proxy, return its controller. Otherwise return None. -.. _`transparent proxies`: objspace-proxies.html#tproxy - Functionality available on py.py (not after translation) - + - ``isfake(obj)``: returns True if ``obj`` is faked. - - ``interp_pdb()``: start a pdb at interpreter-level. - - - diff --git a/pypy/doc/_ref.txt b/pypy/doc/_ref.txt deleted file mode 100644 --- a/pypy/doc/_ref.txt +++ /dev/null @@ -1,114 +0,0 @@ -.. This file is generated automatically by makeref.py script, - which in turn is run manually. - -.. _`ctypes_configure/doc/sample.py`: https://bitbucket.org/pypy/pypy/src/default/ctypes_configure/doc/sample.py -.. _`dotviewer/`: https://bitbucket.org/pypy/pypy/src/default/dotviewer/ -.. _`lib-python/`: https://bitbucket.org/pypy/pypy/src/default/lib-python/ -.. _`lib-python/2.7/dis.py`: https://bitbucket.org/pypy/pypy/src/default/lib-python/2.7/dis.py -.. _`lib_pypy/`: https://bitbucket.org/pypy/pypy/src/default/lib_pypy/ -.. _`lib_pypy/greenlet.py`: https://bitbucket.org/pypy/pypy/src/de
[pypy-commit] pypy default: Mention "python .../bin/rpython" in addition to the default "pypy".
Author: Armin Rigo Branch: Changeset: r74201:80567e953cca Date: 2014-10-25 14:31 +0200 http://bitbucket.org/pypy/pypy/changeset/80567e953cca/ Log:Mention "python .../bin/rpython" in addition to the default "pypy". diff --git a/pypy/doc/build.rst b/pypy/doc/build.rst --- a/pypy/doc/build.rst +++ b/pypy/doc/build.rst @@ -119,6 +119,9 @@ pypy rpython/bin/rpython --opt=2 pypy/goal/targetpypystandalone.py +(You can use ``python`` instead of ``pypy`` here, which will take longer +but works too.) + If everything works correctly this will create an executable ``pypy-c`` in the current directory. The executable behaves mostly like a normal Python interpreter (see :doc:`cpython_differences`). ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: yield from: More tests, and fixes
Author: Amaury Forgeot d'Arc Branch: py3.3 Changeset: r74204:cbd6c0accf8c Date: 2014-10-25 11:29 +0200 http://bitbucket.org/pypy/pypy/changeset/cbd6c0accf8c/ Log:yield from: More tests, and fixes diff --git a/pypy/interpreter/generator.py b/pypy/interpreter/generator.py --- a/pypy/interpreter/generator.py +++ b/pypy/interpreter/generator.py @@ -117,16 +117,14 @@ # Probably a hack (but CPython has the same): # If the current frame is stopped in a "yield from", # return the paused generator. -from pypy.interpreter.pyopcode import bytecode_spec if not self.frame: return None co_code = self.frame.pycode.co_code opcode = ord(co_code[self.frame.last_instr + 1]) -if opcode == opcodedesc.YIELD_FROM.index: +if opcode == YIELD_FROM: return self.frame.peekvalue() def throw(self, w_type, w_val, w_tb): -from pypy.interpreter.pytraceback import check_traceback space = self.space w_yf = self._get_yield_from() @@ -144,27 +142,33 @@ space.call_function(w_close) except OperationError as operr: self.running = False -self.send_ex(space.w_None, operr) -return +return self.send_ex(space.w_None, operr) finally: self.running = False return self._throw_here(space, w_type, w_val, w_tb) else: try: -space.call_method(w_yf, "throw", w_type, w_val, w_tb) +w_throw = space.getattr(w_yf, space.wrap("throw")) +except OperationError as e: +if not e.match(space, space.w_AttributeError): +raise +return self._throw_here(space, w_type, w_val, w_tb) +self.running = True +try: +space.call_function(w_throw, w_type, w_val, w_tb) except OperationError as operr: self.running = False -self.send_ex(space.w_None, operr) -return +# XXX Should pop subiterator from stack? +return self.send_ex(space.w_None, operr) finally: self.running = False - -return self.forward_throw_to_yield_from(yf) # Not paused in a "yield from", quit this generator return self._throw_here(space, w_type, w_val, w_tb) def _throw_here(self, space, w_type, w_val, w_tb): +from pypy.interpreter.pytraceback import check_traceback + msg = "throw() third argument must be a traceback object" if space.is_none(w_tb): tb = None @@ -286,6 +290,7 @@ from pypy.tool.stdlib_opcode import HAVE_ARGUMENT, opmap YIELD_VALUE = opmap['YIELD_VALUE'] +YIELD_FROM = opmap['YIELD_FROM'] @jit.elidable_promote() def should_not_inline(pycode): 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 @@ -485,6 +485,37 @@ "Finishing g1", ] +def test_delegating_throw_to_non_generator(self): +""" +Test delegating 'throw' to non-generator +""" +trace = [] +d = dict(trace=trace) +exec('''if 1: +def g(): +try: +trace.append("Starting g") +yield from range(10) +finally: +trace.append("Finishing g") +''', d) +g = d['g'] +gi = g() +for i in range(5): +x = next(gi) +trace.append("Yielded %s" % (x,)) +exc = raises(ValueError, gi.throw, ValueError("tomato ejected")) +assert exc.value.args[0] == "tomato ejected" +assert trace == [ +"Starting g", +"Yielded 0", +"Yielded 1", +"Yielded 2", +"Yielded 3", +"Yielded 4", +"Finishing g", +] + def test_broken_getattr_handling(self): """ Test subiterator with a broken getattr implementation ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: Merge heads
Author: Amaury Forgeot d'Arc Branch: py3.3 Changeset: r74203:5c7b5a819708 Date: 2014-10-23 23:58 +0200 http://bitbucket.org/pypy/pypy/changeset/5c7b5a819708/ Log:Merge heads diff --git a/pypy/doc/cppyy.rst b/pypy/doc/cppyy.rst --- a/pypy/doc/cppyy.rst +++ b/pypy/doc/cppyy.rst @@ -83,7 +83,7 @@ the selection of scientific software) will also work for a build with the builtin backend. -.. _`download`: http://cern.ch/wlav/reflex-2013-08-14.tar.bz2 +.. _`download`: http://cern.ch/wlav/reflex-2014-10-20.tar.bz2 .. _`ROOT`: http://root.cern.ch/ Besides Reflex, you probably need a version of `gccxml`_ installed, which is @@ -98,8 +98,8 @@ To install the standalone version of Reflex, after download:: -$ tar jxf reflex-2013-08-14.tar.bz2 -$ cd reflex-2013-08-14 +$ tar jxf reflex-2014-10-20.tar.bz2 +$ cd reflex-2014-10-20 $ ./build/autogen $ ./configure $ make && make install @@ -804,7 +804,7 @@ also means that you can't actually find out whether it is in use, other than by running a micro-benchmark or a JIT test). -.. _`provided`: http://cern.ch/wlav/reflex-2013-04-23.tar.bz2 +.. _`provided`: http://cern.ch/wlav/reflex-2014-10-20.tar.bz2 .. _`genreflex-methptrgetter.patch`: https://bitbucket.org/pypy/pypy/src/default/pypy/module/cppyy/genreflex-methptrgetter.patch CPython diff --git a/pypy/goal/targetpypystandalone.py b/pypy/goal/targetpypystandalone.py --- a/pypy/goal/targetpypystandalone.py +++ b/pypy/goal/targetpypystandalone.py @@ -258,7 +258,8 @@ enable_translationmodules(config) config.translation.suggest(check_str_without_nul=True) -config.translation.suggest(shared=True) +if sys.platform.startswith('linux'): +config.translation.suggest(shared=True) if config.translation.thread: config.objspace.usemodules.thread = True 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 @@ -278,12 +278,19 @@ else: errors = None -sys.stdin = sys.__stdin__ = create_stdio( -0, False, "", encoding, errors, unbuffered) +sys.stderr = sys.__stderr__ = create_stdio( +2, True, "", encoding, 'backslashreplace', unbuffered) sys.stdout = sys.__stdout__ = create_stdio( 1, True, "", encoding, errors, unbuffered) -sys.stderr = sys.__stderr__ = create_stdio( -2, True, "", encoding, 'backslashreplace', unbuffered) + +try: +sys.stdin = sys.__stdin__ = create_stdio( +0, False, "", encoding, errors, unbuffered) +except IsADirectoryError: +import os +print("Python error: is a directory, cannot continue", + file=sys.stderr) +os._exit(1) finally: if encerr: display_exception(encerr) diff --git a/pypy/module/micronumpy/boxes.py b/pypy/module/micronumpy/boxes.py --- a/pypy/module/micronumpy/boxes.py +++ b/pypy/module/micronumpy/boxes.py @@ -16,6 +16,7 @@ from pypy.module.micronumpy.base import W_NDimArray, W_NumpyObject from pypy.module.micronumpy.concrete import VoidBoxStorage from pypy.module.micronumpy.flagsobj import W_FlagsObject +from pypy.module.micronumpy import support MIXIN_32 = (W_IntObject.typedef,) if LONG_BIT == 32 else () MIXIN_64 = (W_IntObject.typedef,) if LONG_BIT == 64 else () @@ -144,6 +145,34 @@ def item(self, space): return self.get_dtype(space).itemtype.to_builtin_type(space, self) +def descr_item(self, space, args_w): +if len(args_w) == 1 and space.isinstance_w(args_w[0], space.w_tuple): +args_w = space.fixedview(args_w[0]) +if len(args_w) > 1: +raise oefmt(space.w_ValueError, +"incorrect number of indices for array") +elif len(args_w) == 1: +try: +idx = support.index_w(space, args_w[0]) +except OperationError: +raise oefmt(space.w_TypeError, "an integer is required") +if idx != 0: +raise oefmt(space.w_IndexError, +"index %d is out of bounds for size 1", idx) +return self.item(space) + +def descr_transpose(self, space, args_w): +if len(args_w) == 1 and space.isinstance_w(args_w[0], space.w_tuple): +args_w = space.fixedview(args_w[0]) +if len(args_w) >= 1: +for w_arg in args_w: +try: +idx = support.index_w(space, w_arg) +except OperationError: +raise oefmt(space.w_TypeError, "an integer is required") +raise oefmt(space.w_ValueError, "axes don't match array") +return self + def descr_getitem(self, space, w_item): from pypy.module.micronumpy.base import convert_to_array if space.is_w(w_item, space.w_Ellipsi
[pypy-commit] pypy py3.3: Improve support for "yield from" generators.
Author: Amaury Forgeot d'Arc Branch: py3.3 Changeset: r74202:a6a3f705a6df Date: 2014-10-23 23:56 +0200 http://bitbucket.org/pypy/pypy/changeset/a6a3f705a6df/ Log:Improve support for "yield from" generators. diff --git a/pypy/interpreter/generator.py b/pypy/interpreter/generator.py --- a/pypy/interpreter/generator.py +++ b/pypy/interpreter/generator.py @@ -113,10 +113,58 @@ w_val = self.space.w_None return self.throw(w_type, w_val, w_tb) +def _get_yield_from(self): +# Probably a hack (but CPython has the same): +# If the current frame is stopped in a "yield from", +# return the paused generator. +from pypy.interpreter.pyopcode import bytecode_spec +if not self.frame: +return None +co_code = self.frame.pycode.co_code +opcode = ord(co_code[self.frame.last_instr + 1]) +if opcode == opcodedesc.YIELD_FROM.index: +return self.frame.peekvalue() + def throw(self, w_type, w_val, w_tb): from pypy.interpreter.pytraceback import check_traceback space = self.space +w_yf = self._get_yield_from() +if w_yf is not None: +# Paused in a "yield from", pass the throw to the inner generator. +if space.is_w(w_type, space.w_GeneratorExit): +try: +w_close = space.getattr(w_yf, space.wrap("close")) +except OperationError as e: +if not e.match(space, space.w_AttributeError): +e.write_unraisable(space, "generator.close()") +else: +self.running = True +try: +space.call_function(w_close) +except OperationError as operr: +self.running = False +self.send_ex(space.w_None, operr) +return +finally: +self.running = False +return self._throw_here(space, w_type, w_val, w_tb) +else: +try: +space.call_method(w_yf, "throw", w_type, w_val, w_tb) +except OperationError as operr: +self.running = False +self.send_ex(space.w_None, operr) +return +finally: +self.running = False + +return self.forward_throw_to_yield_from(yf) + +# Not paused in a "yield from", quit this generator +return self._throw_here(space, w_type, w_val, w_tb) + +def _throw_here(self, space, w_type, w_val, w_tb): msg = "throw() third argument must be a traceback object" if space.is_none(w_tb): tb = None 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 @@ -364,3 +364,158 @@ return g.__code__ ''') assert should_not_inline(w_co) == True + +class AppTestYieldFrom: +def test_delegating_close(self): +""" +Test delegating 'close' +""" +trace = [] +d = dict(trace=trace) +exec('''if 1: +def g1(): +try: +trace.append("Starting g1") +yield "g1 ham" +yield from g2() +yield "g1 eggs" +finally: +trace.append("Finishing g1") +def g2(): +try: +trace.append("Starting g2") +yield "g2 spam" +yield "g2 more spam" +finally: +trace.append("Finishing g2") +''', d) +g1, g2 = d['g1'], d['g2'] +g = g1() +for i in range(2): +x = next(g) +trace.append("Yielded %s" % (x,)) +g.close() +assert trace == [ +"Starting g1", +"Yielded g1 ham", +"Starting g2", +"Yielded g2 spam", +"Finishing g2", +"Finishing g1" +] + +def test_handing_exception_while_delegating_close(self): +""" +Test handling exception while delegating 'close' +""" +trace = [] +d = dict(trace=trace) +exec('''if 1: +def g1(): +try: +trace.append("Starting g1") +yield "g1 ham" +yield from g2() +yield "g1 eggs" +finally: +trace.append("Finishing g1") +def g2(): +try: +trace.append("Starting g2") +yield "g2 spam" +yield "g2 more spam" +finally: +trace.append("Finishing g2") +raise ValueError("nybbles have exploded with delight") +''', d) +g1, g2 = d['g1'], d['g2'] +
[pypy-commit] pypy py3.3: Be sure to handle the returned value from delegated throw
Author: Amaury Forgeot d'Arc Branch: py3.3 Changeset: r74205:874078255648 Date: 2014-10-25 11:45 +0200 http://bitbucket.org/pypy/pypy/changeset/874078255648/ Log:Be sure to handle the returned value from delegated throw diff --git a/pypy/interpreter/generator.py b/pypy/interpreter/generator.py --- a/pypy/interpreter/generator.py +++ b/pypy/interpreter/generator.py @@ -130,41 +130,44 @@ w_yf = self._get_yield_from() if w_yf is not None: # Paused in a "yield from", pass the throw to the inner generator. -if space.is_w(w_type, space.w_GeneratorExit): -try: -w_close = space.getattr(w_yf, space.wrap("close")) -except OperationError as e: -if not e.match(space, space.w_AttributeError): -e.write_unraisable(space, "generator.close()") -else: -self.running = True -try: -space.call_function(w_close) -except OperationError as operr: -self.running = False -return self.send_ex(space.w_None, operr) -finally: -self.running = False -return self._throw_here(space, w_type, w_val, w_tb) +return self._throw_delegate(space, w_yf, w_type, w_val, w_tb) +else: +# Not paused in a "yield from", quit this generator +return self._throw_here(space, w_type, w_val, w_tb) + +def _throw_delegate(self, space, w_yf, w_type, w_val, w_tb): +if space.is_w(w_type, space.w_GeneratorExit): +try: +w_close = space.getattr(w_yf, space.wrap("close")) +except OperationError as e: +if not e.match(space, space.w_AttributeError): +e.write_unraisable(space, "generator.close()") else: -try: -w_throw = space.getattr(w_yf, space.wrap("throw")) -except OperationError as e: -if not e.match(space, space.w_AttributeError): -raise -return self._throw_here(space, w_type, w_val, w_tb) self.running = True try: -space.call_function(w_throw, w_type, w_val, w_tb) +space.call_function(w_close) except OperationError as operr: self.running = False -# XXX Should pop subiterator from stack? return self.send_ex(space.w_None, operr) finally: self.running = False - -# Not paused in a "yield from", quit this generator -return self._throw_here(space, w_type, w_val, w_tb) +return self._throw_here(space, w_type, w_val, w_tb) +else: +try: +w_throw = space.getattr(w_yf, space.wrap("throw")) +except OperationError as e: +if not e.match(space, space.w_AttributeError): +raise +return self._throw_here(space, w_type, w_val, w_tb) +self.running = True +try: +return space.call_function(w_throw, w_type, w_val, w_tb) +except OperationError as operr: +self.running = False +# XXX Should pop subiterator from stack? +return self.send_ex(space.w_None, operr) +finally: +self.running = False def _throw_here(self, space, w_type, w_val, w_tb): from pypy.interpreter.pytraceback import check_traceback 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 @@ -550,3 +550,50 @@ gi.close() assert 'ZeroDivisionError' in sys.stderr.getvalue() +def test_returning_value_from_delegated_throw(self): +""" +Test returning value from delegated 'throw' +""" +trace = [] +class LunchError(Exception): +pass +d = dict(trace=trace, LunchError=LunchError) +exec('''if 1: +def g1(): +try: +trace.append("Starting g1") +yield "g1 ham" +yield from g2() +yield "g1 eggs" +finally: +trace.append("Finishing g1") +def g2(): +try: +trace.append("Starting g2") +yield "g2 spam" +yield "g2 more spam" +except LunchError: +trace.append("Caught LunchError in g2") +yield "g2 lunch saved" +yield "g2 yet more spam" +''', d) +g1, g2 = d['g1'], d['g2'] +g = g1() +for i in range(2): +
[pypy-commit] pypy py3.3: yield from: Fix last test failure.
Author: Amaury Forgeot d'Arc Branch: py3.3 Changeset: r74207:82ec5124510e Date: 2014-10-25 14:40 +0200 http://bitbucket.org/pypy/pypy/changeset/82ec5124510e/ Log:yield from: Fix last test failure. diff --git a/pypy/interpreter/generator.py b/pypy/interpreter/generator.py --- a/pypy/interpreter/generator.py +++ b/pypy/interpreter/generator.py @@ -164,8 +164,16 @@ return space.call_function(w_throw, w_type, w_val, w_tb) except OperationError as operr: self.running = False -# XXX Should pop subiterator from stack? -return self.send_ex(space.w_None, operr) +# Pop subiterator from stack. +w_subiter = self.frame.popvalue() +assert space.is_w(w_subiter, w_yf) +# Termination repetition of YIELD_FROM +self.frame.last_instr += 1 +if operr.match(space, space.w_StopIteration): +w_val = operr.get_w_value(space) +return self.send_ex(w_val) +else: +return self.send_ex(space.w_None, operr) finally: self.running = False 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 @@ -597,3 +597,34 @@ "Finishing g1", ] +def test_catching_exception_from_subgen_and_returning(self): +""" +Test catching an exception thrown into a +subgenerator and returning a value +""" +trace = [] +d = dict(trace=trace) +exec('''if 1: +def inner(): +try: +yield 1 +except ValueError: +trace.append("inner caught ValueError") +return 2 + +def outer(): +v = yield from inner() +trace.append("inner returned %r to outer" % v) +yield v +''', d) +inner, outer = d['inner'], d['outer'] +g = outer() +trace.append(next(g)) +trace.append(g.throw(ValueError)) +assert trace == [ +1, +"inner caught ValueError", +"inner returned 2 to outer", +2, +] + ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.3: hg merge heads
Author: Amaury Forgeot d'Arc Branch: py3.3 Changeset: r74206:7b2bd81a69d5 Date: 2014-10-25 11:46 +0200 http://bitbucket.org/pypy/pypy/changeset/7b2bd81a69d5/ Log:hg merge heads diff too long, truncating to 2000 out of 5280 lines diff --git a/lib_pypy/_tkinter/app.py b/lib_pypy/_tkinter/app.py --- a/lib_pypy/_tkinter/app.py +++ b/lib_pypy/_tkinter/app.py @@ -439,7 +439,7 @@ if isinstance(s, int): return s s = s.encode('utf-8') -if '\x00' in s: +if b'\x00' in s: raise TypeError v = tkffi.new("int*") res = tklib.Tcl_GetBoolean(self.interp, s, v) @@ -451,7 +451,7 @@ if isinstance(s, int): return s s = s.encode('utf-8') -if '\x00' in s: +if b'\x00' in s: raise TypeError v = tkffi.new("int*") res = tklib.Tcl_GetInt(self.interp, s, v) @@ -463,7 +463,7 @@ if isinstance(s, float): return s s = s.encode('utf-8') -if '\x00' in s: +if b'\x00' in s: raise TypeError v = tkffi.new("double*") res = tklib.Tcl_GetDouble(self.interp, s, v) @@ -472,7 +472,7 @@ return v[0] def exprboolean(self, s): -if '\x00' in s: +if b'\x00' in s: raise TypeError v = tkffi.new("int*") res = tklib.Tcl_ExprBoolean(self.interp, s, v) @@ -481,7 +481,7 @@ return v[0] def exprlong(self, s): -if '\x00' in s: +if b'\x00' in s: raise TypeError v = tkffi.new("long*") res = tklib.Tcl_ExprLong(self.interp, s, v) @@ -490,7 +490,7 @@ return v[0] def exprdouble(self, s): -if '\x00' in s: +if b'\x00' in s: raise TypeError v = tkffi.new("double*") res = tklib.Tcl_ExprDouble(self.interp, s, v) @@ -499,7 +499,7 @@ return v[0] def exprstring(self, s): -if '\x00' in s: +if b'\x00' in s: raise TypeError res = tklib.Tcl_ExprString(self.interp, s) if res == tklib.TCL_ERROR: diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst --- a/pypy/doc/whatsnew-head.rst +++ b/pypy/doc/whatsnew-head.rst @@ -22,3 +22,6 @@ .. branch: ClassRepr Refactor ClassRepr and make normalizecalls independent of the rtyper. + +.. branch: remove-remaining-smm +Remove all remaining multimethods. diff --git a/pypy/goal/targetpypystandalone.py b/pypy/goal/targetpypystandalone.py --- a/pypy/goal/targetpypystandalone.py +++ b/pypy/goal/targetpypystandalone.py @@ -310,7 +310,8 @@ return self.get_entry_point(config) def jitpolicy(self, driver): -from pypy.module.pypyjit.policy import PyPyJitPolicy, pypy_hooks +from pypy.module.pypyjit.policy import PyPyJitPolicy +from pypy.module.pypyjit.hooks import pypy_hooks return PyPyJitPolicy(pypy_hooks) def get_entry_point(self, config): diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py --- a/pypy/interpreter/baseobjspace.py +++ b/pypy/interpreter/baseobjspace.py @@ -1902,5 +1902,4 @@ 'newdict', 'newslice', 'call_args', -'marshal_w', ] diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py --- a/pypy/interpreter/gateway.py +++ b/pypy/interpreter/gateway.py @@ -644,6 +644,17 @@ elif unwrap_spec == [ObjSpace, W_Root, Arguments]: self.__class__ = BuiltinCodePassThroughArguments1 self.func__args__ = func +elif unwrap_spec == [self_type, ObjSpace, Arguments]: +self.__class__ = BuiltinCodePassThroughArguments1 +miniglobals = {'func': func, 'self_type': self_type} +d = {} +source = """if 1: +def _call(space, w_obj, args): +self = space.descr_self_interp_w(self_type, w_obj) +return func(self, space, args) +\n""" +exec compile2(source) in miniglobals, d +self.func__args__ = d['_call'] else: self.__class__ = globals()['BuiltinCode%d' % arity] setattr(self, 'fastfunc_%d' % arity, fastfunc) diff --git a/pypy/interpreter/test/test_gateway.py b/pypy/interpreter/test/test_gateway.py --- a/pypy/interpreter/test/test_gateway.py +++ b/pypy/interpreter/test/test_gateway.py @@ -906,11 +906,33 @@ assert len(called) == 1 assert isinstance(called[0], argument.Arguments) +def test_pass_trough_arguments_method(self): +space = self.space + +called = [] + +class W_Something(W_Root): +def f(self, space, __args__): +called.append(__args__) +a_w, _ = __args__.unpack() +return space.newtuple([space.wrap('f')]+a_w) + +
[pypy-commit] pypy online-transforms: fix some nonsense with other nonsense
Author: Ronan Lamy Branch: online-transforms Changeset: r74208:e768de5dd66a Date: 2014-10-25 14:57 +0200 http://bitbucket.org/pypy/pypy/changeset/e768de5dd66a/ Log:fix some nonsense with other nonsense diff --git a/rpython/annotator/bookkeeper.py b/rpython/annotator/bookkeeper.py --- a/rpython/annotator/bookkeeper.py +++ b/rpython/annotator/bookkeeper.py @@ -362,6 +362,10 @@ # * a frozen pre-built constant (with _freeze_() == True) # * a bound method of a frozen pre-built constant try: +pyobj = normalize_method(pyobj) +except ValueError: +pass +try: return self.descs[pyobj] except KeyError: if is_user_function(pyobj): diff --git a/rpython/annotator/description.py b/rpython/annotator/description.py --- a/rpython/annotator/description.py +++ b/rpython/annotator/description.py @@ -7,6 +7,7 @@ from rpython.tool.sourcetools import valid_identifier, func_with_new_name from rpython.tool.pairtype import extendabletype from rpython.annotator.model import AnnotatorError +from rpython.tool.descriptor import normalize_method class CallFamily(object): """A family of Desc objects that could be called from common call sites. @@ -516,7 +517,10 @@ # pretend that built-in exceptions have no __init__, # unless explicitly specified in builtin.py from rpython.annotator.builtin import BUILTIN_ANALYZERS -value = getattr(value, 'im_func', value) +try: +value = normalize_method(value) +except ValueError: +pass if value not in BUILTIN_ANALYZERS: return self.classdict[name] = Constant(value) diff --git a/rpython/rtyper/rbuiltin.py b/rpython/rtyper/rbuiltin.py --- a/rpython/rtyper/rbuiltin.py +++ b/rpython/rtyper/rbuiltin.py @@ -7,6 +7,7 @@ from rpython.rtyper import rclass from rpython.rtyper.rmodel import Repr from rpython.tool.pairtype import pairtype +from rpython.tool.descriptor import normalize_method BUILTIN_TYPER = {} @@ -276,13 +277,12 @@ return hop.r_result.newiter(hop) -@typer_for(getattr(object.__init__, 'im_func', object.__init__)) +@typer_for(normalize_method(object.__init__)) def rtype_object__init__(hop): hop.exception_cannot_occur() -@typer_for(getattr(EnvironmentError.__init__, 'im_func', - EnvironmentError.__init__)) +@typer_for(normalize_method(EnvironmentError.__init__)) def rtype_EnvironmentError__init__(hop): hop.exception_cannot_occur() v_self = hop.args_v[0] @@ -306,8 +306,7 @@ except NameError: pass else: -@typer_for( -getattr(WindowsError.__init__, 'im_func', WindowsError.__init__)) +@typer_for(normalize_method(WindowsError.__init__)) def rtype_WindowsError__init__(hop): hop.exception_cannot_occur() if hop.nb_args == 2: diff --git a/rpython/tool/descriptor.py b/rpython/tool/descriptor.py --- a/rpython/tool/descriptor.py +++ b/rpython/tool/descriptor.py @@ -36,8 +36,10 @@ if '__pypy__' in sys.modules: def normalize_method(method): -'''Turn everything that behaves like a method into an InstanceMethod object''' +'''Turn everything that behaves like a method into a regular function or an InstanceMethod object''' if isinstance(method, types.MethodType): +if method.__self__ is None: +return method.im_func return InstanceMethod(method.__func__, method.__self__, method.im_class) else: raise ValueError('Not a method') @@ -48,8 +50,10 @@ method_descriptor = type(str.join) def normalize_method(method): -'''Turn everything that behaves like a method into an InstanceMethod object''' +'''Turn everything that behaves like a method into a regular function or an InstanceMethod object''' if isinstance(method, types.MethodType): +if method.__self__ is None: +return method.__func__ return InstanceMethod(method.__func__, method.__self__, method.im_class) elif isinstance(method, types.BuiltinMethodType): im_self = method.__self__ ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: This change broke some 32-bit tests in jit/backend/x86. Revert it
Author: Armin Rigo Branch: Changeset: r74209:8e7946c8cbe7 Date: 2014-10-25 15:38 +0200 http://bitbucket.org/pypy/pypy/changeset/8e7946c8cbe7/ Log:This change broke some 32-bit tests in jit/backend/x86. Revert it and make the hack more local to pypy/module/bz2. diff --git a/pypy/module/bz2/test/support.py b/pypy/module/bz2/test/support.py --- a/pypy/module/bz2/test/support.py +++ b/pypy/module/bz2/test/support.py @@ -3,6 +3,11 @@ from rpython.rtyper.lltypesystem import ll2ctypes import gc tries = 20 +# remove the GC strings from ll2ctypes +for key, value in ll2ctypes.ALLOCATED.items(): +if value._TYPE._gckind == 'gc': +del ll2ctypes.ALLOCATED[key] +# while tries and ll2ctypes.ALLOCATED: gc.collect() # to make sure we disallocate buffers tries -= 1 diff --git a/rpython/rtyper/lltypesystem/ll2ctypes.py b/rpython/rtyper/lltypesystem/ll2ctypes.py --- a/rpython/rtyper/lltypesystem/ll2ctypes.py +++ b/rpython/rtyper/lltypesystem/ll2ctypes.py @@ -565,8 +565,6 @@ if addr in ALLOCATED: raise Exception("internal ll2ctypes error - " "double conversion from lltype to ctypes?") -if self._TYPE._gckind == 'gc': -return # XXX don't store here immortal structures ALLOCATED[addr] = self ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fix
Author: Armin Rigo Branch: Changeset: r74210:6e0b0996b161 Date: 2014-10-25 15:40 +0200 http://bitbucket.org/pypy/pypy/changeset/6e0b0996b161/ Log:fix diff --git a/pypy/config/test/test_pypyoption.py b/pypy/config/test/test_pypyoption.py --- a/pypy/config/test/test_pypyoption.py +++ b/pypy/config/test/test_pypyoption.py @@ -64,7 +64,7 @@ def check_file_exists(fn): assert configdocdir.join(fn).check() -from pypy.doc.config.confrest import all_optiondescrs +from pypy.doc.config.generate import all_optiondescrs configdocdir = thisdir.dirpath().dirpath().join("doc", "config") for descr in all_optiondescrs: prefix = descr._name ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Windows fix
Author: Armin Rigo Branch: Changeset: r74211:73f11e792f2f Date: 2014-10-25 15:43 +0200 http://bitbucket.org/pypy/pypy/changeset/73f11e792f2f/ Log:Windows fix diff --git a/rpython/translator/c/src/thread_nt.c b/rpython/translator/c/src/thread_nt.c --- a/rpython/translator/c/src/thread_nt.c +++ b/rpython/translator/c/src/thread_nt.c @@ -8,6 +8,7 @@ #include #include #include +#include /* ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fix import
Author: Armin Rigo Branch: Changeset: r74212:8b05a4f20d5b Date: 2014-10-25 15:45 +0200 http://bitbucket.org/pypy/pypy/changeset/8b05a4f20d5b/ Log:fix import diff --git a/rpython/jit/backend/llsupport/test/test_pinned_object_rewrite.py b/rpython/jit/backend/llsupport/test/test_pinned_object_rewrite.py --- a/rpython/jit/backend/llsupport/test/test_pinned_object_rewrite.py +++ b/rpython/jit/backend/llsupport/test/test_pinned_object_rewrite.py @@ -10,7 +10,8 @@ from rpython.jit.metainterp.optimizeopt.util import equaloplists from rpython.jit.codewriter.heaptracker import register_known_gctype from rpython.jit.metainterp.history import JitCellToken, FLOAT -from rpython.rtyper.lltypesystem import lltype, rclass, rffi, lltype, llmemory +from rpython.rtyper.lltypesystem import lltype, rffi, lltype, llmemory +from rpython.rtyper import rclass from rpython.jit.backend.x86.arch import WORD from rpython.rlib import rgc ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy vmprof: (arigo, antocuni): 1) we need to put TABs instead of spaces, else trackgcroots gets confused; 2) use a normal call but use @PLT, instead of movabs+call *%rax; tell asmgcc th
Author: Antonio Cuni Branch: vmprof Changeset: r74213:836ddd6ad747 Date: 2014-10-25 14:20 +0100 http://bitbucket.org/pypy/pypy/changeset/836ddd6ad747/ Log:(arigo, antocuni): 1) we need to put TABs instead of spaces, else trackgcroots gets confused; 2) use a normal call but use @PLT, instead of movabs+call *%rax; tell asmgcc that the frame we push is a GCROOT diff --git a/pypy/module/_vmprof/src/trampoline.s b/pypy/module/_vmprof/src/trampoline.s --- a/pypy/module/_vmprof/src/trampoline.s +++ b/pypy/module/_vmprof/src/trampoline.s @@ -1,15 +1,17 @@ +// NOTE: you need to use TABs, not spaces! + .text -.p2align 4,,-1 + .p2align 4,,-1 .globl pypy_execute_frame_trampoline .type pypy_execute_frame_trampoline, @function pypy_execute_frame_trampoline: .cfi_startproc -pushq %rdi + pushq %rdi .cfi_def_cfa_offset 16 -movabs $pypy_pyframe_execute_frame, %rax - callq *%rax -popq%rdi + call pypy_pyframe_execute_frame@PLT + /* GCROOT 0(%rsp) */ + popq%rdi .cfi_def_cfa_offset 8 -ret + ret .cfi_endproc .size pypy_execute_frame_trampoline, .-pypy_execute_frame_trampoline ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy vmprof: (antocuni, arigo): add Makefile rules to process manually written .asmgcc.s files through trackgcroot; rename trampoline.s into trampoline.asmgcc.s
Author: Antonio Cuni Branch: vmprof Changeset: r74215:585cacafb196 Date: 2014-10-25 15:03 +0100 http://bitbucket.org/pypy/pypy/changeset/585cacafb196/ Log:(antocuni, arigo): add Makefile rules to process manually written .asmgcc.s files through trackgcroot; rename trampoline.s into trampoline.asmgcc.s diff --git a/pypy/module/_vmprof/interp_vmprof.py b/pypy/module/_vmprof/interp_vmprof.py --- a/pypy/module/_vmprof/interp_vmprof.py +++ b/pypy/module/_vmprof/interp_vmprof.py @@ -26,7 +26,7 @@ eci_kwds = dict( include_dirs = [SRC], includes = ['vmprof.h', 'trampoline.h'], -separate_module_files = [SRC.join('trampoline.s')], +separate_module_files = [SRC.join('trampoline.asmgcc.s')], libraries = ['unwind'], post_include_bits=[""" diff --git a/pypy/module/_vmprof/src/trampoline.s b/pypy/module/_vmprof/src/trampoline.asmgcc.s rename from pypy/module/_vmprof/src/trampoline.s rename to pypy/module/_vmprof/src/trampoline.asmgcc.s diff --git a/rpython/translator/c/genc.py b/rpython/translator/c/genc.py --- a/rpython/translator/c/genc.py +++ b/rpython/translator/c/genc.py @@ -458,10 +458,11 @@ mk.definition('PYTHON', get_recent_cpython_executable()) -mk.definition('GCMAPFILES', '$(subst .c,.gcmap,$(SOURCES))') -mk.definition('OBJECTS1', '$(subst .c,.o,$(SOURCES))') +mk.definition('GCMAPFILES', '$(subst .asmgcc.s,.o,$(subst .c,.gcmap,$(SOURCES)))') +mk.definition('OBJECTS1', '$(subst .asmgcc.s,.o,$(subst .c,.o,$(SOURCES)))') mk.definition('OBJECTS', '$(OBJECTS1) gcmaptable.s') + # the rule that transforms %.c into %.o, by compiling it to # %.s, then applying trackgcroot to get %.lbl.s and %.gcmap, and # finally by using the assembler ($(CC) again for now) to get %.o @@ -474,6 +475,14 @@ 'mv $*.gctmp $*.gcmap', 'rm $*.s $*.lbl.s']) +# this is for manually written assembly files which needs to be parsed by asmgcc +mk.rule('%.o %.gcmap', '%.asmgcc.s', [ +'$(PYTHON) $(RPYDIR)/translator/c/gcc/trackgcroot.py ' +'-t $*.asmgcc.s > $*.gctmp', + '$(CC) -o $*.o -c $*.asmgcc.lbl.s', +'mv $*.gctmp $*.gcmap', +'rm $*.asmgcc.lbl.s']) + # the rule to compute gcmaptable.s mk.rule('gcmaptable.s', '$(GCMAPFILES)', [ ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy vmprof: (antocuni, arigo): make _vmprof compatible with the JIT; this includes making sure that we generate the right C functions (by using _dont_inline_)
Author: Antonio Cuni Branch: vmprof Changeset: r74214:ce12494d00f6 Date: 2014-10-25 14:25 +0100 http://bitbucket.org/pypy/pypy/changeset/ce12494d00f6/ Log:(antocuni, arigo): make _vmprof compatible with the JIT; this includes making sure that we generate the right C functions (by using _dont_inline_) diff --git a/pypy/module/_vmprof/interp_vmprof.py b/pypy/module/_vmprof/interp_vmprof.py --- a/pypy/module/_vmprof/interp_vmprof.py +++ b/pypy/module/_vmprof/interp_vmprof.py @@ -3,6 +3,7 @@ from rpython.translator.tool.cbuild import ExternalCompilationInfo from rpython.rtyper.annlowlevel import cast_instance_to_gcref, cast_base_ptr_to_instance from rpython.rlib.objectmodel import we_are_translated, CDefinedIntSymbolic +from rpython.rlib import jit from rpython.tool.pairtype import extendabletype from pypy.interpreter.baseobjspace import W_Root from pypy.interpreter.error import OperationError, oefmt @@ -68,10 +69,18 @@ original_execute_frame = PyFrame.execute_frame.im_func original_execute_frame.c_name = 'pypy_pyframe_execute_frame' +original_execute_frame._dont_inline_ = True class __extend__(PyFrame): def execute_frame(frame, w_inputvalue=None, operr=None): -if we_are_translated() and not FALSE_BUT_NON_CONSTANT: +# go through the asm trampoline ONLY if we are translated but not being JITted. +# +# If we are not translated, we obviously don't want to go through the +# trampoline because there is no C function it can call. +# +# If we are being JITted, we want to skip the trampoline, else the JIT +# cannot see throug it +if we_are_translated() and not jit.we_are_jitted(): # if we are translated, call the trampoline gc_frame = cast_instance_to_gcref(frame) gc_inputvalue = cast_instance_to_gcref(w_inputvalue) @@ -79,9 +88,6 @@ gc_result = pypy_execute_frame_trampoline(gc_frame, gc_inputvalue, gc_operr) return cast_base_ptr_to_instance(W_Root, gc_result) else: -# else, just call the original function. The FALSE_BUT_NON_CONSTANT is -# needed to convince the annotator to always see -# original_execute_frame return original_execute_frame(frame, w_inputvalue, operr) @@ -94,10 +100,13 @@ self._vmprof_registered = 0 + def get_virtual_ip(gc_frame): frame = cast_base_ptr_to_instance(PyFrame, gc_frame) virtual_ip = do_get_virtual_ip(frame) return rffi.cast(rffi.VOIDP, virtual_ip) +get_virtual_ip.c_name = 'pypy_vmprof_get_virtual_ip' +get_virtual_ip._dont_inline_ = True def do_get_virtual_ip(frame): virtual_ip = frame.pycode._vmprof_virtual_ip @@ -124,7 +133,7 @@ frame.pycode._vmprof_registered = _vmprof.counter # return virtual_ip -get_virtual_ip.c_name = 'pypy_vmprof_get_virtual_ip' + class VMProf(object): @@ -138,6 +147,7 @@ self.virtual_ip -= 1 return self.virtual_ip +@jit.dont_look_inside def _annotate_get_virtual_ip(self): if FALSE_BUT_NON_CONSTANT: # make sure it's annotated ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Fix for test_refcounting.py test_llinterp_refcounted_graph_with_del
Author: Armin Rigo Branch: Changeset: r74218:d20973a3d379 Date: 2014-10-25 16:04 +0200 http://bitbucket.org/pypy/pypy/changeset/d20973a3d379/ Log:Fix for test_refcounting.py test_llinterp_refcounted_graph_with_del diff --git a/rpython/rtyper/lltypesystem/rffi.py b/rpython/rtyper/lltypesystem/rffi.py --- a/rpython/rtyper/lltypesystem/rffi.py +++ b/rpython/rtyper/lltypesystem/rffi.py @@ -1147,6 +1147,9 @@ return self.buf def __exit__(self, *args): free_nonmovingbuffer(self.data, self.buf, self.pinned, self.is_raw) +__init__._always_inline_ = True +__enter__._always_inline_ = True +__exit__._always_inline_ = True class scoped_nonmoving_unicodebuffer: def __init__(self, data): @@ -1156,6 +1159,9 @@ return self.buf def __exit__(self, *args): free_nonmoving_unicodebuffer(self.data, self.buf, self.pinned, self.is_raw) +__init__._always_inline_ = True +__enter__._always_inline_ = True +__exit__._always_inline_ = True class scoped_alloc_buffer: def __init__(self, size): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fix import
Author: Armin Rigo Branch: Changeset: r74219:d91ef9f19c89 Date: 2014-10-25 16:08 +0200 http://bitbucket.org/pypy/pypy/changeset/d91ef9f19c89/ Log:fix import diff --git a/pypy/module/pypyjit/test/test_jit_hook.py b/pypy/module/pypyjit/test/test_jit_hook.py --- a/pypy/module/pypyjit/test/test_jit_hook.py +++ b/pypy/module/pypyjit/test/test_jit_hook.py @@ -11,7 +11,7 @@ from rpython.rtyper.lltypesystem import lltype, llmemory from rpython.rtyper.rclass import OBJECT from pypy.module.pypyjit.interp_jit import pypyjitdriver -from pypy.module.pypyjit.policy import pypy_hooks +from pypy.module.pypyjit.hooks import pypy_hooks from rpython.jit.tool.oparser import parse from rpython.jit.metainterp.typesystem import llhelper from rpython.rlib.jit import JitDebugInfo, AsmInfo, Counters ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fix: must be ready for the _pinned_objects list to contain both RPython and LL objects at the same time, for some tests
Author: Armin Rigo Branch: Changeset: r74220:9cd4ddc8935b Date: 2014-10-25 16:19 +0200 http://bitbucket.org/pypy/pypy/changeset/9cd4ddc8935b/ Log:fix: must be ready for the _pinned_objects list to contain both RPython and LL objects at the same time, for some tests diff --git a/rpython/rlib/rgc.py b/rpython/rlib/rgc.py --- a/rpython/rlib/rgc.py +++ b/rpython/rlib/rgc.py @@ -20,8 +20,7 @@ # for test purposes we allow objects to be pinned and use # the following list to keep track of the pinned objects -if not we_are_translated(): -pinned_objects = [] +_pinned_objects = [] def pin(obj): """If 'obj' can move, then attempt to temporarily fix it. This @@ -45,7 +44,7 @@ Note further that pinning an object does not prevent it from being collected if it is not used anymore. """ -pinned_objects.append(obj) +_pinned_objects.append(obj) return True @@ -64,8 +63,13 @@ """Unpin 'obj', allowing it to move again. Must only be called after a call to pin(obj) returned True. """ -pinned_objects.remove(obj) - +for i in range(len(_pinned_objects)): +try: +if _pinned_objects[i] == obj: +del _pinned_objects[i] +except TypeError: +pass + class UnpinEntry(ExtRegistryEntry): _about_ = unpin @@ -79,7 +83,14 @@ def _is_pinned(obj): """Method to check if 'obj' is pinned.""" -return obj in pinned_objects +for i in range(len(_pinned_objects)): +try: +if _pinned_objects[i] == obj: +return True +except TypeError: +pass +return False + class IsPinnedEntry(ExtRegistryEntry): _about_ = _is_pinned ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fix
Author: Armin Rigo Branch: Changeset: r74221:1b9629032983 Date: 2014-10-25 16:23 +0200 http://bitbucket.org/pypy/pypy/changeset/1b9629032983/ Log:fix diff --git a/rpython/rlib/rzlib.py b/rpython/rlib/rzlib.py --- a/rpython/rlib/rzlib.py +++ b/rpython/rlib/rzlib.py @@ -185,16 +185,14 @@ ADLER32_DEFAULT_START = 1 def deflateSetDictionary(stream, string): -bytes = rffi.get_nonmovingbuffer(string) -err = _deflateSetDictionary(stream, rffi.cast(Bytefp, bytes), len(string)) -rffi.free_nonmovingbuffer(string, bytes) +with rffi.scoped_nonmovingbuffer(string) as buf: +err = _deflateSetDictionary(stream, rffi.cast(Bytefp, buf), len(string)) if err == Z_STREAM_ERROR: raise RZlibError("Parameter is invalid or the stream state is inconsistent") def inflateSetDictionary(stream, string): -bytes = rffi.get_nonmovingbuffer(string) -err = _inflateSetDictionary(stream, rffi.cast(Bytefp, bytes), len(string)) -rffi.free_nonmovingbuffer(string, bytes) +with rffi.scoped_nonmovingbuffer(string) as buf: +err = _inflateSetDictionary(stream, rffi.cast(Bytefp, buf), len(string)) if err == Z_STREAM_ERROR: raise RZlibError("Parameter is invalid or the stream state is inconsistent") elif err == Z_DATA_ERROR: ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fix
Author: Armin Rigo Branch: Changeset: r74222:c9e9ae8f448f Date: 2014-10-25 16:24 +0200 http://bitbucket.org/pypy/pypy/changeset/c9e9ae8f448f/ Log:fix diff --git a/rpython/rtyper/lltypesystem/test/test_lltype.py b/rpython/rtyper/lltypesystem/test/test_lltype.py --- a/rpython/rtyper/lltypesystem/test/test_lltype.py +++ b/rpython/rtyper/lltypesystem/test/test_lltype.py @@ -827,10 +827,10 @@ def test_str_from_buffer(self): """gc-managed memory does not need to be freed""" size = 50 -raw_buf, gc_buf = rffi.alloc_buffer(size) +raw_buf, gc_buf, case_num = rffi.alloc_buffer(size) for i in range(size): raw_buf[i] = 'a' -rstr = rffi.str_from_buffer(raw_buf, gc_buf, size, size) -rffi.keep_buffer_alive_until_here(raw_buf, gc_buf) +rstr = rffi.str_from_buffer(raw_buf, gc_buf, case_num, size, size) +rffi.keep_buffer_alive_until_here(raw_buf, gc_buf, case_num) assert not leakfinder.ALLOCATED def test_leak_traceback(self): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fix warnings by the C compiler
Author: Armin Rigo Branch: Changeset: r74223:f1a9e1e2d3c3 Date: 2014-10-25 16:32 +0200 http://bitbucket.org/pypy/pypy/changeset/f1a9e1e2d3c3/ Log:fix warnings by the C compiler diff --git a/rpython/translator/c/src/support.h b/rpython/translator/c/src/support.h --- a/rpython/translator/c/src/support.h +++ b/rpython/translator/c/src/support.h @@ -49,12 +49,12 @@ ((RPyCHECK((index) >= 0 && (index) < (array)->length), \ (array))->items[index]) # define RPyFxItem(ptr, index, fixedsize) \ - ((RPyCHECK((ptr) && (index) >= 0 && (index) < (fixedsize)),\ + ((RPyCHECK((ptr) != NULL && (index) >= 0 && (index) < (fixedsize)),\ (ptr))[index]) # define RPyNLenItem(array, index) \ - ((RPyCHECK((array) && (index) >= 0), (array))->items[index]) + ((RPyCHECK((array) != NULL && (index) >= 0), (array))->items[index]) # define RPyBareItem(array, index) \ - ((RPyCHECK((array) && (index) >= 0), (array))[index]) + ((RPyCHECK((array) != NULL && (index) >= 0), (array))[index]) #else # define RPyField(ptr, name)((ptr)->name) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Oups, this overflows on 32-bit
Author: Armin Rigo Branch: Changeset: r74224:c809adae5034 Date: 2014-10-25 16:41 +0200 http://bitbucket.org/pypy/pypy/changeset/c809adae5034/ Log:Oups, this overflows on 32-bit diff --git a/rpython/translator/c/test/test_newgc.py b/rpython/translator/c/test/test_newgc.py --- a/rpython/translator/c/test/test_newgc.py +++ b/rpython/translator/c/test/test_newgc.py @@ -1514,7 +1514,7 @@ i = 0 j = 0 k = 0 -while i < 300: +while i < 40: k = (k * 1291 + i) % 4603 a = A() if k < 1000: @@ -1546,11 +1546,12 @@ n += ord(a.foo.bar[0]) m += ord(a.foo.bar[1]) return m - n +assert f() == 28495 return f def test_random_pin(self): res = self.run("random_pin") -assert res == 279882 +assert res == 28495 # ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fix
Author: Armin Rigo Branch: Changeset: r74225:ccfbb215e8ed Date: 2014-10-25 16:44 +0200 http://bitbucket.org/pypy/pypy/changeset/ccfbb215e8ed/ Log:fix diff --git a/pypy/module/test_lib_pypy/ctypes_tests/_ctypes_test.c b/pypy/module/test_lib_pypy/ctypes_tests/_ctypes_test.c --- a/pypy/module/test_lib_pypy/ctypes_tests/_ctypes_test.c +++ b/pypy/module/test_lib_pypy/ctypes_tests/_ctypes_test.c @@ -1,13 +1,11 @@ +#include "src/precommondefs.h" + #if defined(_MSC_VER) || defined(__CYGWIN__) #include #define MS_WIN32 #endif -#if defined(MS_WIN32) -#define EXPORT(x) __declspec(dllexport) x -#else -#define EXPORT(x) x -#endif +#define EXPORT(x) RPY_EXPORTED x #include #include diff --git a/pypy/module/test_lib_pypy/ctypes_tests/conftest.py b/pypy/module/test_lib_pypy/ctypes_tests/conftest.py --- a/pypy/module/test_lib_pypy/ctypes_tests/conftest.py +++ b/pypy/module/test_lib_pypy/ctypes_tests/conftest.py @@ -8,6 +8,7 @@ def compile_so_file(): from rpython.translator.platform import platform from rpython.translator.tool.cbuild import ExternalCompilationInfo +from rpython.translator import cdir udir = pytest.ensuretemp('_ctypes_test') cfile = py.path.local(__file__).dirpath().join("_ctypes_test.c") @@ -15,7 +16,8 @@ libraries = ['oleaut32'] else: libraries = [] -eci = ExternalCompilationInfo(libraries=libraries) +eci = ExternalCompilationInfo(libraries=libraries, + include_dirs=[cdir]) return platform.compile([cfile], eci, str(udir.join('_ctypes_test')), standalone=False) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Fix for issue reported with pixie (Timothy): if there is no floats at
Author: Armin Rigo Branch: Changeset: r74226:76cd145da640 Date: 2014-10-25 17:20 +0200 http://bitbucket.org/pypy/pypy/changeset/76cd145da640/ Log:Fix for issue reported with pixie (Timothy): if there is no floats at all, this crashes. Not 100% sure why. diff --git a/rpython/jit/backend/llsupport/descr.py b/rpython/jit/backend/llsupport/descr.py --- a/rpython/jit/backend/llsupport/descr.py +++ b/rpython/jit/backend/llsupport/descr.py @@ -313,17 +313,18 @@ # # CallDescrs +def _missing_call_stub_i(func, args_i, args_r, args_f): +return 0 +def _missing_call_stub_r(func, args_i, args_r, args_f): +return lltype.nullptr(llmemory.GCREF.TO) +def _missing_call_stub_f(func,args_i,args_r,args_f): +return longlong.ZEROF + class CallDescr(AbstractDescr): arg_classes = '' # <-- annotation hack result_type = '\x00' result_flag = '\x00' ffi_flags = 1 -call_stub_i = staticmethod(lambda func, args_i, args_r, args_f: - 0) -call_stub_r = staticmethod(lambda func, args_i, args_r, args_f: - lltype.nullptr(llmemory.GCREF.TO)) -call_stub_f = staticmethod(lambda func,args_i,args_r,args_f: - longlong.ZEROF) def __init__(self, arg_classes, result_type, result_signed, result_size, extrainfo=None, ffi_flags=1): @@ -340,6 +341,9 @@ self.result_size = result_size self.extrainfo = extrainfo self.ffi_flags = ffi_flags +self.call_stub_i = _missing_call_stub_i +self.call_stub_t = _missing_call_stub_r +self.call_stub_f = _missing_call_stub_f # NB. the default ffi_flags is 1, meaning FUNCFLAG_CDECL, which # makes sense on Windows as it's the one for all the C functions # we are compiling together with the JIT. On non-Windows platforms ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: oops
Author: Armin Rigo Branch: Changeset: r74228:41343203ab73 Date: 2014-10-25 17:21 +0200 http://bitbucket.org/pypy/pypy/changeset/41343203ab73/ Log:oops diff --git a/rpython/jit/backend/llsupport/descr.py b/rpython/jit/backend/llsupport/descr.py --- a/rpython/jit/backend/llsupport/descr.py +++ b/rpython/jit/backend/llsupport/descr.py @@ -317,7 +317,7 @@ return 0 def _missing_call_stub_r(func, args_i, args_r, args_f): return lltype.nullptr(llmemory.GCREF.TO) -def _missing_call_stub_f(func,args_i,args_r,args_f): +def _missing_call_stub_f(func, args_i, args_r, args_f): return longlong.ZEROF class CallDescr(AbstractDescr): @@ -342,7 +342,7 @@ self.extrainfo = extrainfo self.ffi_flags = ffi_flags self.call_stub_i = _missing_call_stub_i -self.call_stub_t = _missing_call_stub_r +self.call_stub_r = _missing_call_stub_r self.call_stub_f = _missing_call_stub_f # NB. the default ffi_flags is 1, meaning FUNCFLAG_CDECL, which # makes sense on Windows as it's the one for all the C functions ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy vmprof: bah
Author: Antonio Cuni Branch: vmprof Changeset: r74227:6bf00e5c1588 Date: 2014-10-25 16:21 +0100 http://bitbucket.org/pypy/pypy/changeset/6bf00e5c1588/ Log:bah diff --git a/rpython/translator/c/genc.py b/rpython/translator/c/genc.py --- a/rpython/translator/c/genc.py +++ b/rpython/translator/c/genc.py @@ -458,7 +458,7 @@ mk.definition('PYTHON', get_recent_cpython_executable()) -mk.definition('GCMAPFILES', '$(subst .asmgcc.s,.o,$(subst .c,.gcmap,$(SOURCES)))') +mk.definition('GCMAPFILES', '$(subst .asmgcc.s,.gcmap,$(subst .c,.gcmap,$(SOURCES)))') mk.definition('OBJECTS1', '$(subst .asmgcc.s,.o,$(subst .c,.o,$(SOURCES)))') mk.definition('OBJECTS', '$(OBJECTS1) gcmaptable.s') ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fix?
Author: Armin Rigo Branch: Changeset: r74229:4c9f57a191fc Date: 2014-10-25 17:36 +0200 http://bitbucket.org/pypy/pypy/changeset/4c9f57a191fc/ Log:fix? diff --git a/rpython/rtyper/lltypesystem/rffi.py b/rpython/rtyper/lltypesystem/rffi.py --- a/rpython/rtyper/lltypesystem/rffi.py +++ b/rpython/rtyper/lltypesystem/rffi.py @@ -1147,9 +1147,9 @@ return self.buf def __exit__(self, *args): free_nonmovingbuffer(self.data, self.buf, self.pinned, self.is_raw) -__init__._always_inline_ = True -__enter__._always_inline_ = True -__exit__._always_inline_ = True +__init__._always_inline_ = 'try' +__enter__._always_inline_ = 'try' +__exit__._always_inline_ = 'try' class scoped_nonmoving_unicodebuffer: def __init__(self, data): @@ -1159,9 +1159,9 @@ return self.buf def __exit__(self, *args): free_nonmoving_unicodebuffer(self.data, self.buf, self.pinned, self.is_raw) -__init__._always_inline_ = True -__enter__._always_inline_ = True -__exit__._always_inline_ = True +__init__._always_inline_ = 'try' +__enter__._always_inline_ = 'try' +__exit__._always_inline_ = 'try' class scoped_alloc_buffer: def __init__(self, size): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy vmprof: here are drangons: a libunwind workaround to walk past JIT frames; it still needs a good integration with the JIT, to know which memory regions correspond to JIT code and ho
Author: Antonio Cuni Branch: vmprof Changeset: r74230:15b900c687b8 Date: 2014-10-25 16:48 +0100 http://bitbucket.org/pypy/pypy/changeset/15b900c687b8/ Log:here are drangons: a libunwind workaround to walk past JIT frames; it still needs a good integration with the JIT, to know which memory regions correspond to JIT code and how big is the stack in each (right now we simply assume it's 19 words) diff --git a/pypy/module/_vmprof/src/vmprof.c b/pypy/module/_vmprof/src/vmprof.c --- a/pypy/module/_vmprof/src/vmprof.c +++ b/pypy/module/_vmprof/src/vmprof.c @@ -72,6 +72,62 @@ } +/* ** + * libunwind workaround for process JIT frames correctly + * ** + */ + +static void* jit_start; +static void* jit_end; +void vmprof_set_jit_range(void* start, void* end) { +printf("vmprof JIT range: %p-%p\n", start, end); +jit_start = start; +jit_end = end; +} + +static ptrdiff_t vmprof_unw_get_custom_offset(void* ip) { +/* temporary hack to determine is this particular frame is JITted or not */ +if (ip >= jit_start && ip <= jit_end) { +// it's probably a JIT frame +return 19*8; // XXX +} +return -1; // not JITted code +} + + +typedef struct { +void* _unused1; +void* _unused2; +void* sp; +void* ip; +void* _unused3[sizeof(unw_cursor_t)/sizeof(void*) - 4]; +} vmprof_hacked_unw_cursor_t; + +static int vmprof_unw_step(unw_cursor_t *cp) { + void* ip; +void* sp; +ptrdiff_t sp_offset; +unw_get_reg (cp, UNW_REG_IP, (unw_word_t*)&ip); +unw_get_reg (cp, UNW_REG_SP, (unw_word_t*)&sp); +sp_offset = vmprof_unw_get_custom_offset(ip); +if (sp_offset == -1) { +// it means that the ip is NOT in JITted code, so we can use the +// stardard unw_step +return unw_step(cp); +} +else { +// this is a horrible hack to manually walk the stack frame, by +// setting the IP and SP in the cursor +vmprof_hacked_unw_cursor_t *cp2 = (vmprof_hacked_unw_cursor_t*)cp; +void* bp = (void*)sp + sp_offset; +cp2->sp = bp+8; // the ret will pop a word, so the SP of the caller is +// 8 bytes away from us +cp2->ip = ((void**)bp)[0]; // the ret is on the top of the stack +return 1; +} +} + + /* * * functions to dump the stack trace * * @@ -131,7 +187,7 @@ } result[n++] = ip; -if (unw_step(&cursor) <= 0) { +if (vmprof_unw_step(&cursor) <= 0) { break; } } ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy online-transforms: revert normalize_method() change: it needs to always return an InstanceMethod
Author: Ronan Lamy Branch: online-transforms Changeset: r74231:0382934f651e Date: 2014-10-25 18:01 +0200 http://bitbucket.org/pypy/pypy/changeset/0382934f651e/ Log:revert normalize_method() change: it needs to always return an InstanceMethod diff --git a/rpython/tool/descriptor.py b/rpython/tool/descriptor.py --- a/rpython/tool/descriptor.py +++ b/rpython/tool/descriptor.py @@ -36,10 +36,8 @@ if '__pypy__' in sys.modules: def normalize_method(method): -'''Turn everything that behaves like a method into a regular function or an InstanceMethod object''' +'''Turn everything that behaves like a method into an InstanceMethod object''' if isinstance(method, types.MethodType): -if method.__self__ is None: -return method.im_func return InstanceMethod(method.__func__, method.__self__, method.im_class) else: raise ValueError('Not a method') @@ -50,10 +48,8 @@ method_descriptor = type(str.join) def normalize_method(method): -'''Turn everything that behaves like a method into a regular function or an InstanceMethod object''' +'''Turn everything that behaves like a method into an InstanceMethod object''' if isinstance(method, types.MethodType): -if method.__self__ is None: -return method.__func__ return InstanceMethod(method.__func__, method.__self__, method.im_class) elif isinstance(method, types.BuiltinMethodType): im_self = method.__self__ ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy online-transforms: Normalize methods and avoid using weakrefs in extregistry
Author: Ronan Lamy Branch: online-transforms Changeset: r74232:7530733a07f0 Date: 2014-10-25 18:04 +0200 http://bitbucket.org/pypy/pypy/changeset/7530733a07f0/ Log:Normalize methods and avoid using weakrefs in extregistry diff --git a/rpython/rtyper/extregistry.py b/rpython/rtyper/extregistry.py --- a/rpython/rtyper/extregistry.py +++ b/rpython/rtyper/extregistry.py @@ -1,6 +1,7 @@ import weakref import UserDict from rpython.tool.uid import Hashable +from rpython.tool.descriptor import normalize_method class AutoRegisteringType(type): @@ -21,6 +22,10 @@ else: if key in dict: raise ValueError("duplicate extregistry entry %r" % (selfcls,)) +try: +key = normalize_method(key) +except ValueError: +pass dict[key] = selfcls def _register_value(selfcls, key): @@ -73,13 +78,10 @@ # -class FlexibleWeakDict(UserDict.DictMixin): -"""A WeakKeyDictionary that accepts more or less anything as keys: -weakly referenceable objects or not, hashable objects or not. -""" +class FlexibleDict(UserDict.DictMixin): +"""A dictionary that accepts unhashable objects as keys""" def __init__(self): self._regdict = {} -self._weakdict = weakref.WeakKeyDictionary() self._iddict = {} def ref(self, key): @@ -87,12 +89,7 @@ hash(key) except TypeError: return self._iddict, Hashable(key) # key is not hashable -try: -weakref.ref(key) -except TypeError: -return self._regdict, key# key cannot be weakly ref'ed -else: -return self._weakdict, key # normal case +return self._regdict, key def __getitem__(self, key): d, key = self.ref(key) @@ -108,11 +105,10 @@ def keys(self): return (self._regdict.keys() + -self._weakdict.keys() + [hashable.value for hashable in self._iddict]) -EXT_REGISTRY_BY_VALUE = FlexibleWeakDict() +EXT_REGISTRY_BY_VALUE = FlexibleDict() EXT_REGISTRY_BY_TYPE = weakref.WeakKeyDictionary() # @@ -135,6 +131,10 @@ return _lookup_type_cls(type(instance)) def lookup(instance): +try: +instance = normalize_method(instance) +except ValueError: +pass Entry = _lookup_cls(instance) return Entry(type(instance), instance) diff --git a/rpython/rtyper/test/test_extregistry.py b/rpython/rtyper/test/test_extregistry.py --- a/rpython/rtyper/test/test_extregistry.py +++ b/rpython/rtyper/test/test_extregistry.py @@ -134,3 +134,17 @@ _about_ = n1 assert isinstance(extregistry.lookup(n1), Entry) assert isinstance(extregistry.lookup(n2), Entry) + +def test_register_method_of_frozen(): +class Frozen(object): +def _freeze_(self): +return True +def foo(self): +pass + +f = Frozen() + +class Entry(ExtRegistryEntry): +_about_ = f.foo + +assert isinstance(extregistry.lookup(f.foo), Entry) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: rearrange a bit to fix compilation
Author: Philip Jenvey Branch: py3k Changeset: r74233:8f1cad01a693 Date: 2014-10-25 09:30 -0700 http://bitbucket.org/pypy/pypy/changeset/8f1cad01a693/ Log:rearrange a bit to fix compilation diff --git a/pypy/module/_codecs/locale.c b/pypy/module/_codecs/locale.c --- a/pypy/module/_codecs/locale.c +++ b/pypy/module/_codecs/locale.c @@ -1,6 +1,7 @@ /* From CPython 3.2.3's fileutils.c, and _Py_normalize_encoding from unicodeobject.c */ +#include "src/precommondefs.h" /* #include "Python.h" */ @@ -225,7 +226,7 @@ Conversion errors should never happen, unless there is a bug in the C library. */ -wchar_t* +RPY_EXPORTED_FOR_TESTS wchar_t* pypy_char2wchar(const char* arg, size_t *size) { #if 0 && defined(__APPLE__) @@ -367,7 +368,7 @@ If error_pos is not NULL: *error_pos is the index of the invalid character on conversion error, or (size_t)-1 otherwise. */ -char* +RPY_EXPORTED_FOR_TESTS char* pypy_wchar2char(const wchar_t *text, size_t *error_pos) { #if 0 && defined(__APPLE__) @@ -474,13 +475,13 @@ #endif /* __APPLE__ */ } -void +RPY_EXPORTED_FOR_TESTS void pypy_char2wchar_free(wchar_t *text) { PyMem_Free(text); } -void +RPY_EXPORTED_FOR_TESTS void pypy_wchar2char_free(char *bytes) { PyMem_Free(bytes); diff --git a/pypy/module/_codecs/locale.h b/pypy/module/_codecs/locale.h deleted file mode 100644 --- a/pypy/module/_codecs/locale.h +++ /dev/null @@ -1,8 +0,0 @@ -#include -#include -#include "src/precommondefs.h" - -RPY_EXPORTED_FOR_TESTS wchar_t* pypy_char2wchar(const char* arg, size_t *size); -RPY_EXPORTED_FOR_TESTS void pypy_char2wchar_free(wchar_t *text); -RPY_EXPORTED_FOR_TESTS char* pypy_wchar2char(const wchar_t *text, size_t *error_pos); -RPY_EXPORTED_FOR_TESTS void pypy_wchar2char_free(char *bytes); diff --git a/pypy/module/_codecs/locale.py b/pypy/module/_codecs/locale.py --- a/pypy/module/_codecs/locale.py +++ b/pypy/module/_codecs/locale.py @@ -15,8 +15,7 @@ cwd = py.path.local(__file__).dirpath() eci = ExternalCompilationInfo( -includes=[cwd.join('locale.h')], -include_dirs=[str(cwd), cdir], +include_dirs=[cdir], separate_module_files=[cwd.join('locale.c')]) def llexternal(*args, **kwargs): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy online-transforms: (arigo, ronan) handle constant unbound methods of frozen as a regular function
Author: Ronan Lamy Branch: online-transforms Changeset: r74234:785c06bae563 Date: 2014-10-25 18:36 +0200 http://bitbucket.org/pypy/pypy/changeset/785c06bae563/ Log:(arigo, ronan) handle constant unbound methods of frozen as a regular function diff --git a/rpython/annotator/bookkeeper.py b/rpython/annotator/bookkeeper.py --- a/rpython/annotator/bookkeeper.py +++ b/rpython/annotator/bookkeeper.py @@ -327,6 +327,8 @@ result = s_self.find_method(x.im_func.__name__) else: # unbound method +if hasattr(x.im_class, '_freeze_'): +return self.immutablevalue(x.im_func) cls_s = self.annotationclass(x.im_class) result = cls_s.find_unboundmethod(x.im_func.__name__) else: ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: kill invalid comment
Author: Philip Jenvey Branch: py3k Changeset: r74235:eaad3d70e184 Date: 2014-10-25 09:46 -0700 http://bitbucket.org/pypy/pypy/changeset/eaad3d70e184/ Log:kill invalid comment diff --git a/pypy/objspace/std/floatobject.py b/pypy/objspace/std/floatobject.py --- a/pypy/objspace/std/floatobject.py +++ b/pypy/objspace/std/floatobject.py @@ -391,8 +391,6 @@ if space.isinstance_w(w_obj, space.w_int): return W_FloatObject(space.float_w(w_obj)) -#@staticmethod -# XXX: unwrap_spec index? def descr___round__(self, space, w_ndigits=None): return _round_float(space, self, w_ndigits) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Attempt to fix package.py for buildbot, by looking for 'libpypy-c.so'
Author: Armin Rigo Branch: Changeset: r74236:04b426f357a1 Date: 2014-10-25 18:50 +0200 http://bitbucket.org/pypy/pypy/changeset/04b426f357a1/ Log:Attempt to fix package.py for buildbot, by looking for 'libpypy-c.so' from the same directory as where we found 'pypy-c'. diff --git a/pypy/tool/release/package.py b/pypy/tool/release/package.py --- a/pypy/tool/release/package.py +++ b/pypy/tool/release/package.py @@ -160,9 +160,9 @@ if sys.platform == 'win32' and not rename_pypy_c.lower().endswith('.exe'): rename_pypy_c += '.exe' binaries = [(pypy_c, rename_pypy_c)] -libpypy_c = basedir.join('pypy', 'goal', 'libpypy-c.so') +libpypy_c = pypy_c.new(basename='libpypy-c.so') if libpypy_c.check(): -binaries.append(('libpypy-c.so', 'libpypy-c.so')) +binaries.append((libpypy_c, 'libpypy-c.so')) # builddir = options.builddir pypydir = builddir.ensure(name, dir=True) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Test and fix on Windows: if we pass a timeout larger than 49 days, we
Author: Armin Rigo Branch: Changeset: r74237:66b144c1d6f7 Date: 2014-10-25 19:24 +0200 http://bitbucket.org/pypy/pypy/changeset/66b144c1d6f7/ Log:Test and fix on Windows: if we pass a timeout larger than 49 days, we used to get an abort in thread_nt.c. diff --git a/rpython/rlib/test/test_rthread.py b/rpython/rlib/test/test_rthread.py --- a/rpython/rlib/test/test_rthread.py +++ b/rpython/rlib/test/test_rthread.py @@ -1,5 +1,6 @@ import gc, time from rpython.rlib.rthread import * +from rpython.rlib.rarithmetic import r_longlong from rpython.translator.c.test.test_boehm import AbstractGCTestClass from rpython.rtyper.lltypesystem import lltype, rffi import py @@ -188,6 +189,15 @@ res = fn() assert res < -1.0 +def test_acquire_timed_huge_timeout(self): +t = r_longlong(2 ** 61) +def f(): +l = allocate_lock() +return l.acquire_timed(t) +fn = self.getcompiled(f, []) +res = fn() +assert res == 1 # RPY_LOCK_ACQUIRED + def test_acquire_timed_alarm(self): import sys if not sys.platform.startswith('linux'): diff --git a/rpython/translator/c/src/thread_nt.c b/rpython/translator/c/src/thread_nt.c --- a/rpython/translator/c/src/thread_nt.c +++ b/rpython/translator/c/src/thread_nt.c @@ -103,12 +103,14 @@ // +static BOOL InitializeNonRecursiveMutex(PNRMUTEX mutex) { mutex->sem = CreateSemaphore(NULL, 1, 1, NULL); return !!mutex->sem; } +static VOID DeleteNonRecursiveMutex(PNRMUTEX mutex) { /* No in-use check */ @@ -116,11 +118,24 @@ mutex->sem = NULL ; /* Just in case */ } -DWORD EnterNonRecursiveMutex(PNRMUTEX mutex, DWORD milliseconds) +static +DWORD EnterNonRecursiveMutex(PNRMUTEX mutex, RPY_TIMEOUT_T milliseconds) { -return WaitForSingleObject(mutex->sem, milliseconds); +DWORD res; + +if (milliseconds < 0) +return WaitForSingleObject(mutex->sem, INFINITE); + +while (milliseconds >= (RPY_TIMEOUT_T)INFINITE) { +res = WaitForSingleObject(mutex->sem, INFINITE - 1); +if (res != WAIT_TIMEOUT) +return res; +milliseconds -= (RPY_TIMEOUT_T)(INFINITE - 1); +} +return WaitForSingleObject(mutex->sem, (DWORD)milliseconds); } +static BOOL LeaveNonRecursiveMutex(PNRMUTEX mutex) { return ReleaseSemaphore(mutex->sem, 1, NULL); @@ -162,17 +177,9 @@ milliseconds = microseconds / 1000; if (microseconds % 1000 > 0) ++milliseconds; -if ((DWORD) milliseconds != milliseconds) { -fprintf(stderr, "Timeout too large for a DWORD, " -"please check RPY_TIMEOUT_MAX"); -abort(); -} } -else -milliseconds = INFINITE; -if (lock && EnterNonRecursiveMutex( - lock, (DWORD)milliseconds) == WAIT_OBJECT_0) { +if (lock && EnterNonRecursiveMutex(lock, milliseconds) == WAIT_OBJECT_0) { success = RPY_LOCK_ACQUIRED; } else { ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: kill this header file
Author: Philip Jenvey Branch: Changeset: r74238:673f24170065 Date: 2014-10-25 11:18 -0700 http://bitbucket.org/pypy/pypy/changeset/673f24170065/ Log:kill this header file diff --git a/pypy/module/operator/tscmp.c b/pypy/module/operator/tscmp.c --- a/pypy/module/operator/tscmp.c +++ b/pypy/module/operator/tscmp.c @@ -1,10 +1,9 @@ /* Derived from CPython 3.3.5's operator.c::_tscmp */ -#include "src/precommondefs.h" #include #include -#include "tscmp.h" +#include "src/precommondefs.h" RPY_EXPORTED_FOR_TESTS int pypy_tscmp(const char *a, const char *b, long len_a, long len_b) diff --git a/pypy/module/operator/tscmp.h b/pypy/module/operator/tscmp.h deleted file mode 100644 --- a/pypy/module/operator/tscmp.h +++ /dev/null @@ -1,2 +0,0 @@ -int pypy_tscmp(const char *, const char *, long, long); -int pypy_tscmp_wide(const wchar_t *, const wchar_t *, long, long); diff --git a/pypy/module/operator/tscmp.py b/pypy/module/operator/tscmp.py --- a/pypy/module/operator/tscmp.py +++ b/pypy/module/operator/tscmp.py @@ -12,8 +12,7 @@ cwd = py.path.local(__file__).dirpath() eci = ExternalCompilationInfo( -includes=[cwd.join('tscmp.h')], -include_dirs=[str(cwd), cdir], +include_dirs=[cdir], separate_module_files=[cwd.join('tscmp.c')]) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: merge default
Author: Philip Jenvey Branch: py3k Changeset: r74239:8d5158ea78d5 Date: 2014-10-25 12:31 -0700 http://bitbucket.org/pypy/pypy/changeset/8d5158ea78d5/ Log:merge default diff --git a/pypy/config/test/test_pypyoption.py b/pypy/config/test/test_pypyoption.py --- a/pypy/config/test/test_pypyoption.py +++ b/pypy/config/test/test_pypyoption.py @@ -64,7 +64,7 @@ def check_file_exists(fn): assert configdocdir.join(fn).check() -from pypy.doc.config.confrest import all_optiondescrs +from pypy.doc.config.generate import all_optiondescrs configdocdir = thisdir.dirpath().dirpath().join("doc", "config") for descr in all_optiondescrs: prefix = descr._name diff --git a/pypy/doc/build.rst b/pypy/doc/build.rst --- a/pypy/doc/build.rst +++ b/pypy/doc/build.rst @@ -119,6 +119,9 @@ pypy rpython/bin/rpython --opt=2 pypy/goal/targetpypystandalone.py +(You can use ``python`` instead of ``pypy`` here, which will take longer +but works too.) + If everything works correctly this will create an executable ``pypy-c`` in the current directory. The executable behaves mostly like a normal Python interpreter (see :doc:`cpython_differences`). diff --git a/pypy/module/bz2/test/support.py b/pypy/module/bz2/test/support.py --- a/pypy/module/bz2/test/support.py +++ b/pypy/module/bz2/test/support.py @@ -3,6 +3,11 @@ from rpython.rtyper.lltypesystem import ll2ctypes import gc tries = 20 +# remove the GC strings from ll2ctypes +for key, value in ll2ctypes.ALLOCATED.items(): +if value._TYPE._gckind == 'gc': +del ll2ctypes.ALLOCATED[key] +# while tries and ll2ctypes.ALLOCATED: gc.collect() # to make sure we disallocate buffers tries -= 1 diff --git a/pypy/module/operator/tscmp.c b/pypy/module/operator/tscmp.c --- a/pypy/module/operator/tscmp.c +++ b/pypy/module/operator/tscmp.c @@ -1,9 +1,9 @@ /* Derived from CPython 3.3.5's operator.c::_tscmp */ +#include +#include #include "src/precommondefs.h" -#include -#include "tscmp.h" RPY_EXPORTED_FOR_TESTS int pypy_tscmp(const char *a, const char *b, long len_a, long len_b) diff --git a/pypy/module/operator/tscmp.h b/pypy/module/operator/tscmp.h deleted file mode 100644 --- a/pypy/module/operator/tscmp.h +++ /dev/null @@ -1,1 +0,0 @@ -int pypy_tscmp(const char *, const char *, long, long); diff --git a/pypy/module/operator/tscmp.py b/pypy/module/operator/tscmp.py --- a/pypy/module/operator/tscmp.py +++ b/pypy/module/operator/tscmp.py @@ -13,8 +13,7 @@ cwd = py.path.local(__file__).dirpath() eci = ExternalCompilationInfo( -includes=[cwd.join('tscmp.h')], -include_dirs=[str(cwd), cdir], +include_dirs=[cdir], separate_module_files=[cwd.join('tscmp.c')]) diff --git a/pypy/module/pypyjit/test/test_jit_hook.py b/pypy/module/pypyjit/test/test_jit_hook.py --- a/pypy/module/pypyjit/test/test_jit_hook.py +++ b/pypy/module/pypyjit/test/test_jit_hook.py @@ -11,7 +11,7 @@ from rpython.rtyper.lltypesystem import lltype, llmemory from rpython.rtyper.rclass import OBJECT from pypy.module.pypyjit.interp_jit import pypyjitdriver -from pypy.module.pypyjit.policy import pypy_hooks +from pypy.module.pypyjit.hooks import pypy_hooks from rpython.jit.tool.oparser import parse from rpython.jit.metainterp.typesystem import llhelper from rpython.rlib.jit import JitDebugInfo, AsmInfo, Counters diff --git a/pypy/module/test_lib_pypy/ctypes_tests/_ctypes_test.c b/pypy/module/test_lib_pypy/ctypes_tests/_ctypes_test.c --- a/pypy/module/test_lib_pypy/ctypes_tests/_ctypes_test.c +++ b/pypy/module/test_lib_pypy/ctypes_tests/_ctypes_test.c @@ -1,13 +1,11 @@ +#include "src/precommondefs.h" + #if defined(_MSC_VER) || defined(__CYGWIN__) #include #define MS_WIN32 #endif -#if defined(MS_WIN32) -#define EXPORT(x) __declspec(dllexport) x -#else -#define EXPORT(x) x -#endif +#define EXPORT(x) RPY_EXPORTED x #include #include diff --git a/pypy/module/test_lib_pypy/ctypes_tests/conftest.py b/pypy/module/test_lib_pypy/ctypes_tests/conftest.py --- a/pypy/module/test_lib_pypy/ctypes_tests/conftest.py +++ b/pypy/module/test_lib_pypy/ctypes_tests/conftest.py @@ -8,6 +8,7 @@ def compile_so_file(): from rpython.translator.platform import platform from rpython.translator.tool.cbuild import ExternalCompilationInfo +from rpython.translator import cdir udir = pytest.ensuretemp('_ctypes_test') cfile = py.path.local(__file__).dirpath().join("_ctypes_test.c") @@ -15,7 +16,8 @@ libraries = ['oleaut32'] else: libraries = [] -eci = ExternalCompilationInfo(libraries=libraries) +eci = ExternalCompilationInfo(libraries=libraries, + include_dirs=[cdir]) return platform.compile([cfile], eci, str(udir.join('_ctypes_test')), standalone=False) diff --git a/pypy/tool/release/package.py b/pypy/tool/release/package.py --