| To: vim_dev@googlegroups.com |
| Subject: Patch 7.3.910 |
| Fcc: outbox |
| From: Bram Moolenaar <Bram@moolenaar.net> |
| Mime-Version: 1.0 |
| Content-Type: text/plain; charset=UTF-8 |
| Content-Transfer-Encoding: 8bit |
| |
| |
| Patch 7.3.910 |
| Problem: Python code in #ifdef branches with only minor differences. |
| Solution: Merge the #ifdef branches. (ZyX) |
| Files: src/if_py_both.h, src/if_python.c |
| |
| |
| |
| |
| |
| *** 2853,2859 **** |
| tv->v_type = VAR_FUNC; |
| func_ref(tv->vval.v_string); |
| } |
| - #if PY_MAJOR_VERSION >= 3 |
| else if (PyBytes_Check(obj)) |
| { |
| char_u *result; |
| --- 2853,2858 ---- |
| |
| *** 2873,2902 **** |
| 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; |
| --- 2872,2877 ---- |
| |
| *** 2915,2934 **** |
| |
| 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; |
| ! } |
| else if (PyInt_Check(obj)) |
| { |
| tv->v_type = VAR_NUMBER; |
| --- 2890,2896 ---- |
| |
| tv->v_type = VAR_STRING; |
| } |
| ! #if PY_MAJOR_VERSION < 3 |
| else if (PyInt_Check(obj)) |
| { |
| tv->v_type = VAR_NUMBER; |
| |
| |
| |
| *** 59,64 **** |
| --- 59,65 ---- |
| static void init_structs(void); |
| |
| #define PyBytes_FromString PyString_FromString |
| + #define PyBytes_Check PyString_Check |
| |
| /* No-op conversion functions, use with care! */ |
| #define PyString_AsBytes(obj) (obj) |
| |
| |
| |
| *** 730,731 **** |
| --- 730,733 ---- |
| { /* Add new patch number below this line */ |
| + /**/ |
| + 910, |
| /**/ |
| |
| -- |
| Your fault: core dumped |
| |
| /// Bram Moolenaar -- Bram@Moolenaar.net -- 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 /// |