Loading ...
Sorry, an error occurred while loading the content.

Re: [PATCH] (2/?) Fix platform-specific stuff in tests

Expand Messages
  • ZyX
    # HG changeset patch # User ZyX # Date 1370101974 -14400 # Branch python-extended-4 # Node ID f37c4b0b09f688698e23d14c6f915968d0868523 # Parent
    Message 1 of 9 , Jun 1, 2013
    • 0 Attachment
      # HG changeset patch
      # User ZyX <kp-pav@...>
      # Date 1370101974 -14400
      # Branch python-extended-4
      # Node ID f37c4b0b09f688698e23d14c6f915968d0868523
      # Parent 0921ff181087b318c2322ab5af06758776a59bd1
      Fix platform-specific stuff in tests

      diff -r 0921ff181087 -r f37c4b0b09f6 src/testdir/test86.in
      --- a/src/testdir/test86.in Fri May 31 08:40:24 2013 +0400
      +++ b/src/testdir/test86.in Sat Jun 01 19:52:54 2013 +0400
      @@ -435,6 +435,7 @@
      :py bopts1=vim.buffers[vim.bindeval("g:bufs")[2]].options
      :py bopts2=vim.buffers[vim.bindeval("g:bufs")[1]].options
      :py bopts3=vim.buffers[vim.bindeval("g:bufs")[0]].options
      +:set path=.,..,,
      :let lst=[]
      :let lst+=[['paste', 1, 0, 1, 2, 1, 1, 0 ]]
      :let lst+=[['previewheight', 5, 1, 6, 'a', 0, 1, 0 ]]
      @@ -530,13 +531,14 @@
      b[0:0]=['baz']
      vim.command('call append("$", getbufline(%i, 1, "$"))' % b.number)
      # Test assigning to name property
      +import os
      old_name = cb.name
      cb.name = 'foo'
      -cb.append(cb.name[-11:])
      +cb.append(cb.name[-11:].replace(os.path.sep, '/'))
      b.name = 'bar'
      -cb.append(b.name[-11:])
      +cb.append(b.name[-11:].replace(os.path.sep, '/'))
      cb.name = old_name
      -cb.append(cb.name[-17:])
      +cb.append(cb.name[-17:].replace(os.path.sep, '/'))
      # Test CheckBuffer
      for _b in vim.buffers:
      if _b is not cb:
      diff -r 0921ff181087 -r f37c4b0b09f6 src/testdir/test86.ok
      --- a/src/testdir/test86.ok Fri May 31 08:40:24 2013 +0400
      +++ b/src/testdir/test86.ok Sat Jun 01 19:52:54 2013 +0400
      @@ -310,7 +310,7 @@
      W: 1:0 2:1 3:0 4:1
      B: 1:0 2:1 3:0 4:1
      >>> path
      - p/gopts1: '.,/usr/include,,'
      + p/gopts1: '.,..,,'
      inv: 0! TypeError
      p/wopts1! KeyError
      inv: 0! KeyError
      diff -r 0921ff181087 -r f37c4b0b09f6 src/testdir/test87.in
      --- a/src/testdir/test87.in Fri May 31 08:40:24 2013 +0400
      +++ b/src/testdir/test87.in Sat Jun 01 19:52:54 2013 +0400
      @@ -404,6 +404,7 @@
      :py3 bopts1=vim.buffers[vim.bindeval("g:bufs")[2]].options
      :py3 bopts2=vim.buffers[vim.bindeval("g:bufs")[1]].options
      :py3 bopts3=vim.buffers[vim.bindeval("g:bufs")[0]].options
      +:set path=.,..,,
      :let lst=[]
      :let lst+=[['paste', 1, 0, 1, 2, 1, 1, 0 ]]
      :let lst+=[['previewheight', 5, 1, 6, 'a', 0, 1, 0 ]]
      @@ -499,13 +500,14 @@
      b[0:0]=['baz']
      vim.command('call append("$", getbufline(%i, 1, "$"))' % b.number)
      # Test assigning to name property
      +import os
      old_name = cb.name
      cb.name = 'foo'
      -cb.append(cb.name[-11:])
      +cb.append(cb.name[-11:].replace(os.path.sep, '/'))
      b.name = 'bar'
      -cb.append(b.name[-11:])
      +cb.append(b.name[-11:].replace(os.path.sep, '/'))
      cb.name = old_name
      -cb.append(cb.name[-17:])
      +cb.append(cb.name[-17:].replace(os.path.sep, '/'))
      # Test CheckBuffer
      for _b in vim.buffers:
      if _b is not cb:
      diff -r 0921ff181087 -r f37c4b0b09f6 src/testdir/test87.ok
      --- a/src/testdir/test87.ok Fri May 31 08:40:24 2013 +0400
      +++ b/src/testdir/test87.ok Sat Jun 01 19:52:54 2013 +0400
      @@ -299,7 +299,7 @@
      W: 1:0 2:1 3:0 4:1
      B: 1:0 2:1 3:0 4:1
      >>> path
      - p/gopts1: b'.,/usr/include,,'
      + p/gopts1: b'.,..,,'
      inv: 0! TypeError
      p/wopts1! KeyError
      inv: 0! KeyError

      --
      --
      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 vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • ZyX
      # HG changeset patch # User ZyX # Date 1370092920 -14400 # Branch python-extended-4 # Node ID 0ee8bb6bd07f29fd51c7b753492ac727b69ac7ae # Parent
      Message 2 of 9 , Jun 1, 2013
      • 0 Attachment
        # HG changeset patch
        # User ZyX <kp-pav@...>
        # Date 1370092920 -14400
        # Branch python-extended-4
        # Node ID 0ee8bb6bd07f29fd51c7b753492ac727b69ac7ae
        # Parent f37c4b0b09f688698e23d14c6f915968d0868523
        More possible memory leak fixes

        diff -r f37c4b0b09f6 -r 0ee8bb6bd07f src/if_py_both.h
        --- a/src/if_py_both.h Sat Jun 01 19:52:54 2013 +0400
        +++ b/src/if_py_both.h Sat Jun 01 17:22:00 2013 +0400
        @@ -1017,6 +1017,7 @@
        if (*key == NUL)
        {
        RAISE_NO_EMPTY_KEYS;
        + Py_XDECREF(todecref);
        return NULL;
        }

        @@ -1171,6 +1172,7 @@

        if (!(key = StringToChars(keyObject, &todecref)))
        return -1;
        +
        if (*key == NUL)
        {
        RAISE_NO_EMPTY_KEYS;
        @@ -2204,9 +2206,11 @@

        if (!(key = StringToChars(keyObject, &todecref)))
        return NULL;
        +
        if (*key == NUL)
        {
        RAISE_NO_EMPTY_KEYS;
        + Py_XDECREF(todecref);
        return NULL;
        }

        @@ -2337,9 +2341,11 @@

        if (!(key = StringToChars(keyObject, &todecref)))
        return -1;
        +
        if (*key == NUL)
        {
        RAISE_NO_EMPTY_KEYS;
        + Py_XDECREF(todecref);
        return -1;
        }

        @@ -4556,6 +4562,7 @@
        dict_unref(dict);
        return -1;
        }
        +
        if (*key == NUL)
        {
        dict_unref(dict);
        @@ -4639,6 +4646,7 @@
        dict_unref(dict);
        return -1;
        }
        +
        if (*key == NUL)
        {
        Py_DECREF(keyObject);

        --
        --
        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 vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • ZyX
        Is a replacement for @Xavier de Gaye patch written in C. Main idea is the same. # HG changeset patch # User ZyX # Date 1370102113 -14400 #
        Message 3 of 9 , Jun 1, 2013
        • 0 Attachment
          Is a replacement for @Xavier de Gaye patch written in C. Main idea is the same.

          # HG changeset patch
          # User ZyX <kp-pav@...>
          # Date 1370102113 -14400
          # Branch python-extended-4
          # Node ID 807b755f9898d68e4d93f18e7964783b207826b2
          # Parent 0ee8bb6bd07f29fd51c7b753492ac727b69ac7ae
          Add vim.chdir and vim.fchdir functions, record them as attributes of os module

          diff -r 0ee8bb6bd07f -r 807b755f9898 runtime/doc/if_pyth.txt
          --- a/runtime/doc/if_pyth.txt Sat Jun 01 17:22:00 2013 +0400
          +++ b/runtime/doc/if_pyth.txt Sat Jun 01 19:55:13 2013 +0400
          @@ -180,6 +180,13 @@
          Like |strwidth()|: returns number of display cells str occupies, tab
          is counted as one cell.

          +vim.chdir(*args, **kwargs) *python-chdir*
          +vim.fchdir(*args, **kwargs) *python-fchdir*
          + Run os.chdir or os.fchdir, then all appropriate vim stuff.
          + Note: you should not use these functions directly, use os.chdir and
          + os.fchdir instead. Behavior of vim.fchdir is undefined in case
          + os.fchdir does not exist.
          +
          Error object of the "vim" module

          vim.error *python-error*
          diff -r 0ee8bb6bd07f -r 807b755f9898 src/ex_docmd.c
          --- a/src/ex_docmd.c Sat Jun 01 17:22:00 2013 +0400
          +++ b/src/ex_docmd.c Sat Jun 01 19:55:13 2013 +0400
          @@ -8182,6 +8182,33 @@
          }
          #endif

          + void
          +post_chdir(local)
          + int local;
          +{
          + vim_free(curwin->w_localdir);
          + if (local)
          + {
          + /* If still in global directory, need to remember current
          + * directory as global directory. */
          + if (globaldir == NULL && prev_dir != NULL)
          + globaldir = vim_strsave(prev_dir);
          + /* Remember this local directory for the window. */
          + if (mch_dirname(NameBuff, MAXPATHL) == OK)
          + curwin->w_localdir = vim_strsave(NameBuff);
          + }
          + else
          + {
          + /* We are now in the global directory, no need to remember its
          + * name. */
          + vim_free(globaldir);
          + globaldir = NULL;
          + curwin->w_localdir = NULL;
          + }
          +
          + shorten_fnames(TRUE);
          +}
          +

          /*
          * ":cd", ":lcd", ":chdir" and ":lchdir".
          @@ -8253,27 +8280,7 @@
          EMSG(_(e_failed));
          else
          {
          - vim_free(curwin->w_localdir);
          - if (eap->cmdidx == CMD_lcd || eap->cmdidx == CMD_lchdir)
          - {
          - /* If still in global directory, need to remember current
          - * directory as global directory. */
          - if (globaldir == NULL && prev_dir != NULL)
          - globaldir = vim_strsave(prev_dir);
          - /* Remember this local directory for the window. */
          - if (mch_dirname(NameBuff, MAXPATHL) == OK)
          - curwin->w_localdir = vim_strsave(NameBuff);
          - }
          - else
          - {
          - /* We are now in the global directory, no need to remember its
          - * name. */
          - vim_free(globaldir);
          - globaldir = NULL;
          - curwin->w_localdir = NULL;
          - }
          -
          - shorten_fnames(TRUE);
          + post_chdir(eap->cmdidx == CMD_lcd || eap->cmdidx == CMD_lchdir);

          /* Echo the new current directory if the command was typed. */
          if (KeyTyped || p_verbose >= 5)
          diff -r 0ee8bb6bd07f -r 807b755f9898 src/if_py_both.h
          --- a/src/if_py_both.h Sat Jun 01 17:22:00 2013 +0400
          +++ b/src/if_py_both.h Sat Jun 01 19:55:13 2013 +0400
          @@ -52,6 +52,10 @@

          static PyObject *globals;

          +static PyObject *py_chdir;
          +static PyObject *py_fchdir;
          +static PyObject *py_getcwd;
          +
          /*
          * obtain a lock on the Vim data structures
          */
          @@ -706,17 +710,84 @@
          );
          }

          + static PyObject *
          +_VimChdir(PyObject *_chdir, PyObject *args, PyObject *kwargs)
          +{
          + PyObject *r;
          + PyObject *newwd;
          + PyObject *todecref;
          + char_u *new_dir;
          +
          + if (!(r = PyObject_Call(_chdir, args, kwargs)))
          + return NULL;
          +
          + if (!(newwd = PyObject_CallFunctionObjArgs(py_getcwd, NULL)))
          + {
          + Py_DECREF(r);
          + return NULL;
          + }
          +
          + if (!(new_dir = StringToChars(newwd, &todecref)))
          + {
          + Py_DECREF(r);
          + Py_DECREF(newwd);
          + return NULL;
          + }
          +
          + VimTryStart();
          +
          + if (vim_chdir(new_dir))
          + {
          + Py_DECREF(r);
          + Py_DECREF(newwd);
          + Py_XDECREF(todecref);
          +
          + if (VimTryEnd())
          + return NULL;
          +
          + PyErr_SetVim(_("failed to change directory"));
          + return NULL;
          + }
          +
          + Py_DECREF(newwd);
          + Py_XDECREF(todecref);
          +
          + post_chdir(FALSE);
          +
          + if (VimTryEnd())
          + {
          + Py_DECREF(r);
          + return NULL;
          + }
          +
          + return r;
          +}
          +
          + static PyObject *
          +VimChdir(PyObject *self UNUSED, PyObject *args, PyObject *kwargs)
          +{
          + return _VimChdir(py_chdir, args, kwargs);
          +}
          +
          + static PyObject *
          +VimFchdir(PyObject *self UNUSED, PyObject *args, PyObject *kwargs)
          +{
          + return _VimChdir(py_fchdir, args, kwargs);
          +}
          +
          /*
          * Vim module - Definitions
          */

          static struct PyMethodDef VimMethods[] = {
          - /* name, function, calling, documentation */
          - {"command", VimCommand, METH_VARARGS, "Execute a Vim ex-mode command" },
          - {"eval", VimEval, METH_VARARGS, "Evaluate an expression using Vim evaluator" },
          - {"bindeval", VimEvalPy, METH_VARARGS, "Like eval(), but returns objects attached to vim ones"},
          - {"strwidth", VimStrwidth, METH_VARARGS, "Screen string width, counts <Tab> as having width 1"},
          - { NULL, NULL, 0, NULL }
          + /* name, function, calling, documentation */
          + {"command", VimCommand, METH_VARARGS, "Execute a Vim ex-mode command" },
          + {"eval", VimEval, METH_VARARGS, "Evaluate an expression using Vim evaluator" },
          + {"bindeval", VimEvalPy, METH_VARARGS, "Like eval(), but returns objects attached to vim ones"},
          + {"strwidth", VimStrwidth, METH_VARARGS, "Screen string width, counts <Tab> as having width 1"},
          + {"chdir", (PyCFunction)VimChdir, METH_VARARGS|METH_KEYWORDS, "Change directory"},
          + {"fchdir", (PyCFunction)VimFchdir, METH_VARARGS|METH_KEYWORDS, "Change directory"},
          + { NULL, NULL, 0, NULL }
          };

          /*
          @@ -5262,6 +5333,7 @@
          };

          typedef int (*object_adder)(PyObject *, const char *, PyObject *);
          +typedef PyObject *(*attr_getter)(PyObject *, const char *);

          #define ADD_OBJECT(m, name, obj) \
          if (add_object(m, name, obj)) \
          @@ -5276,9 +5348,10 @@
          }

          static int
          -populate_module(PyObject *m, object_adder add_object)
          +populate_module(PyObject *m, object_adder add_object, attr_getter get_attr)
          {
          int i;
          + PyObject *os;

          for (i = 0; i < (int)(sizeof(numeric_constants)
          / sizeof(struct numeric_constant));
          @@ -5305,5 +5378,27 @@
          ADD_CHECKED_OBJECT(m, "vvars", NEW_DICTIONARY(&vimvardict));
          ADD_CHECKED_OBJECT(m, "options",
          OptionsNew(SREQ_GLOBAL, NULL, dummy_check, NULL));
          +
          + if (!(os = PyImport_ImportModule("os")))
          + return -1;
          + ADD_OBJECT(m, "os", os);
          +
          + if (!(py_getcwd = PyObject_GetAttrString(os, "getcwd")))
          + return -1;
          + ADD_OBJECT(m, "_getcwd", py_getcwd)
          +
          + if (!(py_chdir = PyObject_GetAttrString(os, "chdir")))
          + return -1;
          + ADD_OBJECT(m, "_chdir", py_chdir);
          + if (PyObject_SetAttrString(os, "chdir", get_attr(m, "chdir")))
          + return -1;
          +
          + if ((py_fchdir = PyObject_GetAttrString(os, "fchdir")))
          + {
          + ADD_OBJECT(m, "_fchdir", py_fchdir);
          + if (PyObject_SetAttrString(os, "fchdir", get_attr(m, "fchdir")))
          + return -1;
          + }
          +
          return 0;
          }
          diff -r 0ee8bb6bd07f -r 807b755f9898 src/if_python.c
          --- a/src/if_python.c Sat Jun 01 17:22:00 2013 +0400
          +++ b/src/if_python.c Sat Jun 01 19:55:13 2013 +0400
          @@ -213,6 +213,7 @@
          # define PyObject_HasAttrString dll_PyObject_HasAttrString
          # define PyObject_SetAttrString dll_PyObject_SetAttrString
          # define PyObject_CallFunctionObjArgs dll_PyObject_CallFunctionObjArgs
          +# define PyObject_Call dll_PyObject_Call
          # define PyString_AsString dll_PyString_AsString
          # define PyString_AsStringAndSize dll_PyString_AsStringAndSize
          # define PyString_FromString dll_PyString_FromString
          @@ -346,6 +347,7 @@
          static int (*dll_PyObject_HasAttrString)(PyObject *, const char *);
          static PyObject* (*dll_PyObject_SetAttrString)(PyObject *, const char *, PyObject *);
          static PyObject* (*dll_PyObject_CallFunctionObjArgs)(PyObject *, ...);
          +static PyObject* (*dll_PyObject_Call)(PyObject *, PyObject *, PyObject *);
          static char*(*dll_PyString_AsString)(PyObject *);
          static int(*dll_PyString_AsStringAndSize)(PyObject *, char **, int *);
          static PyObject*(*dll_PyString_FromString)(const char *);
          @@ -510,6 +512,7 @@
          {"PyObject_HasAttrString", (PYTHON_PROC*)&dll_PyObject_HasAttrString},
          {"PyObject_SetAttrString", (PYTHON_PROC*)&dll_PyObject_SetAttrString},
          {"PyObject_CallFunctionObjArgs", (PYTHON_PROC*)&dll_PyObject_CallFunctionObjArgs},
          + {"PyObject_Call", (PYTHON_PROC*)&dll_PyObject_Call},
          {"PyString_AsString", (PYTHON_PROC*)&dll_PyString_AsString},
          {"PyString_AsStringAndSize", (PYTHON_PROC*)&dll_PyString_AsStringAndSize},
          {"PyString_FromString", (PYTHON_PROC*)&dll_PyString_FromString},
          @@ -1364,6 +1367,7 @@
          {
          PyObject *mod;
          PyObject *dict;
          + PyObject *os;

          /* The special value is removed from sys.path in Python_Init(). */
          static char *(argv[2]) = {"/must>not&exist/foo", NULL};
          @@ -1374,10 +1378,11 @@
          /* Set sys.argv[] to avoid a crash in warn(). */
          PySys_SetArgv(1, argv);

          - mod = Py_InitModule4("vim", VimMethods, (char *)NULL, (PyObject *)NULL, PYTHON_API_VERSION);
          + mod = Py_InitModule4("vim", VimMethods, (char *)NULL, (PyObject *)NULL,
          + PYTHON_API_VERSION);
          dict = PyModule_GetDict(mod);

          - return populate_module(dict, add_object);
          + return populate_module(dict, add_object, PyDict_GetItemString);
          }

          /*************************************************************************
          diff -r 0ee8bb6bd07f -r 807b755f9898 src/if_python3.c
          --- a/src/if_python3.c Sat Jun 01 17:22:00 2013 +0400
          +++ b/src/if_python3.c Sat Jun 01 19:55:13 2013 +0400
          @@ -174,6 +174,7 @@
          # define PyObject_HasAttrString py3_PyObject_HasAttrString
          # define PyObject_SetAttrString py3_PyObject_SetAttrString
          # define PyObject_CallFunctionObjArgs py3_PyObject_CallFunctionObjArgs
          +# define PyObject_Call py3_PyObject_Call
          # define PyEval_GetLocals py3_PyEval_GetLocals
          # define PyEval_GetGlobals py3_PyEval_GetGlobals
          # define PySys_SetObject py3_PySys_SetObject
          @@ -290,6 +291,7 @@
          static int (*py3_PyObject_HasAttrString)(PyObject *, const char *);
          static PyObject* (*py3_PyObject_SetAttrString)(PyObject *, const char *, PyObject *);
          static PyObject* (*py3_PyObject_CallFunctionObjArgs)(PyObject *, ...);
          +static PyObject* (*py3_PyObject_Call)(PyObject *, PyObject *, PyObject *);
          static PyObject* (*py3_PyEval_GetGlobals)();
          static PyObject* (*py3_PyEval_GetLocals)();
          static PyObject* (*py3_PyList_GetItem)(PyObject *, Py_ssize_t);
          @@ -446,6 +448,7 @@
          {"PyObject_HasAttrString", (PYTHON_PROC*)&py3_PyObject_HasAttrString},
          {"PyObject_SetAttrString", (PYTHON_PROC*)&py3_PyObject_SetAttrString},
          {"PyObject_CallFunctionObjArgs", (PYTHON_PROC*)&py3_PyObject_CallFunctionObjArgs},
          + {"PyObject_Call", (PYTHON_PROC*)&py3_PyObject_Call},
          {"PyEval_GetGlobals", (PYTHON_PROC*)&py3_PyEval_GetGlobals},
          {"PyEval_GetLocals", (PYTHON_PROC*)&py3_PyEval_GetLocals},
          {"PyList_GetItem", (PYTHON_PROC*)&py3_PyList_GetItem},
          @@ -1586,6 +1589,7 @@
          Py3Init_vim(void)
          {
          PyObject *mod;
          + PyObject *os;

          /* The special value is removed from sys.path in Python3_Init(). */
          static wchar_t *(argv[2]) = {L"/must>not&exist/foo", NULL};
          @@ -1600,7 +1604,7 @@
          if (mod == NULL)
          return NULL;

          - if (populate_module(mod, PyModule_AddObject))
          + if (populate_module(mod, PyModule_AddObject, PyObject_GetAttrString))
          return NULL;

          return mod;
          diff -r 0ee8bb6bd07f -r 807b755f9898 src/proto/ex_docmd.pro
          --- a/src/proto/ex_docmd.pro Sat Jun 01 17:22:00 2013 +0400
          +++ b/src/proto/ex_docmd.pro Sat Jun 01 19:55:13 2013 +0400
          @@ -53,4 +53,5 @@
          int put_line __ARGS((FILE *fd, char *s));
          void dialog_msg __ARGS((char_u *buff, char *format, char_u *fname));
          char_u *get_behave_arg __ARGS((expand_T *xp, int idx));
          +void post_chdir __ARGS((int local));
          /* vim: set ft=c : */
          diff -r 0ee8bb6bd07f -r 807b755f9898 src/testdir/test86.in
          --- a/src/testdir/test86.in Sat Jun 01 17:22:00 2013 +0400
          +++ b/src/testdir/test86.in Sat Jun 01 19:55:13 2013 +0400
          @@ -788,6 +788,20 @@
          :$put =string(pyeval('dl2'))
          :$put =string(pyeval('df(2)'))
          :"
          +:" Test chdir
          +py << EOF
          +import os
          +fnamemodify = vim.Function('fnamemodify')
          +cb.append(fnamemodify('.', ':p:h:t'))
          +cb.append(vim.eval('@%'))
          +os.chdir('..')
          +cb.append(fnamemodify('.', ':p:h:t'))
          +cb.append(vim.eval('@%').replace(os.path.sep, '/'))
          +os.chdir('testdir')
          +cb.append(fnamemodify('.', ':p:h:t'))
          +cb.append(vim.eval('@%'))
          +EOF
          +:"
          :" Test errors
          :fun F() dict
          :endfun
          diff -r 0ee8bb6bd07f -r 807b755f9898 src/testdir/test86.ok
          --- a/src/testdir/test86.ok Sat Jun 01 17:22:00 2013 +0400
          +++ b/src/testdir/test86.ok Sat Jun 01 19:55:13 2013 +0400
          @@ -429,6 +429,12 @@
          ['a', 'b', 'c']
          [2, 2]
          [2, 2]
          +testdir
          +test86.in
          +src
          +testdir/test86.in
          +testdir
          +test86.in
          > Output
          >> OutputSetattr
          del sys.stdout.softspace:(<type 'exceptions.AttributeError'>, AttributeError("can't delete OutputObject attributes",))
          diff -r 0ee8bb6bd07f -r 807b755f9898 src/testdir/test87.in
          --- a/src/testdir/test87.in Sat Jun 01 17:22:00 2013 +0400
          +++ b/src/testdir/test87.in Sat Jun 01 19:55:13 2013 +0400
          @@ -748,6 +748,20 @@
          :$put =string(py3eval('dl2'))
          :$put =string(py3eval('df(2)'))
          :"
          +:" Test chdir
          +py3 << EOF
          +import os
          +fnamemodify = vim.Function('fnamemodify')
          +cb.append(str(fnamemodify('.', ':p:h:t')))
          +cb.append(vim.eval('@%'))
          +os.chdir('..')
          +cb.append(str(fnamemodify('.', ':p:h:t')))
          +cb.append(vim.eval('@%').replace(os.path.sep, '/'))
          +os.chdir('testdir')
          +cb.append(str(fnamemodify('.', ':p:h:t')))
          +cb.append(vim.eval('@%'))
          +EOF
          +:"
          :" Test errors
          :fun F() dict
          :endfun
          diff -r 0ee8bb6bd07f -r 807b755f9898 src/testdir/test87.ok
          --- a/src/testdir/test87.ok Sat Jun 01 17:22:00 2013 +0400
          +++ b/src/testdir/test87.ok Sat Jun 01 19:55:13 2013 +0400
          @@ -418,6 +418,12 @@
          ['a', 'b', 'c']
          [2, 2]
          [2, 2]
          +b'testdir'
          +test87.in
          +b'src'
          +testdir/test87.in
          +b'testdir'
          +test87.in
          > Output
          >> OutputSetattr
          del sys.stdout.softspace:(<class 'AttributeError'>, AttributeError("can't delete OutputObject attributes",))

          --
          --
          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 vim_dev+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • ZyX
          # HG changeset patch # User ZyX # Date 1370102113 -14400 # Branch python-extended-4 # Node ID 807b755f9898d68e4d93f18e7964783b207826b2 # Parent
          Message 4 of 9 , Jun 1, 2013
          • 0 Attachment
            # HG changeset patch
            # User ZyX <kp-pav@...>
            # Date 1370102113 -14400
            # Branch python-extended-4
            # Node ID 807b755f9898d68e4d93f18e7964783b207826b2
            # Parent 0ee8bb6bd07f29fd51c7b753492ac727b69ac7ae
            Add vim.chdir and vim.fchdir functions, record them as attributes of os module

            diff -r 0ee8bb6bd07f -r 807b755f9898 runtime/doc/if_pyth.txt
            --- a/runtime/doc/if_pyth.txt Sat Jun 01 17:22:00 2013 +0400
            +++ b/runtime/doc/if_pyth.txt Sat Jun 01 19:55:13 2013 +0400
            @@ -180,6 +180,13 @@
            Like |strwidth()|: returns number of display cells str occupies, tab
            is counted as one cell.

            +vim.chdir(*args, **kwargs) *python-chdir*
            +vim.fchdir(*args, **kwargs) *python-fchdir*
            + Run os.chdir or os.fchdir, then all appropriate vim stuff.
            + Note: you should not use these functions directly, use os.chdir and
            + os.fchdir instead. Behavior of vim.fchdir is undefined in case
            + os.fchdir does not exist.
            +
            Error object of the "vim" module

            vim.error *python-error*
            diff -r 0ee8bb6bd07f -r 807b755f9898 src/ex_docmd.c
            --- a/src/ex_docmd.c Sat Jun 01 17:22:00 2013 +0400
            +++ b/src/ex_docmd.c Sat Jun 01 19:55:13 2013 +0400
            @@ -8182,6 +8182,33 @@
            }
            #endif

            + void
            +post_chdir(local)
            + int local;
            +{
            + vim_free(curwin->w_localdir);
            + if (local)
            + {
            + /* If still in global directory, need to remember current
            + * directory as global directory. */
            + if (globaldir == NULL && prev_dir != NULL)
            + globaldir = vim_strsave(prev_dir);
            + /* Remember this local directory for the window. */
            + if (mch_dirname(NameBuff, MAXPATHL) == OK)
            + curwin->w_localdir = vim_strsave(NameBuff);
            + }
            + else
            + {
            + /* We are now in the global directory, no need to remember its
            + * name. */
            + vim_free(globaldir);
            + globaldir = NULL;
            + curwin->w_localdir = NULL;
            + }
            +
            + shorten_fnames(TRUE);
            +}
            +

            /*
            * ":cd", ":lcd", ":chdir" and ":lchdir".
            @@ -8253,27 +8280,7 @@
            EMSG(_(e_failed));
            else
            {
            - vim_free(curwin->w_localdir);
            - if (eap->cmdidx == CMD_lcd || eap->cmdidx == CMD_lchdir)
            - {
            - /* If still in global directory, need to remember current
            - * directory as global directory. */
            - if (globaldir == NULL && prev_dir != NULL)
            - globaldir = vim_strsave(prev_dir);
            - /* Remember this local directory for the window. */
            - if (mch_dirname(NameBuff, MAXPATHL) == OK)
            - curwin->w_localdir = vim_strsave(NameBuff);
            - }
            - else
            - {
            - /* We are now in the global directory, no need to remember its
            - * name. */
            - vim_free(globaldir);
            - globaldir = NULL;
            - curwin->w_localdir = NULL;
            - }
            -
            - shorten_fnames(TRUE);
            + post_chdir(eap->cmdidx == CMD_lcd || eap->cmdidx == CMD_lchdir);

            /* Echo the new current directory if the command was typed. */
            if (KeyTyped || p_verbose >= 5)
            diff -r 0ee8bb6bd07f -r 807b755f9898 src/if_py_both.h
            --- a/src/if_py_both.h Sat Jun 01 17:22:00 2013 +0400
            +++ b/src/if_py_both.h Sat Jun 01 19:55:13 2013 +0400
            @@ -52,6 +52,10 @@

            static PyObject *globals;

            +static PyObject *py_chdir;
            +static PyObject *py_fchdir;
            +static PyObject *py_getcwd;
            +
            /*
            * obtain a lock on the Vim data structures
            */
            @@ -706,17 +710,84 @@
            );
            }

            + static PyObject *
            +_VimChdir(PyObject *_chdir, PyObject *args, PyObject *kwargs)
            +{
            + PyObject *r;
            + PyObject *newwd;
            + PyObject *todecref;
            + char_u *new_dir;
            +
            + if (!(r = PyObject_Call(_chdir, args, kwargs)))
            + return NULL;
            +
            + if (!(newwd = PyObject_CallFunctionObjArgs(py_getcwd, NULL)))
            + {
            + Py_DECREF(r);
            + return NULL;
            + }
            +
            + if (!(new_dir = StringToChars(newwd, &todecref)))
            + {
            + Py_DECREF(r);
            + Py_DECREF(newwd);
            + return NULL;
            + }
            +
            + VimTryStart();
            +
            + if (vim_chdir(new_dir))
            + {
            + Py_DECREF(r);
            + Py_DECREF(newwd);
            + Py_XDECREF(todecref);
            +
            + if (VimTryEnd())
            + return NULL;
            +
            + PyErr_SetVim(_("failed to change directory"));
            + return NULL;
            + }
            +
            + Py_DECREF(newwd);
            + Py_XDECREF(todecref);
            +
            + post_chdir(FALSE);
            +
            + if (VimTryEnd())
            + {
            + Py_DECREF(r);
            + return NULL;
            + }
            +
            + return r;
            +}
            +
            + static PyObject *
            +VimChdir(PyObject *self UNUSED, PyObject *args, PyObject *kwargs)
            +{
            + return _VimChdir(py_chdir, args, kwargs);
            +}
            +
            + static PyObject *
            +VimFchdir(PyObject *self UNUSED, PyObject *args, PyObject *kwargs)
            +{
            + return _VimChdir(py_fchdir, args, kwargs);
            +}
            +
            /*
            * Vim module - Definitions
            */

            static struct PyMethodDef VimMethods[] = {
            - /* name, function, calling, documentation */
            - {"command", VimCommand, METH_VARARGS, "Execute a Vim ex-mode command" },
            - {"eval", VimEval, METH_VARARGS, "Evaluate an expression using Vim evaluator" },
            - {"bindeval", VimEvalPy, METH_VARARGS, "Like eval(), but returns objects attached to vim ones"},
            - {"strwidth", VimStrwidth, METH_VARARGS, "Screen string width, counts <Tab> as having width 1"},
            - { NULL, NULL, 0, NULL }
            + /* name, function, calling, documentation */
            + {"command", VimCommand, METH_VARARGS, "Execute a Vim ex-mode command" },
            + {"eval", VimEval, METH_VARARGS, "Evaluate an expression using Vim evaluator" },
            + {"bindeval", VimEvalPy, METH_VARARGS, "Like eval(), but returns objects attached to vim ones"},
            + {"strwidth", VimStrwidth, METH_VARARGS, "Screen string width, counts <Tab> as having width 1"},
            + {"chdir", (PyCFunction)VimChdir, METH_VARARGS|METH_KEYWORDS, "Change directory"},
            + {"fchdir", (PyCFunction)VimFchdir, METH_VARARGS|METH_KEYWORDS, "Change directory"},
            + { NULL, NULL, 0, NULL }
            };

            /*
            @@ -5262,6 +5333,7 @@
            };

            typedef int (*object_adder)(PyObject *, const char *, PyObject *);
            +typedef PyObject *(*attr_getter)(PyObject *, const char *);

            #define ADD_OBJECT(m, name, obj) \
            if (add_object(m, name, obj)) \
            @@ -5276,9 +5348,10 @@
            }

            static int
            -populate_module(PyObject *m, object_adder add_object)
            +populate_module(PyObject *m, object_adder add_object, attr_getter get_attr)
            {
            int i;
            + PyObject *os;

            for (i = 0; i < (int)(sizeof(numeric_constants)
            / sizeof(struct numeric_constant));
            @@ -5305,5 +5378,27 @@
            ADD_CHECKED_OBJECT(m, "vvars", NEW_DICTIONARY(&vimvardict));
            ADD_CHECKED_OBJECT(m, "options",
            OptionsNew(SREQ_GLOBAL, NULL, dummy_check, NULL));
            +
            + if (!(os = PyImport_ImportModule("os")))
            + return -1;
            + ADD_OBJECT(m, "os", os);
            +
            + if (!(py_getcwd = PyObject_GetAttrString(os, "getcwd")))
            + return -1;
            + ADD_OBJECT(m, "_getcwd", py_getcwd)
            +
            + if (!(py_chdir = PyObject_GetAttrString(os, "chdir")))
            + return -1;
            + ADD_OBJECT(m, "_chdir", py_chdir);
            + if (PyObject_SetAttrString(os, "chdir", get_attr(m, "chdir")))
            + return -1;
            +
            + if ((py_fchdir = PyObject_GetAttrString(os, "fchdir")))
            + {
            + ADD_OBJECT(m, "_fchdir", py_fchdir);
            + if (PyObject_SetAttrString(os, "fchdir", get_attr(m, "fchdir")))
            + return -1;
            + }
            +
            return 0;
            }
            diff -r 0ee8bb6bd07f -r 807b755f9898 src/if_python.c
            --- a/src/if_python.c Sat Jun 01 17:22:00 2013 +0400
            +++ b/src/if_python.c Sat Jun 01 19:55:13 2013 +0400
            @@ -213,6 +213,7 @@
            # define PyObject_HasAttrString dll_PyObject_HasAttrString
            # define PyObject_SetAttrString dll_PyObject_SetAttrString
            # define PyObject_CallFunctionObjArgs dll_PyObject_CallFunctionObjArgs
            +# define PyObject_Call dll_PyObject_Call
            # define PyString_AsString dll_PyString_AsString
            # define PyString_AsStringAndSize dll_PyString_AsStringAndSize
            # define PyString_FromString dll_PyString_FromString
            @@ -346,6 +347,7 @@
            static int (*dll_PyObject_HasAttrString)(PyObject *, const char *);
            static PyObject* (*dll_PyObject_SetAttrString)(PyObject *, const char *, PyObject *);
            static PyObject* (*dll_PyObject_CallFunctionObjArgs)(PyObject *, ...);
            +static PyObject* (*dll_PyObject_Call)(PyObject *, PyObject *, PyObject *);
            static char*(*dll_PyString_AsString)(PyObject *);
            static int(*dll_PyString_AsStringAndSize)(PyObject *, char **, int *);
            static PyObject*(*dll_PyString_FromString)(const char *);
            @@ -510,6 +512,7 @@
            {"PyObject_HasAttrString", (PYTHON_PROC*)&dll_PyObject_HasAttrString},
            {"PyObject_SetAttrString", (PYTHON_PROC*)&dll_PyObject_SetAttrString},
            {"PyObject_CallFunctionObjArgs", (PYTHON_PROC*)&dll_PyObject_CallFunctionObjArgs},
            + {"PyObject_Call", (PYTHON_PROC*)&dll_PyObject_Call},
            {"PyString_AsString", (PYTHON_PROC*)&dll_PyString_AsString},
            {"PyString_AsStringAndSize", (PYTHON_PROC*)&dll_PyString_AsStringAndSize},
            {"PyString_FromString", (PYTHON_PROC*)&dll_PyString_FromString},
            @@ -1364,6 +1367,7 @@
            {
            PyObject *mod;
            PyObject *dict;
            + PyObject *os;

            /* The special value is removed from sys.path in Python_Init(). */
            static char *(argv[2]) = {"/must>not&exist/foo", NULL};
            @@ -1374,10 +1378,11 @@
            /* Set sys.argv[] to avoid a crash in warn(). */
            PySys_SetArgv(1, argv);

            - mod = Py_InitModule4("vim", VimMethods, (char *)NULL, (PyObject *)NULL, PYTHON_API_VERSION);
            + mod = Py_InitModule4("vim", VimMethods, (char *)NULL, (PyObject *)NULL,
            + PYTHON_API_VERSION);
            dict = PyModule_GetDict(mod);

            - return populate_module(dict, add_object);
            + return populate_module(dict, add_object, PyDict_GetItemString);
            }

            /*************************************************************************
            diff -r 0ee8bb6bd07f -r 807b755f9898 src/if_python3.c
            --- a/src/if_python3.c Sat Jun 01 17:22:00 2013 +0400
            +++ b/src/if_python3.c Sat Jun 01 19:55:13 2013 +0400
            @@ -174,6 +174,7 @@
            # define PyObject_HasAttrString py3_PyObject_HasAttrString
            # define PyObject_SetAttrString py3_PyObject_SetAttrString
            # define PyObject_CallFunctionObjArgs py3_PyObject_CallFunctionObjArgs
            +# define PyObject_Call py3_PyObject_Call
            # define PyEval_GetLocals py3_PyEval_GetLocals
            # define PyEval_GetGlobals py3_PyEval_GetGlobals
            # define PySys_SetObject py3_PySys_SetObject
            @@ -290,6 +291,7 @@
            static int (*py3_PyObject_HasAttrString)(PyObject *, const char *);
            static PyObject* (*py3_PyObject_SetAttrString)(PyObject *, const char *, PyObject *);
            static PyObject* (*py3_PyObject_CallFunctionObjArgs)(PyObject *, ...);
            +static PyObject* (*py3_PyObject_Call)(PyObject *, PyObject *, PyObject *);
            static PyObject* (*py3_PyEval_GetGlobals)();
            static PyObject* (*py3_PyEval_GetLocals)();
            static PyObject* (*py3_PyList_GetItem)(PyObject *, Py_ssize_t);
            @@ -446,6 +448,7 @@
            {"PyObject_HasAttrString", (PYTHON_PROC*)&py3_PyObject_HasAttrString},
            {"PyObject_SetAttrString", (PYTHON_PROC*)&py3_PyObject_SetAttrString},
            {"PyObject_CallFunctionObjArgs", (PYTHON_PROC*)&py3_PyObject_CallFunctionObjArgs},
            + {"PyObject_Call", (PYTHON_PROC*)&py3_PyObject_Call},
            {"PyEval_GetGlobals", (PYTHON_PROC*)&py3_PyEval_GetGlobals},
            {"PyEval_GetLocals", (PYTHON_PROC*)&py3_PyEval_GetLocals},
            {"PyList_GetItem", (PYTHON_PROC*)&py3_PyList_GetItem},
            @@ -1586,6 +1589,7 @@
            Py3Init_vim(void)
            {
            PyObject *mod;
            + PyObject *os;

            /* The special value is removed from sys.path in Python3_Init(). */
            static wchar_t *(argv[2]) = {L"/must>not&exist/foo", NULL};
            @@ -1600,7 +1604,7 @@
            if (mod == NULL)
            return NULL;

            - if (populate_module(mod, PyModule_AddObject))
            + if (populate_module(mod, PyModule_AddObject, PyObject_GetAttrString))
            return NULL;

            return mod;
            diff -r 0ee8bb6bd07f -r 807b755f9898 src/proto/ex_docmd.pro
            --- a/src/proto/ex_docmd.pro Sat Jun 01 17:22:00 2013 +0400
            +++ b/src/proto/ex_docmd.pro Sat Jun 01 19:55:13 2013 +0400
            @@ -53,4 +53,5 @@
            int put_line __ARGS((FILE *fd, char *s));
            void dialog_msg __ARGS((char_u *buff, char *format, char_u *fname));
            char_u *get_behave_arg __ARGS((expand_T *xp, int idx));
            +void post_chdir __ARGS((int local));
            /* vim: set ft=c : */
            diff -r 0ee8bb6bd07f -r 807b755f9898 src/testdir/test86.in
            --- a/src/testdir/test86.in Sat Jun 01 17:22:00 2013 +0400
            +++ b/src/testdir/test86.in Sat Jun 01 19:55:13 2013 +0400
            @@ -788,6 +788,20 @@
            :$put =string(pyeval('dl2'))
            :$put =string(pyeval('df(2)'))
            :"
            +:" Test chdir
            +py << EOF
            +import os
            +fnamemodify = vim.Function('fnamemodify')
            +cb.append(fnamemodify('.', ':p:h:t'))
            +cb.append(vim.eval('@%'))
            +os.chdir('..')
            +cb.append(fnamemodify('.', ':p:h:t'))
            +cb.append(vim.eval('@%').replace(os.path.sep, '/'))
            +os.chdir('testdir')
            +cb.append(fnamemodify('.', ':p:h:t'))
            +cb.append(vim.eval('@%'))
            +EOF
            +:"
            :" Test errors
            :fun F() dict
            :endfun
            diff -r 0ee8bb6bd07f -r 807b755f9898 src/testdir/test86.ok
            --- a/src/testdir/test86.ok Sat Jun 01 17:22:00 2013 +0400
            +++ b/src/testdir/test86.ok Sat Jun 01 19:55:13 2013 +0400
            @@ -429,6 +429,12 @@
            ['a', 'b', 'c']
            [2, 2]
            [2, 2]
            +testdir
            +test86.in
            +src
            +testdir/test86.in
            +testdir
            +test86.in
            > Output
            >> OutputSetattr
            del sys.stdout.softspace:(<type 'exceptions.AttributeError'>, AttributeError("can't delete OutputObject attributes",))
            diff -r 0ee8bb6bd07f -r 807b755f9898 src/testdir/test87.in
            --- a/src/testdir/test87.in Sat Jun 01 17:22:00 2013 +0400
            +++ b/src/testdir/test87.in Sat Jun 01 19:55:13 2013 +0400
            @@ -748,6 +748,20 @@
            :$put =string(py3eval('dl2'))
            :$put =string(py3eval('df(2)'))
            :"
            +:" Test chdir
            +py3 << EOF
            +import os
            +fnamemodify = vim.Function('fnamemodify')
            +cb.append(str(fnamemodify('.', ':p:h:t')))
            +cb.append(vim.eval('@%'))
            +os.chdir('..')
            +cb.append(str(fnamemodify('.', ':p:h:t')))
            +cb.append(vim.eval('@%').replace(os.path.sep, '/'))
            +os.chdir('testdir')
            +cb.append(str(fnamemodify('.', ':p:h:t')))
            +cb.append(vim.eval('@%'))
            +EOF
            +:"
            :" Test errors
            :fun F() dict
            :endfun
            diff -r 0ee8bb6bd07f -r 807b755f9898 src/testdir/test87.ok
            --- a/src/testdir/test87.ok Sat Jun 01 17:22:00 2013 +0400
            +++ b/src/testdir/test87.ok Sat Jun 01 19:55:13 2013 +0400
            @@ -418,6 +418,12 @@
            ['a', 'b', 'c']
            [2, 2]
            [2, 2]
            +b'testdir'
            +test87.in
            +b'src'
            +testdir/test87.in
            +b'testdir'
            +test87.in
            > Output
            >> OutputSetattr
            del sys.stdout.softspace:(<class 'AttributeError'>, AttributeError("can't delete OutputObject attributes",))

            --
            --
            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 vim_dev+unsubscribe@....
            For more options, visit https://groups.google.com/groups/opt_out.
          • ZyX
            # HG changeset patch # User ZyX # Date 1370096560 -14400 # Branch python-extended-4 # Node ID f322321a58b1a500736527ea82627fd65b2954bb # Parent
            Message 5 of 9 , Jun 1, 2013
            • 0 Attachment
              # HG changeset patch
              # User ZyX <kp-pav@...>
              # Date 1370096560 -14400
              # Branch python-extended-4
              # Node ID f322321a58b1a500736527ea82627fd65b2954bb
              # Parent 807b755f9898d68e4d93f18e7964783b207826b2
              Add vim.version and vim.version_info

              diff -r 807b755f9898 -r f322321a58b1 runtime/doc/if_pyth.txt
              --- a/runtime/doc/if_pyth.txt Sat Jun 01 19:55:13 2013 +0400
              +++ b/runtime/doc/if_pyth.txt Sat Jun 01 18:22:40 2013 +0400
              @@ -285,6 +285,19 @@
              Type of this object is available via "Options" attribute of vim
              module.

              +vim.version_info *python-version_info*
              + 3-tuple containing minor and major vim version and highest patch
              + number.
              +
              + Note: if third number in the tuple is 42 it does not mean patches 1-40
              + were included, it only means that highest included patch has
              + number 42. Use |has()| with |python-Function| to determine
              + whether specific patch was included.
              +
              +vim.version *python-version*
              + A string containing the vim version number plus additional information
              + about compiler.
              +
              Output from Python *python-output*
              Vim displays all Python code output in the Vim message area. Normal
              output appears as information messages, and error output appears as
              diff -r 807b755f9898 -r f322321a58b1 src/if_py_both.h
              --- a/src/if_py_both.h Sat Jun 01 19:55:13 2013 +0400
              +++ b/src/if_py_both.h Sat Jun 01 18:22:40 2013 +0400
              @@ -13,6 +13,8 @@
              * Common code for if_python.c and if_python3.c.
              */

              +#include "version.h"
              +
              #if PY_VERSION_HEX < 0x02050000
              typedef int Py_ssize_t; /* Python 2.4 and earlier don't have this type. */
              #endif
              @@ -5374,6 +5376,46 @@
              return -1;
              ADD_OBJECT(m, "error", VimError);

              + ADD_CHECKED_OBJECT(m, "version_info",
              + Py_BuildValue("(iii)", VIM_VERSION_MAJOR, VIM_VERSION_MINOR,
              + highest_patch()));
              + ADD_CHECKED_OBJECT(m, "version",
              + PyString_FromFormat("%i.%i (%s, %s %s)"
              + "\n[%s]"
              + , VIM_VERSION_MAJOR, VIM_VERSION_MINOR,
              +#ifdef FEAT_HUGE
              + "huge"
              +# else
              +# ifdef FEAT_NORMAL
              + "normal"
              +# else
              +# ifdef FEAT_SMALL
              + "small"
              +# else
              + "tiny"
              +# endif
              +# endif
              +#endif
              + , __DATE__, __TIME__,
              +#ifdef VMS
              + compiler_version
              +#else
              +# ifndef COMPILER
              +# ifdef __GNUC__
              + "GCC " __VERSION__
              +# else
              +# ifdef __cplusplus
              + "C++"
              +# else
              + "C"
              +# endif
              +# endif
              +# else
              + COMPILER
              +# endif
              +#endif
              + ));
              +
              ADD_CHECKED_OBJECT(m, "vars", NEW_DICTIONARY(&globvardict));
              ADD_CHECKED_OBJECT(m, "vvars", NEW_DICTIONARY(&vimvardict));
              ADD_CHECKED_OBJECT(m, "options",
              # HG changeset patch
              # User ZyX <kp-pav@...>
              # Date 1370115249 -14400
              # Branch python-extended-4
              # Node ID 7698aef182526761915fa4c3fa02080555a1b327
              # Parent f322321a58b1a500736527ea82627fd65b2954bb
              Improve vim.version

              diff -r f322321a58b1 -r 7698aef18252 src/if_py_both.h
              --- a/src/if_py_both.h Sat Jun 01 18:22:40 2013 +0400
              +++ b/src/if_py_both.h Sat Jun 01 23:34:09 2013 +0400
              @@ -5380,23 +5380,17 @@
              Py_BuildValue("(iii)", VIM_VERSION_MAJOR, VIM_VERSION_MINOR,
              highest_patch()));
              ADD_CHECKED_OBJECT(m, "version",
              - PyString_FromFormat("%i.%i (%s, %s %s)"
              + PyString_FromFormat(
              + VIM_VERSION_MAJOR_STR "." VIM_VERSION_MINOR_STR
              + " (" __DATE__ " " __TIME__ ")"
              "\n[%s]"
              - , VIM_VERSION_MAJOR, VIM_VERSION_MINOR,
              -#ifdef FEAT_HUGE
              - "huge"
              -# else
              -# ifdef FEAT_NORMAL
              - "normal"
              -# else
              -# ifdef FEAT_SMALL
              - "small"
              -# else
              - "tiny"
              -# endif
              -# endif
              + "\n" VIM_VERSION_TYPE " version "
              +#ifdef VIM_VERSION_GUI
              + "with " VIM_VERSION_GUI
              +#else
              + "without"
              #endif
              - , __DATE__, __TIME__,
              + " GUI",
              #ifdef VMS
              compiler_version
              #else
              diff -r f322321a58b1 -r 7698aef18252 src/version.c
              --- a/src/version.c Sat Jun 01 18:22:40 2013 +0400
              +++ b/src/version.c Sat Jun 01 23:34:09 2013 +0400
              @@ -3044,52 +3044,17 @@
              * internal variables in eval.c!
              */
              MSG(longVersion);
              +
              + MSG_PUTS(_("\n" VIM_VERSION_PLATFORM));
              #ifdef WIN3264
              # ifdef FEAT_GUI_W32
              -# if defined(_MSC_VER) && (_MSC_VER <= 1010)
              - /* Only MS VC 4.1 and earlier can do Win32s */
              - MSG_PUTS(_("\nMS-Windows 16/32-bit GUI version"));
              -# else
              -# ifdef _WIN64
              - MSG_PUTS(_("\nMS-Windows 64-bit GUI version"));
              -# else
              - MSG_PUTS(_("\nMS-Windows 32-bit GUI version"));
              -# endif
              -# endif
              if (gui_is_win32s())
              MSG_PUTS(_(" in Win32s mode"));
              -# ifdef FEAT_OLE
              +# ifdef FEAT_OLE
              MSG_PUTS(_(" with OLE support"));
              -# endif
              -# else
              -# ifdef _WIN64
              - MSG_PUTS(_("\nMS-Windows 64-bit console version"));
              -# else
              - MSG_PUTS(_("\nMS-Windows 32-bit console version"));
              # endif
              # endif
              #endif
              -#ifdef WIN16
              - MSG_PUTS(_("\nMS-Windows 16-bit version"));
              -#endif
              -#ifdef MSDOS
              -# ifdef DJGPP
              - MSG_PUTS(_("\n32-bit MS-DOS version"));
              -# else
              - MSG_PUTS(_("\n16-bit MS-DOS version"));
              -# endif
              -#endif
              -#ifdef MACOS
              -# ifdef MACOS_X
              -# ifdef MACOS_X_UNIX
              - MSG_PUTS(_("\nMacOS X (unix) version"));
              -# else
              - MSG_PUTS(_("\nMacOS X version"));
              -# endif
              -#else
              - MSG_PUTS(_("\nMacOS version"));
              -# endif
              -#endif

              #ifdef VMS
              MSG_PUTS(_("\nOpenVMS version"));
              @@ -3167,66 +3132,21 @@
              }
              #endif

              -#ifdef FEAT_HUGE
              - MSG_PUTS(_("\nHuge version "));
              -#else
              -# ifdef FEAT_BIG
              - MSG_PUTS(_("\nBig version "));
              + MSG_PUTS(_("\n" VIM_VERSION_TYPE " version "));
              +#ifdef VIM_VERSION_GUI
              +# ifdef MSWIN
              + MSG_PUTS(_("with GUI."));
              # else
              -# ifdef FEAT_NORMAL
              - MSG_PUTS(_("\nNormal version "));
              +# if defined(MACOS) && !defined(TARGET_API_MAC_CARBON) && !defined(TARGET_API_MAC_OSX)
              + MSG_PUTS(_("with (classic) GUI."));
              # else
              -# ifdef FEAT_SMALL
              - MSG_PUTS(_("\nSmall version "));
              -# else
              - MSG_PUTS(_("\nTiny version "));
              -# endif
              + MSG_PUTS(_("with " VIM_VERSION_GUI " GUI."));
              # endif
              # endif
              +#else
              + MSG_PUTS(_("without GUI."));
              #endif
              -#ifndef FEAT_GUI
              - MSG_PUTS(_("without GUI."));
              -#else
              -# ifdef FEAT_GUI_GTK
              -# ifdef FEAT_GUI_GNOME
              - MSG_PUTS(_("with GTK2-GNOME GUI."));
              -# else
              - MSG_PUTS(_("with GTK2 GUI."));
              -# endif
              -# else
              -# ifdef FEAT_GUI_MOTIF
              - MSG_PUTS(_("with X11-Motif GUI."));
              -# else
              -# ifdef FEAT_GUI_ATHENA
              -# ifdef FEAT_GUI_NEXTAW
              - MSG_PUTS(_("with X11-neXtaw GUI."));
              -# else
              - MSG_PUTS(_("with X11-Athena GUI."));
              -# endif
              -# else
              -# ifdef FEAT_GUI_PHOTON
              - MSG_PUTS(_("with Photon GUI."));
              -# else
              -# if defined(MSWIN)
              - MSG_PUTS(_("with GUI."));
              -# else
              -# if defined(TARGET_API_MAC_CARBON) && TARGET_API_MAC_CARBON
              - MSG_PUTS(_("with Carbon GUI."));
              -# else
              -# if defined(TARGET_API_MAC_OSX) && TARGET_API_MAC_OSX
              - MSG_PUTS(_("with Cocoa GUI."));
              -# else
              -# if defined(MACOS)
              - MSG_PUTS(_("with (classic) GUI."));
              -# endif
              -# endif
              -# endif
              -# endif
              -# endif
              -# endif
              -# endif
              -# endif
              -#endif
              +
              version_msg(_(" Features included (+) or not (-):\n"));

              list_features();
              diff -r f322321a58b1 -r 7698aef18252 src/version.h
              --- a/src/version.h Sat Jun 01 18:22:40 2013 +0400
              +++ b/src/version.h Sat Jun 01 23:34:09 2013 +0400
              @@ -27,6 +27,112 @@
              /* Used by MacOS port should be one of: development, alpha, beta, final */
              #define VIM_VERSION_RELEASE final

              +#ifdef FEAT_HUGE
              +# define VIM_VERSION_TYPE "Huge"
              +#else
              +# ifdef FEAT_BIG
              +# define VIM_VERSION_TYPE "Big"
              +# else
              +# ifdef FEAT_NORMAL
              +# define VIM_VERSION_TYPE "Normal"
              +# else
              +# ifdef FEAT_SMALL
              +# define VIM_VERSION_TYPE "Small"
              +# else
              +# define VIM_VERSION_TYPE "Tiny"
              +# endif
              +# endif
              +# endif
              +#endif
              +
              +#ifdef FEAT_GUI_GTK
              +# ifdef FEAT_GUI_GNOME
              +# define VIM_VERSION_GUI "GTK2-GNOME"
              +# else
              +# define VIM_VERSION_GUI "GTK2"
              +# endif
              +#else
              +# ifdef FEAT_GUI_MOTIF
              +# define VIM_VERSION_GUI "X11-Motif"
              +# else
              +# ifdef FEAT_GUI_ATHENA
              +# ifdef FEAT_GUI_NEXTAW
              +# define VIM_VERSION_GUI "X11-neXtaw"
              +# else
              +# define VIM_VERSION_GUI "X11-Athena"
              +# endif
              +# else
              +# ifdef FEAT_GUI_PHOTON
              +# define VIM_VERSION_GUI "Photon"
              +# else
              +# if defined(MSWIN)
              +# define "Windows"
              +# else
              +# if defined(TARGET_API_MAC_CARBON) && TARGET_API_MAC_CARBON
              +# define VIM_VERSION_GUI "Carbon"
              +# else
              +# if defined(TARGET_API_MAC_OSX) && TARGET_API_MAC_OSX
              +# define VIM_VERSION_GUI "Cocoa"
              +# else
              +# if defined(MACOS)
              +# define VIM_VERSION_GUI "Mac OS classic"
              +# endif
              +# endif
              +# endif
              +# endif
              +# endif
              +# endif
              +# endif
              +#endif
              +
              +#ifdef WIN3264
              +# ifdef FEAT_GUI_W32
              +# if defined(_MSC_VER) && (_MSC_VER <= 1010)
              +/* Only MS VC 4.1 and earlier can do Win32s */
              +# define VIM_VERSION_PLATFORM "MS-Windows 16/32-bit GUI"
              +# else
              +# ifdef _WIN64
              +# define VIM_VERSION_PLATFORM "MS-Windows 64-bit GUI"
              +# else
              +# define VIM_VERSION_PLATFORM "MS-Windows 32-bit GUI"
              +# endif
              +# endif
              +# else
              +# ifdef _WIN64
              +# define VIM_VERSION_PLATFORM "MS-Windows 64-bit console"
              +# else
              +# define VIM_VERSION_PLATFORM "MS-Windows 32-bit console"
              +# endif
              +# endif
              +#else
              +# ifdef WIN16
              +# define VIM_VERSION_PLATFORM "MS-Windows 16-bit"
              +# else
              +# ifdef MSDOS
              +# ifdef DJGPP
              +# define VIM_VERSION_PLATFORM "32-bit MS-DOS"
              +# else
              +# define VIM_VERSION_PLATFORM "16-bit MS-DOS"
              +# endif
              +# else
              +# ifdef MACOS
              +# ifdef MACOS_X
              +# ifdef MACOS_X_UNIX
              +# define VIM_VERSION_PLATFORM "MacOS X (unix)"
              +# else
              +# define VIM_VERSION_PLATFORM "MacOS X"
              +# endif
              +# else
              +# define VIM_VERSION_PLATFORM "MacOS"
              +# endif
              +# else
              +/* Should not really ever happen */
              +# define VIM_VERSION_PLATFORM "unknown"
              +# endif
              +# endif
              +# endif
              +#endif
              +
              /*
              * VIM_VERSION_NODOT is used for the runtime directory name.
              * VIM_VERSION_SHORT is copied into the swap file (max. length is 6 chars).

              --
              --
              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 vim_dev+unsubscribe@....
              For more options, visit https://groups.google.com/groups/opt_out.
            • ZyX
              # HG changeset patch # User ZyX # Date 1370141913 -14400 # Branch python-extended-4 # Node ID aeb6697bc6851e894681f9baad6ea9dc808c6714 # Parent
              Message 6 of 9 , Jun 1, 2013
              • 0 Attachment
                # HG changeset patch
                # User ZyX <kp-pav@...>
                # Date 1370141913 -14400
                # Branch python-extended-4
                # Node ID aeb6697bc6851e894681f9baad6ea9dc808c6714
                # Parent 7698aef182526761915fa4c3fa02080555a1b327
                Change the meaning of popitem: it should not accept any arguments

                diff -r 7698aef18252 -r aeb6697bc685 runtime/doc/if_pyth.txt
                --- a/runtime/doc/if_pyth.txt Sat Jun 01 23:34:09 2013 +0400
                +++ b/runtime/doc/if_pyth.txt Sun Jun 02 06:58:33 2013 +0400
                @@ -524,10 +524,9 @@
                Remove specified key from dictionary and return
                corresponding value. If key is not found and default is
                given returns the default, otherwise raises KeyError.
                - popitem(key)
                - Remove specified key from dictionary and return a pair
                - with it and the corresponding value. Returned key is a new
                - object.
                + popitem()
                + Remove random key from dictionary and return (key, value)
                + pair.
                has_key(key)
                Check whether dictionary contains specified key, similar
                to `key in dict`.
                diff -r 7698aef18252 -r aeb6697bc685 src/if_py_both.h
                --- a/src/if_py_both.h Sat Jun 01 23:34:09 2013 +0400
                +++ b/src/if_py_both.h Sun Jun 02 06:58:33 2013 +0400
                @@ -1135,17 +1135,6 @@
                dictitem_free(di);
                }

                - if (flags & DICT_FLAG_RETURN_PAIR)
                - {
                - PyObject *tmp = r;
                -
                - if (!(r = Py_BuildValue("(" Py_bytes_fmt "O)", hi->hi_key, tmp)))
                - {
                - Py_DECREF(tmp);
                - return NULL;
                - }
                - }
                -
                return r;
                }

                @@ -1532,15 +1521,38 @@
                }

                static PyObject *
                -DictionaryPopItem(DictionaryObject *self, PyObject *args)
                -{
                - PyObject *keyObject;
                -
                - if (!PyArg_ParseTuple(args, "O", &keyObject))
                +DictionaryPopItem(DictionaryObject *self)
                +{
                + hashitem_T *hi;
                + PyObject *r;
                + PyObject *valObject;
                + dictitem_T *di;
                +
                + if (self->dict->dv_hashtab.ht_used == 0)
                + {
                + PyErr_SetNone(PyExc_KeyError);
                return NULL;
                -
                - return _DictionaryItem(self, keyObject,
                - DICT_FLAG_POP|DICT_FLAG_RETURN_PAIR);
                + }
                +
                + hi = self->dict->dv_hashtab.ht_array;
                + while (HASHITEM_EMPTY(hi))
                + ++hi;
                +
                + di = dict_lookup(hi);
                +
                + if (!(valObject = ConvertToPyObject(&di->di_tv)))
                + return NULL;
                +
                + if (!(r = Py_BuildValue("(" Py_bytes_fmt "O)", hi->hi_key, valObject)))
                + {
                + Py_DECREF(valObject);
                + return NULL;
                + }
                +
                + hash_remove(&self->dict->dv_hashtab, hi);
                + dictitem_free(di);
                +
                + return r;
                }

                static PyObject *
                @@ -1580,7 +1592,7 @@
                {"update", (PyCFunction)DictionaryUpdate, METH_VARARGS|METH_KEYWORDS, ""},
                {"get", (PyCFunction)DictionaryGet, METH_VARARGS, ""},
                {"pop", (PyCFunction)DictionaryPop, METH_VARARGS, ""},
                - {"popitem", (PyCFunction)DictionaryPopItem, METH_VARARGS, ""},
                + {"popitem", (PyCFunction)DictionaryPopItem, METH_NOARGS, ""},
                {"has_key", (PyCFunction)DictionaryHasKey, METH_VARARGS, ""},
                {"__dir__", (PyCFunction)DictionaryDir, METH_NOARGS, ""},
                { NULL, NULL, 0, NULL}
                diff -r 7698aef18252 -r aeb6697bc685 src/testdir/test86.in
                --- a/src/testdir/test86.in Sat Jun 01 23:34:09 2013 +0400
                +++ b/src/testdir/test86.in Sun Jun 02 06:58:33 2013 +0400
                @@ -83,7 +83,7 @@
                :$put =pyeval('repr(''1'' in d)')
                :$put =pyeval('repr(list(iter(d)))')
                :$put =string(d)
                -:$put =pyeval('repr(d.popitem(''0''))')
                +:$put =pyeval('repr(d.popitem())')
                :$put =pyeval('repr(d.get(''0''))')
                :$put =pyeval('repr(list(iter(d)))')
                :"
                @@ -226,7 +226,7 @@
                em('d[u"a\\0b"]=1')

                em('d.pop("abc")')
                -em('d.popitem("abc")')
                +em('d.popitem()')
                EOF
                :$put =messages
                :unlet messages
                diff -r 7698aef18252 -r aeb6697bc685 src/testdir/test86.ok
                --- a/src/testdir/test86.ok Sat Jun 01 23:34:09 2013 +0400
                +++ b/src/testdir/test86.ok Sun Jun 02 06:58:33 2013 +0400
                @@ -26,7 +26,7 @@
                False
                ['0']
                {'0': -1}
                -('', -1L)
                +('0', -1L)
                None
                []
                [0, 1, 2, 3]
                @@ -672,7 +672,7 @@
                d.update((("a", FailingMappingKey()),)):(<type 'exceptions.NotImplementedError'>, NotImplementedError())
                <<< Finished
                >> DictionaryPopItem
                -d.popitem(1, 2):(<type 'exceptions.TypeError'>, TypeError('function takes exactly 1 argument (2 given)',))
                +d.popitem(1, 2):(<type 'exceptions.TypeError'>, TypeError('popitem() takes no arguments (2 given)',))
                >> DictionaryHasKey
                d.has_key():(<type 'exceptions.TypeError'>, TypeError('function takes exactly 1 argument (0 given)',))
                > List
                diff -r 7698aef18252 -r aeb6697bc685 src/testdir/test87.in
                --- a/src/testdir/test87.in Sat Jun 01 23:34:09 2013 +0400
                +++ b/src/testdir/test87.in Sun Jun 02 06:58:33 2013 +0400
                @@ -77,7 +77,7 @@
                :$put =py3eval('repr(''1'' in d)')
                :$put =py3eval('repr(list(iter(d)))')
                :$put =string(d)
                -:$put =py3eval('repr(d.popitem(''0''))')
                +:$put =py3eval('repr(d.popitem())')
                :$put =py3eval('repr(d.get(''0''))')
                :$put =py3eval('repr(list(iter(d)))')
                :"
                @@ -220,7 +220,7 @@
                em('d[b"a\\0b"]=1')

                em('d.pop("abc")')
                -em('d.popitem("abc")')
                +em('d.popitem()')
                EOF
                :$put =messages
                :unlet messages
                diff -r 7698aef18252 -r aeb6697bc685 src/testdir/test87.ok
                --- a/src/testdir/test87.ok Sat Jun 01 23:34:09 2013 +0400
                +++ b/src/testdir/test87.ok Sun Jun 02 06:58:33 2013 +0400
                @@ -26,7 +26,7 @@
                False
                [b'0']
                {'0': -1}
                -(b'', -1)
                +(b'0', -1)
                None
                []
                [0, 1, 2, 3]
                @@ -669,7 +669,7 @@
                d.update((("a", FailingMappingKey()),)):(<class 'NotImplementedError'>, NotImplementedError())
                <<< Finished
                >> DictionaryPopItem
                -d.popitem(1, 2):(<class 'TypeError'>, TypeError('function takes exactly 1 argument (2 given)',))
                +d.popitem(1, 2):(<class 'TypeError'>, TypeError('popitem() takes no arguments (2 given)',))
                >> DictionaryHasKey
                d.has_key():(<class 'TypeError'>, TypeError('function takes exactly 1 argument (0 given)',))
                > List

                --
                --
                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 vim_dev+unsubscribe@....
                For more options, visit https://groups.google.com/groups/opt_out.
              • Bram Moolenaar
                ... This breaks translations. And string concatenation doesn t work with older compilers. Should at least be split up into: MSG_PUTS( n );
                Message 7 of 9 , Jun 2, 2013
                • 0 Attachment
                  ZyX wrote:

                  > # HG changeset patch
                  > # User ZyX <kp-pav@...>
                  > # Date 1370096560 -14400
                  > # Branch python-extended-4
                  > # Node ID f322321a58b1a500736527ea82627fd65b2954bb
                  > # Parent 807b755f9898d68e4d93f18e7964783b207826b2
                  > Add vim.version and vim.version_info

                  I am not including this patch, for these reasons:

                  > + MSG_PUTS(_("\n" VIM_VERSION_PLATFORM));

                  This breaks translations. And string concatenation doesn't work with
                  older compilers. Should at least be split up into:

                  MSG_PUTS("\n");
                  MSG_PUTS(_(VIM_VERSION_PLATFORM));

                  All the messages in version.h need to have N_() around them so that they
                  can be translated.

                  You can't leave out the trailing "version", because after translation it
                  may appear somewhere else in the text.


                  --
                  The real
                  trick is
                  this: to
                  keep the
                  lines as
                  short as
                  possible
                  and keep
                  the size
                  the same
                  yet free
                  from the
                  need for
                  hyphena-
                  Dammit!! (Matthew Winn)

                  /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
                  /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
                  \\\ an exciting new programming language -- http://www.Zimbu.org ///
                  \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

                  --
                  --
                  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 vim_dev+unsubscribe@....
                  For more options, visit https://groups.google.com/groups/opt_out.
                Your message has been successfully submitted and would be delivered to recipients shortly.