[Python-checkins] cpython (3.2): Fix broken test and replace redundant generator with a tuple

Trent Nelson trent at snakebite.org
Fri Oct 19 16:55:47 CEST 2012


I think this broke all the buildbots :-)

======================================================================
ERROR: test_rewrite_pyc_with_read_only_source (test.test_import.ImportTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/home/buildbot/python-clang/3.2.koobs-freebsd-clang/build/Lib/test/test_import.py", line 163, in test_rewrite_pyc_with_read_only_source
    m3 = __import__(TESTFN)
ImportError: No module named @test_66613_tmp

----------------------------------------------------------------------

> -----Original Message-----
> From: Python-checkins [mailto:python-checkins-
> bounces+trent=snakebite.org at python.org] On Behalf Of nick.coghlan
> Sent: Friday, October 19, 2012 10:05 AM
> To: python-checkins at python.org
> Subject: [Python-checkins] cpython (3.2): Fix broken test and replace redundant
> generator with a tuple
> 
> http://hg.python.org/cpython/rev/d459a9576d6c
> changeset:   79840:d459a9576d6c
> branch:      3.2
> parent:      79836:8cf7f6fe4282
> user:        Nick Coghlan <ncoghlan at gmail.com>
> date:        Sat Oct 20 00:03:46 2012 +1000
> summary:
>   Fix broken test and replace redundant generator with a tuple
> 
> files:
>   Lib/test/test_import.py |  22 +++++++++++++---------
>   1 files changed, 13 insertions(+), 9 deletions(-)
> 
> 
> diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py
> --- a/Lib/test/test_import.py
> +++ b/Lib/test/test_import.py
> @@ -20,16 +20,15 @@
>  from test import script_helper
> 
> 
> -def _iter_files(name):
> -    for f in (name + os.extsep + "py",
> -              name + os.extsep + "pyc",
> -              name + os.extsep + "pyo",
> -              name + os.extsep + "pyw",
> -              name + "$py.class"):
> -        yield f
> +def _files(name):
> +    return (name + os.extsep + "py",
> +            name + os.extsep + "pyc",
> +            name + os.extsep + "pyo",
> +            name + os.extsep + "pyw",
> +            name + "$py.class")
> 
>  def chmod_files(name):
> -    for f in _iter_files(name):
> +    for f in _files(name):
>          try:
>              os.chmod(f, 0o600)
>          except OSError as exc:
> @@ -37,7 +36,7 @@
>                  raise
> 
>  def remove_files(name):
> -    for f in _iter_files(name):
> +    for f in _files(name):
>          unlink(f)
>      rmtree('__pycache__')
> 
> @@ -160,6 +159,11 @@
>              # Now delete the source file and check the pyc was rewritten
>              unlink(fname)
>              unload(TESTFN)
> +            if __debug__:
> +                bytecode_name = fname + "c"
> +            else:
> +                bytecode_name = fname + "o"
> +            os.rename(imp.cache_from_source(fname), bytecode_name)
>              m3 = __import__(TESTFN)
>              self.assertEqual(m3.x, 'rewritten')
>          finally:
> 
> --
> Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list