Skip to content

Commit 42042ae

Browse files
committed
Updated python 3 support; updated version number
1 parent 5eacedf commit 42042ae

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

context.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,7 +1313,11 @@ context_get_attributes(getdns_ContextObject *self, PyObject *unused)
13131313
PyObject *py_attr_list = PyList_New(NSETTERS);
13141314

13151315
for (i = 0 ; i < NSETTERS ; i++) {
1316+
#if PY_MAJOR_VERSION >= 3
1317+
(void)PyList_SetItem(py_attr_list, (Py_ssize_t) i, PyUnicode_FromString(setters[i].name));
1318+
#else
13161319
(void)PyList_SetItem(py_attr_list, (Py_ssize_t) i, PyString_FromString(setters[i].name));
1320+
#endif
13171321
}
13181322
return py_attr_list;
13191323
}

pygetdns.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#ifndef PYGETDNS_H
3333
#define PYGETDNS_H
3434

35-
#define PYGETDNS_VERSION "0.4.1"
35+
#define PYGETDNS_VERSION "0.5.0"
3636
#define GETDNS_DOCSTRING "getdns bindings for Python (see http://www.getdnsapi.net)"
3737

3838
#define GETDNS_STR_IPV4 "IPv4"

pygetdns_util.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,12 +385,21 @@ getdnsify_addressdict(PyObject *pydict)
385385
getdns_dict_set_bindata(addr_dict, "scope_id", &scope_id);
386386
}
387387
if ((str = PyDict_GetItemString(pydict, "tls_port")) != NULL) {
388+
#if PY_MAJOR_VERSION >= 3
389+
if (!PyLong_Check(str)) {
390+
PyErr_SetString(getdns_error, GETDNS_RETURN_INVALID_PARAMETER_TEXT);
391+
return NULL;
392+
}
393+
tls_port = (uint32_t)PyLong_AsLong(str);
394+
getdns_dict_set_int(addr_dict, "tls_port", tls_port);
395+
#else
388396
if (!PyInt_Check(str)) {
389397
PyErr_SetString(getdns_error, GETDNS_RETURN_INVALID_PARAMETER_TEXT);
390398
return NULL;
391399
}
392400
tls_port = (uint32_t)PyInt_AsLong(str);
393401
getdns_dict_set_int(addr_dict, "tls_port", tls_port);
402+
#endif
394403
}
395404

396405
if ((str = PyDict_GetItemString(pydict, "address_type")) == NULL) {

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
)
6666

6767
setup(name='getdns',
68-
version='0.4.1',
68+
version='0.5.0',
6969
description='getdns Python bindings for getdns',
7070
long_description=long_description,
7171
license='BSD',

0 commit comments

Comments
 (0)