Checkout
futatuki
committed
on 14 Feb
On branch swig-py3: accept both of bytes/str for input char * arguments

* Replace typemap(in) for char * using 'parse' modifier with one us… Show more
On branch swig-py3: accept both of bytes/str for input char * arguments

* Replace typemap(in) for char * using 'parse' modifier with one using

function allows both of bytes/str in py2/py3 in libsvn_swig_py library

* Fix functions to convert Python objects into char pointer to accept

both of bytes/str object in py2/py3

* Fix to accept None as representation of NULL value on conversion

 prop dict into apr_hash_t * and apr_array_header_t * of svn_props_t *

[In subversion/bindings/swig]

* core.i (%typemap(in) (const char *data, apr_size_t *len): Allow str

as well as bytes for data argment of svn_stream_write()

* include/svn_global.swg

(remove)(%typemap(in) char *, char const *, char * const,

 char const * const): Move this typemap into include/svn_strings as

 typemap (in) IN_STRING

* include/svn_string.swg (new)(%typemap(in) IN_STRING): replacement of

%typemap(in) char *, char const *, char * const, char const * const.

actual processing code is moved new svn_swig_py_string_to_cstring()

function in python/libsvn_swig_py/swigutil_py.c

* include/svn_types.swg (%typemap(in) const char *MAY_BE_NULL):

 Move processing code into new svn_swig_py_string_to_cstring() function

 in python/libsvn_swig_py/swigutil_py.c

* python/libsvn_swig_py/swigutil_py.c

(svn_swig_py_string_to_cstring): New function to convert Python

 bytes or str into const char *, with better TypeError exception message

(svn_swig_py_string_type_exception): New function to construct

 TypeError exception for new make_string_from_ob_maybe_null() function

(make_string_from_ob, make_svn_string_from_ob):

 - Allow str as well as bytes for ob

 - Don't raise TypeError exception because all callers don't expect it

(make_string_from_ob_maybe_null, make_svn_string_from_ob_maybe_null):

 New function same as make_string_from_ob() and make_svn_string_fromob()

 but allows None input represents NULL value and raise TypeError

 if input value don't have appropriate type

(svn_swig_py_stringhash_from_dict, svn_swig_py_mergeinfo_from_dict,

 svn_swig_py_proparray_from_dict, svn_swig_py_prophash_from_dict,

 svn_swig_py_path_rev_hash_from_dict,

 svn_swig_py_struct_ptr_hash_from_dict): separate check of key conversion

 result and value conversion result

(svn_swig_py_proparray_from_dict, svn_swig_py_prophash_from_dict):

 allow NULL for prop values

(svn_swig_py_unwrap_string):

 - Allow str as well as bytes for source argument

(svn_swig_py_make_file):

 - Allow str as well as bytes for py_file argument as file path

(svn_swig_py_auth_gnome_keyring_unlock_prompt_func):

 - Use new function make_string_from_ob_maybe_null() instead of

  make_string_from_ob() to check TypeError

 - Report Python exception caused by Python callback function as

  callback exception error

* python/libsvn_swig_py/swigutil_py.h

Expose new public function make_string_from_ob_maybe_null(), which is

used by typemap(in) char IN_STRING, typemap(in) const char *MAY_BY_NULL

* python/tests/client.py

(SubversionClientTestCase.log_entry_receiver_whole): New helper

 callback function for new SubversionClientTestCase.test_log5_revprops

(SubversionClientTestCase.test_log5_revprops): new test for

 typemap(in) apr_array_t *STRINGLIST and its helper function

 svn_swig_py_unwrap_string()

* python/tests/core.py

(SubversionCoreTestCase.test_stream_write_exception):

 - As unicode input is now valid, use int value as invalid input

 - Add case to be expected to cause UnicodeEncodeError

(SubversionCoreTestCase.test_stream_write_str):(Only for Python 3)

 New test case for svn_stream_write() to pass str object as data argument

(SubversionCoreTestCase.test_stream_write_bytes):

 Renamed from SubversionCoreTestCase.test_stream_write

* python/tests/run_all.py: Register new test module typemap

* python/tests/typemap.py: New unittest module for typemaps

(SubversionTypemapTestCase): New unittest subclass for unit test about

 typemaps

(SubversionTypemapTestCase.test_char_ptr_in): New test case

(SubversionTypemapTestCase.test_char_ptr_in_unicode_exception):

 New test case

(SubversionTypemapTestCase.test_char_ptr_may_be_null): New test case

(SubversionTypemapTestCase.test_char_ptr_may_be_null_unicode_exception):

 New test case

(SubversionTypemapTestCase.test_make_string_from_ob): New test case

(SubversionTypemapTestCase.test_prophash_from_dict_null_value):

 New test case

(SubversionTypemapTestCase.test_make-string_ob_unicode_exception):

 New test case

(SubversionTypemapTestCase.test_make_svn_string_ob_unicode_exception):

 New test case

(suite): New function to drive SubversionTypemapTestCase

Show less