From 8b8a8eabbf1484a757922f7c569acb502697a7e9 Mon Sep 17 00:00:00 2001 From: Bob Ippolito Date: Sat, 31 Dec 2005 23:01:25 +0000 Subject: [PATCH 1/8] tag 1.1 release git-svn-id: http://simplejson.googlecode.com/svn/tags/simplejson-1.1@10 a4795897-2c25-0410-b006-0d3caba88fa1 From b37893b8e7950748966bd0ab179661b77340e49a Mon Sep 17 00:00:00 2001 From: Daniel Jowett Date: Thu, 3 Jul 2014 17:34:13 +0100 Subject: [PATCH 2/8] We don't have setuptools in Python 2.2 --- setup.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 21b0be01..1da0d16b 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,15 @@ #!/usr/bin/env python +import sys +if sys.version_info < (2, 3): + from distutils.core import setup -import ez_setup -ez_setup.use_setuptools() + def find_packages(exclude=None): + return ['simplejson', 'simplejson.tests'] +else: + import ez_setup + ez_setup.use_setuptools() -from setuptools import setup, find_packages + from setuptools import setup, find_packages VERSION = '1.1' DESCRIPTION = "Simple, fast, extensible JSON encoder/decoder for Python" From 6576080fdd39db56f1431c1eb222de4159af9018 Mon Sep 17 00:00:00 2001 From: Daniel Jowett Date: Thu, 3 Jul 2014 18:02:08 +0100 Subject: [PATCH 3/8] We don't have generators in Python2.2 - so import them from the future --- simplejson/encoder.py | 1 + simplejson/scanner.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/simplejson/encoder.py b/simplejson/encoder.py index 5b4b7cd3..109e3a7b 100644 --- a/simplejson/encoder.py +++ b/simplejson/encoder.py @@ -1,6 +1,7 @@ """ Implementation of JSONEncoder """ +from __future__ import generators import re # this should match any kind of infinity diff --git a/simplejson/scanner.py b/simplejson/scanner.py index 95d3f2bb..742e1bf6 100644 --- a/simplejson/scanner.py +++ b/simplejson/scanner.py @@ -1,6 +1,8 @@ """ Iterator based sre token scanner """ +from __future__ import generators + import sre_parse, sre_compile, sre_constants from sre_constants import BRANCH, SUBPATTERN from sre import VERBOSE, MULTILINE, DOTALL From 7af9acb67758b620862308e95148f1b4739079bc Mon Sep 17 00:00:00 2001 From: Daniel Jowett Date: Thu, 3 Jul 2014 18:05:25 +0100 Subject: [PATCH 4/8] Slicing not available in Python 2.2 - fortunately it's only used on a static value, so we can just hard-code the result --- simplejson/decoder.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/simplejson/decoder.py b/simplejson/decoder.py index cd8ef630..bfffa723 100644 --- a/simplejson/decoder.py +++ b/simplejson/decoder.py @@ -12,7 +12,9 @@ def _floatconstants(): import sys _BYTES = '7FF80000000000007FF0000000000000'.decode('hex') if sys.byteorder != 'big': - _BYTES = _BYTES[:8][::-1] + _BYTES[8:][::-1] + # slicing not available in Python 2.2 + #_BYTES = _BYTES[:8][::-1] + _BYTES[8:][::-1] + _BYTES = '000000000000f87f000000000000f07f'.decode('hex') nan, inf = struct.unpack('dd', _BYTES) return nan, inf, -inf From 2e1b24ce0721914144a6e2422a9392620b9072cd Mon Sep 17 00:00:00 2001 From: Daniel Jowett Date: Thu, 3 Jul 2014 18:07:04 +0100 Subject: [PATCH 5/8] define an 'enumerate' function (which is not defined in Python2.2) --- simplejson/scanner.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/simplejson/scanner.py b/simplejson/scanner.py index 742e1bf6..fc88885c 100644 --- a/simplejson/scanner.py +++ b/simplejson/scanner.py @@ -2,6 +2,8 @@ Iterator based sre token scanner """ from __future__ import generators +import __builtin__ +__builtin__.enumerate = lambda seq: zip(xrange(len(seq)), seq) import sre_parse, sre_compile, sre_constants from sre_constants import BRANCH, SUBPATTERN From e89ac5b593af047283e88633120268aa0de598b8 Mon Sep 17 00:00:00 2001 From: Daniel Jowett Date: Thu, 3 Jul 2014 18:07:44 +0100 Subject: [PATCH 6/8] basestring is not defined in Python2.2 --- simplejson/encoder.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/simplejson/encoder.py b/simplejson/encoder.py index 109e3a7b..3a06f905 100644 --- a/simplejson/encoder.py +++ b/simplejson/encoder.py @@ -159,7 +159,7 @@ def _iterencode_dict(self, dct, markers=None): encoder = encode_basestring allow_nan = self.allow_nan for key, value in dct.iteritems(): - if isinstance(key, basestring): + if isinstance(key, (str, unicode)): pass # JavaScript is weakly typed for these, so it makes sense to # also allow them. Many encoders seem to do something like this. @@ -190,7 +190,7 @@ def _iterencode_dict(self, dct, markers=None): del markers[markerid] def _iterencode(self, o, markers=None): - if isinstance(o, basestring): + if isinstance(o, (str, unicode)): if self.ensure_ascii: encoder = encode_basestring_ascii else: From 44b190d4b645a6fd85bdfca5c4ad22517f0a8d76 Mon Sep 17 00:00:00 2001 From: Daniel Jowett Date: Wed, 22 Oct 2014 15:39:58 +0100 Subject: [PATCH 7/8] Create README.md --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 00000000..cee56135 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +simplejson +========== + +simplejson is a simple, fast, extensible JSON encoder/decoder for Python + +This branch is for use in extreme situations where you cannot upgrade from Python 2.2, expect to get your hands dirty! + +There is no release of this egg, you will rather want to check it out: + + git clone https://github.com/simplejson/simplejson.git --branch python2.2 + +Add install it in your old python: + + python2.2 setup.py install + +Any features missing from the mainline version need to be coded in by hand. +I hope this is useful, it should be better than starting from scratch! From 7cd9839ec3b529dcf8ddb08c8a684fb8c8ba5bf3 Mon Sep 17 00:00:00 2001 From: Daniel Jowett Date: Wed, 22 Oct 2014 15:41:06 +0100 Subject: [PATCH 8/8] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cee56135..ceeb2992 100644 --- a/README.md +++ b/README.md @@ -7,11 +7,11 @@ This branch is for use in extreme situations where you cannot upgrade from Pytho There is no release of this egg, you will rather want to check it out: - git clone https://github.com/simplejson/simplejson.git --branch python2.2 + git clone https://github.com/simplejson/simplejson.git --branch python2.2 Add install it in your old python: - python2.2 setup.py install + python2.2 setup.py install Any features missing from the mainline version need to be coded in by hand. I hope this is useful, it should be better than starting from scratch!