[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

One more issue in tests on Windows with Python 3

From: Yasuhito FUTATSUKI <futatuki_at_poem.co.jp>
Date: Thu, 7 May 2020 20:46:47 +0900

While I'm browsing faillog on svn-windows-ra buildbot, I found
another failure not to be reported here, on Windows with Python 3

From https://ci.apache.org/builders/svn-windows-ra/builds/2935/steps/Test%20fsfs%2Bserf/logs/faillog:
[[[
W: CWD: E:\svn-ra\tests\subversion\tests\cmdline
Traceback (most recent call last):
  File "D:\ra\svn-ra\build\subversion\tests\cmdline\svntest\main.py", line 1931, in run
    rc = self.pred.run(sandbox)
  File "D:\ra\svn-ra\build\subversion\tests\cmdline\svntest\testcase.py", line 258, in run
    return self._delegate.run(sandbox)
  File "D:\ra\svn-ra\build\subversion\tests\cmdline\svntest\testcase.py", line 178, in run
    result = self.func(sandbox)
  File "D:\ra\svn-ra\build\subversion\tests\cmdline\update_tests.py", line 6393, in windows_update_backslash
    svntest.actions.run_and_verify_status(wc_dir, expected_status)
  File "D:\ra\svn-ra\build\subversion\tests\cmdline\svntest\actions.py", line 1605, in run_and_verify_status
    actual_entries = wc.State.from_entries(wc_dir_name)
  File "D:\ra\svn-ra\build\subversion\tests\cmdline\svntest\wc.py", line 735, in from_entries
    dump_data = svntest.main.run_entriesdump_tree(base)
  File "D:\ra\svn-ra\build\subversion\tests\cmdline\svntest\main.py", line 933, in run_entriesdump_tree
    exec(''.join(filter_dbg(stdout_lines)))
  File "<string>", line 201
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 10-11: truncated \uXXXX escape
FAIL: update_tests.py 76: test filename with backslashes inside
]]]

It seems this is caused by evaluation of "e.name = 'completely\unusable\dir'"
line generated by subversion/tests/cmdline/entries-dump. This is acceptable
by Python 2.7, but not acceptable by Python 3.7.

e.g.
[[[
$ python2.7 -c "print(repr('completely\unusable\dir'))"
'completely\\unusable\\dir'
$ python3.7 -c "print(repr('completely\unusable\dir'))"
  File "<string>", line 1
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 10-11: truncated \uXXXX escape
]]]

I think it is need to escape characters in char *value when we print
them as Python's str value. The patch below may work for this purpose,
but I want someone to write more nice code :)
[[[
Index: subversion/tests/cmdline/entries-dump.c
===================================================================
--- subversion/tests/cmdline/entries-dump.c (revision 1877407)
+++ subversion/tests/cmdline/entries-dump.c (working copy)
@@ -46,7 +46,15 @@
   if (value == NULL)
     printf("e.%s = None\n", name);
   else
- printf("e.%s = '%s'\n", name, value);
+ {
+ printf("e.%s = (lambda x: x if isinstance(x, str) else "
+ "x.decode('utf-8', 'surrogateescape'))(b'", name);
+ while(*value)
+ {
+ printf("\\x%02x", (int)*value++);
+ }
+ printf("')\n");
+ }
 }

]]]

Cheers,

-- 
Yasuhito FUTATSUKI <futatuki_at_poem.co.jp>/<futatuki_at_yf.bsdclub.org>
Received on 2020-05-07 13:47:17 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.