summaryrefslogtreecommitdiff
path: root/usr/src/lib/pylibbe/common/libbe_py.c
diff options
context:
space:
mode:
authorAlexander Pyhalov <apyhalov@gmail.com>2020-01-14 21:23:25 +0300
committerDan McDonald <danmcd@joyent.com>2020-01-15 15:23:30 -0500
commitb0858fdc3790ef1d1f955bd584621c6fd539050d (patch)
tree65d9745af0d5ab456750a0d9fc2493ebd205523c /usr/src/lib/pylibbe/common/libbe_py.c
parente25cb0e77ab84d3147918b8aef1f5161fbccb30e (diff)
downloadillumos-joyent-b0858fdc3790ef1d1f955bd584621c6fd539050d.tar.gz
11522 illumos-gate has some runtime dependencies on Python 2.7
12192 python3 modules treat strings incorrectly Reviewed by: Andrew Stormont <andyjstormont@gmail.com> Reviewed by: Andy Fiddaman <omnios@citrus-it.co.uk> Reviewed by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org> Reviewed by: Toomas Soome <tsoome@me.com> Approved by: Dan McDonald <danmcd@joyent.com>
Diffstat (limited to 'usr/src/lib/pylibbe/common/libbe_py.c')
-rw-r--r--usr/src/lib/pylibbe/common/libbe_py.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/usr/src/lib/pylibbe/common/libbe_py.c b/usr/src/lib/pylibbe/common/libbe_py.c
index 6e35228128..6402e0daad 100644
--- a/usr/src/lib/pylibbe/common/libbe_py.c
+++ b/usr/src/lib/pylibbe/common/libbe_py.c
@@ -202,9 +202,15 @@ beCopy(PyObject *self, PyObject *args)
NULL, NULL));
}
while (PyDict_Next(beNameProperties, &pos, &pkey, &pvalue)) {
+#if PY_MAJOR_VERSION >= 3
+ if (!convertPyArgsToNvlist(&beProps, 2,
+ PyUnicode_AsUTF8(pkey),
+ PyUnicode_AsUTF8(pvalue))) {
+#else
if (!convertPyArgsToNvlist(&beProps, 2,
- PyBytes_AS_STRING(pkey),
- PyBytes_AS_STRING(pvalue))) {
+ PyString_AsString(pkey),
+ PyString_AsString(pvalue))) {
+#endif
nvlist_free(beProps);
nvlist_free(beAttrs);
return (Py_BuildValue("[iss]", BE_PY_ERR_NVLIST,