subversion-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Fuhrmann <stef...@apache.org>
Subject Re: svn commit: r1743591 - /subversion/trunk/build/run_tests.py
Date Thu, 19 May 2016 14:42:18 GMT
On 13.05.2016 05:03, Branko ─îibej wrote:
> On 13.05.2016 04:19,stefan2@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.
As it turns out, using codecs.open() would only work in Python 3.
In Python 2, imp.load_module() requires a plain file parameter
and anything wrapped etc. would not work.

-- Stefan^2.


Mime
View raw message