Author: Philip Jenvey <[email protected]>
Branch: py3k
Changeset: r71745:9a4c6f4f53b6
Date: 2014-05-27 13:07 -0700
http://bitbucket.org/pypy/pypy/changeset/9a4c6f4f53b6/

Log:    oops, avoid we_are_translated at module scope

diff --git a/rpython/rlib/runicode.py b/rpython/rlib/runicode.py
--- a/rpython/rlib/runicode.py
+++ b/rpython/rlib/runicode.py
@@ -11,7 +11,6 @@
 else:
     MAXUNICODE = 0xffff
 
-NARROW_HOST = not we_are_translated() and sys.maxunicode == 0xFFFF
 BYTEORDER = sys.byteorder
 
 # python 2.7 has a preview of py3k behavior, so those functions
@@ -64,7 +63,7 @@
 
 if MAXUNICODE > 0xFFFF:
     def code_to_unichr(code):
-        if NARROW_HOST:
+        if is_narrow_host():
             # Host CPython is narrow build, generate surrogates
             return unichr_returns_surrogate(code)
         else:
@@ -84,6 +83,9 @@
         result.append(hi)
         result.append(lo)
 
+def is_narrow_host():
+    return not we_are_translated() and sys.maxunicode == 0xFFFF
+
 def default_unicode_error_decode(errors, encoding, msg, s,
                                  startingpos, endingpos):
     if errors == 'replace':
@@ -336,7 +338,7 @@
                         # Check for low surrogate and combine the two to
                         # form a UCS4 value
                         if ((allow_surrogates or MAXUNICODE < 65536
-                             or NARROW_HOST) and
+                             or is_narrow_host()) and
                             ch <= 0xDBFF and 0xDC00 <= ch2 <= 0xDFFF):
                             ch3 = ((ch - 0xD800) << 10 | (ch2 - 0xDC00)) + 
0x10000
                             assert ch3 >= 0
@@ -1344,7 +1346,7 @@
 
             # The following logic is enabled only if MAXUNICODE == 0xffff, or
             # for testing on top of a host Python where sys.maxunicode == 
0xffff
-            if ((MAXUNICODE < 65536 or NARROW_HOST)
+            if ((MAXUNICODE < 65536 or is_narrow_host())
                 and 0xD800 <= oc < 0xDC00 and pos + 1 < size):
                 # Map UTF-16 surrogate pairs to Unicode \UXXXXXXXX escapes
                 pos += 1
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to