Alex Gaynor avatar Alex Gaynor committed b67cae9 Merge

Merged upstream.

Comments (0)

Files changed (2)

pypy/rlib/runicode.py

                                  errorhandler=None,
                                  byteorder='little'):
     if size == 0:
+        if byteorder == 'native':
+            result = StringBuilder(2)
+            _STORECHAR(result, 0xFEFF, BYTEORDER)
+            return result.build()
         return ""
 
     result = StringBuilder(size * 2 + 2)
                                  errorhandler=None,
                                  byteorder='little'):
     if size == 0:
+        if byteorder == 'native':
+            result = StringBuilder(4)
+            _STORECHAR32(result, 0xFEFF, BYTEORDER)
+            return result.build()
         return ""
 
     result = StringBuilder(size * 4 + 4)

pypy/rlib/test/test_runicode.py

                          "utf-32 utf-32-be utf-32-le").split():
             self.checkencode(uni, encoding)
 
+    def test_empty(self):
+        for encoding in ("utf-8 utf-16 utf-16-be utf-16-le "
+                         "utf-32 utf-32-be utf-32-le").split():
+            self.checkencode(u'', encoding)
+
     def test_single_chars_utf8(self):
         # check every number of bytes per char
         for s in ["\xd7\x90", "\xd6\x96", "\xeb\x96\x95", "\xf0\x90\x91\x93"]:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.