Skip to content

Commit

Permalink
Do not use private _PyErr_ChainExceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
sebschrader committed Jul 6, 2016
1 parent dc103a7 commit b3d4f52
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 29 deletions.
4 changes: 4 additions & 0 deletions README.rst
Expand Up @@ -69,6 +69,10 @@ every BSD, Linux and Mac OS.
Changelog
---------

v0.3.1 (2016-07-06)
^^^^^^^^^^^^^^^^^^^
* Don't use private _PyErr_ChainExceptions (breaks on Debian Jessie)

v0.3.0 (2016-06-26)
^^^^^^^^^^^^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -37,7 +37,7 @@
author='Sebastian Schrader',
author_email='sebastian.schrader@ossmail.de',
url='https://github.com/sebschrader/python-arpreq',
version='0.3.0',
version='0.3.1',
description="Query the Kernel ARP cache for the MAC address "
"corresponding to IP address",
long_description=readme,
Expand Down
36 changes: 8 additions & 28 deletions src/arpreq.c
Expand Up @@ -21,9 +21,6 @@
# if PY_VERSION_HEX >= 0x3030000
# define IS_PY33
# endif
# if PY_VERSION_HEX >= 0x3040000
# define IS_PY34
# endif
# if PY_VERSION_HEX >= 0x3050000
# define IS_PY35
# endif
Expand Down Expand Up @@ -317,30 +314,6 @@ static PyMethodDef arpreq_methods[] = {
};


#if defined IS_PY3 && !defined IS_PY34
static void
_PyErr_ChainExceptions(PyObject *exc, PyObject *val, PyObject *tb)
{
if (exc == NULL)
return;

if (PyErr_Occurred()) {
PyObject *exc2, *val2, *tb2;
PyErr_Fetch(&exc2, &val2, &tb2);
PyErr_NormalizeException(&exc, &val, &tb);
Py_DECREF(exc);
Py_XDECREF(tb);
PyErr_NormalizeException(&exc2, &val2, &tb2);
PyException_SetContext(val2, val);
PyErr_Restore(exc2, val2, tb2);
}
else {
PyErr_Restore(exc, val, tb);
}
}
#endif


/**
* Execute the module
*/
Expand Down Expand Up @@ -379,8 +352,15 @@ arpreq_exec(PyObject *module)
#ifdef IS_PY3
PyObject *type, *value, *traceback;
PyErr_Fetch(&type, &value, &traceback);
PyErr_NormalizeException(&type, &value, &traceback);
Py_DECREF(type);
Py_XDECREF(traceback);
PyErr_SetFromErrno(PyExc_OSError);
_PyErr_ChainExceptions(type, value, traceback);
PyObject *type2, *value2, *traceback2;
PyErr_Fetch(&type2, &value2, &traceback2);
PyErr_NormalizeException(&type2, &value2, &traceback2);
PyException_SetContext(value2, value);
PyErr_Restore(type2, value2, traceback2);
#else
PyErr_SetFromErrno(PyExc_OSError);
#endif
Expand Down

0 comments on commit b3d4f52

Please sign in to comment.