You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by tr...@apache.org on 2018/12/31 04:14:58 UTC

svn commit: r1850011 - /subversion/branches/swig-py3/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c

Author: troycurtisjr
Date: Mon Dec 31 04:14:58 2018
New Revision: 1850011

URL: http://svn.apache.org/viewvc?rev=1850011&view=rev
Log:
On branch swig-py3: Fix macro usage to distinguish py2 and py3 context.

* subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c
   Include "swigutil_py3c.h" file before define SVN_SWIG_BYTES_FMT to use
     IS_PY3 macro to switch py2 and py3 context.
   (add_directory, add_file, apply_textdelta, change_file_prop,
    close_file, parse_fn3_set_revision_property,
    parse_fn3_set_node_property, svn_swig_py_notify_func,
    svn_swig_py_notify_func, svn_swig_py_delta_path_driver_cb_func,
    svn_swig_py_repos_authz_func, svn_swig_py_log_receiver,
    svn_swig_py_client_blame_receiver_func,
    svn_swig_py_changelist_receiver_func,
    svn_swig_py_auth_simple_prompt_func,
    svn_swig_py_config_auth_walk_func,
    ra_callbacks_get_wc_prop, ra_callbacks_push_or_set_wc_prop,
    ra_callbacks_invalidate_wc_props, svn_swig_py_commit_callback,
    reporter_set_path, reporter_link_path,
    wc_diff_callbacks2_file_changed_or_added,
    wc_diff_callbacks2_file_deleted, wc_diff_callbacks2_dir_added,
    wc_diff_callbacks2_dir_props_changed,
    svn_swig_py_config_enumerator2):
     Use IS_PY3 macro instead of comparison of PY_VERSION_HEX.
   (add_directory, add_file, apply_textdelta, change_file_prop,
    close_file, parse_fn3_set_revision_property,
    parse_fn3_set_node_property, ra_callbacks_get_wc_prop,
    ra_callbacks_push_or_set_wc_prop, ra_callbacks_invalidate_wc_props):
     Enclose only format argument of Py_CallFunction or Py_CallMethod
     with #if IS_PY3 #else #endif block.

Patch By: Yasuhito Futatsuki <fu...@poem.co.jp>


Modified:
    subversion/branches/swig-py3/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c

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=1850011&r1=1850010&r2=1850011&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 Mon Dec 31 04:14:58 2018
@@ -51,8 +51,9 @@
 
 #include "swig_python_external_runtime.swg"
 #include "swigutil_py.h"
+#include "swigutil_py3c.h"
 
-#if PY_VERSION_HEX >= 0x03000000
+#if IS_PY3
 
 /* In Python 3 use the bytes format character for raw data */
 #define SVN_SWIG_BYTES_FMT "y"
@@ -64,8 +65,6 @@
 
 #endif
 
-#include "swigutil_py3c.h"
-
 /* Py_ssize_t for old Pythons */
 /* This code is as recommended by: */
 /* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */
@@ -1781,11 +1780,12 @@ static svn_error_t *add_directory(const
 
   /* ### python doesn't have 'const' on the method name and format */
   if ((result = PyObject_CallMethod(ib->editor, (char *)"add_directory",
-#if PY_VERSION_HEX >= 0x03000000
-                                    (char *)"yOylO&", path, ib->baton,
+#if IS_PY3
+                                    (char *)"yOylO&",
 #else
-                                    (char *)"sOslO&", path, ib->baton,
+                                    (char *)"sOslO&",
 #endif
+                                    path, ib->baton,
                                     copyfrom_path, copyfrom_revision,
                                     make_ob_pool, dir_pool)) == NULL)
     {
@@ -1846,11 +1846,12 @@ static svn_error_t *change_dir_prop(void
 
   /* ### python doesn't have 'const' on the method name and format */
   if ((result = PyObject_CallMethod(ib->editor, (char *)"change_dir_prop",
-#if PY_VERSION_HEX >= 0x03000000
-                                    (char *)"Oyy#O&", ib->baton, name,
+#if IS_PY3
+                                    (char *)"Oyy#O&",
 #else
-                                    (char *)"Oss#O&", ib->baton, name,
+                                    (char *)"Oss#O&",
 #endif
+                                    ib->baton, name,
                                     value ? value->data : NULL,
                                     value ? value->len : 0,
                                     make_ob_pool, pool)) == NULL)
@@ -1889,11 +1890,12 @@ static svn_error_t *add_file(const char
 
   /* ### python doesn't have 'const' on the method name and format */
   if ((result = PyObject_CallMethod(ib->editor, (char *)"add_file",
-#if PY_VERSION_HEX >= 0x03000000
-                                    (char *)"yOylO&", path, ib->baton,
+#if IS_PY3
+                                    (char *)"yOylO&",
 #else
-                                    (char *)"sOslO&", path, ib->baton,
+                                    (char *)"sOslO&",
 #endif
+                                    path, ib->baton,
                                     copyfrom_path, copyfrom_revision,
                                     make_ob_pool, file_pool)) == NULL)
     {
@@ -1999,11 +2001,12 @@ static svn_error_t *apply_textdelta(void
 
   /* ### python doesn't have 'const' on the method name and format */
   if ((result = PyObject_CallMethod(ib->editor, (char *)"apply_textdelta",
-#if PY_VERSION_HEX >= 0x03000000
-                                    (char *)"(Oy)", ib->baton,
+#if IS_PY3
+                                    (char *)"(Oy)",
 #else
-                                    (char *)"(Os)", ib->baton,
+                                    (char *)"(Os)",
 #endif
+                                    ib->baton,
                                     base_checksum)) == NULL)
     {
       err = callback_exception_error();
@@ -2048,11 +2051,12 @@ static svn_error_t *change_file_prop(voi
 
   /* ### python doesn't have 'const' on the method name and format */
   if ((result = PyObject_CallMethod(ib->editor, (char *)"change_file_prop",
-#if PY_VERSION_HEX >= 0x03000000
-                                    (char *)"Oyy#O&", ib->baton, name,
+#if IS_PY3
+                                    (char *)"Oyy#O&",
 #else
-                                    (char *)"Oss#O&", ib->baton, name,
+                                    (char *)"Oss#O&",
 #endif
+                                    ib->baton, name,
                                     value ? value->data : NULL,
                                     value ? value->len : 0,
                                     make_ob_pool, pool)) == NULL)
@@ -2082,11 +2086,12 @@ static svn_error_t *close_file(void *fil
 
   /* ### python doesn't have 'const' on the method name and format */
   if ((result = PyObject_CallMethod(ib->editor, (char *)"close_file",
-#if PY_VERSION_HEX >= 0x03000000
-                                    (char *)"(Oy)", ib->baton,
+#if IS_PY3
+                                    (char *)"(Oy)",
 #else
-                                    (char *)"(Os)", ib->baton,
+                                    (char *)"(Os)",
 #endif
+                                    ib->baton,
                                     text_checksum)) == NULL)
     {
       err = callback_exception_error();
@@ -2283,11 +2288,12 @@ static svn_error_t *parse_fn3_set_revisi
 
   /* ### python doesn't have 'const' on the method name and format */
   if ((result = PyObject_CallMethod(ib->editor, (char *)"set_revision_property",
-#if PY_VERSION_HEX >= 0x03000000
-                                    (char *)"Oyy#", ib->baton, name,
+#if IS_PY3
+                                    (char *)"Oyy#",
 #else
-                                    (char *)"Oss#", ib->baton, name,
+                                    (char *)"Oss#",
 #endif
+                                    ib->baton, name,
                                     value ? value->data : NULL,
                                     value ? value->len : 0)) == NULL)
     {
@@ -2317,11 +2323,12 @@ static svn_error_t *parse_fn3_set_node_p
 
   /* ### python doesn't have 'const' on the method name and format */
   if ((result = PyObject_CallMethod(ib->editor, (char *)"set_node_property",
-#if PY_VERSION_HEX >= 0x03000000
-                                    (char *)"Oyy#", ib->baton, name,
+#if IS_PY3
+                                    (char *)"Oyy#",
 #else
-                                    (char *)"Oss#", ib->baton, name,
+                                    (char *)"Oss#",
 #endif
+                                    ib->baton, name,
                                     value ? value->data : NULL,
                                     value ? value->len : 0)) == NULL)
     {
@@ -2766,7 +2773,7 @@ void svn_swig_py_notify_func(void *baton
 
   svn_swig_py_acquire_py_lock();
   if ((result = PyObject_CallFunction(function,
-#if PY_VERSION_HEX >= 0x03000000
+#if IS_PY3
                                       (char *)"(yiiyiii)",
 #else
                                       (char *)"(siisiii)",
@@ -2919,7 +2926,7 @@ svn_error_t *svn_swig_py_delta_path_driv
                                                  NULL);
 
   result = PyObject_CallFunction(function,
-#if PY_VERSION_HEX >= 0x03000000
+#if IS_PY3
                                  (char *)"OyO&",
 #else
                                  (char *)"OsO&",
@@ -3189,7 +3196,7 @@ svn_error_t *svn_swig_py_repos_authz_fun
     }
 
   if ((result = PyObject_CallFunction(function,
-#if PY_VERSION_HEX >= 0x03000000
+#if IS_PY3
                                       (char *)"OyO",
 #else
                                       (char *)"OsO",
@@ -3417,7 +3424,7 @@ svn_error_t *svn_swig_py_log_receiver(vo
     }
 
   if ((result = PyObject_CallFunction(receiver,
-#if PY_VERSION_HEX >= 0x03000000
+#if IS_PY3
                                       (char *)"OlyyyO",
 #else
                                       (char *)"OlsssO",
@@ -3569,7 +3576,7 @@ svn_error_t *svn_swig_py_client_blame_re
 
   if ((result = PyObject_CallFunction(receiver,
                                       (char *)
-#if PY_VERSION_HEX >= 0x03000000
+#if IS_PY3
                                       (SVN_APR_INT64_T_PYCFMT "lyyyO&"),
 #else
                                       (SVN_APR_INT64_T_PYCFMT "lsssO&"),
@@ -3605,7 +3612,7 @@ svn_error_t *svn_swig_py_changelist_rece
   svn_swig_py_acquire_py_lock();
 
   if ((result = PyObject_CallFunction(receiver,
-#if PY_VERSION_HEX >= 0x03000000
+#if IS_PY3
                                       (char *)"yyO&",
 #else
                                       (char *)"ssO&",
@@ -3680,7 +3687,7 @@ svn_swig_py_auth_simple_prompt_func(svn_
   svn_swig_py_acquire_py_lock();
 
   if ((result = PyObject_CallFunction(function,
-#if PY_VERSION_HEX >= 0x03000000
+#if IS_PY3
                                       (char *)"yylO&",
 #else
                                       (char *)"sslO&",
@@ -3958,7 +3965,7 @@ svn_swig_py_config_auth_walk_func(svn_bo
     }
 
   if ((result = PyObject_CallFunction(function,
-#if PY_VERSION_HEX >= 0x03000000
+#if IS_PY3
                                       (char *)"yyOO",
 #else
                                       (char *)"ssOO",
@@ -4061,11 +4068,12 @@ ra_callbacks_get_wc_prop(void *baton,
     }
 
   if ((result = PyObject_CallFunction(py_callback,
-#if PY_VERSION_HEX >= 0x03000000
-                                      (char *)"yyO&", path, name,
+#if IS_PY3
+                                      (char *)"yyO&",
 #else
-                                      (char *)"ssO&", path, name,
+                                      (char *)"ssO&",
 #endif
+                                      path, name,
                                       make_ob_pool, pool)) == NULL)
     {
       err = callback_exception_error();
@@ -4124,11 +4132,12 @@ ra_callbacks_push_or_set_wc_prop(const c
     }
 
   if ((result = PyObject_CallFunction(py_callback,
-#if PY_VERSION_HEX >= 0x03000000
-                                      (char *)"yyOO&", path, name, py_value,
+#if IS_PY3
+                                      (char *)"yyOO&",
 #else
-                                      (char *)"ssOO&", path, name, py_value,
+                                      (char *)"ssOO&",
 #endif
+                                      path, name, py_value,
                                       make_ob_pool, pool)) == NULL)
     {
       err = callback_exception_error();
@@ -4191,11 +4200,12 @@ ra_callbacks_invalidate_wc_props(void *b
     }
 
   if ((result = PyObject_CallFunction(py_callback,
-#if PY_VERSION_HEX >= 0x03000000
-                                      (char *)"yyO&", path, name,
+#if IS_PY3
+                                      (char *)"yyO&",
 #else
-                                      (char *)"ssO&", path, name,
+                                      (char *)"ssO&",
 #endif
+                                      path, name,
                                       make_ob_pool, pool)) == NULL)
     {
       err = callback_exception_error();
@@ -4427,7 +4437,7 @@ svn_error_t *svn_swig_py_commit_callback
   svn_swig_py_acquire_py_lock();
 
   if ((result = PyObject_CallFunction(receiver,
-#if PY_VERSION_HEX >= 0x03000000
+#if IS_PY3
                                       (char *)"lyy",
 #else
                                       (char *)"lss",
@@ -4566,7 +4576,7 @@ static svn_error_t *reporter_set_path(vo
 
   if ((result = PyObject_CallMethod(py_reporter,
                                     (char *)"set_path",
-#if PY_VERSION_HEX >= 0x03000000
+#if IS_PY3
                                     (char *)"ylbyO&",
 #else
                                     (char *)"slbsO&",
@@ -4639,7 +4649,7 @@ static svn_error_t *reporter_link_path(v
 
   if ((result = PyObject_CallMethod(py_reporter,
                                     (char *)"link_path",
-#if PY_VERSION_HEX >= 0x03000000
+#if IS_PY3
                                     (char *)"yylbsO&",
 #else
                                     (char *)"sslbsO&",
@@ -4774,7 +4784,7 @@ wc_diff_callbacks2_file_changed_or_added
     }
 
   result = PyObject_CallFunction(py_callback,
-#if PY_VERSION_HEX >= 0x03000000
+#if IS_PY3
                                  (char *)"O&yyyllyyO&O&",
 #else
                                  (char *)"O&sssllssO&O&",
@@ -4901,7 +4911,7 @@ wc_diff_callbacks2_file_deleted(svn_wc_a
     }
 
   result = PyObject_CallFunction(py_callback,
-#if PY_VERSION_HEX >= 0x03000000
+#if IS_PY3
                                  (char *)"O&yyyyyO&",
 #else
                                  (char *)"O&sssssO&",
@@ -4959,7 +4969,7 @@ wc_diff_callbacks2_dir_added(svn_wc_adm_
     }
 
   result = PyObject_CallFunction(py_callback,
-#if PY_VERSION_HEX >= 0x03000000
+#if IS_PY3
                                  (char *)"O&yl",
 #else
                                  (char *)"O&sl",
@@ -5065,7 +5075,7 @@ wc_diff_callbacks2_dir_props_changed(svn
     }
 
   result = PyObject_CallFunction(py_callback,
-#if PY_VERSION_HEX >= 0x03000000
+#if IS_PY3
                                  (char *)"O&yO&O&",
 #else
                                  (char *)"O&sO&O&",
@@ -5125,7 +5135,7 @@ svn_swig_py_config_enumerator2(const cha
   svn_swig_py_acquire_py_lock();
 
   if ((result = PyObject_CallFunction(function,
-#if PY_VERSION_HEX >= 0x03000000
+#if IS_PY3
                                       (char *)"yyO&",
 #else
                                       (char *)"ssO&",