Author: Armin Rigo <[email protected]>
Branch:
Changeset: r1057:bd4b6090aea0
Date: 2012-11-21 00:35 +0100
http://bitbucket.org/cffi/cffi/changeset/bd4b6090aea0/
Log: Python 3 confusionness and jumping though hoops.
diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -3951,6 +3951,15 @@
/* like PyErr_WriteUnraisable(), but write a full traceback */
PyObject *f, *t, *v, *tb;
PyErr_Fetch(&t, &v, &tb);
+#if PY_MAJOR_VERSION >= 3
+ /* jump through hoops to ensure the tb is attached to v, on Python 3 */
+ PyErr_NormalizeException(&t, &v, &tb);
+ if (tb == NULL) {
+ tb = Py_None;
+ Py_INCREF(tb);
+ }
+ PyException_SetTraceback(v, tb);
+#endif
f = PySys_GetObject("stderr");
if (f != NULL) {
PyFile_WriteString("From callback ", f);
diff --git a/c/test_c.py b/c/test_c.py
--- a/c/test_c.py
+++ b/c/test_c.py
@@ -1105,7 +1105,8 @@
except ImportError:
import io as cStringIO # Python 3
import linecache
- def matches(str, pattern):
+ def matches(istr, ipattern):
+ str, pattern = istr, ipattern
while '$' in pattern:
i = pattern.index('$')
assert str[:i] == pattern[:i]
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit