diff options
Diffstat (limited to 'usr/src/lib/pylibbe/common')
| -rw-r--r-- | usr/src/lib/pylibbe/common/libbe_py.c | 66 | ||||
| -rw-r--r-- | usr/src/lib/pylibbe/common/mapfile-py3 | 47 |
2 files changed, 96 insertions, 17 deletions
diff --git a/usr/src/lib/pylibbe/common/libbe_py.c b/usr/src/lib/pylibbe/common/libbe_py.c index fb5102bdb6..3b4a3a3c42 100644 --- a/usr/src/lib/pylibbe/common/libbe_py.c +++ b/usr/src/lib/pylibbe/common/libbe_py.c @@ -60,7 +60,6 @@ PyObject *beUnmount(PyObject *, PyObject *); PyObject *bePrintErrors(PyObject *, PyObject *); PyObject *beGetErrDesc(PyObject *, PyObject *); char *beMapLibbePyErrorToString(int); -void initlibbe_py(); static boolean_t convertBEInfoToDictionary(be_node_list_t *be, PyObject **listDict); @@ -204,8 +203,8 @@ beCopy(PyObject *self, PyObject *args) } while (PyDict_Next(beNameProperties, &pos, &pkey, &pvalue)) { if (!convertPyArgsToNvlist(&beProps, 2, - PyString_AsString(pkey), - PyString_AsString(pvalue))) { + PyBytes_AS_STRING(pkey), + PyBytes_AS_STRING(pvalue))) { nvlist_free(beProps); nvlist_free(beAttrs); return (Py_BuildValue("[iss]", BE_PY_ERR_NVLIST, @@ -833,21 +832,21 @@ convertBEInfoToDictionary(be_node_list_t *be, PyObject **listDict) { if (be->be_node_name != NULL) { if (PyDict_SetItemString(*listDict, BE_ATTR_ORIG_BE_NAME, - PyString_FromString(be->be_node_name)) != 0) { + PyUnicode_FromString(be->be_node_name)) != 0) { return (B_FALSE); } } if (be->be_rpool != NULL) { if (PyDict_SetItemString(*listDict, BE_ATTR_ORIG_BE_POOL, - PyString_FromString(be->be_rpool)) != 0) { + PyUnicode_FromString(be->be_rpool)) != 0) { return (B_FALSE); } } if (be->be_mntpt != NULL) { if (PyDict_SetItemString(*listDict, BE_ATTR_MOUNTPOINT, - PyString_FromString(be->be_mntpt)) != 0) { + PyUnicode_FromString(be->be_mntpt)) != 0) { return (B_FALSE); } } @@ -881,7 +880,7 @@ convertBEInfoToDictionary(be_node_list_t *be, PyObject **listDict) if (be->be_root_ds != NULL) { if (PyDict_SetItemString(*listDict, BE_ATTR_ROOT_DS, - PyString_FromString(be->be_root_ds)) != 0) { + PyUnicode_FromString(be->be_root_ds)) != 0) { return (B_FALSE); } } @@ -895,14 +894,14 @@ convertBEInfoToDictionary(be_node_list_t *be, PyObject **listDict) if (be->be_policy_type != NULL) { if (PyDict_SetItemString(*listDict, BE_ATTR_POLICY, - PyString_FromString(be->be_policy_type)) != 0) { + PyUnicode_FromString(be->be_policy_type)) != 0) { return (B_FALSE); } } if (be->be_uuid_str != NULL) { if (PyDict_SetItemString(*listDict, BE_ATTR_UUID_STR, - PyString_FromString(be->be_uuid_str)) != 0) { + PyUnicode_FromString(be->be_uuid_str)) != 0) { return (B_FALSE); } } @@ -915,7 +914,7 @@ convertDatasetInfoToDictionary(be_dataset_list_t *ds, PyObject **listDict) { if (ds->be_dataset_name != NULL) { if (PyDict_SetItemString(*listDict, BE_ATTR_DATASET, - PyString_FromString(ds->be_dataset_name)) != 0) { + PyUnicode_FromString(ds->be_dataset_name)) != 0) { return (B_FALSE); } } @@ -927,7 +926,7 @@ convertDatasetInfoToDictionary(be_dataset_list_t *ds, PyObject **listDict) if (ds->be_ds_mntpt != NULL) { if (PyDict_SetItemString(*listDict, BE_ATTR_MOUNTPOINT, - PyString_FromString(ds->be_ds_mntpt)) != 0) { + PyUnicode_FromString(ds->be_ds_mntpt)) != 0) { return (B_FALSE); } } @@ -947,14 +946,14 @@ convertDatasetInfoToDictionary(be_dataset_list_t *ds, PyObject **listDict) if (ds->be_dataset_name != 0) { if (PyDict_SetItemString(*listDict, BE_ATTR_DATASET, - PyString_FromString(ds->be_dataset_name)) != 0) { + PyUnicode_FromString(ds->be_dataset_name)) != 0) { return (B_FALSE); } } if (ds->be_ds_plcy_type != NULL) { if (PyDict_SetItemString(*listDict, BE_ATTR_POLICY, - PyString_FromString(ds->be_ds_plcy_type)) != 0) { + PyUnicode_FromString(ds->be_ds_plcy_type)) != 0) { return (B_FALSE); } } @@ -974,7 +973,7 @@ convertSnapshotInfoToDictionary(be_snapshot_list_t *ss, PyObject **listDict) { if (ss->be_snapshot_name != NULL) { if (PyDict_SetItemString(*listDict, BE_ATTR_SNAP_NAME, - PyString_FromString(ss->be_snapshot_name)) != 0) { + PyUnicode_FromString(ss->be_snapshot_name)) != 0) { return (B_FALSE); } } @@ -988,7 +987,7 @@ convertSnapshotInfoToDictionary(be_snapshot_list_t *ss, PyObject **listDict) if (ss->be_snapshot_type != NULL) { if (PyDict_SetItemString(*listDict, BE_ATTR_POLICY, - PyString_FromString(ss->be_snapshot_type)) != 0) { + PyUnicode_FromString(ss->be_snapshot_type)) != 0) { return (B_FALSE); } } @@ -1103,9 +1102,42 @@ static struct PyMethodDef libbeMethods[] = { {NULL, NULL, 0, NULL} }; -void -initlibbe_py() +#if PY_MAJOR_VERSION >= 3 +static struct PyModuleDef libbe_module = { + PyModuleDef_HEAD_INIT, + "libbe_py", + NULL, + -1, + libbeMethods +}; +#endif + +static PyObject * +moduleinit() { /* PyMODINIT_FUNC; */ +#if PY_MAJOR_VERSION >= 3 + return (PyModule_Create(&libbe_module)); +#else + /* + * Python2 module initialisation functions are void and may not return + * a value. However, they will set an exception if appropriate. + */ (void) Py_InitModule("libbe_py", libbeMethods); + return (NULL); +#endif +} + +#if PY_MAJOR_VERSION >= 3 +PyMODINIT_FUNC +PyInit_libbe_py(void) +{ + return (moduleinit()); +} +#else +PyMODINIT_FUNC +initlibbe_py(void) +{ + (void) moduleinit(); } +#endif diff --git a/usr/src/lib/pylibbe/common/mapfile-py3 b/usr/src/lib/pylibbe/common/mapfile-py3 new file mode 100644 index 0000000000..ea39f9cfd8 --- /dev/null +++ b/usr/src/lib/pylibbe/common/mapfile-py3 @@ -0,0 +1,47 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2018 OmniOS Community Edition (OmniOSce) Association. +# + +# +# MAPFILE HEADER START +# +# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. +# Object versioning must comply with the rules detailed in +# +# usr/src/lib/README.mapfiles +# +# You should not be making modifications here until you've read the most current +# copy of that file. If you need help, contact a gatekeeper for guidance. +# +# MAPFILE HEADER END +# + +$mapfile_version 2 + +SYMBOL_VERSION SUNWprivate { + global: + PyInit_libbe_py; + local: + *; +}; |
