[pypy-svn] pypy interplevel-exception-classes: pyexpat.error at interp-level
amauryfa
commits-noreply at bitbucket.org
Fri Feb 18 13:13:00 CET 2011
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: interplevel-exception-classes
Changeset: r42148:4142c25d9610
Date: 2011-02-18 13:07 +0100
http://bitbucket.org/pypy/pypy/changeset/4142c25d9610/
Log: pyexpat.error at interp-level
diff --git a/pypy/module/pyexpat/__init__.py b/pypy/module/pyexpat/__init__.py
--- a/pypy/module/pyexpat/__init__.py
+++ b/pypy/module/pyexpat/__init__.py
@@ -6,8 +6,6 @@
"Python wrapper for Expat parser."
appleveldefs = {
- 'ExpatError' : 'app_pyexpat.ExpatError',
- 'error' : 'app_pyexpat.ExpatError',
}
interpleveldefs = {
@@ -15,6 +13,9 @@
'XMLParserType': 'interp_pyexpat.W_XMLParserType',
'ErrorString': 'interp_pyexpat.ErrorString',
+ 'ExpatError': 'space.fromcache(interp_pyexpat.Cache).w_error',
+ 'error': 'space.fromcache(interp_pyexpat.Cache).w_error',
+
'__version__': 'space.wrap("85819")',
'EXPAT_VERSION': 'interp_pyexpat.get_expat_version(space)',
'version_info': 'interp_pyexpat.get_expat_version_info(space)',
diff --git a/pypy/module/pyexpat/app_pyexpat.py b/pypy/module/pyexpat/app_pyexpat.py
deleted file mode 100644
--- a/pypy/module/pyexpat/app_pyexpat.py
+++ /dev/null
@@ -1,2 +0,0 @@
-class ExpatError(Exception):
- pass
diff --git a/pypy/module/pyexpat/interp_pyexpat.py b/pypy/module/pyexpat/interp_pyexpat.py
--- a/pypy/module/pyexpat/interp_pyexpat.py
+++ b/pypy/module/pyexpat/interp_pyexpat.py
@@ -325,6 +325,10 @@
space.wrap(XML_MINOR_VERSION),
space.wrap(XML_MICRO_VERSION)])
+class Cache:
+ def __init__(self, space):
+ self.w_error = space.new_exception_class("pyexpat.ExpatError")
+
class W_XMLParserType(Wrappable):
def __init__(self, space, parser, w_intern):
@@ -590,8 +594,7 @@
lineno = XML_GetCurrentLineNumber(self.itself)
colno = XML_GetCurrentColumnNumber(self.itself)
msg = "%s: line %d, column %d" % (err, lineno, colno)
- w_module = space.getbuiltinmodule('pyexpat')
- w_errorcls = space.getattr(w_module, space.wrap('error'))
+ w_errorcls = space.fromcache(Cache).w_error
w_error = space.call_function(w_errorcls, space.wrap(msg))
space.setattr(w_error, space.wrap("code"), space.wrap(code))
space.setattr(w_error, space.wrap("offset"), space.wrap(colno))
More information about the Pypy-commit
mailing list