[pypy-svn] r9043 - in pypy/dist/pypy: module objspace/std translator/tool
pedronis at codespeak.net
pedronis at codespeak.net
Thu Feb 10 13:56:04 CET 2005
Author: pedronis
Date: Thu Feb 10 13:56:04 2005
New Revision: 9043
Added:
pypy/dist/pypy/translator/tool/tointerplevel.py (contents, props changed)
Modified:
pypy/dist/pypy/module/exceptionsinterp.py
pypy/dist/pypy/objspace/std/objspace.py
Log:
* tointerplevel.py: simple tool wrapping GenRpy functionality
usage: tointerplevel.py [options] module-file obj-name...
options:
-h, --help show this help message and exit
--import-as=AS import module-file with this name
-oOUTPUT, --out=OUTPUT
output file
--modname=MODNAME modname to be used by GenRpy
from a module it creates an interp-level version with an init<modname> func that returns a specified set
of objects from the module
* version of exceptionsinterp.py obtained with:
tointerplevel.py --modname=exceptions --out module/exceptionsinterp.py lib/_exceptions.py __dict__
Changed glue in objspace to work with it
Modified: pypy/dist/pypy/module/exceptionsinterp.py
==============================================================================
--- pypy/dist/pypy/module/exceptionsinterp.py (original)
+++ pypy/dist/pypy/module/exceptionsinterp.py Thu Feb 10 13:56:04 2005
@@ -93,20 +93,141 @@
+-- RuntimeWarning
+-- FutureWarning"""
+# global declarations
+# global object g47dict
+# global object gs_MemoryError
+# global object gcls_MemoryError
+# global object gcls_StandardError
+# global object gcls_Exception
+# global object gs___module__
+# global object gs__exceptions
+# global object gs___doc__
+# global object gs_Exception
+# global object gs_StandardError
+# global object gs_ImportError
+# global object gcls_ImportError
+# global object gs_RuntimeError
+# global object gcls_RuntimeError
+# global object gs_UnicodeTranslateError
+# global object gcls_UnicodeTranslateError
+# global object gcls_UnicodeError
+# global object gcls_ValueError
+# global object gs_ValueError
+# global object gs_UnicodeError
+# global object gs_KeyError
+# global object gcls_KeyError
+# global object gcls_LookupError
+# global object gs_LookupError
+# global object gs_TaskletExit
+# global object gcls_TaskletExit
+# global object gcls_SystemExit
+# global object gs_SystemExit
+# global object gs_StopIteration
+# global object gcls_StopIteration
+# global object gs_PendingDeprecationWarning
+# global object gcls_PendingDeprecationWarning
+# global object gcls_Warning
+# global object gs_Warning
+# global object gs_EnvironmentError
+# global object gcls_EnvironmentError
+# global object gs_OSError
+# global object gcls_OSError
+# global object gs_DeprecationWarning
+# global object gcls_DeprecationWarning
+# global object gs_FloatingPointError
+# global object gcls_FloatingPointError
+# global object gcls_ArithmeticError
+# global object gs_ArithmeticError
+# global object gs_AttributeError
+# global object gcls_AttributeError
+# global object gs_IndentationError
+# global object gcls_IndentationError
+# global object gcls_SyntaxError
+# global object gs_SyntaxError
+# global object gs_NameError
+# global object gcls_NameError
+# global object gs_OverflowWarning
+# global object gcls_OverflowWarning
+# global object gs_IOError
+# global object gcls_IOError
+# global object gs_FutureWarning
+# global object gcls_FutureWarning
+# global object gs_ZeroDivisionError
+# global object gcls_ZeroDivisionError
+# global object gs_EOFError
+# global object gcls_EOFError
+# global object gs_TabError
+# global object gcls_TabError
+# global object gs_UnicodeEncodeError
+# global object gcls_UnicodeEncodeError
+# global object gs_UnboundLocalError
+# global object gcls_UnboundLocalError
+# global object gs___name__
+# global object gs_ReferenceError
+# global object gcls_ReferenceError
+# global object gs_AssertionError
+# global object gcls_AssertionError
+# global object gs_UnicodeDecodeError
+# global object gcls_UnicodeDecodeError
+# global object gs_TypeError
+# global object gcls_TypeError
+# global object gs_IndexError
+# global object gcls_IndexError
+# global object gs_RuntimeWarning
+# global object gcls_RuntimeWarning
+# global object gs_KeyboardInterrupt
+# global object gcls_KeyboardInterrupt
+# global object gs_UserWarning
+# global object gcls_UserWarning
+# global object gs_SyntaxWarning
+# global object gcls_SyntaxWarning
+# global object gs_NotImplementedError
+# global object gcls_NotImplementedError
+# global object gs_SystemError
+# global object gcls_SystemError
+# global object gs_OverflowError
+# global object gcls_OverflowError
+# global object gs_WindowsError
+# global object gcls_WindowsError
+# global object gs___init__
+# global object gfunc_UnicodeDecodeError___init__
+# global object gs___str__
+# global object gfunc_UnicodeDecodeError___str__
+# global object gfunc_UnicodeEncodeError___init__
+# global object gfunc_UnicodeEncodeError___str__
+# global object gfunc_SyntaxError___init__
+# global object gfunc_SyntaxError___str__
+# global object gs_filename
+# global object gs_lineno
+# global object gs_msg
+# global object gs__emptystr_
+# global object gs_offset
+# global object gs_print_file_and_line
+# global object gs_text
+# global object gfunc_EnvironmentError___init__
+# global object gfunc_EnvironmentError___str__
+# global object gfunc_SystemExit___init__
+# global object gfunc_KeyError___str__
+# global object gfunc_UnicodeTranslateError___init__
+# global object gfunc_UnicodeTranslateError___str__
+# global object gs___getitem__
+# global object gfunc_Exception___getitem__
+# global object gfunc_Exception___init__
+# global object gfunc_Exception___str__
+
##SECTION##
-## filename '/home/tinuviel/pypy/pypy/lib/_exceptions.py'
+## filename '/u/pedronis/PyPy/dist/pypy/lib/_exceptions.py'
## function '__getitem__'
## firstlineno 94
##SECTION##
def __getitem__(space, __args__):
funcname = "__getitem__"
signature = ['self', 'idx'], None, None
- def_w = []
- w_self, w_idx = __args__.parse(funcname, signature, def_w)
+ defaults_w = []
+ w_self, w_idx = __args__.parse(funcname, signature, defaults_w)
return fastf_Exception___getitem__(space, w_self, w_idx)
f_Exception___getitem__ = __getitem__
-del __getitem__
def __getitem__(space, w_self, w_idx):
@@ -125,22 +246,20 @@
return w_4
fastf_Exception___getitem__ = __getitem__
-del __getitem__
##SECTION##
-## filename '/home/tinuviel/pypy/pypy/lib/_exceptions.py'
+## filename '/u/pedronis/PyPy/dist/pypy/lib/_exceptions.py'
## function '__init__'
## firstlineno 98
##SECTION##
def __init__(space, __args__):
funcname = "__init__"
signature = ['self'], 'args', None
- def_w = []
- w_self, w_args = __args__.parse(funcname, signature, def_w)
+ defaults_w = []
+ w_self, w_args = __args__.parse(funcname, signature, defaults_w)
return fastf_Exception___init__(space, w_self, w_args)
f_Exception___init__ = __init__
-del __init__
def __init__(space, w_self, w_args):
@@ -158,10 +277,9 @@
return w_3
fastf_Exception___init__ = __init__
-del __init__
##SECTION##
-## filename '/home/tinuviel/pypy/pypy/lib/_exceptions.py'
+## filename '/u/pedronis/PyPy/dist/pypy/lib/_exceptions.py'
## function '__str__'
## firstlineno 102
##SECTION##
@@ -173,12 +291,11 @@
def __str__(space, __args__):
funcname = "__str__"
signature = ['self'], None, None
- def_w = []
- w_self, = __args__.parse(funcname, signature, def_w)
+ defaults_w = []
+ w_self, = __args__.parse(funcname, signature, defaults_w)
return fastf_Exception___str__(space, w_self)
f_Exception___str__ = __str__
-del __str__
def __str__(space, w_self):
@@ -227,10 +344,9 @@
return w_5
fastf_Exception___str__ = __str__
-del __str__
##SECTION##
-## filename '/home/tinuviel/pypy/pypy/lib/_exceptions.py'
+## filename '/u/pedronis/PyPy/dist/pypy/lib/_exceptions.py'
## function '__init__'
## firstlineno 131
##SECTION##
@@ -242,12 +358,11 @@
def __init__(space, __args__):
funcname = "__init__"
signature = ['self'], 'args', None
- def_w = []
- w_self, w_args = __args__.parse(funcname, signature, def_w)
+ defaults_w = []
+ w_self, w_args = __args__.parse(funcname, signature, defaults_w)
return fastf_UnicodeTranslateError___init__(space, w_self, w_args)
f_UnicodeTranslateError___init__ = __init__
-del __init__
def __init__(space, w_self, w_args):
@@ -286,10 +401,9 @@
return w_6
fastf_UnicodeTranslateError___init__ = __init__
-del __init__
##SECTION##
-## filename '/home/tinuviel/pypy/pypy/lib/_exceptions.py'
+## filename '/u/pedronis/PyPy/dist/pypy/lib/_exceptions.py'
## function '__str__'
## firstlineno 141
##SECTION##
@@ -310,12 +424,11 @@
def __str__(space, __args__):
funcname = "__str__"
signature = ['self'], None, None
- def_w = []
- w_self, = __args__.parse(funcname, signature, def_w)
+ defaults_w = []
+ w_self, = __args__.parse(funcname, signature, defaults_w)
return fastf_UnicodeTranslateError___str__(space, w_self)
f_UnicodeTranslateError___str__ = __str__
-del __str__
def __str__(space, w_self):
@@ -350,22 +463,20 @@
return w_18
fastf_UnicodeTranslateError___str__ = __str__
-del __str__
##SECTION##
-## filename '/home/tinuviel/pypy/pypy/lib/_exceptions.py'
+## filename '/u/pedronis/PyPy/dist/pypy/lib/_exceptions.py'
## function '__str__'
## firstlineno 159
##SECTION##
def __str__(space, __args__):
funcname = "__str__"
signature = ['self'], None, None
- def_w = []
- w_self, = __args__.parse(funcname, signature, def_w)
+ defaults_w = []
+ w_self, = __args__.parse(funcname, signature, defaults_w)
return fastf_KeyError___str__(space, w_self)
f_KeyError___str__ = __str__
-del __str__
def __str__(space, w_self):
@@ -414,22 +525,20 @@
return w_5
fastf_KeyError___str__ = __str__
-del __str__
##SECTION##
-## filename '/home/tinuviel/pypy/pypy/lib/_exceptions.py'
+## filename '/u/pedronis/PyPy/dist/pypy/lib/_exceptions.py'
## function '__init__'
## firstlineno 185
##SECTION##
def __init__(space, __args__):
funcname = "__init__"
signature = ['self'], 'args', None
- def_w = []
- w_self, w_args = __args__.parse(funcname, signature, def_w)
+ defaults_w = []
+ w_self, w_args = __args__.parse(funcname, signature, defaults_w)
return fastf_EnvironmentError___init__(space, w_self, w_args)
f_EnvironmentError___init__ = __init__
-del __init__
def __init__(space, w_self, w_args):
@@ -506,10 +615,9 @@
return w_18
fastf_EnvironmentError___init__ = __init__
-del __init__
##SECTION##
-## filename '/home/tinuviel/pypy/pypy/lib/_exceptions.py'
+## filename '/u/pedronis/PyPy/dist/pypy/lib/_exceptions.py'
## function '__str__'
## firstlineno 199
##SECTION##
@@ -523,12 +631,11 @@
def __str__(space, __args__):
funcname = "__str__"
signature = ['self'], None, None
- def_w = []
- w_self, = __args__.parse(funcname, signature, def_w)
+ defaults_w = []
+ w_self, = __args__.parse(funcname, signature, defaults_w)
return fastf_EnvironmentError___str__(space, w_self)
f_EnvironmentError___str__ = __str__
-del __str__
def __str__(space, w_self):
@@ -560,10 +667,9 @@
return w_15
fastf_EnvironmentError___str__ = __str__
-del __str__
##SECTION##
-## filename '/home/tinuviel/pypy/pypy/lib/_exceptions.py'
+## filename '/u/pedronis/PyPy/dist/pypy/lib/_exceptions.py'
## function '__init__'
## firstlineno 219
##SECTION##
@@ -573,12 +679,11 @@
def __init__(space, __args__):
funcname = "__init__"
signature = ['self'], 'args', None
- def_w = []
- w_self, w_args = __args__.parse(funcname, signature, def_w)
+ defaults_w = []
+ w_self, w_args = __args__.parse(funcname, signature, defaults_w)
return fastf_UnicodeEncodeError___init__(space, w_self, w_args)
f_UnicodeEncodeError___init__ = __init__
-del __init__
def __init__(space, w_self, w_args):
@@ -619,10 +724,9 @@
return w_6
fastf_UnicodeEncodeError___init__ = __init__
-del __init__
##SECTION##
-## filename '/home/tinuviel/pypy/pypy/lib/_exceptions.py'
+## filename '/u/pedronis/PyPy/dist/pypy/lib/_exceptions.py'
## function '__str__'
## firstlineno 230
##SECTION##
@@ -633,12 +737,11 @@
def __str__(space, __args__):
funcname = "__str__"
signature = ['self'], None, None
- def_w = []
- w_self, = __args__.parse(funcname, signature, def_w)
+ defaults_w = []
+ w_self, = __args__.parse(funcname, signature, defaults_w)
return fastf_UnicodeEncodeError___str__(space, w_self)
f_UnicodeEncodeError___str__ = __str__
-del __str__
def __str__(space, w_self):
@@ -676,22 +779,20 @@
return w_21
fastf_UnicodeEncodeError___str__ = __str__
-del __str__
##SECTION##
-## filename '/home/tinuviel/pypy/pypy/lib/_exceptions.py'
+## filename '/u/pedronis/PyPy/dist/pypy/lib/_exceptions.py'
## function '__init__'
## firstlineno 270
##SECTION##
def __init__(space, __args__):
funcname = "__init__"
signature = ['self'], 'args', None
- def_w = []
- w_self, w_args = __args__.parse(funcname, signature, def_w)
+ defaults_w = []
+ w_self, w_args = __args__.parse(funcname, signature, defaults_w)
return fastf_SyntaxError___init__(space, w_self, w_args)
f_SyntaxError___init__ = __init__
-del __init__
def __init__(space, w_self, w_args):
@@ -752,22 +853,20 @@
return w_10
fastf_SyntaxError___init__ = __init__
-del __init__
##SECTION##
-## filename '/home/tinuviel/pypy/pypy/lib/_exceptions.py'
+## filename '/u/pedronis/PyPy/dist/pypy/lib/_exceptions.py'
## function '__str__'
## firstlineno 282
##SECTION##
def __str__(space, __args__):
funcname = "__str__"
signature = ['self'], None, None
- def_w = []
- w_self, = __args__.parse(funcname, signature, def_w)
+ defaults_w = []
+ w_self, = __args__.parse(funcname, signature, defaults_w)
return fastf_SyntaxError___str__(space, w_self)
f_SyntaxError___str__ = __str__
-del __str__
def __str__(space, w_self):
@@ -789,10 +888,9 @@
return w_6
fastf_SyntaxError___str__ = __str__
-del __str__
##SECTION##
-## filename '/home/tinuviel/pypy/pypy/lib/_exceptions.py'
+## filename '/u/pedronis/PyPy/dist/pypy/lib/_exceptions.py'
## function '__init__'
## firstlineno 296
##SECTION##
@@ -802,12 +900,11 @@
def __init__(space, __args__):
funcname = "__init__"
signature = ['self'], 'args', None
- def_w = []
- w_self, w_args = __args__.parse(funcname, signature, def_w)
+ defaults_w = []
+ w_self, w_args = __args__.parse(funcname, signature, defaults_w)
return fastf_SystemExit___init__(space, w_self, w_args)
f_SystemExit___init__ = __init__
-del __init__
def __init__(space, w_self, w_args):
@@ -873,22 +970,20 @@
return w_13
fastf_SystemExit___init__ = __init__
-del __init__
##SECTION##
-## filename '/home/tinuviel/pypy/pypy/lib/_exceptions.py'
+## filename '/u/pedronis/PyPy/dist/pypy/lib/_exceptions.py'
## function '__init__'
## firstlineno 331
##SECTION##
def __init__(space, __args__):
funcname = "__init__"
signature = ['self'], 'args', None
- def_w = []
- w_self, w_args = __args__.parse(funcname, signature, def_w)
+ defaults_w = []
+ w_self, w_args = __args__.parse(funcname, signature, defaults_w)
return fastf_UnicodeDecodeError___init__(space, w_self, w_args)
f_UnicodeDecodeError___init__ = __init__
-del __init__
def __init__(space, w_self, w_args):
@@ -929,22 +1024,20 @@
return w_6
fastf_UnicodeDecodeError___init__ = __init__
-del __init__
##SECTION##
-## filename '/home/tinuviel/pypy/pypy/lib/_exceptions.py'
+## filename '/u/pedronis/PyPy/dist/pypy/lib/_exceptions.py'
## function '__str__'
## firstlineno 342
##SECTION##
def __str__(space, __args__):
funcname = "__str__"
signature = ['self'], None, None
- def_w = []
- w_self, = __args__.parse(funcname, signature, def_w)
+ defaults_w = []
+ w_self, = __args__.parse(funcname, signature, defaults_w)
return fastf_UnicodeDecodeError___str__(space, w_self)
f_UnicodeDecodeError___str__ = __str__
-del __str__
def __str__(space, w_self):
@@ -982,192 +1075,24 @@
return w_21
fastf_UnicodeDecodeError___str__ = __str__
-del __str__
-
-##SECTION##
-## filename 'geninterplevel.py'
-## function 'test_exceptions'
-## firstlineno 1306
-##SECTION##
-# global declarations
-# global object gfunc_test_exceptions
-# global object gbltinmethod_keys
-# global object g47dict
-# global object gs_keys
-
-def test_exceptions(space, __args__):
- """ enumerate all exceptions """
-
- funcname = "test_exceptions"
- signature = [], None, None
- def_w = []
- __args__.parse(funcname, signature, def_w)
- return fastf_test_exceptions(space)
-
-f_test_exceptions = test_exceptions
-del test_exceptions
-
-def test_exceptions(space):
- """ enumerate all exceptions """
-
- w_0=w_1=None
-
- goto = 1 # startblock
- while True:
-
- if goto == 1:
- w_0 = space.call_function(gbltinmethod_keys, )
- w_1 = w_0
- goto = 2
-
- if goto == 2:
- return w_1
-
-fastf_test_exceptions = test_exceptions
-del test_exceptions
-
-# global declarations
-# global object gs_MemoryError
-# global object gcls_MemoryError
-# global object gcls_StandardError
-# global object gcls_Exception
-# global object gs___module__
-# global object gs_exceptions
-# global object gs___doc__
-# global object gs_Exception
-# global object gs_StandardError
-# global object gs_ImportError
-# global object gcls_ImportError
-# global object gs_RuntimeError
-# global object gcls_RuntimeError
-# global object gs_UnicodeTranslateError
-# global object gcls_UnicodeTranslateError
-# global object gcls_UnicodeError
-# global object gcls_ValueError
-# global object gs_ValueError
-# global object gs_UnicodeError
-# global object gs_KeyError
-# global object gcls_KeyError
-# global object gcls_LookupError
-# global object gs_LookupError
-# global object gs_TaskletExit
-# global object gcls_TaskletExit
-# global object gcls_SystemExit
-# global object gs_SystemExit
-# global object gs_StopIteration
-# global object gcls_StopIteration
-# global object gs_PendingDeprecationWarning
-# global object gcls_PendingDeprecationWarning
-# global object gcls_Warning
-# global object gs_Warning
-# global object gs_EnvironmentError
-# global object gcls_EnvironmentError
-# global object gs_OSError
-# global object gcls_OSError
-# global object gs_DeprecationWarning
-# global object gcls_DeprecationWarning
-# global object gs_FloatingPointError
-# global object gcls_FloatingPointError
-# global object gcls_ArithmeticError
-# global object gs_ArithmeticError
-# global object gs_AttributeError
-# global object gcls_AttributeError
-# global object gs_IndentationError
-# global object gcls_IndentationError
-# global object gcls_SyntaxError
-# global object gs_SyntaxError
-# global object gs_NameError
-# global object gcls_NameError
-# global object gs_OverflowWarning
-# global object gcls_OverflowWarning
-# global object gs_IOError
-# global object gcls_IOError
-# global object gs_FutureWarning
-# global object gcls_FutureWarning
-# global object gs_ZeroDivisionError
-# global object gcls_ZeroDivisionError
-# global object gs_EOFError
-# global object gcls_EOFError
-# global object gs_TabError
-# global object gcls_TabError
-# global object gs_UnicodeEncodeError
-# global object gcls_UnicodeEncodeError
-# global object gs_UnboundLocalError
-# global object gcls_UnboundLocalError
-# global object gs___name__
-# global object gs_ReferenceError
-# global object gcls_ReferenceError
-# global object gs_AssertionError
-# global object gcls_AssertionError
-# global object gs_UnicodeDecodeError
-# global object gcls_UnicodeDecodeError
-# global object gs_TypeError
-# global object gcls_TypeError
-# global object gs_IndexError
-# global object gcls_IndexError
-# global object gs_RuntimeWarning
-# global object gcls_RuntimeWarning
-# global object gs_KeyboardInterrupt
-# global object gcls_KeyboardInterrupt
-# global object gs_UserWarning
-# global object gcls_UserWarning
-# global object gs_SyntaxWarning
-# global object gcls_SyntaxWarning
-# global object gs_NotImplementedError
-# global object gcls_NotImplementedError
-# global object gs_SystemError
-# global object gcls_SystemError
-# global object gs_OverflowError
-# global object gcls_OverflowError
-# global object gs_WindowsError
-# global object gcls_WindowsError
-# global object gs___init__
-# global object gfunc_UnicodeDecodeError___init__
-# global object gs___str__
-# global object gfunc_UnicodeDecodeError___str__
-# global object gfunc_UnicodeEncodeError___init__
-# global object gfunc_UnicodeEncodeError___str__
-# global object gfunc_SyntaxError___init__
-# global object gfunc_SyntaxError___str__
-# global object gs_filename
-# global object gs_lineno
-# global object gs_msg
-# global object gs__emptystr_
-# global object gs_offset
-# global object gs_print_file_and_line
-# global object gs_text
-# global object gfunc_EnvironmentError___init__
-# global object gfunc_EnvironmentError___str__
-# global object gfunc_SystemExit___init__
-# global object gfunc_KeyError___str__
-# global object gfunc_UnicodeTranslateError___init__
-# global object gfunc_UnicodeTranslateError___str__
-# global object gs___getitem__
-# global object gfunc_Exception___getitem__
-# global object gfunc_Exception___init__
-# global object gfunc_Exception___str__
##SECTION##
#*************************************************************
-def inittest_exceptions_1(space):
+def initexceptions(space):
"""NOT_RPYTHON"""
class m: pass # fake module
m.__dict__ = globals()
# make sure that this function is run only once:
- m.inittest_exceptions_1 = lambda *ign:True
+ m.initexceptions = lambda *ign:True
- from pypy.interpreter.gateway import interp2app
- m.gfunc_test_exceptions = space.wrap(interp2app(f_test_exceptions))
- m.__doc__ = space.wrap(m.__doc__)
m.g47dict = space.newdict([])
- m.gs_keys = space.wrap('keys')
- m.gbltinmethod_keys = space.getattr(g47dict, gs_keys)
+ m.__doc__ = space.wrap(m.__doc__)
m.gs_MemoryError = space.wrap('MemoryError')
_dic = space.newdict([])
m.gs___module__ = space.wrap('__module__')
- m.gs_exceptions = space.wrap('exceptions')
- space.setitem(_dic, gs___module__, gs_exceptions)
+ m.gs__exceptions = space.wrap('_exceptions')
+ space.setitem(_dic, gs___module__, gs__exceptions)
m.gs___doc__ = space.wrap('__doc__')
_doc = space.wrap("""Common base class for all exceptions.""")
space.setitem(_dic, gs___doc__, _doc)
@@ -1176,7 +1101,7 @@
_args = space.newtuple([gs_Exception, _bases, _dic])
m.gcls_Exception = space.call(space.w_type, _args)
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Base class for all standard Python exceptions.""")
space.setitem(_dic, gs___doc__, _doc)
m.gs_StandardError = space.wrap('StandardError')
@@ -1184,7 +1109,7 @@
_args = space.newtuple([gs_StandardError, _bases, _dic])
m.gcls_StandardError = space.call(space.w_type, _args)
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Out of memory.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_StandardError])
@@ -1193,7 +1118,7 @@
space.setitem(g47dict, gs_MemoryError, gcls_MemoryError)
m.gs_ImportError = space.wrap('ImportError')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Import can't find module, or can't find name in module.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_StandardError])
@@ -1202,7 +1127,7 @@
space.setitem(g47dict, gs_ImportError, gcls_ImportError)
m.gs_RuntimeError = space.wrap('RuntimeError')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Unspecified run-time error.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_StandardError])
@@ -1211,7 +1136,7 @@
space.setitem(g47dict, gs_RuntimeError, gcls_RuntimeError)
m.gs_UnicodeTranslateError = space.wrap('UnicodeTranslateError')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Inappropriate argument value (of correct type).""")
space.setitem(_dic, gs___doc__, _doc)
m.gs_ValueError = space.wrap('ValueError')
@@ -1219,7 +1144,7 @@
_args = space.newtuple([gs_ValueError, _bases, _dic])
m.gcls_ValueError = space.call(space.w_type, _args)
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Unicode related error.""")
space.setitem(_dic, gs___doc__, _doc)
m.gs_UnicodeError = space.wrap('UnicodeError')
@@ -1227,7 +1152,7 @@
_args = space.newtuple([gs_UnicodeError, _bases, _dic])
m.gcls_UnicodeError = space.call(space.w_type, _args)
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Unicode translation error.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_UnicodeError])
@@ -1236,7 +1161,7 @@
space.setitem(g47dict, gs_UnicodeTranslateError, gcls_UnicodeTranslateError)
m.gs_KeyError = space.wrap('KeyError')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Base class for lookup errors.""")
space.setitem(_dic, gs___doc__, _doc)
m.gs_LookupError = space.wrap('LookupError')
@@ -1244,7 +1169,7 @@
_args = space.newtuple([gs_LookupError, _bases, _dic])
m.gcls_LookupError = space.call(space.w_type, _args)
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Mapping key not found.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_LookupError])
@@ -1253,7 +1178,7 @@
space.setitem(g47dict, gs_KeyError, gcls_KeyError)
m.gs_TaskletExit = space.wrap('TaskletExit')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Request to exit from the interpreter.""")
space.setitem(_dic, gs___doc__, _doc)
m.gs_SystemExit = space.wrap('SystemExit')
@@ -1261,7 +1186,7 @@
_args = space.newtuple([gs_SystemExit, _bases, _dic])
m.gcls_SystemExit = space.call(space.w_type, _args)
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Request to exit from a tasklet.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_SystemExit])
@@ -1270,7 +1195,7 @@
space.setitem(g47dict, gs_TaskletExit, gcls_TaskletExit)
m.gs_StopIteration = space.wrap('StopIteration')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Signal the end from iterator.next().""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_Exception])
@@ -1279,7 +1204,7 @@
space.setitem(g47dict, gs_StopIteration, gcls_StopIteration)
m.gs_PendingDeprecationWarning = space.wrap('PendingDeprecationWarning')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Base class for warning categories.""")
space.setitem(_dic, gs___doc__, _doc)
m.gs_Warning = space.wrap('Warning')
@@ -1287,7 +1212,7 @@
_args = space.newtuple([gs_Warning, _bases, _dic])
m.gcls_Warning = space.call(space.w_type, _args)
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Base class for warnings about features which will be deprecated in the future.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_Warning])
@@ -1296,7 +1221,7 @@
space.setitem(g47dict, gs_PendingDeprecationWarning, gcls_PendingDeprecationWarning)
m.gs_EnvironmentError = space.wrap('EnvironmentError')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Base class for I/O related errors.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_StandardError])
@@ -1306,7 +1231,7 @@
space.setitem(g47dict, gs_LookupError, gcls_LookupError)
m.gs_OSError = space.wrap('OSError')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""OS system call failed.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_EnvironmentError])
@@ -1315,7 +1240,7 @@
space.setitem(g47dict, gs_OSError, gcls_OSError)
m.gs_DeprecationWarning = space.wrap('DeprecationWarning')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Base class for warnings about deprecated features.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_Warning])
@@ -1325,7 +1250,7 @@
space.setitem(g47dict, gs_UnicodeError, gcls_UnicodeError)
m.gs_FloatingPointError = space.wrap('FloatingPointError')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Base class for arithmetic errors.""")
space.setitem(_dic, gs___doc__, _doc)
m.gs_ArithmeticError = space.wrap('ArithmeticError')
@@ -1333,7 +1258,7 @@
_args = space.newtuple([gs_ArithmeticError, _bases, _dic])
m.gcls_ArithmeticError = space.call(space.w_type, _args)
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Floating point operation failed.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_ArithmeticError])
@@ -1342,7 +1267,7 @@
space.setitem(g47dict, gs_FloatingPointError, gcls_FloatingPointError)
m.gs_AttributeError = space.wrap('AttributeError')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Attribute not found.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_StandardError])
@@ -1351,7 +1276,7 @@
space.setitem(g47dict, gs_AttributeError, gcls_AttributeError)
m.gs_IndentationError = space.wrap('IndentationError')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Invalid syntax.""")
space.setitem(_dic, gs___doc__, _doc)
m.gs_SyntaxError = space.wrap('SyntaxError')
@@ -1359,7 +1284,7 @@
_args = space.newtuple([gs_SyntaxError, _bases, _dic])
m.gcls_SyntaxError = space.call(space.w_type, _args)
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Improper indentation.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_SyntaxError])
@@ -1368,7 +1293,7 @@
space.setitem(g47dict, gs_IndentationError, gcls_IndentationError)
m.gs_NameError = space.wrap('NameError')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Name not found globally.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_StandardError])
@@ -1377,7 +1302,7 @@
space.setitem(g47dict, gs_NameError, gcls_NameError)
m.gs_OverflowWarning = space.wrap('OverflowWarning')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Base class for warnings about numeric overflow.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_Warning])
@@ -1386,7 +1311,7 @@
space.setitem(g47dict, gs_OverflowWarning, gcls_OverflowWarning)
m.gs_IOError = space.wrap('IOError')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""I/O operation failed.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_EnvironmentError])
@@ -1396,7 +1321,7 @@
space.setitem(g47dict, gs_ValueError, gcls_ValueError)
m.gs_FutureWarning = space.wrap('FutureWarning')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Base class for warnings about constructs that will change semantically in the future.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_Warning])
@@ -1405,7 +1330,7 @@
space.setitem(g47dict, gs_FutureWarning, gcls_FutureWarning)
m.gs_ZeroDivisionError = space.wrap('ZeroDivisionError')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Second argument to a division or modulo operation was zero.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_ArithmeticError])
@@ -1416,7 +1341,7 @@
space.setitem(g47dict, gs_Exception, gcls_Exception)
m.gs_EOFError = space.wrap('EOFError')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Read beyond end of file.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_StandardError])
@@ -1426,7 +1351,7 @@
space.setitem(g47dict, gs_StandardError, gcls_StandardError)
m.gs_TabError = space.wrap('TabError')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Improper mixture of spaces and tabs.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_IndentationError])
@@ -1436,7 +1361,7 @@
space.setitem(g47dict, gs_SyntaxError, gcls_SyntaxError)
m.gs_UnicodeEncodeError = space.wrap('UnicodeEncodeError')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Unicode encoding error.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_UnicodeError])
@@ -1445,7 +1370,7 @@
space.setitem(g47dict, gs_UnicodeEncodeError, gcls_UnicodeEncodeError)
m.gs_UnboundLocalError = space.wrap('UnboundLocalError')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Local name referenced but not bound to a value.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_NameError])
@@ -1453,10 +1378,10 @@
m.gcls_UnboundLocalError = space.call(space.w_type, _args)
space.setitem(g47dict, gs_UnboundLocalError, gcls_UnboundLocalError)
m.gs___name__ = space.wrap('__name__')
- space.setitem(g47dict, gs___name__, gs_exceptions)
+ space.setitem(g47dict, gs___name__, gs__exceptions)
m.gs_ReferenceError = space.wrap('ReferenceError')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Weak ref proxy used after referent went away.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_StandardError])
@@ -1465,7 +1390,7 @@
space.setitem(g47dict, gs_ReferenceError, gcls_ReferenceError)
m.gs_AssertionError = space.wrap('AssertionError')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Assertion failed.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_StandardError])
@@ -1474,7 +1399,7 @@
space.setitem(g47dict, gs_AssertionError, gcls_AssertionError)
m.gs_UnicodeDecodeError = space.wrap('UnicodeDecodeError')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Unicode decoding error.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_UnicodeError])
@@ -1483,7 +1408,7 @@
space.setitem(g47dict, gs_UnicodeDecodeError, gcls_UnicodeDecodeError)
m.gs_TypeError = space.wrap('TypeError')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Inappropriate argument type.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_StandardError])
@@ -1492,7 +1417,7 @@
space.setitem(g47dict, gs_TypeError, gcls_TypeError)
m.gs_IndexError = space.wrap('IndexError')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Sequence index out of range.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_LookupError])
@@ -1501,7 +1426,7 @@
space.setitem(g47dict, gs_IndexError, gcls_IndexError)
m.gs_RuntimeWarning = space.wrap('RuntimeWarning')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Base class for warnings about dubious runtime behavior.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_Warning])
@@ -1510,7 +1435,7 @@
space.setitem(g47dict, gs_RuntimeWarning, gcls_RuntimeWarning)
m.gs_KeyboardInterrupt = space.wrap('KeyboardInterrupt')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Program interrupted by user.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_StandardError])
@@ -1519,7 +1444,7 @@
space.setitem(g47dict, gs_KeyboardInterrupt, gcls_KeyboardInterrupt)
m.gs_UserWarning = space.wrap('UserWarning')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Base class for warnings generated by user code.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_Warning])
@@ -1528,7 +1453,7 @@
space.setitem(g47dict, gs_UserWarning, gcls_UserWarning)
m.gs_SyntaxWarning = space.wrap('SyntaxWarning')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Base class for warnings about dubious syntax.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_Warning])
@@ -1540,7 +1465,7 @@
space.setitem(g47dict, gs_Warning, gcls_Warning)
m.gs_NotImplementedError = space.wrap('NotImplementedError')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Method or function hasn't been implemented yet.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_RuntimeError])
@@ -1549,7 +1474,7 @@
space.setitem(g47dict, gs_NotImplementedError, gcls_NotImplementedError)
m.gs_SystemError = space.wrap('SystemError')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Internal error in the Python interpreter.
Please report this to the Python maintainer, along with the traceback,
@@ -1561,7 +1486,7 @@
space.setitem(g47dict, gs_SystemError, gcls_SystemError)
m.gs_OverflowError = space.wrap('OverflowError')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""Result too large to be represented.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_ArithmeticError])
@@ -1570,7 +1495,7 @@
space.setitem(g47dict, gs_OverflowError, gcls_OverflowError)
m.gs_WindowsError = space.wrap('WindowsError')
_dic = space.newdict([])
- space.setitem(_dic, gs___module__, gs_exceptions)
+ space.setitem(_dic, gs___module__, gs__exceptions)
_doc = space.wrap("""MS-Windows OS system call failed.""")
space.setitem(_dic, gs___doc__, _doc)
_bases = space.newtuple([gcls_OSError])
@@ -1578,6 +1503,7 @@
m.gcls_WindowsError = space.call(space.w_type, _args)
space.setitem(g47dict, gs_WindowsError, gcls_WindowsError)
m.gs___init__ = space.wrap('__init__')
+ from pypy.interpreter.gateway import interp2app
m.gfunc_UnicodeDecodeError___init__ = space.wrap(interp2app(f_UnicodeDecodeError___init__))
space.setattr(gcls_UnicodeDecodeError, gs___init__, gfunc_UnicodeDecodeError___init__)
m.gs___str__ = space.wrap('__str__')
@@ -1626,6 +1552,9 @@
m.gs_args = space.wrap('args')
m.gi_0 = space.newint(0)
m.gi_1 = space.newint(1)
+ del m.__str__
+ del m.__init__
+ del m.__getitem__
m.gs_start = space.wrap('start')
m.gs_start_ = space.wrap('start=')
m.gs_reason = space.wrap('reason')
@@ -1650,17 +1579,5 @@
m.gs_encoding = space.wrap('encoding')
m.gs_encoding_ = space.wrap('encoding=')
m.gi_5 = space.newint(5)
-
-# entry point: test_exceptions, gfunc_test_exceptions
-if __name__ == "__main__":
- from pypy.objspace.std import StdObjSpace
- from pypy.objspace.std.default import UnwrapError
- space = StdObjSpace()
- inittest_exceptions_1(space)
- ret = space.call(gfunc_test_exceptions, space.newtuple([]))
- try:
- print space.unwrap(ret)
- except UnwrapError:
- print "cannot unwrap, here the wrapped result:"
- print ret
+ return g47dict
Modified: pypy/dist/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/dist/pypy/objspace/std/objspace.py (original)
+++ pypy/dist/pypy/objspace/std/objspace.py Thu Feb 10 13:56:04 2005
@@ -102,20 +102,27 @@
bases = [space.w_object]
res = W_TypeObject(space, name, bases, dic)
return res
- w_dic = self.newdict([])
try:
# note that we hide the real call method by an instance variable!
self.call = call
- ex.inittest_exceptions_1(self)
- for name, w_obj in ex.__dict__.items():
- if name.startswith("gcls_"):
- excname = name[5:]
- setattr(self, "w_"+excname, w_obj) # into space
- for_builtins[excname] = w_obj # into builtins
- self.setitem(w_dic, self.wrap(excname), w_obj) # into exc
- self.setitem(w_dic, self.wrap("__doc__"), ex.__doc__)
+ w_dic = ex.initexceptions(self)
+
+ self.w_IndexError = self.getitem(w_dic, self.wrap("IndexError"))
+ self.w_StopIteration = self.getitem(w_dic, self.wrap("StopIteration"))
finally:
- del self.call # revert to the class' method
+ del self.call # revert
+
+ names_w = self.unpackiterable(self.call_function(self.getattr(w_dic, self.wrap("keys"))))
+
+ for w_name in names_w:
+ name = self.str_w(w_name)
+ if not name.startswith('__'):
+ excname = name
+ w_exc = self.getitem(w_dic, w_name)
+ setattr(self, "w_"+excname, w_exc)
+
+ for_builtins[excname] = w_exc
+
# XXX refine things, clean up, create a builtin module...
# but for now, we do a regular one.
from pypy.interpreter.module import Module
Added: pypy/dist/pypy/translator/tool/tointerplevel.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/tool/tointerplevel.py Thu Feb 10 13:56:04 2005
@@ -0,0 +1,73 @@
+import autopath
+import sys
+import optparse
+import os
+import new
+
+from pypy.translator.translator import Translator
+from pypy.translator.geninterplevel import GenRpy
+
+def main():
+ opt_parser = optparse.OptionParser(usage="usage: %prog [options] module-file obj-name...")
+ opt_parser.add_option("--import-as", dest="as", type="string",
+ help="import module-file with this name")
+ opt_parser.add_option("-o","--out",dest="output",type="string", help="output file")
+ opt_parser.add_option("--modname",dest="modname", type="string", help="modname to be used by GenRpy")
+
+ options, args = opt_parser.parse_args()
+
+ if len(args) < 2:
+ opt_parser.error("missing module-file and at least one obj-name")
+
+ modfile = os.path.abspath(args[0])
+
+ name = os.path.splitext(os.path.basename(modfile))[0]
+
+ as = options.as or name
+
+ mod = new.module(as)
+ execfile(modfile, mod.__dict__)
+
+ del mod.__dict__['__builtins__']
+
+ modname = options.modname or name
+
+ objs = []
+
+ for objname in args[1:]:
+ try:
+ objs.append(getattr(mod, objname))
+ except AttributeError, e:
+ raise Exception,"module has no object '%s'" % name
+
+ if len(objs) == 1:
+ entrypoint = objs[0]
+ else:
+ entrypoint = tuple(objs)
+
+ t = Translator(None, verbose=False, simplifying=True)
+ gen = GenRpy(t, entrypoint, modname)
+ def gen_trailer(info, indent):
+ print >>gen.f, indent + "return %s" % gen.nameof(entrypoint)
+ print >>gen.f
+
+ gen.use_fast_call = True
+ gen.moddict = mod.__dict__ # xxx control this
+ gen.gen_trailer = gen_trailer
+
+ output = options.output or modname + "interp.py"
+
+ print "generating %s..." % output
+
+ gen.gen_source(output)
+
+
+
+if __name__ == "__main__":
+ main()
+
+
+
+
+
+
More information about the Pypy-commit
mailing list