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

Re: swig-py3 str/bytes difference in svn_config_*()

From: Yasuhito FUTATSUKI <futatuki_at_poem.co.jp>
Date: Fri, 13 Dec 2019 14:13:47 +0900

On 2019/12/13 12:11, Daniel Shahaf wrote:
> With swig-py3 in trunk:
>
>>>> from svn.core import *
>>>> svn_config_get_user_config_path(None, '')
> b'/home/daniel/.subversion'
>>>> d = _
>>>> svn_config_ensure(d)
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "${prefix}/lib/svn-python/libsvn/core.py", line 6014, in svn_config_ensure
> return _core.svn_config_ensure(*args)
> TypeError: svn_config_ensure() argument 1 must be str or None, not bytes
>>>> svn_config_ensure(d.decode())
>>>>
>
> svn_config_get_user_config_path() returns bytes but svn_config_ensure() expects
> str. I expected them both to use the same type, since in C they do:
> svn_config_get_user_config_path() has a «const char **» output parameter and
> svn_config_ensure() has a «const char *» input parameter.

I'll take a look it later, but I reply to easir one in advance.

>
> Cheers,
>
> Daniel
>
> P.S. Unrelated issue: «svn_config_get_user_config_path(None, None)» raises
> TypeError, even though at the C level the second input parameter, FNAME,
> is allowed to be NULL.
>
This is because "const char *fname" is not in
"%apply const char *MAY_BE_NULL {}" list in subversion/bindings/swig/core.i.

"const char *fname" is also used in svn_io_file_open() and svn_io_stat(),
however both are marked as "%ignore" in subversion/bindings/swig/core.i,
so it seems it can be added to the MAY_BE_NULL lists.

[[[
Index: subversion/bindings/swig/core.i
===================================================================
--- subversion/bindings/swig/core.i (revision 1871280)
+++ subversion/bindings/swig/core.i (working copy)
@@ -370,7 +370,8 @@
      const char *conflict_separator,
      /* svn_cmdline_create_auth_baton */
      const char *username,
- const char *password
+ const char *password,
+ const char *fname
  };
  
  /* -----------------------------------------------------------------------
]]]

Cheers,

-- 
Yasuhito FUTATSUKI <futatuki_at_yf.bsdclub.org>/<futatuki_at_poem.co.jp>
Received on 2019-12-13 06:15:24 CET

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.