[pypy-svn] r10978 - in pypy/dist/pypy: interpreter module/builtin
pedronis at codespeak.net
pedronis at codespeak.net
Thu Apr 21 18:40:06 CEST 2005
Author: pedronis
Date: Thu Apr 21 17:38:17 2005
New Revision: 10978
Modified:
pypy/dist/pypy/interpreter/function.py
pypy/dist/pypy/interpreter/pyframe.py
pypy/dist/pypy/module/builtin/compiling.py
Log:
make comment more precise
more double interpclass_w removal
make eval impl more annotator friendly
Modified: pypy/dist/pypy/interpreter/function.py
==============================================================================
--- pypy/dist/pypy/interpreter/function.py (original)
+++ pypy/dist/pypy/interpreter/function.py Thu Apr 21 17:38:17 2005
@@ -48,6 +48,8 @@
raise OperationError( space.w_TypeError, space.wrap("setting function's dictionary to a non-dict") )
self.w_func_dict = w_dict
+ # unwrapping is done through unwrap_specs in typedef.py
+
def descr_function_get(self, w_obj, w_cls=None):
space = self.space
wrap = space.wrap
@@ -64,39 +66,32 @@
def descr_function_call(self, __args__):
return self.call_args(__args__)
- def fget_func_defaults(space, w_self):
- self = space.interpclass_w(w_self)
+ def fget_func_defaults(space, self):
values_w = self.defs_w
if not values_w:
return space.w_None
return space.newtuple(values_w)
- def fset_func_defaults(space, w_self, w_defaults):
- self = space.interpclass_w(w_self)
+ def fset_func_defaults(space, self, w_defaults):
if not space.is_true( space.isinstance( w_defaults, space.w_tuple ) ):
raise OperationError( space.w_TypeError, space.wrap("func_defaults must be set to a tuple object") )
self.defs_w = space.unpackiterable( w_defaults )
- def fdel_func_defaults(space, w_self):
- self = space.interpclass_w(w_self)
+ def fdel_func_defaults(space, self):
self.defs_w = []
- def fget_func_doc(space, w_self):
- self = space.interpclass_w(w_self)
+ def fget_func_doc(space, self):
if self.w_doc is None:
self.w_doc = space.wrap(self.code.getdocstring())
return self.w_doc
- def fset_func_doc(space, w_self, w_doc):
- self = space.interpclass_w(w_self)
+ def fset_func_doc(space, self, w_doc):
self.w_doc = w_doc
- def fdel_func_doc(space, w_self):
- self = space.interpclass_w(w_self)
+ def fdel_func_doc(space, self):
self.w_doc = space.w_None
- def fget___module__(space, w_self):
- self = space.interpclass_w(w_self)
+ def fget___module__(space, self):
if self.w_module is None:
if self.w_func_globals is not None and not space.is_w(self.w_func_globals, space.w_None):
self.w_module = space.call_method( self.w_func_globals, "get", space.wrap("__name__") )
@@ -104,27 +99,22 @@
self.w_module = space.w_None
return self.w_module
- def fset___module__(space, w_self, w_module):
- self = space.interpclass_w(w_self)
+ def fset___module__(space, self, w_module):
self.w_module = w_module
- def fdel___module__(space, w_self):
- self = space.interpclass_w(w_self)
+ def fdel___module__(space, self):
self.w_module = space.w_None
- def fget_func_code(space, w_self):
- self = space.interpclass_w(w_self)
+ def fget_func_code(space, self):
return space.wrap(self.code)
- def fset_func_code(space, w_self, w_code):
- self = space.interpclass_w(w_self)
+ def fset_func_code(space, self, w_code):
code = space.interpclass_w(w_code)
if not isinstance(code, Code ):
raise OperationError( space.w_TypeError, space.wrap("func_code must be set to a code object") )
self.code = code
- def fget_func_closure(space, w_self):
- self = space.interpclass_w(w_self)
+ def fget_func_closure(space, self):
if self.closure is not None:
w_res = space.newtuple( [ space.wrap(i) for i in self.closure ] )
else:
Modified: pypy/dist/pypy/interpreter/pyframe.py
==============================================================================
--- pypy/dist/pypy/interpreter/pyframe.py (original)
+++ pypy/dist/pypy/interpreter/pyframe.py Thu Apr 21 17:38:17 2005
@@ -131,7 +131,7 @@
### line numbers ###
- # for fget_f_* unwrapping through unwrap_spec in typedef.py
+ # for f*_f_* unwrapping through unwrap_spec in typedef.py
def fget_f_lineno(space, self):
"Returns the line number of the instruction currently being executed."
Modified: pypy/dist/pypy/module/builtin/compiling.py
==============================================================================
--- pypy/dist/pypy/module/builtin/compiling.py (original)
+++ pypy/dist/pypy/module/builtin/compiling.py Thu Apr 21 17:38:17 2005
@@ -43,18 +43,18 @@
compile.unwrap_spec = [ObjSpace,W_Root,str,str,int,int]
-def eval(space, w_source, w_globals=NoneNotWrapped, w_locals=NoneNotWrapped):
+def eval(space, w_code, w_globals=NoneNotWrapped, w_locals=NoneNotWrapped):
w = space.wrap
- if (space.is_true(space.isinstance(w_source, space.w_str)) or
- space.is_true(space.isinstance(w_source, space.w_unicode))):
- w_codeobj = compile(space,
- space.call_method(w_source, 'lstrip',
- space.wrap(' \t')),
- "<string>", "eval")
- elif isinstance(space.interpclass_w(w_source), PyCode):
- w_codeobj = w_source
- else:
+ if (space.is_true(space.isinstance(w_code, space.w_str)) or
+ space.is_true(space.isinstance(w_code, space.w_unicode))):
+ w_code = compile(space,
+ space.call_method(w_code, 'lstrip',
+ space.wrap(' \t')),
+ "<string>", "eval")
+
+ codeobj = space.interpclass_w(w_code)
+ if not isinstance(codeobj, PyCode):
raise OperationError(space.w_TypeError,
w('eval() arg 1 must be a string or code object'))
@@ -81,4 +81,4 @@
w_builtin = space.builtin.pick_builtin(caller.w_globals)
space.setitem(w_globals, space.wrap('__builtins__'), w_builtin)
- return space.interpclass_w(w_codeobj).exec_code(space, w_globals, w_locals)
+ return codeobj.exec_code(space, w_globals, w_locals)
More information about the Pypy-commit
mailing list