Author: svn-role
Date: Sun Mar 27 14:53:32 2022
New Revision: 1899243
URL: http://svn.apache.org/viewvc?rev=1899243&view=rev
Log:
Merge r1885199 from trunk:
* r1885199
swig-py: Skip some tests on Python 2 if default encoding is 'utf-8'.
Justification:
Fix check-swig-py not working at all since r1889654 merged from r1889487
(r1889487 depends on r1885199).
Votes:
+1: jun66j5, futatuki
Modified:
subversion/branches/1.14.x/ (props changed)
subversion/branches/1.14.x/STATUS
subversion/branches/1.14.x/subversion/bindings/swig/python/tests/client.py
subversion/branches/1.14.x/subversion/bindings/swig/python/tests/core.py
subversion/branches/1.14.x/subversion/bindings/swig/python/tests/typemap.py
subversion/branches/1.14.x/subversion/bindings/swig/python/tests/utils.py
Propchange: subversion/branches/1.14.x/
------------------------------------------------------------------------------
Merged /subversion/trunk:r1885199
Modified: subversion/branches/1.14.x/STATUS
URL:
http://svn.apache.org/viewvc/subversion/branches/1.14.x/STATUS?rev=1899243&r1=1899242&r2=1899243&view=diff
==============================================================================
--- subversion/branches/1.14.x/STATUS (original)
+++ subversion/branches/1.14.x/STATUS Sun Mar 27 14:53:32 2022
@@ -108,14 +108,6 @@ Veto-blocked changes:
Approved changes:
=================
- * r1885199
- swig-py: Skip some tests on Python 2 if default encoding is 'utf-8'.
- Justification:
- Fix check-swig-py not working at all since r1889654 merged from r1889487
- (r1889487 depends on r1885199).
- Votes:
- +1: jun66j5, futatuki
-
* r1897441
swig-py: Fix cleanup failing in unit tests with Python 3 on Windows.
Justification:
Modified:
subversion/branches/1.14.x/subversion/bindings/swig/python/tests/client.py
URL:
http://svn.apache.org/viewvc/subversion/branches/1.14.x/subversion/bindings/swig/python/tests/client.py?rev=1899243&r1=1899242&r2=1899243&view=diff
==============================================================================
--- subversion/branches/1.14.x/subversion/bindings/swig/python/tests/client.py
(original)
+++ subversion/branches/1.14.x/subversion/bindings/swig/python/tests/client.py
Sun Mar 27 14:53:32 2022
@@ -233,9 +233,17 @@ class SubversionClientTestCase(unittest.
u" message")
self.client_ctx.log_msg_baton3 = bogus_log_message_func
- with self.assertRaises(UnicodeEncodeError):
- commit_info = client.mkdir3((directory,), 1, {b'customprop':b'value'},
- self.client_ctx)
+ if not utils.IS_PY3 and utils.is_defaultencoding_utf8():
+ # 'utf-8' codecs on Python 2 does not raise UnicodeEncodeError
+ # on surrogate code point U+dc00 - U+dcff, however it causes
+ # Subversion error on property validation of svn:log
+ with self.assertRaises(core.SubversionException):
+ commit_info = client.mkdir3((directory,), 1, {b'customprop':b'value'},
+ self.client_ctx)
+ else:
+ with self.assertRaises(UnicodeEncodeError):
+ commit_info = client.mkdir3((directory,), 1, {b'customprop':b'value'},
+ self.client_ctx)
def test_log3_url(self):
"""Test svn_client_log3 on a file:// URL"""
@@ -302,10 +310,14 @@ class SubversionClientTestCase(unittest.
self.assertEqual(revprops[b'svn:author'], b"john")
with self.assertRaises(KeyError):
commit_date = revprops['svn:date']
- with self.assertRaises(UnicodeEncodeError):
- client.log5((directory,), start, (rev_range,), 1, True, False, False,
- (u'svn:\udc61uthor', b'svn:log'),
- log_entry_receiver_whole, self.client_ctx)
+ if utils.IS_PY3 or not utils.is_defaultencoding_utf8():
+ # 'utf-8' codecs on Python 2 does not raise UnicodeEncodeError
+ # on surrogate code point U+dc00 - U+dcff. So we need to skip
+ # below in such a case.
+ with self.assertRaises(UnicodeEncodeError):
+ client.log5((directory,), start, (rev_range,), 1, True, False, False,
+ (u'svn:\udc61uthor', b'svn:log'),
+ log_entry_receiver_whole, self.client_ctx)
def test_uuid_from_url(self):
"""Test svn_client_uuid_from_url on a file:// URL"""
Modified:
subversion/branches/1.14.x/subversion/bindings/swig/python/tests/core.py
URL:
http://svn.apache.org/viewvc/subversion/branches/1.14.x/subversion/bindings/swig/python/tests/core.py?rev=1899243&r1=1899242&r2=1899243&view=diff
==============================================================================
--- subversion/branches/1.14.x/subversion/bindings/swig/python/tests/core.py
(original)
+++ subversion/branches/1.14.x/subversion/bindings/swig/python/tests/core.py
Sun Mar 27 14:53:32 2022
@@ -23,8 +23,6 @@ import os
import tempfile
import sys
-IS_PY3 = sys.version_info[0] >= 3
-
import svn.core, svn.client
import utils
@@ -222,6 +220,8 @@ class SubversionCoreTestCase(unittest.Te
self.assertEqual(svn.core.svn_stream_read2(stream, 4096), b'')
svn.core.svn_stream_close(stream)
+ @unittest.skipIf(not utils.IS_PY3 and utils.is_defaultencoding_utf8(),
+ "'utf-8' codecs of Python 2 accepts any unicode strings")
def test_stream_write_exception(self):
stream = svn.core.svn_stream_empty()
with self.assertRaises(TypeError):
@@ -238,7 +238,8 @@ class SubversionCoreTestCase(unittest.Te
# As default codec of Python 2 is 'ascii', conversion from unicode to bytes
# will be success only if all characters of target strings are in the range
# of \u0000 ~ \u007f.
- @unittest.skipUnless(IS_PY3, "test for Python 3 only")
+ @unittest.skipUnless(utils.IS_PY3 or utils.is_defaultencoding_utf8(),
+ "test ony for Python 3 or Python 2 'utf-8' codecs")
def test_stream_write_str(self):
o1_str = u'Python\x00\u3071\u3044\u305d\u3093\r\n'
o2_str = u'subVersioN\x00\u3055\u3076\u3070\u30fc\u3058\u3087\u3093'
Modified:
subversion/branches/1.14.x/subversion/bindings/swig/python/tests/typemap.py
URL:
http://svn.apache.org/viewvc/subversion/branches/1.14.x/subversion/bindings/swig/python/tests/typemap.py?rev=1899243&r1=1899242&r2=1899243&view=diff
==============================================================================
--- subversion/branches/1.14.x/subversion/bindings/swig/python/tests/typemap.py
(original)
+++ subversion/branches/1.14.x/subversion/bindings/swig/python/tests/typemap.py
Sun Mar 27 14:53:32 2022
@@ -23,6 +23,7 @@ import os
import tempfile
import svn.core
+import utils
class SubversionTypemapTestCase(unittest.TestCase):
"""Test cases for the SWIG typemaps argments and return values transration"""
@@ -47,6 +48,8 @@ class SubversionTypemapTestCase(unittest
"svn_dirent_join() argument component must be"
" bytes or str, not int")
+ @unittest.skipIf(not utils.IS_PY3 and utils.is_defaultencoding_utf8(),
+ "'utf-8' codecs of Python 2 accepts any unicode strings")
def test_char_ptr_in_unicode_exception(self):
"""Check %typemap(in) IN_STRING handles unicode encode error correctly"""
with self.assertRaises(UnicodeEncodeError):
@@ -67,6 +70,8 @@ class SubversionTypemapTestCase(unittest
" must be bytes or str or None, not %s"
% self.__class__.__name__)
+ @unittest.skipIf(not utils.IS_PY3 and utils.is_defaultencoding_utf8(),
+ "'utf-8' codecs of Python 2 accepts any unicode strings")
def test_char_ptr_may_be_null_unicode_exception(self):
"""Check %typemap(in) char *MAY_BE_NULL handles unicode encode error
correctly"""
cfg = svn.core.svn_config_create2(False, False)
@@ -101,6 +106,8 @@ class SubversionTypemapTestCase(unittest
self.assertEqual(svn.core.svn_prop_diffs(target_props, source_props),
expected)
+ @unittest.skipIf(not utils.IS_PY3 and utils.is_defaultencoding_utf8(),
+ "'utf-8' codecs of Python 2 accepts any unicode strings")
def test_make_string_from_ob_unicode_exception(self):
"""Check make_string_from_ob handles unicode encode error correctly"""
source_props = { b'a' : b'foo',
@@ -112,6 +119,8 @@ class SubversionTypemapTestCase(unittest
with self.assertRaises(UnicodeEncodeError):
svn.core.svn_prop_diffs(target_props, source_props)
+ @unittest.skipIf(not utils.IS_PY3 and utils.is_defaultencoding_utf8(),
+ "'utf-8' codecs of Python 2 accepts any unicode strings")
def test_make_svn_string_from_ob_unicode_exception(self):
"""Check make_string_from_ob handles unicode encode error correctly"""
source_props = { b'a' : b'foo',
Modified:
subversion/branches/1.14.x/subversion/bindings/swig/python/tests/utils.py
URL:
http://svn.apache.org/viewvc/subversion/branches/1.14.x/subversion/bindings/swig/python/tests/utils.py?rev=1899243&r1=1899242&r2=1899243&view=diff
==============================================================================
--- subversion/branches/1.14.x/subversion/bindings/swig/python/tests/utils.py
(original)
+++ subversion/branches/1.14.x/subversion/bindings/swig/python/tests/utils.py
Sun Mar 27 14:53:32 2022
@@ -18,7 +18,7 @@
# under the License.
#
#
-import os.path, sys, tempfile
+import os.path, sys, tempfile, codecs
from svn import core, repos
from io import BytesIO
try:
@@ -28,6 +28,8 @@ except ImportError:
# Python <3.0
from urllib import pathname2url
+IS_PY3 = sys.hexversion >= 0x3000000
+
class Temper(object):
"""Class to simplify allocation and cleanup of dummy Subversion
structures, such as repositories and working copies."""
@@ -87,3 +89,9 @@ def file_uri_for_path(path):
# it returns both the authority and path parts for no reason, which
# means we have to trim the leading slashes to "normalize" the result.
return b'file:///' + uri_path.lstrip(b'/')
+
+def codecs_eq(a, b):
+ return codecs.lookup(a) == codecs.lookup(b)
+
+def is_defaultencoding_utf8():
+ return codecs_eq(sys.getdefaultencoding(), 'utf-8')