Mercurial > vim
comparison src/if_py_both.h @ 4597:00eecb2f8e3e v7.3.1046
updated for version 7.3.1046
Problem: Python: Using Py_BuildValue for building strings.
Solution: Python patch 7 and 7.5: Replace Py_BuildValue with
PyString_FromString. (ZyX)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Wed, 29 May 2013 22:26:18 +0200 |
parents | 29b2be2bba0d |
children | 89bec74fd793 |
comparison
equal
deleted
inserted
replaced
4596:baf9bfa3df3d | 4597:00eecb2f8e3e |
---|---|
440 } | 440 } |
441 } | 441 } |
442 | 442 |
443 if (our_tv->v_type == VAR_STRING) | 443 if (our_tv->v_type == VAR_STRING) |
444 { | 444 { |
445 result = Py_BuildValue("s", our_tv->vval.v_string == NULL | 445 result = PyString_FromString(our_tv->vval.v_string == NULL |
446 ? "" : (char *)our_tv->vval.v_string); | 446 ? "" : (char *)our_tv->vval.v_string); |
447 } | 447 } |
448 else if (our_tv->v_type == VAR_NUMBER) | 448 else if (our_tv->v_type == VAR_NUMBER) |
449 { | 449 { |
450 char buf[NUMBUFLEN]; | 450 char buf[NUMBUFLEN]; |
451 | 451 |
452 /* For backwards compatibility numbers are stored as strings. */ | 452 /* For backwards compatibility numbers are stored as strings. */ |
453 sprintf(buf, "%ld", (long)our_tv->vval.v_number); | 453 sprintf(buf, "%ld", (long)our_tv->vval.v_number); |
454 result = Py_BuildValue("s", buf); | 454 result = PyString_FromString((char *) buf); |
455 } | 455 } |
456 # ifdef FEAT_FLOAT | 456 # ifdef FEAT_FLOAT |
457 else if (our_tv->v_type == VAR_FLOAT) | 457 else if (our_tv->v_type == VAR_FLOAT) |
458 { | 458 { |
459 char buf[NUMBUFLEN]; | 459 char buf[NUMBUFLEN]; |
460 | 460 |
461 sprintf(buf, "%f", our_tv->vval.v_float); | 461 sprintf(buf, "%f", our_tv->vval.v_float); |
462 result = Py_BuildValue("s", buf); | 462 result = PyString_FromString((char *) buf); |
463 } | 463 } |
464 # endif | 464 # endif |
465 else if (our_tv->v_type == VAR_LIST) | 465 else if (our_tv->v_type == VAR_LIST) |
466 { | 466 { |
467 list_T *list = our_tv->vval.v_list; | 467 list_T *list = our_tv->vval.v_list; |
3254 | 3254 |
3255 static PyObject * | 3255 static PyObject * |
3256 BufferAttr(BufferObject *self, char *name) | 3256 BufferAttr(BufferObject *self, char *name) |
3257 { | 3257 { |
3258 if (strcmp(name, "name") == 0) | 3258 if (strcmp(name, "name") == 0) |
3259 return Py_BuildValue("s", self->buf->b_ffname); | 3259 return PyString_FromString((self->buf->b_ffname == NULL |
3260 ? "" : (char *) self->buf->b_ffname)); | |
3260 else if (strcmp(name, "number") == 0) | 3261 else if (strcmp(name, "number") == 0) |
3261 return Py_BuildValue(Py_ssize_t_fmt, self->buf->b_fnum); | 3262 return Py_BuildValue(Py_ssize_t_fmt, self->buf->b_fnum); |
3262 else if (strcmp(name, "vars") == 0) | 3263 else if (strcmp(name, "vars") == 0) |
3263 return DictionaryNew(self->buf->b_vars); | 3264 return DictionaryNew(self->buf->b_vars); |
3264 else if (strcmp(name, "options") == 0) | 3265 else if (strcmp(name, "options") == 0) |