1.1 --- a/lib/__builtins__/identity.py Wed Nov 23 15:17:29 2016 +0100
1.2 +++ b/lib/__builtins__/identity.py Wed Nov 23 15:25:48 2016 +0100
1.3 @@ -3,7 +3,7 @@
1.4 """
1.5 Identity-related functions.
1.6
1.7 -Copyright (C) 2015 Paul Boddie <paul@boddie.org.uk>
1.8 +Copyright (C) 2015, 2016 Paul Boddie <paul@boddie.org.uk>
1.9
1.10 This program is free software; you can redistribute it and/or modify it under
1.11 the terms of the GNU General Public License as published by the Free Software
1.12 @@ -45,6 +45,10 @@
1.13
1.14 def issubclass(obj, cls_or_tuple): pass
1.15
1.16 -def repr(obj): pass
1.17 +def repr(obj):
1.18 +
1.19 + "Return a program representation for 'obj'."
1.20 +
1.21 + return obj.__repr__()
1.22
1.23 # vim: tabstop=4 expandtab shiftwidth=4
2.1 --- a/lib/__builtins__/int.py Wed Nov 23 15:17:29 2016 +0100
2.2 +++ b/lib/__builtins__/int.py Wed Nov 23 15:25:48 2016 +0100
2.3 @@ -144,6 +144,8 @@
2.4 "Return a string representation."
2.5 return native._int_str(self)
2.6
2.7 + __repr__ = __str__
2.8 +
2.9 def __lshift__(self): pass
2.10 def __rlshift__(self): pass
2.11 def __rshift__(self): pass
3.1 --- a/lib/__builtins__/list.py Wed Nov 23 15:17:29 2016 +0100
3.2 +++ b/lib/__builtins__/list.py Wed Nov 23 15:25:48 2016 +0100
3.3 @@ -112,12 +112,14 @@
3.4 first = False
3.5 else:
3.6 b.append(", ")
3.7 - b.append(self.__get_single_item__(i))
3.8 + b.append(repr(self.__get_single_item__(i)))
3.9 i += 1
3.10 b.append("]")
3.11
3.12 return str(b)
3.13
3.14 + __repr__ = __str__
3.15 +
3.16 def __bool__(self):
3.17
3.18 "Lists are true if non-empty."
4.1 --- a/lib/__builtins__/str.py Wed Nov 23 15:17:29 2016 +0100
4.2 +++ b/lib/__builtins__/str.py Wed Nov 23 15:25:48 2016 +0100
4.3 @@ -75,8 +75,15 @@
4.4 return native._str_len(self)
4.5
4.6 def __str__(self):
4.7 + "Return a string representation."
4.8 return self
4.9
4.10 + def __repr__(self):
4.11 + "Return a string literal representation."
4.12 + # NOTE: To be implemented with proper quoting.
4.13 + b = buffer(['"', self, '"'])
4.14 + return str(b)
4.15 +
4.16 def __bool__(self):
4.17 return native._str_nonempty(self)
4.18