# HG changeset patch # User Paul Boddie # Date 1484500254 -3600 # Node ID 3a12bbe877883aadfd89f854af8f266833644971 # Parent 96998974b85585c84e78709453a79421cf300565 Make string representations of integers Unicode objects having an implicit UTF-8 encoding, thus permitting them to be combined successfully with other Unicode objects. diff -r 96998974b855 -r 3a12bbe87788 lib/__builtins__/int.py --- a/lib/__builtins__/int.py Sun Jan 15 16:18:03 2017 +0100 +++ b/lib/__builtins__/int.py Sun Jan 15 18:10:54 2017 +0100 @@ -20,6 +20,7 @@ """ from __builtins__.operator import _negate +from __builtins__.unicode import utf8string from native import isinstance as _isinstance, get_maxint, get_minint, \ int_add, int_and, int_div, int_eq, int_gt, int_lt, int_mod, \ int_mul, int_ne, int_neg, int_not, int_or, int_pow, \ @@ -217,7 +218,7 @@ "Return a string representation." - return int_str(self.__data__) + return utf8string(int_str(self.__data__)) __repr__ = __str__ diff -r 96998974b855 -r 3a12bbe87788 tests/numbers.py --- a/tests/numbers.py Sun Jan 15 16:18:03 2017 +0100 +++ b/tests/numbers.py Sun Jan 15 18:10:54 2017 +0100 @@ -1,3 +1,5 @@ +# -*- coding: ISO-8859-1 -*- + import sys print "# sys.maxint: ", @@ -52,3 +54,15 @@ print "# hash((sys.maxint - 1, 0)): ", print hash((sys.maxint - 1, 0)) + +# Test combining numbers with strings. + +s = "Number is " + str(123) +s2 = "זרו -> " + str(123) +print s.__class__ +print s2.__class__ +print s +print s2 + +sys.stdout.encoding = "UTF-8" +print s2