summaryrefslogtreecommitdiffstats
path: root/src/if_py_both.h
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-01-12 22:47:31 +0100
committerBram Moolenaar <Bram@vim.org>2019-01-12 22:47:31 +0100
commit6e5ea8d2a995b32bbc5972edc4f827b959f2702f (patch)
treeb1ad7d6a83f53220227122719d5eb97dd32ff1e6 /src/if_py_both.h
parente3c74d249ac36404d8af25f74baf335d143b30e3 (diff)
patch 8.1.0735: cannot handle binary datav8.1.0735
Problem: Cannot handle binary data. Solution: Add the Blob type. (Yasuhiro Matsumoto, closes #3638)
Diffstat (limited to 'src/if_py_both.h')
-rw-r--r--src/if_py_both.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/if_py_both.h b/src/if_py_both.h
index 1c159260c7..0b8a3600e4 100644
--- a/src/if_py_both.h
+++ b/src/if_py_both.h
@@ -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: