diff src/if_python3.c @ 4589:fa39483a1363 v7.3.1042

updated for version 7.3.1042 Problem: Python: can't assign to vim.Buffer.name. Solution: Python patch 3. (ZyX)
author Bram Moolenaar <bram@vim.org>
date Wed, 29 May 2013 22:02:22 +0200
parents b9f87487d935
children 0cf552b325b5
line wrap: on
line diff
--- a/src/if_python3.c
+++ b/src/if_python3.c
@@ -638,32 +638,6 @@ static int py3initialised = 0;
 
 #define PYINITIALISED py3initialised
 
-#define DICTKEY_DECL PyObject *bytes = NULL;
-
-#define DICTKEY_GET(err) \
-    if (PyBytes_Check(keyObject)) \
-    { \
-	if (PyString_AsStringAndSize(keyObject, (char **) &key, NULL) == -1) \
-	    return err; \
-    } \
-    else if (PyUnicode_Check(keyObject)) \
-    { \
-	bytes = PyString_AsBytes(keyObject); \
-	if (bytes == NULL) \
-	    return err; \
-	if (PyString_AsStringAndSize(bytes, (char **) &key, NULL) == -1) \
-	    return err; \
-    } \
-    else \
-    { \
-	PyErr_SetString(PyExc_TypeError, _("only string keys are allowed")); \
-	return err; \
-    }
-
-#define DICTKEY_UNREF \
-    if (bytes != NULL) \
-	Py_XDECREF(bytes);
-
 #define DESTRUCTOR_FINISH(self) Py_TYPE(self)->tp_free((PyObject*)self)
 
 #define WIN_PYTHON_REF(win) win->w_python3_ref
@@ -696,6 +670,7 @@ static PyObject *BufferDir(PyObject *);
 static PyObject *OutputGetattro(PyObject *, PyObject *);
 static int OutputSetattro(PyObject *, PyObject *, PyObject *);
 static PyObject *BufferGetattro(PyObject *, PyObject *);
+static int BufferSetattro(PyObject *, PyObject *, PyObject *);
 static PyObject *TabPageGetattro(PyObject *, PyObject *);
 static PyObject *WindowGetattro(PyObject *, PyObject *);
 static int WindowSetattro(PyObject *, PyObject *, PyObject *);
@@ -1108,6 +1083,14 @@ BufferGetattro(PyObject *self, PyObject*
 	return PyObject_GenericGetAttr(self, nameobj);
 }
 
+    static int
+BufferSetattro(PyObject *self, PyObject *nameobj, PyObject *val)
+{
+    GET_ATTR_STRING(name, nameobj);
+
+    return BufferSetattr((BufferObject *)(self), name, val);
+}
+
     static PyObject *
 BufferDir(PyObject *self UNUSED)
 {