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

Re: svn commit: r37006 - in trunk/subversion/tests/cmdline: . svntest

From: Greg Stein <gstein_at_gmail.com>
Date: Mon, 6 Apr 2009 01:07:16 +0200

Look. I *know* they're "harmless" to Python 2. That is NOT THE POINT.

You're increasing the complexity of our Python code. You're
introducing problems into our test suite's ability to detect certain
kinds of output. And these problems are not providing us any benefit.
"decrease the difference to the branch" is not a valid benefit --
we're trying to improve *trunk* rather than the branches.

-g

On Sun, Apr 5, 2009 at 22:54, Arfrever Frehtes Taifersar Arahesis
<arfrever.fta_at_gmail.com> wrote:
> 2009-04-05 21:44:11 Greg Stein napisał(a):
>> 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.
>
> It contains changes harmless in Python 2 [1] and it decreases the difference to
> the 'python-3-compatibility' branch.
>
> [1] Except a change in svntest.wc.State.from_wc() on Windows.
>
>> 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):
>> >
>
>
> --
> Arfrever Frehtes Taifersar Arahesis
>

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=1555584
Received on 2009-04-06 01:07:32 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.