diff src/if_py_both.h @ 4321:d8d9c591c50f v7.3.910

updated for version 7.3.910 Problem: Python code in #ifdef branches with only minor differences. Solution: Merge the #ifdef branches. (ZyX)
author Bram Moolenaar <bram@vim.org>
date Wed, 24 Apr 2013 13:47:45 +0200
parents b79f3c3a584c
children f1eab4f77a6f
line wrap: on
line diff
--- a/src/if_py_both.h
+++ b/src/if_py_both.h
@@ -2853,7 +2853,6 @@ ConvertFromPyObject(PyObject *obj, typva
 	tv->v_type = VAR_FUNC;
 	func_ref(tv->vval.v_string);
     }
-#if PY_MAJOR_VERSION >= 3
     else if (PyBytes_Check(obj))
     {
 	char_u	*result;
@@ -2873,30 +2872,6 @@ ConvertFromPyObject(PyObject *obj, typva
 	PyObject	*bytes;
 	char_u	*result;
 
-	bytes = PyString_AsBytes(obj);
-	if (bytes == NULL)
-	    return -1;
-
-	if(PyString_AsStringAndSize(bytes, (char **) &result, NULL) == -1)
-	    return -1;
-	if (result == NULL)
-	    return -1;
-
-	if (set_string_copy(result, tv) == -1)
-	{
-	    Py_XDECREF(bytes);
-	    return -1;
-	}
-	Py_XDECREF(bytes);
-
-	tv->v_type = VAR_STRING;
-    }
-#else
-    else if (PyUnicode_Check(obj))
-    {
-	PyObject	*bytes;
-	char_u	*result;
-
 	bytes = PyUnicode_AsEncodedString(obj, (char *)ENC_OPT, NULL);
 	if (bytes == NULL)
 	    return -1;
@@ -2915,20 +2890,7 @@ ConvertFromPyObject(PyObject *obj, typva
 
 	tv->v_type = VAR_STRING;
     }
-    else if (PyString_Check(obj))
-    {
-	char_u	*result;
-
-	if(PyString_AsStringAndSize(obj, (char **) &result, NULL) == -1)
-	    return -1;
-	if (result == NULL)
-	    return -1;
-
-	if (set_string_copy(result, tv) == -1)
-	    return -1;
-
-	tv->v_type = VAR_STRING;
-    }
+#if PY_MAJOR_VERSION < 3
     else if (PyInt_Check(obj))
     {
 	tv->v_type = VAR_NUMBER;