And this one fixes tests. And I still do not have any memory access errors, 
probably they were fixed by the previous posted diff. Some memory leaks are 
there, but nothing marked “definitely lost” in my code:

==8730== 33 bytes in 1 blocks are definitely lost in loss record 272 of 2,807
==8730==    at 0x4C2C88D: malloc (in 
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==8730==    by 0xC3B0C2C: ??? (in /usr/lib64/opengl/nvidia/lib/libGL.so.313.30)
==8730==    by 0x797A2F656D6F682E: ???
==8730==    by 0x72502F612E612F77: ???
==8730==    by 0x6D69762F632F6A6E: ???
==8730==    by 0x6D69762F6372732E: ???
==8730== 
==8730== 47 bytes in 1 blocks are definitely lost in loss record 348 of 2,807
==8730==    at 0x4C2C88D: malloc (in 
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==8730==    by 0x67DE5DA: XStringListToTextProperty (in 
/usr/lib64/libX11.so.6.3.0)
==8730==    by 0x596564: set_x11_title (os_unix.c:1982)
==8730==    by 0x595FD3: mch_settitle (os_unix.c:2121)
==8730==    by 0x5967A3: mch_restore_title (os_unix.c:2171)
==8730==    by 0x5977F1: mch_exit (os_unix.c:3158)
==8730==    by 0x6BB720: getout (main.c:1504)
==8730==    by 0x4BE8C9: ex_exit (ex_docmd.c:6974)
==8730==    by 0x4B57FC: do_one_cmd (ex_docmd.c:2686)
==8730==    by 0x4B19D2: do_cmdline (ex_docmd.c:1124)
==8730==    by 0x568B66: nv_colon (normal.c:5457)
==8730==    by 0x55E27A: normal_cmd (normal.c:1200)
==8730==    by 0x6BC1B0: main_loop (main.c:1329)
==8730==    by 0x6B8434: main (main.c:1020)
==8730== 
==8730== 49 bytes in 1 blocks are definitely lost in loss record 360 of 2,807
==8730==    at 0x4C2C88D: malloc (in 
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==8730==    by 0x67DE5DA: XStringListToTextProperty (in 
/usr/lib64/libX11.so.6.3.0)
==8730==    by 0x596564: set_x11_title (os_unix.c:1982)
==8730==    by 0x595FD3: mch_settitle (os_unix.c:2121)
==8730==    by 0x443288: resettitle (buffer.c:3464)
==8730==    by 0x43DCAE: maketitle (buffer.c:3432)
==8730==    by 0x6BBEFE: main_loop (main.c:1240)
==8730==    by 0x6B8434: main (main.c:1020)

…

==8730== 292 (52 direct, 240 indirect) bytes in 1 blocks are definitely lost in 
loss record 1,964 of 2,807
==8730==    at 0x4C2C88D: malloc (in 
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==8730==    by 0x7A9D63A: nss_parse_service_list (in /lib64/libc-2.15.so)
==8730==    by 0x7A9DB1D: __nss_database_lookup (in /lib64/libc-2.15.so)
==8730==    by 0x108B155F: ???
==8730==    by 0x108B3014: ???
==8730==    by 0x7A5A79C: getpwuid_r@@GLIBC_2.2.5 (in /lib64/libc-2.15.so)
==8730==    by 0x7A5A036: getpwuid (in /lib64/libc-2.15.so)
==8730==    by 0x596C99: mch_get_uname (os_unix.c:2304)
==8730==    by 0x596C71: mch_get_user_name (os_unix.c:2287)
==8730==    by 0x54E3DC: get_user_name (misc2.c:6012)
==8730==    by 0x5162D4: set_b0_fname (memline.c:963)
==8730==    by 0x515EF0: ml_open (memline.c:352)
==8730==    by 0x439344: open_buffer (buffer.c:98)
==8730==    by 0x6BAE7B: create_windows (main.c:2670)
==8730==    by 0x6B7FCC: main (main.c:855)

# HG changeset patch
# User ZyX <[email protected]>
# Date 1369940446 -14400
# Branch python-extended-4
# Node ID 969d365e3905ef96abdda7ba4fb43fd5bf45ae36
# Parent  b16cc3931caec2373abc5eac9396f88aac318e80
Fix SystemErrors by adding RAISE_NO_EMPTY_KEYS in proper places; purge 
DICTKEY_* macros

diff -r b16cc3931cae -r 969d365e3905 src/if_py_both.h
--- a/src/if_py_both.h  Thu May 30 22:33:32 2013 +0400
+++ b/src/if_py_both.h  Thu May 30 23:00:46 2013 +0400
@@ -26,31 +26,13 @@
 
 #define PyErr_SetVim(str) PyErr_SetString(VimError, str)
 
+#define RAISE_NO_EMPTY_KEYS PyErr_SetString(PyExc_ValueError, \
+                                               _("empty keys are not allowed"))
+
 #define INVALID_BUFFER_VALUE ((buf_T *)(-1))
 #define INVALID_WINDOW_VALUE ((win_T *)(-1))
 #define INVALID_TABPAGE_VALUE ((tabpage_T *)(-1))
 
-#define DICTKEY_DECL \
-    PyObject   *dictkey_todecref = NULL;
-#define DICTKEY_GET(err, decref) \
-    if (!(key = StringToChars(keyObject, &dictkey_todecref))) \
-    { \
-       if (decref) \
-       { \
-           Py_DECREF(keyObject); \
-       } \
-       return err; \
-    } \
-    if (decref && !dictkey_todecref) \
-       dictkey_todecref = keyObject; \
-    if (*key == NUL) \
-    { \
-       PyErr_SetString(PyExc_ValueError, _("empty keys are not allowed")); \
-       return err; \
-    }
-#define DICTKEY_UNREF \
-    Py_XDECREF(dictkey_todecref);
-
 typedef void (*rangeinitializer)(void *);
 typedef void (*runner)(const char *, void *
 #ifdef PY_CAN_RECURSE
@@ -1016,8 +998,7 @@
     dictitem_T *di;
     dict_T     *dict = self->dict;
     hashitem_T *hi;
-
-    DICTKEY_DECL
+    PyObject   *todecref;
 
     if (flags & DICT_FLAG_HAS_DEFAULT)
     {
@@ -1030,11 +1011,18 @@
     if (flags & DICT_FLAG_RETURN_BOOL)
        defObject = Py_False;
 
-    DICTKEY_GET(NULL, 0)
+    if (!(key = StringToChars(keyObject, &todecref)))
+       return NULL;
+
+    if (*key == NUL)
+    {
+       RAISE_NO_EMPTY_KEYS;
+       return NULL;
+    }
 
     hi = hash_find(&dict->dv_hashtab, key);
 
-    DICTKEY_UNREF
+    Py_XDECREF(todecref);
 
     if (HASHITEM_EMPTY(hi))
     {
@@ -1173,7 +1161,7 @@
     typval_T   tv;
     dict_T     *dict = self->dict;
     dictitem_T *di;
-    DICTKEY_DECL
+    PyObject   *todecref;
 
     if (dict->dv_lock)
     {
@@ -1181,7 +1169,13 @@
        return -1;
     }
 
-    DICTKEY_GET(-1, 0)
+    if (!(key = StringToChars(keyObject, &todecref)))
+       return -1;
+    if (*key == NUL)
+    {
+       RAISE_NO_EMPTY_KEYS;
+       return -1;
+    }
 
     di = dict_find(dict, key, -1);
 
@@ -1191,7 +1185,7 @@
 
        if (di == NULL)
        {
-           DICTKEY_UNREF
+           Py_XDECREF(todecref);
            PyErr_SetObject(PyExc_KeyError, keyObject);
            return -1;
        }
@@ -1208,6 +1202,7 @@
     {
        if (!(di = dictitem_alloc(key)))
        {
+           Py_XDECREF(todecref);
            PyErr_NoMemory();
            return -1;
        }
@@ -1216,7 +1211,7 @@
 
        if (dict_add(dict, di) == FAIL)
        {
-           DICTKEY_UNREF
+           Py_XDECREF(todecref);
            vim_free(di);
            dictitem_free(di);
            PyErr_SetVim(_("failed to add key to dictionary"));
@@ -1226,7 +1221,7 @@
     else
        clear_tv(&di->di_tv);
 
-    DICTKEY_UNREF
+    Py_XDECREF(todecref);
 
     copy_tv(&tv, &di->di_tv);
     clear_tv(&tv);
@@ -2202,17 +2197,23 @@
     int                flags;
     long       numval;
     char_u     *stringval;
-    DICTKEY_DECL
+    PyObject   *todecref;
 
     if (self->Check(self->from))
        return NULL;
 
-    DICTKEY_GET(NULL, 0)
+    if (!(key = StringToChars(keyObject, &todecref)))
+       return NULL;
+    if (*key == NUL)
+    {
+       RAISE_NO_EMPTY_KEYS;
+       return NULL;
+    }
 
     flags = get_option_value_strict(key, &numval, &stringval,
                                    self->opt_type, self->from);
 
-    DICTKEY_UNREF
+    Py_XDECREF(todecref);
 
     if (flags == 0)
     {
@@ -2329,12 +2330,18 @@
     int                flags;
     int                opt_flags;
     int                r = 0;
-    DICTKEY_DECL
+    PyObject   *todecref;
 
     if (self->Check(self->from))
        return -1;
 
-    DICTKEY_GET(-1, 0)
+    if (!(key = StringToChars(keyObject, &todecref)))
+       return -1;
+    if (*key == NUL)
+    {
+       RAISE_NO_EMPTY_KEYS;
+       return -1;
+    }
 
     flags = get_option_value_strict(key, NULL, NULL,
                                    self->opt_type, self->from);
@@ -2342,7 +2349,7 @@
     if (flags == 0)
     {
        PyErr_SetObject(PyExc_KeyError, keyObject);
-       DICTKEY_UNREF
+       Py_XDECREF(todecref);
        return -1;
     }
 
@@ -2352,20 +2359,20 @@
        {
            PyErr_SetString(PyExc_ValueError,
                    _("unable to unset global option"));
-           DICTKEY_UNREF
+           Py_XDECREF(todecref);
            return -1;
        }
        else if (!(flags & SOPT_GLOBAL))
        {
            PyErr_SetString(PyExc_ValueError, _("unable to unset option "
                                                "without global value"));
-           DICTKEY_UNREF
+           Py_XDECREF(todecref);
            return -1;
        }
        else
        {
            unset_global_local_option(key, self->from);
-           DICTKEY_UNREF
+           Py_XDECREF(todecref);
            return 0;
        }
     }
@@ -2396,7 +2403,7 @@
        else
        {
            PyErr_SetString(PyExc_TypeError, _("object must be integer"));
-           DICTKEY_UNREF
+           Py_XDECREF(todecref);
            return -1;
        }
 
@@ -2418,7 +2425,7 @@
            r = -1;
     }
 
-    DICTKEY_UNREF
+    Py_XDECREF(todecref);
 
     return r;
 }
@@ -4553,6 +4560,7 @@
        {
            dict_unref(dict);
            Py_XDECREF(todecref);
+           RAISE_NO_EMPTY_KEYS;
            return -1;
        }
 
@@ -4637,6 +4645,7 @@
            Py_DECREF(iterator);
            Py_XDECREF(todecref);
            dict_unref(dict);
+           RAISE_NO_EMPTY_KEYS;
            return -1;
        }
 
diff -r b16cc3931cae -r 969d365e3905 src/testdir/test86.in
--- a/src/testdir/test86.in     Thu May 30 22:33:32 2013 +0400
+++ b/src/testdir/test86.in     Thu May 30 23:00:46 2013 +0400
@@ -8,8 +8,6 @@
 STARTTEST
 :so small.vim
 :set encoding=latin1
-:" HACK: currently crashes, skip the test
-:e! test.ok | wq! test.out
 :if !has('python') | e! test.ok | wq! test.out | endif
 :lang C
 :py import vim
diff -r b16cc3931cae -r 969d365e3905 src/testdir/test87.in
--- a/src/testdir/test87.in     Thu May 30 22:33:32 2013 +0400
+++ b/src/testdir/test87.in     Thu May 30 23:00:46 2013 +0400
@@ -2,8 +2,6 @@
 
 STARTTEST
 :so small.vim
-:" HACK: currently crashes, skip the test
-:e! test.ok | wq! test.out
 :if !has('python3') | e! test.ok | wq! test.out | endif
 :lang C
 :py3 import vim

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Raspunde prin e-mail lui