[pypy-commit] pypy cpyext-cleanup: Simplify declaration of _PyExc_xxx objects
rlamy
pypy.commits at gmail.com
Tue Jan 3 11:45:26 EST 2017
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: cpyext-cleanup
Changeset: r89339:b0f085b855a5
Date: 2017-01-03 16:44 +0000
http://bitbucket.org/pypy/pypy/changeset/b0f085b855a5/
Log: Simplify declaration of _PyExc_xxx objects
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -572,7 +572,9 @@
# PyExc_AttributeError, PyExc_OverflowError, PyExc_ImportError,
# PyExc_NameError, PyExc_MemoryError, PyExc_RuntimeError,
# PyExc_UnicodeEncodeError, PyExc_UnicodeDecodeError, ...
- for exc_name in exceptions.Module.interpleveldefs.keys():
+ global all_exceptions
+ all_exceptions = list(exceptions.Module.interpleveldefs)
+ for exc_name in all_exceptions:
register_global('PyExc_' + exc_name,
'PyTypeObject*',
'space.gettypeobject(interp_exceptions.W_%s.typedef)'% (exc_name, ))
@@ -1055,15 +1057,8 @@
""" % dict(members=structmembers)
global_objects = []
- for name, (typ, expr) in GLOBALS.iteritems():
- if '#' in name:
- continue
- if typ == 'PyDateTime_CAPI*':
- continue
- elif name.startswith('PyExc_'):
- global_objects.append('%s _%s;' % (typ[:-1], name))
- else:
- global_objects.append('%s %s = NULL;' % (typ, name))
+ for name in all_exceptions:
+ global_objects.append('PyTypeObject _PyExc_%s;' % name)
global_code = '\n'.join(global_objects)
prologue = ("#include <Python.h>\n"
More information about the pypy-commit
mailing list