[pypy-svn] r7500 - in pypy/trunk/src/pypy: interpreter translator
arigo at codespeak.net
arigo at codespeak.net
Sat Nov 20 12:41:43 CET 2004
Author: arigo
Date: Sat Nov 20 12:41:42 2004
New Revision: 7500
Modified:
pypy/trunk/src/pypy/interpreter/extmodule.py
pypy/trunk/src/pypy/translator/genc.h
pypy/trunk/src/pypy/translator/genc.py
Log:
nameof(subclass_of_Exception)
Modified: pypy/trunk/src/pypy/interpreter/extmodule.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/extmodule.py (original)
+++ pypy/trunk/src/pypy/interpreter/extmodule.py Sat Nov 20 12:41:42 2004
@@ -38,6 +38,7 @@
w_dict = self.w_dict
# Compile the xxxmodule.py source file
+ self.__name__ = 'interpreter-level %s' % modulename
self.__file__ = sourcefile or os.path.join(autopath.pypydir, 'module',
modulename+'module.py')
space.setitem(w_dict, space.wrap('__file__'),
Modified: pypy/trunk/src/pypy/translator/genc.h
==============================================================================
--- pypy/trunk/src/pypy/translator/genc.h (original)
+++ pypy/trunk/src/pypy/translator/genc.h Sat Nov 20 12:41:42 2004
@@ -197,8 +197,7 @@
PyModule_AddStringConstant(m, "__sourcefile__", __FILE__); \
this_module_globals = PyModule_GetDict(m); \
PyGenCFunction_Type.tp_base = &PyCFunction_Type; \
- PyType_Ready(&PyGenCFunction_Type); \
- PyExc_OperationError = PyErr_NewException(#modname ".OperationError", NULL, NULL);
+ PyType_Ready(&PyGenCFunction_Type);
/*** operations with a variable number of arguments ***/
@@ -596,8 +595,6 @@
}
#endif
-static PyObject* PyExc_OperationError;
-
#ifdef USE_CALL_TRACE
static int
trace_frame(PyThreadState *tstate, PyFrameObject *f, int code, PyObject *val)
Modified: pypy/trunk/src/pypy/translator/genc.py
==============================================================================
--- pypy/trunk/src/pypy/translator/genc.py (original)
+++ pypy/trunk/src/pypy/translator/genc.py Sat Nov 20 12:41:42 2004
@@ -316,13 +316,14 @@
if cls.__doc__ and cls.__doc__.lstrip().startswith('NOT_RPYTHON'):
raise Exception, "%r should never be reached" % (cls,)
+ metaclass = "&PyType_Type"
if issubclass(cls, Exception):
if cls.__module__ == 'exceptions':
return 'PyExc_%s'%cls.__name__
else:
- assert cls.__name__ == "OperationError"
- return 'PyExc_%s'%cls.__name__
-
+ # exceptions must be old-style classes (grr!)
+ metaclass = "&PyClass_Type"
+
name = self.uniquename('gcls_' + cls.__name__)
basenames = [self.nameof(base) for base in cls.__bases__]
def initclassobj():
@@ -349,8 +350,8 @@
baseargs = ", ".join(basenames)
if baseargs:
baseargs = ', '+baseargs
- self.initcode.append('INITCHK(%s = PyObject_CallFunction((PyObject*) &PyType_Type,'
- %(name,))
+ self.initcode.append('INITCHK(%s = PyObject_CallFunction((PyObject*) %s,'
+ %(name, metaclass))
self.initcode.append('\t\t"s(%s){}", "%s"%s))'
%("O"*len(basenames), cls.__name__, baseargs))
More information about the Pypy-commit
mailing list