[pypy-commit] pypy release-1.6.x: Windows fix.

arigo noreply at buildbot.pypy.org
Fri Aug 12 09:36:48 CEST 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: release-1.6.x
Changeset: r46446:a221cae5c841
Date: 2011-08-12 09:38 +0200
http://bitbucket.org/pypy/pypy/changeset/a221cae5c841/

Log:	Windows fix.

diff --git a/pypy/rlib/runicode.py b/pypy/rlib/runicode.py
--- a/pypy/rlib/runicode.py
+++ b/pypy/rlib/runicode.py
@@ -1505,17 +1505,16 @@
             rffi.free_nonmovingbuffer(s, dataptr)
 
     def unicode_encode_mbcs(p, size, errors, errorhandler=None):
+        if size == 0:
+            return ''
         dataptr = rffi.get_nonmoving_unicodebuffer(p)
         try:
             # first get the size of the result
-            if size > 0:
-                mbcssize = WideCharToMultiByte(CP_ACP, 0,
-                                               dataptr, size, None, 0,
-                                               None, None)
-                if mbcssize == 0:
-                    raise rwin32.lastWindowsError()
-            else:
-                mbcssize = 0
+            mbcssize = WideCharToMultiByte(CP_ACP, 0,
+                                           dataptr, size, None, 0,
+                                           None, None)
+            if mbcssize == 0:
+                raise rwin32.lastWindowsError()
 
             raw_buf, gc_buf = rffi.alloc_buffer(mbcssize)
             try:


More information about the pypy-commit mailing list