[pypy-svn] r9227 - in pypy/dist/pypy: interpreter interpreter/test module objspace/std

pedronis at codespeak.net pedronis at codespeak.net
Tue Feb 15 01:46:05 CET 2005


Author: pedronis
Date: Tue Feb 15 01:46:04 2005
New Revision: 9227

Modified:
   pypy/dist/pypy/interpreter/main.py
   pypy/dist/pypy/interpreter/test/test_interpreter.py
   pypy/dist/pypy/module/__builtin__interp.py
   pypy/dist/pypy/objspace/std/unicodeobject.py
Log:
fixes for tests and comments

str_w works with unicode



Modified: pypy/dist/pypy/interpreter/main.py
==============================================================================
--- pypy/dist/pypy/interpreter/main.py	(original)
+++ pypy/dist/pypy/interpreter/main.py	Tue Feb 15 01:46:04 2005
@@ -16,7 +16,7 @@
 
         compile = space.builtin.compile
         w = space.wrap
-        w_code = compile(source, filename, cmd, 0, 0)
+        w_code = compile(w(source), filename, cmd, 0, 0)
 
         w_main = space.wrap('__main__')
         mainmodule = module.Module(space, w_main)

Modified: pypy/dist/pypy/interpreter/test/test_interpreter.py
==============================================================================
--- pypy/dist/pypy/interpreter/test/test_interpreter.py	(original)
+++ pypy/dist/pypy/interpreter/test/test_interpreter.py	Tue Feb 15 01:46:04 2005
@@ -12,7 +12,7 @@
 
         compile = space.builtin.compile
         w = space.wrap
-        w_code = compile(source, '<string>', 'exec', 0, 0)
+        w_code = compile(w(source), '<string>', 'exec', 0, 0)
 
         ec = executioncontext.ExecutionContext(space)
 

Modified: pypy/dist/pypy/module/__builtin__interp.py
==============================================================================
--- pypy/dist/pypy/module/__builtin__interp.py	(original)
+++ pypy/dist/pypy/module/__builtin__interp.py	Tue Feb 15 01:46:04 2005
@@ -197,20 +197,12 @@
         w_exc = space.call_function(space.w_ImportError, w_failing)
         raise OperationError(space.w_ImportError, w_exc)
 
-def compile(w_str_, w_filename, w_startstr,
-            w_supplied_flags=None, w_dont_inherit=None):
+def compile(w_str_, filename, startstr,
+            supplied_flags=0, dont_inherit=0):
     if space.is_true(space.isinstance(w_str_, space.w_unicode)):
-        str_ = space.unwrap(w_str_)
+        str_ = space.unwrap(w_str_) # xxx generic unwrap
     else:
         str_ = space.str_w(w_str_)
-    filename = space.str_w(w_filename)
-    startstr = space.str_w(w_startstr)
-    supplied_flags = 0
-    if not space.is_w(w_supplied_flags, space.w_None):
-        supplied_flags = space.int_w(w_supplied_flags)
-    dont_inherit = 0
-    if not space.is_w(w_dont_inherit, space.w_None):
-        dont_inherit = space.int_w(w_dont_inherit)
     #print (str_, filename, startstr, supplied_flags, dont_inherit)
     # XXX we additionally allow GENERATORS because compiling some builtins
     #     requires it. doesn't feel quite right to do that here.
@@ -235,7 +227,7 @@
         raise OperationError(space.w_TypeError,space.wrap(str(e)))
     return space.wrap(PyCode(space)._from_code(c))
 #
-#compile.unwrap_spec = [str,str,str,int,int]
+compile.unwrap_spec = [W_Root,str,str,int,int]
 
 
 def eval(w_source, w_globals=NoneNotWrapped, w_locals=NoneNotWrapped):
@@ -243,7 +235,7 @@
 
     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.call_method(w_source, 'lstrip', space.wrap(' \t')), space.wrap("<string>"), space.wrap("eval"), space.w_None, space.w_None)
+        w_codeobj = compile(space.call_method(w_source, 'lstrip', space.wrap(' \t')), "<string>", "eval")
     elif isinstance(space.interpclass_w(w_source), PyCode):
         w_codeobj = w_source
     else:
@@ -274,7 +266,7 @@
     return space.w_None
 
 def getattr(w_object, w_name, w_defvalue=NoneNotWrapped):
-    if space.is_true(space.isinstance(w_name, space.w_unicode)):
+    if space.is_true(space.isinstance(w_name, space.w_unicode)): # xxx collect this logic somewhere
         w_name = space.call_method(w_name, 'encode')
     try:
         return space.getattr(w_object, w_name)

Modified: pypy/dist/pypy/objspace/std/unicodeobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/unicodeobject.py	(original)
+++ pypy/dist/pypy/objspace/std/unicodeobject.py	Tue Feb 15 01:46:04 2005
@@ -29,6 +29,8 @@
     space = w_str.space
     return W_UnicodeObject(space, unicode(space.str_w(w_str)))
 
+def str_w__Unicode(space, w_uni):
+    return space.str_w(space.call_method(w_uni, 'encode'))
 
 def eq__Unicode_ANY(space, w_uni, w_other):
     try:



More information about the Pypy-commit mailing list