subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmpil...@apache.org
Subject svn commit: r1848763 - /subversion/trunk/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c
Date Wed, 12 Dec 2018 13:57:17 GMT
Author: cmpilato
Date: Wed Dec 12 13:57:17 2018
New Revision: 1848763

URL: http://svn.apache.org/viewvc?rev=1848763&view=rev
Log:
swig-py: Followup to r1848577, simplifying svn_stream_t pointer handling.

* subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c
  (svn_swig_py_make_stream): Use svn_swig_py_convert_ptr() rather than
    manually checking for an instance of libsvn.core.svn_stream_t
    using Python APIs.

Patch by: Jun Omae <jun66j5 at gmail.com>

Modified:
    subversion/trunk/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c

Modified: subversion/trunk/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c?rev=1848763&r1=1848762&r2=1848763&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c (original)
+++ subversion/trunk/subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c Wed Dec
12 13:57:17 2018
@@ -2578,36 +2578,18 @@ svn_swig_py_stream_destroy(void *py_io)
 svn_stream_t *
 svn_swig_py_make_stream(PyObject *py_io, apr_pool_t *pool)
 {
-  PyObject *libsvn_core = NULL;
-  PyObject *py_stream_t = NULL;
   PyObject *_stream = NULL;
-  svn_stream_t *result = NULL;
+  void *result = NULL;
   swig_type_info *typeinfo = svn_swig_TypeQuery("svn_stream_t *");
 
-  libsvn_core = PyImport_ImportModule("libsvn.core");
-  if (PyErr_Occurred()) {
-    goto finished;
-  }
-  py_stream_t = PyObject_GetAttrString(libsvn_core, "svn_stream_t");
-  if (PyErr_Occurred()) {
-    goto finished;
-  }
-  if (PyObject_IsInstance(py_io, py_stream_t)) {
-    result = (svn_stream_t *)svn_swig_py_must_get_ptr(py_io, typeinfo, 0);
-    if (PyErr_Occurred()) {
-      result = NULL;
-      goto finished;
-    }
-  }
-  else if (PyObject_HasAttrString(py_io, "_stream")) {
-    _stream = PyObject_GetAttrString(py_io, "_stream");
-    if (PyObject_IsInstance(_stream, py_stream_t)) {
-      result = (svn_stream_t *)svn_swig_py_must_get_ptr(_stream, typeinfo, 0);
-      if (PyErr_Occurred()) {
-        result = NULL;
-        goto finished;
+  if (svn_swig_py_convert_ptr(py_io, &result, typeinfo) != 0) {
+      PyErr_Clear();
+      if (PyObject_HasAttrString(py_io, "_stream")) {
+        _stream = PyObject_GetAttrString(py_io, "_stream");
+        if (svn_swig_py_convert_ptr(_stream, &result, typeinfo) != 0) {
+          PyErr_Clear();
+        }
       }
-    }
   }
   if (result == NULL) {
     if (!PyObject_HasAttrString(py_io, "read")
@@ -2627,8 +2609,6 @@ svn_swig_py_make_stream(PyObject *py_io,
 
 finished:
   Py_XDECREF(_stream);
-  Py_XDECREF(py_stream_t);
-  Py_XDECREF(libsvn_core);
 
   return result;
 }



Mime
View raw message