Skip to content

Commit

Permalink
Remofe remnants of Python 2.4 support.
Browse files Browse the repository at this point in the history
Clean up the code by removing workarounds for supporting Python 2.4.
  • Loading branch information
serhiy-storchaka committed May 8, 2017
1 parent f1a06fc commit b715bfe
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 35 deletions.
13 changes: 0 additions & 13 deletions simplejson/_speedups.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,6 @@ json_PyOS_string_to_double(const char *s, char **endptr, PyObject *overflow_exce
#endif
#endif /* PY_VERSION_HEX < 0x02060000 */

#if PY_VERSION_HEX < 0x02050000
#if !defined(PY_SSIZE_T_MIN)
typedef int Py_ssize_t;
#define PY_SSIZE_T_MAX INT_MAX
#define PY_SSIZE_T_MIN INT_MIN
#define PyInt_FromSsize_t PyInt_FromLong
#define PyInt_AsSsize_t PyInt_AsLong
#endif
#if !defined(Py_IS_FINITE)
#define Py_IS_FINITE(X) (!Py_IS_INFINITY(X) && !Py_IS_NAN(X))
#endif
#endif /* PY_VERSION_HEX < 0x02050000 */

#ifdef __GNUC__
#define UNUSED __attribute__((__unused__))
#else
Expand Down
6 changes: 1 addition & 5 deletions simplejson/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ def _import_c_scanstring():
def _floatconstants():
if sys.version_info < (2, 6):
_BYTES = '7FF80000000000007FF0000000000000'.decode('hex')
# The struct module in Python 2.4 would get frexp() out of range here
# when an endian is specified in the format string. Fixed in Python 2.5+
if sys.byteorder != 'big':
_BYTES = _BYTES[:8][::-1] + _BYTES[8:][::-1]
nan, inf = struct.unpack('dd', _BYTES)
nan, inf = struct.unpack('>dd', _BYTES)
else:
nan = float('nan')
inf = float('inf')
Expand Down
18 changes: 1 addition & 17 deletions simplejson/ordered_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,6 @@
"""
from UserDict import DictMixin

# Modified from original to support Python 2.4, see
# http://code.google.com/p/simplejson/issues/detail?id=53
try:
all
except NameError:
def all(seq):
for elem in seq:
if not elem:
return False
return True

class OrderedDict(dict, DictMixin):

def __init__(self, *args, **kwds):
Expand Down Expand Up @@ -63,12 +52,7 @@ def __reversed__(self):
def popitem(self, last=True):
if not self:
raise KeyError('dictionary is empty')
# Modified from original to support Python 2.4, see
# http://code.google.com/p/simplejson/issues/detail?id=53
if last:
key = reversed(self).next()
else:
key = iter(self).next()
key = reversed(self).next() if last else iter(self).next()
value = self.pop(key)
return key, value

Expand Down

0 comments on commit b715bfe

Please sign in to comment.