Code Monkey home page Code Monkey logo

Comments (11)

etrepum avatar etrepum commented on July 22, 2024

You're welcome to fork it and maintain your own Python 2.4 compatible simplejson, but simplejson has gotten by for a few years without Python 2.4 support and I am reluctant to take on that additional maintenance burden after just one request.

from simplejson.

crleblanc avatar crleblanc commented on July 22, 2024

Fair enough, I can understand that.

from simplejson.

cjerdonek avatar cjerdonek commented on July 22, 2024

@crleblanc, you can also grab or require an earlier version for Python 2.4, which is what I'm doing for Python 2.4 compatibility. Version 2.0.9 is the last version of simplejson that officially supported 2.4.

from simplejson.

crleblanc avatar crleblanc commented on July 22, 2024

@cjerdonek good point, I'll give that a try. I think pip should be able to do that quite easily. Thanks.

from simplejson.

error-empire avatar error-empire commented on July 22, 2024

@crleblanc I'm heavily interested in your patch, as I currently try to backport a XBMC Addon which uses simplejson for XBMC4XBOX (there is still Python 2.4 used 8-( ). Simplejson 2.5 seems to be sufficient for this Addon.
However, due to formatting issues it's not possible to apply your patch.
Could you please send me a link to that patch file or a copy of its content via pastebin.com or a similar service?

from simplejson.

crleblanc avatar crleblanc commented on July 22, 2024

Hi error-empire,

I solved my problem by using Sphinx on a modern Ubuntu machine, and copying the artifacts to other machines with Jenkins. I've also jumped on the git bandwagon, but since I don't have a need for this code I'll just include the diff in a code block below. Good luck with XBMC.

diff --git a/simplejson/encoder.py b/simplejson/encoder.py
index 05dd05c..5710e67 100644
--- a/simplejson/encoder.py
+++ b/simplejson/encoder.py
@@ -394,10 +394,10 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
             elif value is False:
                 yield buf + 'false'
             elif isinstance(value, (int, long)):
-                yield ((buf + str(value))
-                       if (not _bigint_as_string or
-                           (-1 << 53) < value < (1 << 53))
-                           else (buf + '"' + str(value) + '"'))
+                if not _bigint_as_string or (-1 << 53) < value < (1 << 53):
+                    yield buf + str(value)
+                else:
+                    yield buf + '"' + str(value) + '"'
             elif isinstance(value, float):
                 yield buf + _floatstr(value)
             elif _use_decimal and isinstance(value, Decimal):
@@ -487,10 +487,10 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
             elif value is False:
                 yield 'false'
             elif isinstance(value, (int, long)):
-                yield (str(value)
-                       if (not _bigint_as_string or
-                           (-1 << 53) < value < (1 << 53))
-                           else ('"' + str(value) + '"'))
+                if not _bigint_as_string or (-1 << 53) < value < (1 << 53):
+                    yield str(value)
+                else:
+                    yield '"' + str(value) + '"'
             elif isinstance(value, float):
                 yield _floatstr(value)
             elif _use_decimal and isinstance(value, Decimal):
@@ -528,10 +528,10 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
         elif o is False:
             yield 'false'
         elif isinstance(o, (int, long)):
-            yield (str(o)
-                   if (not _bigint_as_string or
-                       (-1 << 53) < o < (1 << 53))
-                       else ('"' + str(o) + '"'))
+            if not _bigint_as_string or (-1 << 53) < o < (1 << 53):
+                yield str(o)
+            else:
+                yield '"' + str(o) + '"'
         elif isinstance(o, float):
             yield _floatstr(o)
         elif isinstance(o, list):

from simplejson.

etrepum avatar etrepum commented on July 22, 2024

Alternatively, you can just download the last version of simplejson that did support Python 2.4 https://pypi.python.org/pypi/simplejson/2.0.9

from simplejson.

error-empire avatar error-empire commented on July 22, 2024

I already tried that version, however it misses some functionality which is already added in version 2.5.

from simplejson.

error-empire avatar error-empire commented on July 22, 2024

@crleblanc: Thank you for the patch! As I am new to python, it really helps me a lot. :)

from simplejson.

etrepum avatar etrepum commented on July 22, 2024

Of course it has a bit less functionality, but what do you actually need that isn't available? Perhaps there's an easier way.

from simplejson.

error-empire avatar error-empire commented on July 22, 2024

If I remember right it was "object_pairs_hook" which is not available in 2.0.9.
Sadly, the streaming service (which the XBMC Addon accesses) has been completely shut down yesterday evening, so my small task to backport it to Python 2.4 makes no longer sense.

from simplejson.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.