aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Miroshnychenko <roman.miroshnychenko@comeet.co>2020-10-19 11:36:32 +0300
committerRoman Miroshnychenko <roman.miroshnychenko@comeet.co>2020-10-22 15:53:33 +0300
commit61d3a2e253b9581ab1764d36a57e042540c38dcb (patch)
treefe556d6dd78e3bd900bcaf07fa94e9d7428e3384
parent588a38221d1fb101138cbd9d086280fd85b31978 (diff)
Accept Python bytes type into a buffer
-rw-r--r--xbmc/interfaces/python/typemaps/python.buffer.intm11
1 files changed, 10 insertions, 1 deletions
diff --git a/xbmc/interfaces/python/typemaps/python.buffer.intm b/xbmc/interfaces/python/typemaps/python.buffer.intm
index 57f350d81f..f074b2bad2 100644
--- a/xbmc/interfaces/python/typemaps/python.buffer.intm
+++ b/xbmc/interfaces/python/typemaps/python.buffer.intm
@@ -16,6 +16,15 @@
${api}.put(str, size);
${api}.flip(); // prepare the buffer for reading from
}
+ else if (PyBytes_Check(${slarg}))
+ {
+ Py_ssize_t pysize = PyBytes_GET_SIZE(${slarg});
+ const char* str = PyBytes_AS_STRING(${slarg});
+ size_t size = static_cast<size_t>(pysize);
+ ${api}.allocate(size);
+ ${api}.put(str, size);
+ ${api}.flip(); // prepare the buffer for reading from
+ }
else if (PyByteArray_Check(${slarg}))
{
size_t size = PyByteArray_Size(${slarg});
@@ -24,4 +33,4 @@
${api}.flip(); // prepare the buffer for reading from
}
else
- throw XBMCAddon::WrongTypeException("argument \"%s\" for \"%s\" must be a string or a bytearray", "${api}", "${method.@name}"); \ No newline at end of file
+ throw XBMCAddon::WrongTypeException("argument \"%s\" for \"%s\" must be a string, bytes or a bytearray", "${api}", "${method.@name}"); \ No newline at end of file