[pypy-svn] r64134 - in pypy/branch/wip-fix-stackless-O2-pickling/pypy: interpreter interpreter/pyparser objspace/std
cfbolz at codespeak.net
cfbolz at codespeak.net
Thu Apr 16 10:17:01 CEST 2009
Author: cfbolz
Date: Thu Apr 16 10:16:59 2009
New Revision: 64134
Added:
pypy/branch/wip-fix-stackless-O2-pickling/pypy/interpreter/unicodehelper.py (contents, props changed)
Modified:
pypy/branch/wip-fix-stackless-O2-pickling/pypy/interpreter/pyparser/parsestring.py
pypy/branch/wip-fix-stackless-O2-pickling/pypy/objspace/std/marshal_impl.py
Log:
(pedronis, cfbolz): fix another builtin code object that exists twice.
Modified: pypy/branch/wip-fix-stackless-O2-pickling/pypy/interpreter/pyparser/parsestring.py
==============================================================================
--- pypy/branch/wip-fix-stackless-O2-pickling/pypy/interpreter/pyparser/parsestring.py (original)
+++ pypy/branch/wip-fix-stackless-O2-pickling/pypy/interpreter/pyparser/parsestring.py Thu Apr 16 10:16:59 2009
@@ -1,5 +1,5 @@
-from pypy.interpreter import gateway
from pypy.interpreter.error import OperationError
+from pypy.interpreter import unicodehelper
def parsestr(space, encoding, s):
# compiler.transformer.Transformer.decode_literal depends on what
@@ -74,9 +74,9 @@
assert 0 <= bufp <= bufq
w_substr = space.wrap(buf[bufp : bufq])
if rawmode:
- w_v = PyUnicode_DecodeRawUnicodeEscape(space, w_substr)
+ w_v = unicodehelper.PyUnicode_DecodeRawUnicodeEscape(space, w_substr)
else:
- w_v = PyUnicode_DecodeUnicodeEscape(space, w_substr)
+ w_v = unicodehelper.PyUnicode_DecodeUnicodeEscape(space, w_substr)
return w_v
need_encoding = (encoding is not None and
@@ -86,9 +86,9 @@
substr = s[ps : q]
if rawmode or '\\' not in s[ps:]:
if need_encoding:
- w_u = PyUnicode_DecodeUTF8(space, space.wrap(substr))
+ w_u = unicodehelper.PyUnicode_DecodeUTF8(space, space.wrap(substr))
#w_v = space.wrap(space.unwrap(w_u).encode(encoding)) this works
- w_v = PyUnicode_AsEncodedString(space, w_u, space.wrap(encoding))
+ w_v = Punicodehelper.yUnicode_AsEncodedString(space, w_u, space.wrap(encoding))
return w_v
else:
return space.wrap(substr)
@@ -193,28 +193,6 @@
ch >= 'a' and ch <= 'f' or
ch >= 'A' and ch <= 'F')
-app = gateway.applevel(r'''
- def PyUnicode_DecodeUnicodeEscape(data):
- import _codecs
- return _codecs.unicode_escape_decode(data)[0]
-
- def PyUnicode_DecodeRawUnicodeEscape(data):
- import _codecs
- return _codecs.raw_unicode_escape_decode(data)[0]
-
- def PyUnicode_DecodeUTF8(data):
- import _codecs
- return _codecs.utf_8_decode(data)[0]
-
- def PyUnicode_AsEncodedString(data, encoding):
- import _codecs
- return _codecs.encode(data, encoding)
-''')
-
-PyUnicode_DecodeUnicodeEscape = app.interphook('PyUnicode_DecodeUnicodeEscape')
-PyUnicode_DecodeRawUnicodeEscape = app.interphook('PyUnicode_DecodeRawUnicodeEscape')
-PyUnicode_DecodeUTF8 = app.interphook('PyUnicode_DecodeUTF8')
-PyUnicode_AsEncodedString = app.interphook('PyUnicode_AsEncodedString')
def decode_utf8(space, s, ps, end, encoding):
assert ps >= 0
@@ -222,8 +200,8 @@
# while (s < end && *s != '\\') s++; */ /* inefficient for u".."
while ps < end and ord(s[ps]) & 0x80:
ps += 1
- w_u = PyUnicode_DecodeUTF8(space, space.wrap(s[pt : ps]))
- w_v = PyUnicode_AsEncodedString(space, w_u, space.wrap(encoding))
+ w_u = unicodehelper.PyUnicode_DecodeUTF8(space, space.wrap(s[pt : ps]))
+ w_v = unicodehelper.PyUnicode_AsEncodedString(space, w_u, space.wrap(encoding))
v = space.str_w(w_v)
return v, ps
Added: pypy/branch/wip-fix-stackless-O2-pickling/pypy/interpreter/unicodehelper.py
==============================================================================
--- (empty file)
+++ pypy/branch/wip-fix-stackless-O2-pickling/pypy/interpreter/unicodehelper.py Thu Apr 16 10:16:59 2009
@@ -0,0 +1,24 @@
+from pypy.interpreter import gateway
+
+app = gateway.applevel(r'''
+ def PyUnicode_DecodeUnicodeEscape(data):
+ import _codecs
+ return _codecs.unicode_escape_decode(data)[0]
+
+ def PyUnicode_DecodeRawUnicodeEscape(data):
+ import _codecs
+ return _codecs.raw_unicode_escape_decode(data)[0]
+
+ def PyUnicode_DecodeUTF8(data):
+ import _codecs
+ return _codecs.utf_8_decode(data)[0]
+
+ def PyUnicode_AsEncodedString(data, encoding):
+ import _codecs
+ return _codecs.encode(data, encoding)
+''')
+
+PyUnicode_DecodeUnicodeEscape = app.interphook('PyUnicode_DecodeUnicodeEscape')
+PyUnicode_DecodeRawUnicodeEscape = app.interphook('PyUnicode_DecodeRawUnicodeEscape')
+PyUnicode_DecodeUTF8 = app.interphook('PyUnicode_DecodeUTF8')
+PyUnicode_AsEncodedString = app.interphook('PyUnicode_AsEncodedString')
Modified: pypy/branch/wip-fix-stackless-O2-pickling/pypy/objspace/std/marshal_impl.py
==============================================================================
--- pypy/branch/wip-fix-stackless-O2-pickling/pypy/objspace/std/marshal_impl.py (original)
+++ pypy/branch/wip-fix-stackless-O2-pickling/pypy/objspace/std/marshal_impl.py Thu Apr 16 10:16:59 2009
@@ -17,7 +17,7 @@
from pypy.objspace.std.objspace import StdObjSpace
from pypy.interpreter.special import Ellipsis
from pypy.interpreter.pycode import PyCode
-from pypy.interpreter import gateway
+from pypy.interpreter import gateway, unicodehelper
from pypy.rlib.rstruct import ieee
from pypy.objspace.std.boolobject import W_BoolObject
@@ -435,25 +435,12 @@
return space.wrap(code)
register(TYPE_CODE, unmarshal_pycode)
-app = gateway.applevel(r'''
- def PyUnicode_EncodeUTF8(data):
- import _codecs
- return _codecs.utf_8_encode(data)[0]
-
- def PyUnicode_DecodeUTF8(data):
- import _codecs
- return _codecs.utf_8_decode(data)[0]
-''')
-
-PyUnicode_EncodeUTF8 = app.interphook('PyUnicode_EncodeUTF8')
-PyUnicode_DecodeUTF8 = app.interphook('PyUnicode_DecodeUTF8')
-
def marshal_w__Unicode(space, w_unicode, m):
- s = space.str_w(PyUnicode_EncodeUTF8(space, w_unicode))
+ s = space.str_w(unicodehelper.PyUnicode_EncodeUTF8(space, w_unicode))
m.atom_str(TYPE_UNICODE, s)
def unmarshal_Unicode(space, u, tc):
- return PyUnicode_DecodeUTF8(space, space.wrap(u.get_str()))
+ return unicodehelper.PyUnicode_DecodeUTF8(space, space.wrap(u.get_str()))
register(TYPE_UNICODE, unmarshal_Unicode)
app = gateway.applevel(r'''
More information about the Pypy-commit
mailing list