1.1 --- a/lib/__builtins__/character.py Thu Feb 02 23:15:24 2017 +0100
1.2 +++ b/lib/__builtins__/character.py Thu Feb 02 23:17:08 2017 +0100
1.3 @@ -19,9 +19,19 @@
1.4 this program. If not, see <http://www.gnu.org/licenses/>.
1.5 """
1.6
1.7 -from native import str_ord
1.8 +from __builtins__.types import check_int, check_string
1.9 +from native import str_chr, str_ord
1.10 +
1.11 +def chr(i):
1.12 +
1.13 + "Return a string containing a character having the value 'i'."
1.14
1.15 -def chr(i): pass
1.16 + check_int(i)
1.17 +
1.18 + if 0 <= i <= 255:
1.19 + return str_chr(i.__data__)
1.20 + else:
1.21 + raise ValueError, i
1.22
1.23 _hexdigits = "0123456789abcdef"
1.24
1.25 @@ -75,10 +85,12 @@
1.26
1.27 "Return the value of the given character 'c'."
1.28
1.29 - if isinstance(c, string) and len(c) == 1:
1.30 + check_string(c)
1.31 +
1.32 + if c.__len__() == 1:
1.33 return str_ord(c.__data__)
1.34 else:
1.35 - raise ValueError(c)
1.36 + raise ValueError, c
1.37
1.38 def unichr(i): pass
1.39