[pypy-commit] pypy default: merge heads

cfbolz pypy.commits at gmail.com
Fri Jan 31 08:12:18 EST 2020


Author: Carl Friedrich Bolz-Tereick <cfbolz at gmx.de>
Branch: 
Changeset: r98612:39bcfae01bee
Date: 2020-01-31 14:10 +0100
http://bitbucket.org/pypy/pypy/changeset/39bcfae01bee/

Log:	merge heads

diff --git a/pypy/module/mmap/interp_mmap.py b/pypy/module/mmap/interp_mmap.py
--- a/pypy/module/mmap/interp_mmap.py
+++ b/pypy/module/mmap/interp_mmap.py
@@ -177,8 +177,10 @@
             return space.newbytes(self.mmap.getslice(start, length))
         else:
             b = StringBuilder(length)
-            for i in range(start, stop, step):
-                b.append(self.mmap.getitem(i))
+            index = start
+            for i in range(length):
+                b.append(self.mmap.getitem(index))
+                index += step
             return space.newbytes(b.build())
 
     def descr_setitem(self, w_index, w_value):
diff --git a/pypy/module/mmap/test/test_mmap.py b/pypy/module/mmap/test/test_mmap.py
--- a/pypy/module/mmap/test/test_mmap.py
+++ b/pypy/module/mmap/test/test_mmap.py
@@ -433,6 +433,15 @@
         m.close()
         f.close()
 
+    def test_get_crash(self):
+        import sys
+        from mmap import mmap
+        s = b'hallo!!!'
+        m = mmap(-1, len(s))
+        m[:] = s
+        assert m[1:None:sys.maxsize] == b'a'
+        m.close()
+
     def test_set_item(self):
         import mmap
 
diff --git a/pypy/objspace/std/newformat.py b/pypy/objspace/std/newformat.py
--- a/pypy/objspace/std/newformat.py
+++ b/pypy/objspace/std/newformat.py
@@ -772,7 +772,7 @@
                     digits = self._upcase_string(digits)
                 out.append(digits)
             if spec.n_decimal:
-                out.append(self._lit(".")[0])
+                out.append(self._lit(self._loc_dec)[0])
             if spec.n_remainder:
                 out.append(num[to_remainder:])
             if spec.n_rpadding:
diff --git a/pypy/objspace/std/test/test_newformat.py b/pypy/objspace/std/test/test_newformat.py
--- a/pypy/objspace/std/test/test_newformat.py
+++ b/pypy/objspace/std/test/test_newformat.py
@@ -389,6 +389,24 @@
         finally:
             locale.setlocale(locale.LC_NUMERIC, 'C')
 
+    def test_locale_german(self):
+        import locale
+        for name in ['de_DE', 'de_DE.utf8']:
+            try:
+                locale.setlocale(locale.LC_NUMERIC, name)
+                break
+            except locale.Error:
+                pass
+        else:
+            skip("no german locale")
+        x = 1234.567890
+        try:
+            assert locale.format('%g', x, grouping=True) == '1.234,57'
+            assert format(x, 'n') == '1.234,57'
+            assert format(12345678901234, 'n') == '12.345.678.901.234'
+        finally:
+            locale.setlocale(locale.LC_NUMERIC, 'C')
+
     def test_dont_switch_to_g(self):
         skip("must fix when float formatting is figured out")
         assert len(format(1.1234e90, "f")) == 98


More information about the pypy-commit mailing list