On 13.05.2016 04:19, stef...@apache.org wrote:
> Author: stefan2
> Date: Fri May 13 02:19:12 2016
> New Revision: 1743591
>
> URL: http://svn.apache.org/viewvc?rev=1743591&view=rev
> Log:
> Make our test runner locale independent in Python 3.
>
> Running our test suite with autodavcheck will change the environment
> such that text files default to ascii - causing some test scripts to
> fail upon loading.
>
> * build/run_tests.py
>   (TestHarness._run_py_test): Explicitly load our tests as UTF-8 when
>                               supported. We can't load as binary here
>                               because Windows tests would fail miserably.
>
> Modified:
>     subversion/trunk/build/run_tests.py
>
> Modified: subversion/trunk/build/run_tests.py
> URL: 
> http://svn.apache.org/viewvc/subversion/trunk/build/run_tests.py?rev=1743591&r1=1743590&r2=1743591&view=diff
> ==============================================================================
> --- subversion/trunk/build/run_tests.py (original)
> +++ subversion/trunk/build/run_tests.py Fri May 13 02:19:12 2016
> @@ -809,8 +809,13 @@ class TestHarness:
>    def _run_py_test(self, progabs, progdir, progbase, test_nums, dot_count):
>      'Run a python test, passing parameters as needed.'
>      try:
> -      prog_mod = imp.load_module(progbase[:-3], open(progabs, 'r'), progabs,
> -                                 ('.py', 'U', imp.PY_SOURCE))
> +      if sys.version_info < (3, 0):
> +        prog_mod = imp.load_module(progbase[:-3], open(progabs, 'r'), 
> progabs,
> +                                   ('.py', 'U', imp.PY_SOURCE))
> +      else:
> +        prog_mod = imp.load_module(progbase[:-3],
> +                                   open(progabs, 'r', encoding="utf-8"),
> +                                   progabs, ('.py', 'U', imp.PY_SOURCE))
>      except:
>        print("\nError loading test (details in following traceback): " + 
> progbase)
>        traceback.print_exc()

See, that's what I was talking about in the other post: if you'd just
used codecs.open() instead of open(), you wouldn't need the conditional
statement.

-- Brane

Reply via email to