[pypy-svn] r48507 - in pypy/branch/unicode-objspace/pypy: module/sys objspace/std

cfbolz at codespeak.net cfbolz at codespeak.net
Sat Nov 10 15:54:17 CET 2007


Author: cfbolz
Date: Sat Nov 10 15:54:15 2007
New Revision: 48507

Modified:
   pypy/branch/unicode-objspace/pypy/module/sys/__init__.py
   pypy/branch/unicode-objspace/pypy/module/sys/interp_encoding.py
   pypy/branch/unicode-objspace/pypy/objspace/std/unicodetype.py
Log:
yet another approach: do the same thing as with the recursionlimit and stick
the encoding directly onto the module. probably a good idea, it's easily
accessible and doesn't require a function call. Thanks Alexander.


Modified: pypy/branch/unicode-objspace/pypy/module/sys/__init__.py
==============================================================================
--- pypy/branch/unicode-objspace/pypy/module/sys/__init__.py	(original)
+++ pypy/branch/unicode-objspace/pypy/module/sys/__init__.py	Sat Nov 10 15:54:15 2007
@@ -8,6 +8,7 @@
         super(Module, self).__init__(space, w_name) 
         self.checkinterval = 100
         self.recursionlimit = 100
+        self.defaultencoding = "ascii"
         
     interpleveldefs = {
         '__name__'              : '(space.wrap("sys"))', 

Modified: pypy/branch/unicode-objspace/pypy/module/sys/interp_encoding.py
==============================================================================
--- pypy/branch/unicode-objspace/pypy/module/sys/interp_encoding.py	(original)
+++ pypy/branch/unicode-objspace/pypy/module/sys/interp_encoding.py	Sat Nov 10 15:54:15 2007
@@ -1,13 +1,7 @@
-
-class EncodingState(object):
-    def __init__(self, space):
-        self.space = space
-        self.defaultencoding = "ascii"
-
 def getdefaultencoding(space):
     """Return the current default string encoding used by the Unicode 
 implementation."""
-    return space.wrap(space.fromcache(EncodingState).defaultencoding)
+    return space.wrap(space.sys.defaultencoding)
 
 def setdefaultencoding(space, w_encoding):
     """Set the current default string encoding used by the Unicode 
@@ -17,4 +11,4 @@
     w_lookup = space.getattr(mod, space.wrap("lookup"))
     # check whether the encoding is there
     space.call_function(w_lookup, w_encoding)
-    space.fromcache(EncodingState).defaultencoding = encoding
+    space.sys.defaultencoding = encoding

Modified: pypy/branch/unicode-objspace/pypy/objspace/std/unicodetype.py
==============================================================================
--- pypy/branch/unicode-objspace/pypy/objspace/std/unicodetype.py	(original)
+++ pypy/branch/unicode-objspace/pypy/objspace/std/unicodetype.py	Sat Nov 10 15:54:15 2007
@@ -143,10 +143,7 @@
 # ____________________________________________________________
 
 def getdefaultencoding(space):
-    w_sys = space.getbuiltinmodule("sys")
-    return space.str_w(
-        space.call_function(
-            space.getattr(w_sys, space.wrap("getdefaultencoding"))))
+    return space.sys.defaultencoding
 
 def unicode_from_encoded_object(space, w_obj, encoding, errors):
     w_codecs = space.getbuiltinmodule("_codecs")



More information about the Pypy-commit mailing list