You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by fu...@apache.org on 2019/09/28 06:59:54 UTC
svn commit: r1867653 - in
/subversion/branches/swig-py3/subversion/bindings/swig/python/tests:
trac/versioncontrol/tests/svn_fs.py utils.py
Author: futatuki
Date: Sat Sep 28 06:59:54 2019
New Revision: 1867653
URL: http://svn.apache.org/viewvc?rev=1867653&view=rev
Log:
On branch swig-py3: fix test for swig-py on Python 3 on Windows
[ in subversion/bindings/swig/python/tests/]
* trac/versioncontrol/tests/svn_fs.py (REPOS_PATH, REPOS_URL),
On Python 3, pass a str object as argument to urllib.request.pathname2url()
instead of a bytes.
* util.py (file_uri_for_path):
On Python 3, pass a str object as argument to urllib.request.pathname2url()
instead of a bytes even if the argment `path' is a bytes object.
Reported by: jcorvel
Modified:
subversion/branches/swig-py3/subversion/bindings/swig/python/tests/trac/versioncontrol/tests/svn_fs.py
subversion/branches/swig-py3/subversion/bindings/swig/python/tests/utils.py
Modified: subversion/branches/swig-py3/subversion/bindings/swig/python/tests/trac/versioncontrol/tests/svn_fs.py
URL: http://svn.apache.org/viewvc/subversion/branches/swig-py3/subversion/bindings/swig/python/tests/trac/versioncontrol/tests/svn_fs.py?rev=1867653&r1=1867652&r2=1867653&view=diff
==============================================================================
--- subversion/branches/swig-py3/subversion/bindings/swig/python/tests/trac/versioncontrol/tests/svn_fs.py (original)
+++ subversion/branches/swig-py3/subversion/bindings/swig/python/tests/trac/versioncontrol/tests/svn_fs.py Sat Sep 28 06:59:54 2019
@@ -68,8 +68,8 @@ from trac.test import TestSetup
from trac.versioncontrol import Changeset, Node
from trac.versioncontrol.svn_fs import SubversionRepository
-temp_path = tempfile.mktemp("-trac-svnrepos").encode('UTF-8')
-REPOS_PATH = core.svn_dirent_internal_style(temp_path)
+temp_path = tempfile.mktemp("-trac-svnrepos")
+REPOS_PATH = core.svn_dirent_internal_style(temp_path.encode('UTF-8'))
REPOS_URL = pathname2url(temp_path).encode('UTF-8')
del temp_path
Modified: subversion/branches/swig-py3/subversion/bindings/swig/python/tests/utils.py
URL: http://svn.apache.org/viewvc/subversion/branches/swig-py3/subversion/bindings/swig/python/tests/utils.py?rev=1867653&r1=1867652&r2=1867653&view=diff
==============================================================================
--- subversion/branches/swig-py3/subversion/bindings/swig/python/tests/utils.py (original)
+++ subversion/branches/swig-py3/subversion/bindings/swig/python/tests/utils.py Sat Sep 28 06:59:54 2019
@@ -79,7 +79,10 @@ class Temper(object):
def file_uri_for_path(path):
"""Return the file: URI corresponding to the given path."""
- uri_path = pathname2url(path).encode('UTF-8')
+ if isinstance(path, str):
+ uri_path = pathname2url(path).encode('UTF-8')
+ else:
+ uri_path = pathname2url(path.decode('UTF-8')).encode('UTF-8')
# pathname2url claims to return the path part of the URI, but on Windows
# it returns both the authority and path parts for no reason, which
Re: svn commit: r1867653 - in
/subversion/branches/swig-py3/subversion/bindings/swig/python/tests:
trac/versioncontrol/tests/svn_fs.py utils.py
Posted by Yasuhito FUTATSUKI <fu...@poem.co.jp>.
On 2019/09/28 22:42, Branko Čibej wrote:
> On 28.09.2019 15:39, Branko Čibej wrote:
>> On 28.09.2019 08:59, futatuki@apache.org wrote:
>>> Author: futatuki
>>> Date: Sat Sep 28 06:59:54 2019
>>> New Revision: 1867653
>>>
>>> URL: http://svn.apache.org/viewvc?rev=1867653&view=rev
>>> Log:
>>> On branch swig-py3: fix test for swig-py on Python 3 on Windows
>>>
>>> [ in subversion/bindings/swig/python/tests/]
>>> * trac/versioncontrol/tests/svn_fs.py (REPOS_PATH, REPOS_URL),
>>> On Python 3, pass a str object as argument to urllib.request.pathname2url()
>>> instead of a bytes.
>>> * util.py (file_uri_for_path):
>>> On Python 3, pass a str object as argument to urllib.request.pathname2url()
>>> instead of a bytes even if the argment `path' is a bytes object.
>>>
>>> Reported by: jcorvel
>>> ==============================================================================
>>> --- subversion/branches/swig-py3/subversion/bindings/swig/python/tests/utils.py (original)
>>> +++ subversion/branches/swig-py3/subversion/bindings/swig/python/tests/utils.py Sat Sep 28 06:59:54 2019
>>> @@ -79,7 +79,10 @@ class Temper(object):
>>>
>>> def file_uri_for_path(path):
>>> """Return the file: URI corresponding to the given path."""
>>> - uri_path = pathname2url(path).encode('UTF-8')
>>> + if isinstance(path, str):
>>> + uri_path = pathname2url(path).encode('UTF-8')
>>> + else:
>>> + uri_path = pathname2url(path.decode('UTF-8')).encode('UTF-8')
>> I'd write this differently:
>
> First, I'd not send the message to soon (facepalm).
>
> Then, I'd write:
>
> if isinstance(path, str):
> path = path.decode('UTF-8')
> uri_path = pathname2url(path).encode('UTF-8')
>
>
> This way, there's only on call to pathname2url and someone who changes
> the code in future doesn't have to remember to follow both branches of
> the conditional.
I see. It's reasonable.
Thanks,
--
Yasuhito FUTATSUKI <fu...@poem.co.jp>
Re: svn commit: r1867653 - in
/subversion/branches/swig-py3/subversion/bindings/swig/python/tests:
trac/versioncontrol/tests/svn_fs.py utils.py
Posted by Branko Čibej <br...@apache.org>.
On 28.09.2019 15:39, Branko Čibej wrote:
> On 28.09.2019 08:59, futatuki@apache.org wrote:
>> Author: futatuki
>> Date: Sat Sep 28 06:59:54 2019
>> New Revision: 1867653
>>
>> URL: http://svn.apache.org/viewvc?rev=1867653&view=rev
>> Log:
>> On branch swig-py3: fix test for swig-py on Python 3 on Windows
>>
>> [ in subversion/bindings/swig/python/tests/]
>> * trac/versioncontrol/tests/svn_fs.py (REPOS_PATH, REPOS_URL),
>> On Python 3, pass a str object as argument to urllib.request.pathname2url()
>> instead of a bytes.
>> * util.py (file_uri_for_path):
>> On Python 3, pass a str object as argument to urllib.request.pathname2url()
>> instead of a bytes even if the argment `path' is a bytes object.
>>
>> Reported by: jcorvel
>> ==============================================================================
>> --- subversion/branches/swig-py3/subversion/bindings/swig/python/tests/utils.py (original)
>> +++ subversion/branches/swig-py3/subversion/bindings/swig/python/tests/utils.py Sat Sep 28 06:59:54 2019
>> @@ -79,7 +79,10 @@ class Temper(object):
>>
>> def file_uri_for_path(path):
>> """Return the file: URI corresponding to the given path."""
>> - uri_path = pathname2url(path).encode('UTF-8')
>> + if isinstance(path, str):
>> + uri_path = pathname2url(path).encode('UTF-8')
>> + else:
>> + uri_path = pathname2url(path.decode('UTF-8')).encode('UTF-8')
> I'd write this differently:
First, I'd not send the message to soon (facepalm).
Then, I'd write:
if isinstance(path, str):
path = path.decode('UTF-8')
uri_path = pathname2url(path).encode('UTF-8')
This way, there's only on call to pathname2url and someone who changes
the code in future doesn't have to remember to follow both branches of
the conditional.
-- Brane
Re: svn commit: r1867653 - in
/subversion/branches/swig-py3/subversion/bindings/swig/python/tests:
trac/versioncontrol/tests/svn_fs.py utils.py
Posted by Branko Čibej <br...@apache.org>.
On 28.09.2019 08:59, futatuki@apache.org wrote:
> Author: futatuki
> Date: Sat Sep 28 06:59:54 2019
> New Revision: 1867653
>
> URL: http://svn.apache.org/viewvc?rev=1867653&view=rev
> Log:
> On branch swig-py3: fix test for swig-py on Python 3 on Windows
>
> [ in subversion/bindings/swig/python/tests/]
> * trac/versioncontrol/tests/svn_fs.py (REPOS_PATH, REPOS_URL),
> On Python 3, pass a str object as argument to urllib.request.pathname2url()
> instead of a bytes.
> * util.py (file_uri_for_path):
> On Python 3, pass a str object as argument to urllib.request.pathname2url()
> instead of a bytes even if the argment `path' is a bytes object.
>
> Reported by: jcorvel
> ==============================================================================
> --- subversion/branches/swig-py3/subversion/bindings/swig/python/tests/utils.py (original)
> +++ subversion/branches/swig-py3/subversion/bindings/swig/python/tests/utils.py Sat Sep 28 06:59:54 2019
> @@ -79,7 +79,10 @@ class Temper(object):
>
> def file_uri_for_path(path):
> """Return the file: URI corresponding to the given path."""
> - uri_path = pathname2url(path).encode('UTF-8')
> + if isinstance(path, str):
> + uri_path = pathname2url(path).encode('UTF-8')
> + else:
> + uri_path = pathname2url(path.decode('UTF-8')).encode('UTF-8')
I'd write this differently: