Project

General

Profile

Actions

Bug #12192

closed

python3 modules treat strings incorrectly

Added by Alexander Pyhalov over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

When we try to use python3.5 pyzfs, we get

python3.5 /usr/lib/zfs/pyzfs.py allow alp mount data/zones
Traceback (most recent call last):
  File "/usr/lib/zfs/pyzfs.py", line 68, in <module>
    subfunc()
  File "/usr/lib/python3.5/vendor-packages/zfs/allow.py", line 395, in do_allow
    ds.set_fsacl(un, d)
  File "/usr/lib/python3.5/vendor-packages/zfs/dataset.py", line 198, in set_fsacl
    return zfs.ioctl.set_fsacl(self.name, un, d)
KeyError: 'ul$101'

This is because strings are treated incorrectly as bytes in ioctl.c. The following seems to fix the issue.

--- a/usr/src/lib/pyzfs/common/ioctl.c
+++ b/usr/src/lib/pyzfs/common/ioctl.c
@@ -144,7 +144,7 @@ dict2nvl(PyObject *d)

        while (PyDict_Next(d, &pos, &key, &value)) {
 #if PY_MAJOR_VERSION >= 3
-               char *keystr = PyBytes_AsString(key);
+               char *keystr = PyUnicode_AsUTF8(key);
 #else
                char *keystr = PyString_AsString(key);
 #endif
@@ -161,12 +161,12 @@ dict2nvl(PyObject *d)
                } else if (value == Py_None) {
                        err = nvlist_add_boolean(nvl, keystr);
 #if PY_MAJOR_VERSION >= 3
-               } else if (PyBytes_Check(value)) {
+               } else if (PyUnicode_Check(value)) {
 #else
                } else if (PyString_Check(value)) {
 #endif
 #if PY_MAJOR_VERSION >= 3
-                       char *valstr = PyBytes_AsString(value);
+                       char *valstr = PyUnicode_AsUTF8(value);
 #else
                        char *valstr = PyString_AsString(value);
 #endif


Related issues

Related to illumos gate - Bug #11522: illumos-gate has some runtime dependencies on Python 2.7Closed

Actions
Related to illumos gate - Bug #12215: pyzfs module does not build with python 3.7ClosedAndy Fiddaman

Actions
Actions

Also available in: Atom PDF