Python3 patch update
This commit is contained in:
parent
9e592fe1d9
commit
4b1b37eb16
@ -1,6 +1,6 @@
|
||||
diff -urNp net-snmp-5.7.3/configure pnew/configure
|
||||
--- net-snmp-5.7.3/configure 2018-05-09 13:53:32.757997551 +0200
|
||||
+++ pnew/configure 2018-05-02 12:09:38.592944958 +0200
|
||||
diff -urNp old/configure new/configure
|
||||
--- old/configure 2018-05-29 08:27:03.342448982 +0200
|
||||
+++ new/configure 2018-05-29 08:27:15.317394863 +0200
|
||||
@@ -6412,8 +6412,8 @@ $as_echo "no" >&6; }
|
||||
fi
|
||||
|
||||
@ -12,9 +12,9 @@ diff -urNp net-snmp-5.7.3/configure pnew/configure
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
|
||||
$as_echo_n "checking for $ac_word... " >&6; }
|
||||
if ${ac_cv_path_PYTHONPROG+:} false; then :
|
||||
diff -urNp net-snmp-5.7.3/configure.d/config_os_progs pnew/configure.d/config_os_progs
|
||||
--- net-snmp-5.7.3/configure.d/config_os_progs 2014-12-08 21:23:22.000000000 +0100
|
||||
+++ pnew/configure.d/config_os_progs 2018-05-02 11:54:39.816551980 +0200
|
||||
diff -urNp old/configure.d/config_os_progs new/configure.d/config_os_progs
|
||||
--- old/configure.d/config_os_progs 2018-05-29 08:27:03.368448865 +0200
|
||||
+++ new/configure.d/config_os_progs 2018-05-29 08:27:15.341394754 +0200
|
||||
@@ -57,7 +57,7 @@ AC_PATH_PROG(AUTOCONF, autoconf)
|
||||
AC_PATH_PROG(AUTOHEADER, autoheader)
|
||||
AC_PATH_PROG([PERLPROG], perl)
|
||||
@ -24,9 +24,9 @@ diff -urNp net-snmp-5.7.3/configure.d/config_os_progs pnew/configure.d/config_os
|
||||
|
||||
AC_PATH_PROG([UNAMEPROG], uname)
|
||||
AC_DEFINE_UNQUOTED(UNAMEPROG,"$UNAMEPROG", [Where is the uname command])
|
||||
diff -urNp net-snmp-5.7.3/Makefile.in pnew/Makefile.in
|
||||
--- net-snmp-5.7.3/Makefile.in 2014-12-08 21:23:22.000000000 +0100
|
||||
+++ pnew/Makefile.in 2018-05-02 10:12:12.496567598 +0200
|
||||
diff -urNp old/Makefile.in new/Makefile.in
|
||||
--- old/Makefile.in 2018-05-29 08:27:03.340448991 +0200
|
||||
+++ new/Makefile.in 2018-05-29 08:27:15.307394908 +0200
|
||||
@@ -222,7 +222,7 @@ perlcleanfeatures:
|
||||
|
||||
# python specific build rules
|
||||
@ -36,19 +36,64 @@ diff -urNp net-snmp-5.7.3/Makefile.in pnew/Makefile.in
|
||||
pythonmodules: subdirs
|
||||
@(dir=`pwd`; cd python; $(PYMAKE) build --basedir=$$dir) ; \
|
||||
if test $$? != 0 ; then \
|
||||
diff -urNp net-snmp-5.7.3/python/netsnmp/client_intf.c pnew/python/netsnmp/client_intf.c
|
||||
--- net-snmp-5.7.3/python/netsnmp/client_intf.c 2014-12-08 21:23:22.000000000 +0100
|
||||
+++ pnew/python/netsnmp/client_intf.c 2018-05-02 11:19:54.447257954 +0200
|
||||
@@ -979,7 +979,7 @@ py_netsnmp_attr_string(PyObject *obj, ch
|
||||
diff -urNp old/python/netsnmp/client_intf.c new/python/netsnmp/client_intf.c
|
||||
--- old/python/netsnmp/client_intf.c 2018-05-29 08:27:03.390448765 +0200
|
||||
+++ new/python/netsnmp/client_intf.c 2018-05-31 10:28:43.202727021 +0200
|
||||
@@ -1,11 +1,5 @@
|
||||
#include <Python.h>
|
||||
|
||||
-#if PY_VERSION_HEX < 0x02050000
|
||||
-typedef int Py_ssize_t;
|
||||
-#define PY_SSIZE_T_MAX INT_MAX
|
||||
-#define PY_SSIZE_T_MIN INT_MIN
|
||||
-#endif
|
||||
-
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <sys/types.h>
|
||||
@@ -978,8 +972,40 @@ py_netsnmp_attr_string(PyObject *obj, ch
|
||||
if (obj && attr_name && PyObject_HasAttrString(obj, attr_name)) {
|
||||
PyObject *attr = PyObject_GetAttrString(obj, attr_name);
|
||||
if (attr) {
|
||||
+ *val = PyUnicode_AsUTF8AndSize(attr, len);
|
||||
+ Py_DECREF(attr);
|
||||
+ return 0;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+py_netsnmp_attr_set_bytes(PyObject *obj, char *attr_name,
|
||||
+ char *val, size_t len)
|
||||
+{
|
||||
+ int ret = -1;
|
||||
+ if (obj && attr_name) {
|
||||
+ PyObject* val_obj = (val ?
|
||||
+ PyBytes_FromStringAndSize(val, len) :
|
||||
+ Py_BuildValue(""));
|
||||
+ ret = PyObject_SetAttrString(obj, attr_name, val_obj);
|
||||
+ Py_DECREF(val_obj);
|
||||
+ }
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+py_netsnmp_attr_bytes(PyObject *obj, char * attr_name, char **val,
|
||||
+ Py_ssize_t *len)
|
||||
+{
|
||||
+ *val = NULL;
|
||||
+ if (obj && attr_name && PyObject_HasAttrString(obj, attr_name)) {
|
||||
+ PyObject *attr = PyObject_GetAttrString(obj, attr_name);
|
||||
+ if (attr) {
|
||||
int retval;
|
||||
- retval = PyString_AsStringAndSize(attr, val, len);
|
||||
+ retval = PyBytes_AsStringAndSize(attr, val, len);
|
||||
Py_DECREF(attr);
|
||||
return retval;
|
||||
}
|
||||
@@ -996,7 +996,7 @@ py_netsnmp_attr_long(PyObject *obj, char
|
||||
@@ -996,7 +1022,7 @@ py_netsnmp_attr_long(PyObject *obj, char
|
||||
if (obj && attr_name && PyObject_HasAttrString(obj, attr_name)) {
|
||||
PyObject *attr = PyObject_GetAttrString(obj, attr_name);
|
||||
if (attr) {
|
||||
@ -57,7 +102,7 @@ diff -urNp net-snmp-5.7.3/python/netsnmp/client_intf.c pnew/python/netsnmp/clien
|
||||
Py_DECREF(attr);
|
||||
}
|
||||
}
|
||||
@@ -1079,11 +1079,11 @@ __py_netsnmp_update_session_errors(PyObj
|
||||
@@ -1079,11 +1105,11 @@ __py_netsnmp_update_session_errors(PyObj
|
||||
|
||||
py_netsnmp_attr_set_string(session, "ErrorStr", err_str, STRLEN(err_str));
|
||||
|
||||
@ -71,7 +116,52 @@ diff -urNp net-snmp-5.7.3/python/netsnmp/client_intf.c pnew/python/netsnmp/clien
|
||||
PyObject_SetAttrString(session, "ErrorInd", tmp_for_conversion);
|
||||
Py_DECREF(tmp_for_conversion);
|
||||
}
|
||||
@@ -2607,10 +2607,22 @@ static PyMethodDef ClientMethods[] = {
|
||||
@@ -1588,7 +1614,7 @@ netsnmp_get(PyObject *self, PyObject *ar
|
||||
len = __snprint_value((char *) str_buf, sizeof(str_buf),
|
||||
vars, tp, type, sprintval_flag);
|
||||
str_buf[len] = '\0';
|
||||
- py_netsnmp_attr_set_string(varbind, "val", (char *) str_buf, len);
|
||||
+ py_netsnmp_attr_set_bytes(varbind, "val", (char *) str_buf, len);
|
||||
|
||||
/* save in return tuple as well */
|
||||
if ((type == SNMP_ENDOFMIBVIEW) ||
|
||||
@@ -1808,7 +1834,7 @@ netsnmp_getnext(PyObject *self, PyObject
|
||||
vars, tp, type, sprintval_flag);
|
||||
str_buf[len] = '\0';
|
||||
|
||||
- py_netsnmp_attr_set_string(varbind, "val", (char *) str_buf, len);
|
||||
+ py_netsnmp_attr_set_bytes(varbind, "val", (char *) str_buf, len);
|
||||
|
||||
/* save in return tuple as well */
|
||||
if ((type == SNMP_ENDOFMIBVIEW) ||
|
||||
@@ -2138,7 +2164,7 @@ netsnmp_walk(PyObject *self, PyObject *a
|
||||
vars,tp,type,sprintval_flag);
|
||||
str_buf[len] = '\0';
|
||||
|
||||
- py_netsnmp_attr_set_string(varbind, "val", (char *) str_buf,
|
||||
+ py_netsnmp_attr_set_bytes(varbind, "val", (char *) str_buf,
|
||||
len);
|
||||
|
||||
/* push the varbind onto the return varbinds */
|
||||
@@ -2386,7 +2412,7 @@ netsnmp_getbulk(PyObject *self, PyObject
|
||||
|
||||
__get_type_str(type, type_str);
|
||||
|
||||
- py_netsnmp_attr_set_string(varbind, "type", type_str,
|
||||
+ py_netsnmp_attr_set_bytes(varbind, "type", type_str,
|
||||
strlen(type_str));
|
||||
|
||||
len = __snprint_value((char *) str_buf, sizeof(str_buf),
|
||||
@@ -2527,7 +2553,7 @@ netsnmp_set(PyObject *self, PyObject *ar
|
||||
}
|
||||
}
|
||||
|
||||
- if (py_netsnmp_attr_string(varbind, "val", &val, &tmplen) < 0) {
|
||||
+ if (py_netsnmp_attr_bytes(varbind, "val", &val, &tmplen) < 0) {
|
||||
snmp_free_pdu(pdu);
|
||||
goto done;
|
||||
}
|
||||
@@ -2607,10 +2633,23 @@ static PyMethodDef ClientMethods[] = {
|
||||
{NULL, NULL, 0, NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
@ -88,16 +178,28 @@ diff -urNp net-snmp-5.7.3/python/netsnmp/client_intf.c pnew/python/netsnmp/clien
|
||||
+};
|
||||
+
|
||||
PyMODINIT_FUNC
|
||||
initclient_intf(void)
|
||||
-initclient_intf(void)
|
||||
+PyInit_client_intf(void)
|
||||
{
|
||||
- (void) Py_InitModule("client_intf", ClientMethods);
|
||||
+ PyModule_Create(&ModuleDefinition);
|
||||
+ PyObject *module = PyModule_Create(&ModuleDefinition);
|
||||
+ return module;
|
||||
}
|
||||
|
||||
|
||||
diff -urNp net-snmp-5.7.3/python/netsnmp/client.py pnew/python/netsnmp/client.py
|
||||
--- net-snmp-5.7.3/python/netsnmp/client.py 2014-12-08 21:23:22.000000000 +0100
|
||||
+++ pnew/python/netsnmp/client.py 2018-05-02 13:06:08.609571674 +0200
|
||||
diff -urNp old/python/netsnmp/client.py new/python/netsnmp/client.py
|
||||
--- old/python/netsnmp/client.py 2018-05-29 08:27:03.390448765 +0200
|
||||
+++ new/python/netsnmp/client.py 2018-05-31 09:27:03.964289879 +0200
|
||||
@@ -1,8 +1,8 @@
|
||||
-import client_intf
|
||||
import string
|
||||
import re
|
||||
import types
|
||||
from sys import stderr
|
||||
+from netsnmp import client_intf
|
||||
|
||||
# control verbosity of error output
|
||||
verbose = 1
|
||||
@@ -35,12 +35,12 @@ def _parse_session_args(kargs):
|
||||
'TheirHostname':'',
|
||||
'TrustCert':''
|
||||
@ -114,7 +216,28 @@ diff -urNp net-snmp-5.7.3/python/netsnmp/client.py pnew/python/netsnmp/client.py
|
||||
return sessArgs
|
||||
|
||||
def STR(obj):
|
||||
@@ -127,7 +127,7 @@ class Session(object):
|
||||
@@ -53,7 +53,7 @@ class Varbind(object):
|
||||
def __init__(self, tag=None, iid=None, val=None, type=None):
|
||||
self.tag = STR(tag)
|
||||
self.iid = STR(iid)
|
||||
- self.val = STR(val)
|
||||
+ self.val = val
|
||||
self.type = STR(type)
|
||||
# parse iid out of tag if needed
|
||||
if iid == None and tag != None:
|
||||
@@ -63,7 +63,10 @@ class Varbind(object):
|
||||
(self.tag, self.iid) = match.group(1,2)
|
||||
|
||||
def __setattr__(self, name, val):
|
||||
- self.__dict__[name] = STR(val)
|
||||
+ if name == 'val':
|
||||
+ self.__dict__[name] = val
|
||||
+ else:
|
||||
+ self.__dict__[name] = STR(val)
|
||||
|
||||
def print_str(self):
|
||||
return self.tag, self.iid, self.val, self.type
|
||||
@@ -127,7 +130,7 @@ class Session(object):
|
||||
|
||||
sess_args = _parse_session_args(args)
|
||||
|
||||
@ -123,15 +246,15 @@ diff -urNp net-snmp-5.7.3/python/netsnmp/client.py pnew/python/netsnmp/client.py
|
||||
self.__dict__[k] = v
|
||||
|
||||
|
||||
diff -urNp net-snmp-5.7.3/python/netsnmp/__init__.py pnew/python/netsnmp/__init__.py
|
||||
--- net-snmp-5.7.3/python/netsnmp/__init__.py 2014-12-08 21:23:22.000000000 +0100
|
||||
+++ pnew/python/netsnmp/__init__.py 2018-05-09 13:47:17.708229826 +0200
|
||||
diff -urNp old/python/netsnmp/__init__.py new/python/netsnmp/__init__.py
|
||||
--- old/python/netsnmp/__init__.py 2018-05-29 08:27:03.390448765 +0200
|
||||
+++ new/python/netsnmp/__init__.py 2018-05-29 08:27:15.362394659 +0200
|
||||
@@ -1 +1 @@
|
||||
-from client import *
|
||||
+from .client import *
|
||||
diff -urNp net-snmp-5.7.3/python/netsnmp/tests/test.py pnew/python/netsnmp/tests/test.py
|
||||
--- net-snmp-5.7.3/python/netsnmp/tests/test.py 2014-12-08 21:23:22.000000000 +0100
|
||||
+++ pnew/python/netsnmp/tests/test.py 2018-05-09 13:47:57.132106532 +0200
|
||||
diff -urNp old/python/netsnmp/tests/test.py new/python/netsnmp/tests/test.py
|
||||
--- old/python/netsnmp/tests/test.py 2018-05-29 08:27:03.390448765 +0200
|
||||
+++ new/python/netsnmp/tests/test.py 2018-05-29 08:27:15.363394655 +0200
|
||||
@@ -8,7 +8,7 @@ import time
|
||||
|
||||
class BasicTests(unittest.TestCase):
|
||||
@ -500,9 +623,9 @@ diff -urNp net-snmp-5.7.3/python/netsnmp/tests/test.py pnew/python/netsnmp/tests
|
||||
|
||||
|
||||
if __name__=='__main__':
|
||||
diff -urNp net-snmp-5.7.3/python/setup.py pnew/python/setup.py
|
||||
--- net-snmp-5.7.3/python/setup.py 2014-12-08 21:23:22.000000000 +0100
|
||||
+++ pnew/python/setup.py 2018-05-02 10:12:12.499567600 +0200
|
||||
diff -urNp old/python/setup.py new/python/setup.py
|
||||
--- old/python/setup.py 2018-05-29 08:27:03.389448770 +0200
|
||||
+++ new/python/setup.py 2018-05-29 08:27:15.362394659 +0200
|
||||
@@ -9,9 +9,9 @@ intree=0
|
||||
|
||||
args = sys.argv[:]
|
||||
|
Loading…
Reference in New Issue
Block a user