0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.1.0735: cannot handle binary data

Problem:    Cannot handle binary data.
Solution:   Add the Blob type. (Yasuhiro Matsumoto, closes #3638)
This commit is contained in:
Bram Moolenaar
2019-01-12 22:47:31 +01:00
parent e3c74d249a
commit 6e5ea8d2a9
27 changed files with 1354 additions and 114 deletions

View File

@@ -867,6 +867,10 @@ VimToPython(typval_T *our_tv, int depth, PyObject *lookup_dict)
}
return ret;
}
else if (our_tv->v_type == VAR_BLOB)
ret = PyBytes_FromStringAndSize(
(char*) our_tv->vval.v_blob->bv_ga.ga_data,
(Py_ssize_t) our_tv->vval.v_blob->bv_ga.ga_len);
else
{
Py_INCREF(Py_None);
@@ -6394,6 +6398,10 @@ ConvertToPyObject(typval_T *tv)
tv->vval.v_partial->pt_argc, argv,
tv->vval.v_partial->pt_dict,
tv->vval.v_partial->pt_auto);
case VAR_BLOB:
return PyBytes_FromStringAndSize(
(char*) tv->vval.v_blob->bv_ga.ga_data,
(Py_ssize_t) tv->vval.v_blob->bv_ga.ga_len);
case VAR_UNKNOWN:
case VAR_CHANNEL:
case VAR_JOB: