[python-simplejson/el5/master] add patch for containerless unicode float decoding (bz 622835)

Felix Schwarz fschwarz at fedoraproject.org
Wed Aug 11 10:23:44 UTC 2010


commit f9d79ac1da823e7e6c0fd0d00289c37e3315810b
Author: Felix Schwarz <felix.schwarz at oss.schwarz.eu>
Date:   Wed Aug 11 12:23:17 2010 +0200

    add patch for containerless unicode float decoding (bz 622835)

 ...-for-containerless-unicode-float-decoding.patch |   12 +++++
 ...containerless-unicode-float-decoding-r177.patch |   44 ++++++++++++++++++++
 python-simplejson.spec                             |   12 ++++-
 3 files changed, 66 insertions(+), 2 deletions(-)
---
diff --git a/python-simplejson-add-test-for-containerless-unicode-float-decoding.patch b/python-simplejson-add-test-for-containerless-unicode-float-decoding.patch
new file mode 100644
index 0000000..04442ca
--- /dev/null
+++ b/python-simplejson-add-test-for-containerless-unicode-float-decoding.patch
@@ -0,0 +1,12 @@
+diff -r c91a23d98699 simplejson/tests/test_float.py
+--- a/simplejson/tests/test_float.py	Wed Aug 11 12:06:40 2010 +0200
++++ b/simplejson/tests/test_float.py	Wed Aug 11 12:07:29 2010 +0200
+@@ -17,3 +17,8 @@
+             self.assertEquals(int(json.dumps(num)), num)
+             self.assertEquals(json.loads(json.dumps(num)), num)
+             self.assertEquals(json.loads(unicode(json.dumps(num))), num)
++    
++    def test_can_decode_containerless_unicode_float(self):
++        # needs to have two decimal places
++        self.assertEquals(2.75, json.loads(u'2.75'))
++
diff --git a/python-simplejson-fix-containerless-unicode-float-decoding-r177.patch b/python-simplejson-fix-containerless-unicode-float-decoding-r177.patch
new file mode 100644
index 0000000..c3f443d
--- /dev/null
+++ b/python-simplejson-fix-containerless-unicode-float-decoding-r177.patch
@@ -0,0 +1,44 @@
+diff -r 288a7e1d137d simplejson/_speedups.c
+--- a/simplejson/_speedups.c	Wed Aug 11 12:06:18 2010 +0200
++++ b/simplejson/_speedups.c	Wed Aug 11 12:06:35 2010 +0200
+@@ -1413,7 +1413,7 @@
+     if (idx < end_idx && str[idx] == '.' && str[idx + 1] >= '0' && str[idx + 1] <= '9') {
+         is_float = 1;
+         idx += 2;
+-        while (idx < end_idx && str[idx] >= '0' && str[idx] <= '9') idx++;
++        while (idx <= end_idx && str[idx] >= '0' && str[idx] <= '9') idx++;
+     }
+ 
+     /* if the next char is 'e' or 'E' then maybe read the exponent (or backtrack) */
+diff -r 288a7e1d137d simplejson/decoder.py
+--- a/simplejson/decoder.py	Wed Aug 11 12:06:18 2010 +0200
++++ b/simplejson/decoder.py	Wed Aug 11 12:06:35 2010 +0200
+@@ -68,7 +68,7 @@
+     Unescapes all valid JSON string escape sequences and raises ValueError
+     on attempt to decode an invalid string. If strict is False then literal
+     control characters are allowed in the string.
+-    
++
+     Returns a tuple of the decoded string and the index of the character in s
+     after the end quote."""
+     if encoding is None:
+diff -r 288a7e1d137d simplejson/tests/test_float.py
+--- a/simplejson/tests/test_float.py	Wed Aug 11 12:06:18 2010 +0200
++++ b/simplejson/tests/test_float.py	Wed Aug 11 12:06:35 2010 +0200
+@@ -5,11 +5,15 @@
+ 
+ class TestFloat(TestCase):
+     def test_floats(self):
+-        for num in [1617161771.7650001, math.pi, math.pi**100, math.pi**-100, 3.1]:
++        for num in [1617161771.7650001, math.pi, math.pi**100,
++                    math.pi**-100, 3.1]:
+             self.assertEquals(float(json.dumps(num)), num)
+             self.assertEquals(json.loads(json.dumps(num)), num)
++            self.assertEquals(json.loads(unicode(json.dumps(num))), num)
+ 
+     def test_ints(self):
+         for num in [1, 1L, 1<<32, 1<<64]:
+             self.assertEquals(json.dumps(num), str(num))
+             self.assertEquals(int(json.dumps(num)), num)
++            self.assertEquals(json.loads(json.dumps(num)), num)
++            self.assertEquals(json.loads(unicode(json.dumps(num))), num)
diff --git a/python-simplejson.spec b/python-simplejson.spec
index a5cf7f0..c844163 100644
--- a/python-simplejson.spec
+++ b/python-simplejson.spec
@@ -3,13 +3,17 @@
 
 Name:           python-simplejson
 Version:        2.0.9
-Release:        1%{?dist}
+Release:        2%{?dist}
 Summary:        Simple, fast, extensible JSON encoder/decoder for Python
 
 Group:          System Environment/Libraries
 License:        MIT
 URL:            http://undefined.org/python/#simplejson
 Source0:        http://pypi.python.org/packages/source/s/simplejson/simplejson-%{version}.tar.gz
+Patch0:         %{name}-fix-containerless-unicode-float-decoding-r177.patch
+# not upstreamed, but just modifies the test suite to verify that the issue 
+# above is really fixed.
+Patch1:         %{name}-add-test-for-containerless-unicode-float-decoding.patch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 BuildRequires:  python-devel
@@ -36,7 +40,8 @@ The decoder can handle incoming JSON strings of any specified encoding
 
 %prep
 %setup -q -n simplejson-%{version}
-
+%patch0 -p1
+%patch1 -p1
 
 %build
 %{__python} setup.py build
@@ -65,6 +70,9 @@ rm -rf $RPM_BUILD_ROOT
 
 
 %changelog
+* Wed Aug 11 2010 Felix Schwarz <felix.schwarz at oss.schwarz.eu> - 2.0.9-2
+- add patch to fix containerless unicode float decoding (bz 622835)
+
 * Thu Jun  4 2009 Kyle VanderBeek <kylev at kylev.com> - 2.0.9-1
 - Update to 2.0.9
 - Make sure to require gcc to the speedups get compiled


More information about the scm-commits mailing list