Ugh. I thought all the "bytes" stuff was for the branch. NOT the trunk.
The revision below, and the others, is adding a whole bunch of
complexity. For no benefit.
-g
On Sat, Apr 4, 2009 at 23:54, Arfrever Frehtes Taifersar Arahesis
<Arfrever.FTA_at_gmail.com> wrote:
> Author: arfrever
> Date: Sat Apr  4 14:54:11 2009
> New Revision: 37006
>
> Log:
> Python 3 compatibility:
> Add encoding / decoding of some variables in 'subversion/tests' directory.
>
> * subversion/tests/cmdline/diff_tests.py:
> * subversion/tests/cmdline/patch_tests.py:
> * subversion/tests/cmdline/svntest/actions.py:
> * subversion/tests/cmdline/svntest/main.py:
> * subversion/tests/cmdline/svntest/wc.py: Add encoding / decoding of some
> Â variables.
>
> Modified:
> Â trunk/subversion/tests/cmdline/diff_tests.py
> Â trunk/subversion/tests/cmdline/patch_tests.py
> Â trunk/subversion/tests/cmdline/svntest/actions.py
> Â trunk/subversion/tests/cmdline/svntest/main.py
> Â trunk/subversion/tests/cmdline/svntest/wc.py
>
> Modified: trunk/subversion/tests/cmdline/diff_tests.py
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/tests/cmdline/diff_tests.py?pathrev=37006&r1=37005&r2=37006
> ==============================================================================
> --- trunk/subversion/tests/cmdline/diff_tests.py     Sat Apr  4 13:45:09 2009     (r37005)
> +++ trunk/subversion/tests/cmdline/diff_tests.py     Sat Apr  4 14:54:11 2009     (r37006)
> @@ -3041,12 +3041,19 @@ def diff_svnpatch(sbox):
> Â Â Â i = i - 1
> Â Â ll = l[i+1:]
> Â Â return ll
> +
> + Â def convert_svnpatch_line(l):
> + Â Â if sys.version_info[0] >= 3:
> + Â Â Â # Python >=3.0
> + Â Â Â if isinstance(l, str):
> + Â Â Â Â return l.encode()
> + Â Â return l
>
> Â def svnpatch_encode(l):
> - Â Â return [x + "\n" for x in textwrap.wrap(base64.encodestring(zlib.compress("".join(l))), 76)]
> + Â Â return [x + "\n" for x in textwrap.wrap(base64.encodestring(zlib.compress("".join([convert_svnpatch_line(x) for x in l]))).decode(), 76)]
>
> Â def svnpatch_decode(l):
> - Â Â return zlib.decompress(base64.decodestring("".join([x.rstrip("\n") for x in l])))
> + Â Â return zlib.decompress(base64.decodestring("".join([x.rstrip("\n") for x in l]).encode()))
>
> Â def verify_svnpatch(actual, expected):
> Â Â if svntest.main.verbose_mode:
>
> Modified: trunk/subversion/tests/cmdline/patch_tests.py
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/tests/cmdline/patch_tests.py?pathrev=37006&r1=37005&r2=37006
> ==============================================================================
> --- trunk/subversion/tests/cmdline/patch_tests.py    Sat Apr  4 13:45:09 2009     (r37005)
> +++ trunk/subversion/tests/cmdline/patch_tests.py    Sat Apr  4 14:54:11 2009     (r37006)
> @@ -41,8 +41,15 @@ Item = svntest.wc.StateItem
> Â ########################################################################
> Â #Tools
>
> +def convert_svnpatch_line(l):
> + Â if sys.version_info[0] >= 3:
> + Â Â # Python >=3.0
> + Â Â if isinstance(l, str):
> + Â Â Â return l.encode()
> + Â return l
> +
> Â def svnpatch_encode(l):
> - Â return [x + "\n" for x in textwrap.wrap(base64.encodestring(zlib.compress("".join(l))), 76)]
> + Â return [x + "\n" for x in textwrap.wrap(base64.encodestring(zlib.compress("".join([convert_svnpatch_line(x) for x in l]))).decode(), 76)]
>
> Â gnupatch_garbage_re =\
> Â re.compile("^patch: \*\*\*\* Only garbage was found in the patch input.$")
> @@ -98,6 +105,10 @@ def patch_basic(sbox):
> Â ]
>
> Â svnpatch = svnpatch_encode(svnpatch)
> + Â if sys.version_info[0] < 3:
> + Â Â # Python <3.0
> + Â Â svnpatch = [x.encode() for x in svnpatch]
> +
> Â svntest.main.file_write(patch_file_path,\
> Â '========================= SVNPATCH1 BLOCK =========================\n')
> Â svntest.main.file_append(patch_file_path, ''.join(svnpatch))
> @@ -288,6 +299,9 @@ def patch_copy_and_move(sbox):
> Â ]
>
> Â svnpatch = svnpatch_encode(svnpatch)
> + Â if sys.version_info[0] < 3:
> + Â Â # Python <3.0
> + Â Â svnpatch = [x.encode() for x in svnpatch]
>
> Â svntest.main.file_write(patch_file_path, ''.join(unidiff_patch))
> Â svntest.main.file_append(patch_file_path,
>
> Modified: trunk/subversion/tests/cmdline/svntest/actions.py
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/tests/cmdline/svntest/actions.py?pathrev=37006&r1=37005&r2=37006
> ==============================================================================
> --- trunk/subversion/tests/cmdline/svntest/actions.py  Sat Apr  4 13:45:09 2009     (r37005)
> +++ trunk/subversion/tests/cmdline/svntest/actions.py  Sat Apr  4 14:54:11 2009     (r37006)
> @@ -1560,6 +1560,10 @@ def set_prop(name, value, path, expected
> Â Â from tempfile import mkstemp
> Â Â value_file_path = mkstemp()[1]
> Â Â value_file = open(value_file_path, 'wb')
> + Â Â if sys.version_info[0] >= 3:
> + Â Â Â # Python >=3.0
> + Â Â Â if isinstance(value, str):
> + Â Â Â Â value = value.encode()
> Â Â value_file.write(value)
> Â Â value_file.flush()
> Â Â value_file.close()
>
> Modified: trunk/subversion/tests/cmdline/svntest/main.py
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/tests/cmdline/svntest/main.py?pathrev=37006&r1=37005&r2=37006
> ==============================================================================
> --- trunk/subversion/tests/cmdline/svntest/main.py    Sat Apr  4 13:45:09 2009     (r37005)
> +++ trunk/subversion/tests/cmdline/svntest/main.py    Sat Apr  4 14:54:11 2009     (r37006)
> @@ -432,6 +432,14 @@ def wait_on_pipe(waiter, binary_mode, st
>
> Â kid, command = waiter
> Â stdout, stderr = kid.communicate(stdin)
> + Â try:
> + Â Â stdout = stdout.decode()
> + Â except UnicodeDecodeError:
> + Â Â pass
> + Â try:
> + Â Â stderr = stderr.decode()
> + Â except UnicodeDecodeError:
> + Â Â pass
> Â exit_code = kid.returncode
>
> Â # Normalize Windows line endings if in text mode.
> @@ -475,6 +483,8 @@ def spawn_process(command, binary_mode=0
>
> Â if stdin_lines:
> Â Â for x in stdin_lines:
> + Â Â Â if isinstance(x, str):
> + Â Â Â Â x = x.encode()
> Â Â Â infile.write(x)
>
> Â stdout_lines, stderr_lines, exit_code = wait_on_pipe(kid, binary_mode)
>
> Modified: trunk/subversion/tests/cmdline/svntest/wc.py
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/tests/cmdline/svntest/wc.py?pathrev=37006&r1=37005&r2=37006
> ==============================================================================
> --- trunk/subversion/tests/cmdline/svntest/wc.py     Sat Apr  4 13:45:09 2009     (r37005)
> +++ trunk/subversion/tests/cmdline/svntest/wc.py     Sat Apr  4 14:54:11 2009     (r37006)
> @@ -206,7 +206,7 @@ class State:
> Â Â Â Â Â os.makedirs(dirpath)
>
> Â Â Â Â # write out the file contents now
> - Â Â Â Â open(fullpath, 'wb').write(item.contents)
> + Â Â Â Â open(fullpath, 'wb').write(item.contents.encode())
>
> Â def normalize(self):
> Â Â """Return a "normalized" version of self.
> @@ -491,7 +491,11 @@ class State:
> Â Â Â for name in dirs + files:
> Â Â Â Â node = os.path.join(dirpath, name)
> Â Â Â Â if os.path.isfile(node):
> - Â Â Â Â Â contents = open(node, 'r').read()
> + Â Â Â Â Â contents = open(node, 'rb').read()
> + Â Â Â Â Â try:
> + Â Â Â Â Â Â contents = contents.decode()
> + Â Â Â Â Â except UnicodeDecodeError:
> + Â Â Â Â Â Â pass
> Â Â Â Â else:
> Â Â Â Â Â contents = None
> Â Â Â Â desc[repos_join(parent, name)] = StateItem(contents=contents)
> @@ -646,9 +650,16 @@ class StateItem:
>
> Â def tweak(self, **kw):
> Â Â for name, value in kw.items():
> - Â Â Â ### refine the revision args (for now) to ensure they are strings
> + Â Â Â # Refine the revision args (for now) to ensure they are strings.
> Â Â Â if value is not None and name == 'wc_rev':
> Â Â Â Â value = str(value)
> + Â Â Â if sys.version_info[0] >= 3:
> + Â Â Â Â # Python >=3.0
> + Â Â Â Â # Property values with invalid UTF-8 characters have bytes type.
> + Â Â Â Â if value is not None and name == 'props':
> + Â Â Â Â Â for prop, prop_value in value.items():
> + Â Â Â Â Â Â if isinstance(prop_value, bytes):
> + Â Â Â Â Â Â Â value[prop] = str(prop_value)
> Â Â Â setattr(self, name, value)
>
> Â def __eq__(self, other):
>
> ------------------------------------------------------
> http://subversion.tigris.org/ds/viewMessage.do?dsForumId=495&dsMessageId=1546254
>
------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=1553778
Received on 2009-04-05 21:44:34 CEST