Author: Armin Rigo <ar...@tunes.org> Branch: stmgc-c8 Changeset: r77747:b0f74e631c15 Date: 2015-06-01 16:12 +0100 http://bitbucket.org/pypy/pypy/changeset/b0f74e631c15/
Log: hg merge stmgc-c7 diff --git a/lib_pypy/pypy_test/test_transaction.py b/lib_pypy/pypy_test/test_transaction.py --- a/lib_pypy/pypy_test/test_transaction.py +++ b/lib_pypy/pypy_test/test_transaction.py @@ -47,6 +47,19 @@ print lsts assert lsts == (range(10),) * 5, lsts +def test_add_generator(): + lst = [] + def do_stuff(n): + for i in range(n): + lst.append(i) + yield + tq = transaction.TransactionQueue() + tq.add_generator(do_stuff(10)) + tq.run() + if VERBOSE: + print lst + assert lst == range(10), lst + def test_raise(): class FooError(Exception): pass diff --git a/lib_pypy/transaction.py b/lib_pypy/transaction.py --- a/lib_pypy/transaction.py +++ b/lib_pypy/transaction.py @@ -128,6 +128,19 @@ # thread-local list. self._pending.append((f, args, kwds)) + def add_generator(self, generator_iterator): + """Register N new transactions to be done by a generator-iterator + object. Each 'yield' marks the limit of transactions. + """ + def transact_until_yield(): + # Ask for the next item in this transaction. If we get it, + # then the 'for' loop below adds this function again and + # returns. + for ignored_yielded_value in generator_iterator: + self.add(transact_until_yield) + return + self.add(transact_until_yield) + def run(self, nb_segments=0): """Run all transactions, and all transactions started by these ones, recursively, until the queue is empty. If one transaction 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 @@ -65,6 +65,9 @@ add --without-{0} option to skip packaging binary CFFI extension.""".format(module) raise MissingDependenciesError(module) +def pypy_runs(pypy_c): + return subprocess.call([str(pypy_c), '-c', 'pass']) == 0 + def create_package(basedir, options): retval = 0 name = options.name @@ -87,6 +90,8 @@ ' Please compile pypy first, using translate.py,' ' or check that you gave the correct path' ' with --override_pypy_c' % pypy_c) + if not pypy_runs(pypy_c): + raise OSError("Running %r failed!" % (str(pypy_c),)) if not options.no_cffi: try: create_cffi_import_libraries(pypy_c, options) @@ -100,8 +105,22 @@ libpypy_name = 'libpypy-c.so' if not sys.platform.startswith('darwin') else 'libpypy-c.dylib' libpypy_c = pypy_c.new(basename=libpypy_name) if libpypy_c.check(): + # check that this libpypy_c is really needed + os.rename(str(libpypy_c), str(libpypy_c) + '~') + try: + if pypy_runs(pypy_c): + raise Exception("It seems that %r runs without needing %r. " + "Please check and remove the latter" % + (str(pypy_c), str(libpypy_c))) + finally: + os.rename(str(libpypy_c) + '~', str(libpypy_c)) binaries.append((libpypy_c, libpypy_name)) # + # PyPy-STM only + p = basedir.join('pypy', 'stm', 'print_stm_log.py') + assert p.check(), "this version should be run in the stm branch" + binaries.append((p, p.basename)) + # builddir = options.builddir pypydir = builddir.ensure(name, dir=True) includedir = basedir.join('include') _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit