Author: Carl Friedrich Bolz <[email protected]>
Branch: space-newtext
Changeset: r88099:b2eced084549
Date: 2016-11-02 15:37 +0100
http://bitbucket.org/pypy/pypy/changeset/b2eced084549/
Log: unicodedata
diff --git a/pypy/module/_csv/interp_reader.py
b/pypy/module/_csv/interp_reader.py
--- a/pypy/module/_csv/interp_reader.py
+++ b/pypy/module/_csv/interp_reader.py
@@ -24,13 +24,13 @@
self.line_num = 0
def iter_w(self):
- return self.space.wrap(self)
+ return self
@objectmodel.dont_inline
def error(self, msg):
space = self.space
w_module = space.getbuiltinmodule('_csv')
- w_error = space.getattr(w_module, space.wrap('Error'))
+ w_error = space.getattr(w_module, space.newtext('Error'))
raise oefmt(w_error, "line %d: %s", self.line_num, msg)
def add_char(self, field_builder, c):
@@ -49,10 +49,10 @@
try:
ff = string_to_float(field)
except ParseStringError as e:
- raise wrap_parsestringerror(space, e, space.wrap(field))
- w_obj = space.wrap(ff)
+ raise wrap_parsestringerror(space, e, space.newtext(field))
+ w_obj = space.newfloat(ff)
else:
- w_obj = space.wrap(field)
+ w_obj = space.newtext(field)
self.fields_w.append(w_obj)
def next_w(self):
@@ -267,4 +267,4 @@
old_limit = field_limit.limit
if new_limit >= 0:
field_limit.limit = new_limit
- return space.wrap(old_limit)
+ return space.newint(old_limit)
diff --git a/pypy/module/binascii/interp_binascii.py
b/pypy/module/binascii/interp_binascii.py
--- a/pypy/module/binascii/interp_binascii.py
+++ b/pypy/module/binascii/interp_binascii.py
@@ -7,8 +7,8 @@
def raise_Error(space, msg):
w_error = space.fromcache(Cache).w_error
- raise OperationError(w_error, space.wrap(msg))
+ raise OperationError(w_error, space.newtext(msg))
def raise_Incomplete(space, msg):
w_error = space.fromcache(Cache).w_incomplete
- raise OperationError(w_error, space.wrap(msg))
+ raise OperationError(w_error, space.newtext(msg))
diff --git a/pypy/module/binascii/interp_crc32.py
b/pypy/module/binascii/interp_crc32.py
--- a/pypy/module/binascii/interp_crc32.py
+++ b/pypy/module/binascii/interp_crc32.py
@@ -9,4 +9,4 @@
crc = rzipfile.crc32(data, r_uint(oldcrc))
crc = rffi.cast(rffi.INT, crc) # unsigned => 32-bit signed
- return space.wrap(intmask(crc))
+ return space.newint(intmask(crc))
diff --git a/pypy/module/unicodedata/interp_ucd.py
b/pypy/module/unicodedata/interp_ucd.py
--- a/pypy/module/unicodedata/interp_ucd.py
+++ b/pypy/module/unicodedata/interp_ucd.py
@@ -99,18 +99,18 @@
try:
code = self._lookup(name.upper())
except KeyError:
- msg = space.mod(space.wrap("undefined character name '%s'"),
space.wrap(name))
+ msg = space.mod(space.newtext("undefined character name '%s'"),
space.newtext(name))
raise OperationError(space.w_KeyError, msg)
- return space.wrap(code)
+ return space.newint(code)
@unwrap_spec(name=str)
def lookup(self, space, name):
try:
code = self._lookup(name.upper())
except KeyError:
- msg = space.mod(space.wrap("undefined character name '%s'"),
space.wrap(name))
+ msg = space.mod(space.newtext("undefined character name '%s'"),
space.newtext(name))
raise OperationError(space.w_KeyError, msg)
- return space.wrap(code_to_unichr(code))
+ return space.newunicode(code_to_unichr(code))
def name(self, space, w_unichr, w_default=None):
code = unichr_to_code_w(space, w_unichr)
@@ -120,12 +120,12 @@
if w_default is not None:
return w_default
raise oefmt(space.w_ValueError, "no such name")
- return space.wrap(name)
+ return space.newtext(name)
def decimal(self, space, w_unichr, w_default=None):
code = unichr_to_code_w(space, w_unichr)
try:
- return space.wrap(self._decimal(code))
+ return space.newint(self._decimal(code))
except KeyError:
pass
if w_default is not None:
@@ -135,7 +135,7 @@
def digit(self, space, w_unichr, w_default=None):
code = unichr_to_code_w(space, w_unichr)
try:
- return space.wrap(self._digit(code))
+ return space.newint(self._digit(code))
except KeyError:
pass
if w_default is not None:
@@ -145,7 +145,7 @@
def numeric(self, space, w_unichr, w_default=None):
code = unichr_to_code_w(space, w_unichr)
try:
- return space.wrap(self._numeric(code))
+ return space.newfloat(self._numeric(code))
except KeyError:
pass
if w_default is not None:
@@ -154,28 +154,28 @@
def category(self, space, w_unichr):
code = unichr_to_code_w(space, w_unichr)
- return space.wrap(self._category(code))
+ return space.newtext(self._category(code))
def east_asian_width(self, space, w_unichr):
code = unichr_to_code_w(space, w_unichr)
- return space.wrap(self._east_asian_width(code))
+ return space.newtext(self._east_asian_width(code))
def bidirectional(self, space, w_unichr):
code = unichr_to_code_w(space, w_unichr)
- return space.wrap(self._bidirectional(code))
+ return space.newtext(self._bidirectional(code))
def combining(self, space, w_unichr):
code = unichr_to_code_w(space, w_unichr)
- return space.wrap(self._combining(code))
+ return space.newint(self._combining(code))
def mirrored(self, space, w_unichr):
code = unichr_to_code_w(space, w_unichr)
# For no reason, unicodedata.mirrored() returns an int, not a bool
- return space.wrap(int(self._mirrored(code)))
+ return space.newint(int(self._mirrored(code)))
def decomposition(self, space, w_unichr):
code = unichr_to_code_w(space, w_unichr)
- return space.wrap(self._decomposition(code))
+ return space.newtext(self._decomposition(code))
@unwrap_spec(form=str)
def normalize(self, space, form, w_unistr):
@@ -204,7 +204,7 @@
resultlen = len(result)
# Expand the character
for i in range(strlen):
- ch = space.int_w(space.ord(space.getitem(w_unistr, space.wrap(i))))
+ ch = space.int_w(space.ord(space.getitem(w_unistr,
space.newint(i))))
# Do Hangul decomposition
if SBase <= ch < SBase + SCount:
SIndex = ch - SBase
@@ -259,10 +259,10 @@
result[0] = ch
if not composed: # If decomposed normalization we are done
- return space.wrap(u''.join([unichr(i) for i in result[:j]]))
+ return space.newunicode(u''.join([unichr(i) for i in result[:j]]))
if j <= 1:
- return space.wrap(u''.join([unichr(i) for i in result[:j]]))
+ return space.newunicode(u''.join([unichr(i) for i in result[:j]]))
current = result[0]
starter_pos = 0
@@ -309,7 +309,7 @@
result[starter_pos] = current
- return space.wrap(u''.join([unichr(i) for i in result[:next_insert]]))
+ return space.newunicode(u''.join([unichr(i) for i in
result[:next_insert]]))
methods = {}
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit