subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From troycurti...@apache.org
Subject svn commit: r1849037 - in /subversion/branches/swig-py3/subversion/bindings/swig: core.i include/svn_types.swg python/libsvn_swig_py/swigutil_py.c
Date Sun, 16 Dec 2018 16:53:39 GMT
Author: troycurtisjr
Date: Sun Dec 16 16:53:38 2018
New Revision: 1849037

URL: http://svn.apache.org/viewvc?rev=1849037&view=rev
Log:
On branch swig-py3: Address compiler warnings under Python 3.

Resolved compiler warnings relating to handling of const values when the SWIG
bindings are built under Python 3.

* subversion/bindings/swig/core.i
  (const char *data, apr_size_t *len): Explicitly cast away const and document
    the rationale.
  (const void *value): Fix variable initialization from PyStr_AsString to be
    const.

* subversion/bindings/swig/include/svn_types.swg
  (const char *PTR, apr_size_t LEN): Explicitly cast away const and document the
    rationale.

* subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c
  (svn_swig_py_make_file): Fix variable initialization from PyStr_AsString to be
    const.


Modified:
    subversion/branches/swig-py3/subversion/bindings/swig/core.i
    subversion/branches/swig-py3/subversion/bindings/swig/include/svn_types.swg
    subversion/branches/swig-py3/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c

Modified: subversion/branches/swig-py3/subversion/bindings/swig/core.i
URL: http://svn.apache.org/viewvc/subversion/branches/swig-py3/subversion/bindings/swig/core.i?rev=1849037&r1=1849036&r2=1849037&view=diff
==============================================================================
--- subversion/branches/swig-py3/subversion/bindings/swig/core.i (original)
+++ subversion/branches/swig-py3/subversion/bindings/swig/core.i Sun Dec 16 16:53:38 2018
@@ -447,7 +447,11 @@
                         "expecting a string for the buffer");
         SWIG_fail;
     }
-    $1 = PyStr_AsUTF8AndSize($input, &temp);
+    /* Explicitly cast away const from PyStr_AsUTF8AndSize (in Python 3). The
+       swig generated argument ($1) here will be "char *", but since its only
+       use is to pass directly into the "const char *" argument of the wrapped
+       function, this is safe to do. */
+    $1 = (char *)PyStr_AsUTF8AndSize($input, &temp);
     $2 = ($2_ltype)&temp;
 }
 #endif
@@ -501,7 +505,7 @@
     }
 
     if (PyStr_Check($input)) {
-        char *value = PyStr_AsString($input);
+        const char *value = PyStr_AsString($input);
         $1 = apr_pstrdup(_global_pool, value);
     }
     else if (PyLong_Check($input)) {

Modified: subversion/branches/swig-py3/subversion/bindings/swig/include/svn_types.swg
URL: http://svn.apache.org/viewvc/subversion/branches/swig-py3/subversion/bindings/swig/include/svn_types.swg?rev=1849037&r1=1849036&r2=1849037&view=diff
==============================================================================
--- subversion/branches/swig-py3/subversion/bindings/swig/include/svn_types.swg (original)
+++ subversion/branches/swig-py3/subversion/bindings/swig/include/svn_types.swg Sun Dec 16
16:53:38 2018
@@ -469,7 +469,11 @@ svn_ ## TYPE ## _swig_rb_closed(VALUE se
         PyErr_SetString(PyExc_TypeError, "expecting a string");
         SWIG_fail;
     }
-    $1 = PyStr_AsUTF8AndSize($input, &pyStrLen);
+    /* Explicitly cast away const from PyStr_AsUTF8AndSize (in Python 3). The
+       swig generated argument ($1) here will be "char *", but since its only
+       use is to pass directly into the "const char *" argument of the wrapped
+       function, this is safe to do. */
+    $1 = (char *)PyStr_AsUTF8AndSize($input, &pyStrLen);
     $2 = pyStrLen;
 }
 #endif

Modified: subversion/branches/swig-py3/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c
URL: http://svn.apache.org/viewvc/subversion/branches/swig-py3/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c?rev=1849037&r1=1849036&r2=1849037&view=diff
==============================================================================
--- subversion/branches/swig-py3/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c
(original)
+++ subversion/branches/swig-py3/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c
Sun Dec 16 16:53:38 2018
@@ -2511,7 +2511,7 @@ apr_file_t *svn_swig_py_make_file(PyObje
   if (PyStr_Check(py_file))
     {
       /* input is a path -- just open an apr_file_t */
-      char* fname = PyStr_AsString(py_file);
+      const char* fname = PyStr_AsString(py_file);
       apr_err = apr_file_open(&apr_file, fname,
                               APR_CREATE | APR_READ | APR_WRITE,
                               APR_OS_DEFAULT, pool);



Mime
View raw message