[pypy-commit] pypy refactor-str-types: Add app-level unicode.isdecimal and unicode.isnumeric.
Manuel Jacob
noreply at buildbot.pypy.org
Sat Jul 27 14:19:53 CEST 2013
Author: Manuel Jacob
Branch: refactor-str-types
Changeset: r65706:5e677015dc17
Date: 2013-07-27 14:17 +0200
http://bitbucket.org/pypy/pypy/changeset/5e677015dc17/
Log: Add app-level unicode.isdecimal and unicode.isnumeric.
diff --git a/pypy/objspace/std/test/test_unicodeobject.py b/pypy/objspace/std/test/test_unicodeobject.py
--- a/pypy/objspace/std/test/test_unicodeobject.py
+++ b/pypy/objspace/std/test/test_unicodeobject.py
@@ -888,3 +888,15 @@
assert b == u'hello \u1234'
assert u'%s' % S(u'mar\xe7') == u'mar\xe7'
+
+ def test_isdecimal(self):
+ assert u'0'.isdecimal()
+ assert not u''.isdecimal()
+ assert not u'a'.isdecimal()
+ assert not u'\u2460'.isdecimal() # CIRCLED DIGIT ONE
+
+ def test_isnumeric(self):
+ assert u'0'.isnumeric()
+ assert not u''.isnumeric()
+ assert not u'a'.isnumeric()
+ assert u'\u2460'.isnumeric() # CIRCLED DIGIT ONE
diff --git a/pypy/objspace/std/unicodeobject.py b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -96,6 +96,9 @@
def _islower(self, ch):
return unicodedb.islower(ord(ch))
+ def _isnumeric(self, ch):
+ return unicodedb.isnumeric(ord(ch))
+
def _istitle(self, ch):
return unicodedb.istitle(ord(ch))
@@ -111,6 +114,9 @@
def _isdigit(self, ch):
return unicodedb.isdigit(ord(ch))
+ def _isdecimal(self, ch):
+ return unicodedb.isdecimal(ord(ch))
+
def _iscased(self, ch):
return unicodedb.iscased(ord(ch))
@@ -205,6 +211,12 @@
tformat = unicode_template_formatter(space, space.unicode_w(self))
return tformat.formatter_field_name_split()
+ def descr_isdecimal(self, space):
+ return self._is_generic(space, '_isdecimal')
+
+ def descr_isnumeric(self, space):
+ return self._is_generic(space, '_isnumeric')
+
def wrapunicode(space, uni):
return W_UnicodeObject(uni)
@@ -429,8 +441,10 @@
rindex = interp2app(W_UnicodeObject.descr_rindex),
isalnum = interp2app(W_UnicodeObject.descr_isalnum),
isalpha = interp2app(W_UnicodeObject.descr_isalpha),
+ isdecimal = interp2app(W_UnicodeObject.descr_isdecimal),
isdigit = interp2app(W_UnicodeObject.descr_isdigit),
islower = interp2app(W_UnicodeObject.descr_islower),
+ isnumeric = interp2app(W_UnicodeObject.descr_isnumeric),
isspace = interp2app(W_UnicodeObject.descr_isspace),
istitle = interp2app(W_UnicodeObject.descr_istitle),
isupper = interp2app(W_UnicodeObject.descr_isupper),
More information about the pypy-commit
mailing list