Merge lp:~cjwatson/storm/drop-pre-2.6 into lp:storm

Proposed by Colin Watson
Status: Merged
Merged at revision: 494
Proposed branch: lp:~cjwatson/storm/drop-pre-2.6
Merge into: lp:storm
Diff against target: 277 lines (+9/-121)
8 files modified
NEWS (+1/-0)
storm/cextensions.c (+0/-57)
storm/compat.py (+1/-7)
storm/variables.py (+3/-26)
tests/helper.py (+1/-6)
tests/mocker.py (+0/-9)
tests/properties.py (+1/-8)
tests/variables.py (+2/-8)
To merge this branch: bzr merge lp:~cjwatson/storm/drop-pre-2.6
Reviewer Review Type Date Requested Status
Adam Collard (community) Approve
Review via email: mp+368250@code.launchpad.net

Commit message

Remove support for Python < 2.6.

Description of the change

Python 2.5 reached EOL in 2011; there's really no need to carry around compatibility cruft for it or for earlier versions any more.

(Indeed, 2.6 is also pretty dead, and I don't have a good way to test that Storm still works on it at the moment; but we don't have any compatibility code for it, so it isn't getting in the way regardless.)

To post a comment you must log in.
Revision history for this message
Adam Collard (adam-collard) wrote :

Approved with one inline cleanup suggestion

review: Approve
lp:~cjwatson/storm/drop-pre-2.6 updated
494. By Colin Watson

Remove now-useless JSONVariable.__init__.

Revision history for this message
Colin Watson (cjwatson) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'NEWS'
--- NEWS 2019-05-31 15:27:10 +0000
+++ NEWS 2019-06-05 09:49:59 +0000
@@ -21,6 +21,7 @@
2121
22- Removed Django support, storm.django is no more.22- Removed Django support, storm.django is no more.
23- Removed MySQL support.23- Removed MySQL support.
24- Removed support for Python < 2.6.
2425
250.20 (2013-06-28)260.20 (2013-06-28)
26=================27=================
2728
=== modified file 'storm/cextensions.c'
--- storm/cextensions.c 2019-04-08 07:36:11 +0000
+++ storm/cextensions.c 2019-06-05 09:49:59 +0000
@@ -24,13 +24,6 @@
24#include <structmember.h>24#include <structmember.h>
2525
2626
27#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
28typedef int Py_ssize_t;
29#define PY_SSIZE_T_MAX INT_MAX
30#define PY_SSIZE_T_MIN INT_MIN
31#endif
32
33
34#define CATCH(error_value, expression) \27#define CATCH(error_value, expression) \
35 do { \28 do { \
36 if ((expression) == error_value) {\29 if ((expression) == error_value) {\
@@ -47,56 +40,6 @@
47 } while(0)40 } while(0)
4841
4942
50/* Python 2.4 does not include the PySet_* API, so provide a minimal
51 implementation for the calls we care about. */
52#if PY_VERSION_HEX < 0x02050000 && !defined(PySet_GET_SIZE)
53# define PySet_GET_SIZE(so) \
54 ((PyDictObject *)((PySetObject *)so)->data)->ma_used
55static PyObject *
56PySet_New(PyObject *p)
57{
58 return PyObject_CallObject((PyObject *)&PySet_Type, NULL);
59}
60
61static int
62PySet_Add(PyObject *set, PyObject *key)
63{
64 PyObject *dict;
65
66 if (!PyType_IsSubtype(set->ob_type, &PySet_Type)) {
67 PyErr_BadInternalCall();
68 return -1;
69 }
70 dict = ((PySetObject *)set)->data;
71 return PyDict_SetItem(dict, key, Py_True);
72}
73
74static int
75PySet_Discard(PyObject *set, PyObject *key)
76{
77 PyObject *dict;
78 int result;
79
80 if (!PyType_IsSubtype(set->ob_type, &PySet_Type)) {
81 PyErr_BadInternalCall();
82 return -1;
83 }
84 dict = ((PySetObject *)set)->data;
85 result = PyDict_DelItem(dict, key);
86 if (result == 0) {
87 /* key found and removed */
88 result = 1;
89 } else {
90 if (PyErr_ExceptionMatches(PyExc_KeyError)) {
91 /* key not found */
92 PyErr_Clear();
93 result = 0;
94 }
95 }
96 return result;
97}
98#endif
99
100static PyObject *Undef = NULL;43static PyObject *Undef = NULL;
101static PyObject *LazyValue = NULL;44static PyObject *LazyValue = NULL;
102static PyObject *raise_none_error = NULL;45static PyObject *raise_none_error = NULL;
10346
=== modified file 'storm/compat.py'
--- storm/compat.py 2011-09-07 14:31:09 +0000
+++ storm/compat.py 2019-06-05 09:49:59 +0000
@@ -22,10 +22,4 @@
22__all__ = ["json"]22__all__ = ["json"]
2323
2424
25try:25import json
26 import json
27except ImportError:
28 try:
29 import simplejson as json
30 except ImportError:
31 json = None
3226
=== modified file 'storm/variables.py'
--- storm/variables.py 2019-04-07 16:20:40 +0000
+++ storm/variables.py 2019-06-05 09:49:59 +0000
@@ -20,12 +20,10 @@
20#20#
21from datetime import datetime, date, time, timedelta21from datetime import datetime, date, time, timedelta
22from decimal import Decimal22from decimal import Decimal
23from functools import partial
23import cPickle as pickle24import cPickle as pickle
24import re25import re
25try:26import uuid
26 import uuid
27except ImportError:
28 uuid = None
29import weakref27import weakref
3028
31from storm.compat import json29from storm.compat import json
@@ -75,22 +73,7 @@
75 raise NoneError("None isn't acceptable as a value for %s" % name)73 raise NoneError("None isn't acceptable as a value for %s" % name)
7674
7775
78def VariableFactory(cls, **old_kwargs):76VariableFactory = partial
79 """Build cls with kwargs of constructor updated by kwargs of call.
80
81 This is really an implementation of partial/curry functions, and
82 is replaced by 'partial' when 2.5+ is in use.
83 """
84 def variable_factory(**new_kwargs):
85 kwargs = old_kwargs.copy()
86 kwargs.update(new_kwargs)
87 return cls(**kwargs)
88 return variable_factory
89
90try:
91 from functools import partial as VariableFactory
92except ImportError:
93 pass
9477
9578
96class Variable(object):79class Variable(object):
@@ -502,7 +485,6 @@
502 __slots__ = ()485 __slots__ = ()
503486
504 def parse_set(self, value, from_db):487 def parse_set(self, value, from_db):
505 assert uuid is not None, "The uuid module was not found."
506 if from_db and isinstance(value, basestring):488 if from_db and isinstance(value, basestring):
507 value = uuid.UUID(value)489 value = uuid.UUID(value)
508 elif not isinstance(value, uuid.UUID):490 elif not isinstance(value, uuid.UUID):
@@ -628,11 +610,6 @@
628610
629 __slots__ = ()611 __slots__ = ()
630612
631 def __init__(self, *args, **kwargs):
632 assert json is not None, (
633 "Neither the json nor the simplejson module was found.")
634 super(JSONVariable, self).__init__(*args, **kwargs)
635
636 def _loads(self, value):613 def _loads(self, value):
637 if not isinstance(value, unicode):614 if not isinstance(value, unicode):
638 raise TypeError(615 raise TypeError(
639616
=== modified file 'tests/helper.py'
--- tests/helper.py 2012-04-04 23:42:51 +0000
+++ tests/helper.py 2019-06-05 09:49:59 +0000
@@ -52,12 +52,7 @@
5252
53 @property53 @property
54 def _testMethod(self):54 def _testMethod(self):
55 try:55 return getattr(self, self._testMethodName)
56 name = self._testMethodName
57 except AttributeError:
58 # On Python < 2.5
59 name = self._TestCase__testMethodName
60 return getattr(self, name)
6156
62 def run(self, result=None):57 def run(self, result=None):
63 # Skip if is_supported() does not return True.58 # Skip if is_supported() does not return True.
6459
=== modified file 'tests/mocker.py'
--- tests/mocker.py 2019-05-30 13:39:54 +0000
+++ tests/mocker.py 2019-06-05 09:49:59 +0000
@@ -8,16 +8,11 @@
8import unittest8import unittest
9import inspect9import inspect
10import shutil10import shutil
11import types
12import sys11import sys
13import os12import os
14import gc13import gc
1514
1615
17if sys.version_info < (2, 4):
18 from sets import Set as set # pragma: nocover
19
20
21__all__ = ["Mocker", "expect", "IS", "CONTAINS", "IN", "MATCH",16__all__ = ["Mocker", "expect", "IS", "CONTAINS", "IN", "MATCH",
22 "ANY", "ARGS", "KWARGS"]17 "ANY", "ARGS", "KWARGS"]
2318
@@ -305,10 +300,6 @@
305 assertNotApproximates = failIfApproximates300 assertNotApproximates = failIfApproximates
306 assertMethodsMatch = failUnlessMethodsMatch301 assertMethodsMatch = failUnlessMethodsMatch
307302
308 # The following are missing in Python < 2.4.
309 assertTrue = unittest.TestCase.failUnless
310 assertFalse = unittest.TestCase.failIf
311
312 # The following is provided for compatibility with Twisted's trial.303 # The following is provided for compatibility with Twisted's trial.
313 assertIdentical = assertIs304 assertIdentical = assertIs
314 assertNotIdentical = assertIsNot305 assertNotIdentical = assertIsNot
315306
=== modified file 'tests/properties.py'
--- tests/properties.py 2011-09-07 14:04:04 +0000
+++ tests/properties.py 2019-06-05 09:49:59 +0000
@@ -21,10 +21,7 @@
21from datetime import datetime, date, time, timedelta21from datetime import datetime, date, time, timedelta
22from decimal import Decimal as decimal22from decimal import Decimal as decimal
23import gc23import gc
24try:24import uuid
25 import uuid
26except ImportError:
27 uuid = None
2825
29from storm.compat import json26from storm.compat import json
30from storm.exceptions import NoneError, PropertyPathError27from storm.exceptions import NoneError, PropertyPathError
@@ -556,10 +553,6 @@
556 self.assertRaises(TypeError, setattr, self.obj, "prop1", object())553 self.assertRaises(TypeError, setattr, self.obj, "prop1", object())
557554
558 def test_uuid(self):555 def test_uuid(self):
559 # Skip test if uuid module is not available.
560 if uuid is None:
561 return
562
563 value1 = uuid.UUID("{0609f76b-878f-4546-baf5-c1b135e8de72}")556 value1 = uuid.UUID("{0609f76b-878f-4546-baf5-c1b135e8de72}")
564 value2 = uuid.UUID("{c9703f9d-0abb-47d7-a793-8f90f1b98d5e}")557 value2 = uuid.UUID("{c9703f9d-0abb-47d7-a793-8f90f1b98d5e}")
565 self.setup(UUID, default=value1, allow_none=False)558 self.setup(UUID, default=value1, allow_none=False)
566559
=== modified file 'tests/variables.py'
--- tests/variables.py 2019-05-30 13:39:54 +0000
+++ tests/variables.py 2019-06-05 09:49:59 +0000
@@ -23,10 +23,7 @@
23import cPickle as pickle23import cPickle as pickle
24import gc24import gc
25import weakref25import weakref
26try:26import uuid
27 import uuid
28except ImportError:
29 uuid = None
3027
31from storm.compat import json28from storm.compat import json
32from storm.exceptions import NoneError29from storm.exceptions import NoneError
@@ -787,9 +784,6 @@
787784
788class UUIDVariableTest(TestHelper):785class UUIDVariableTest(TestHelper):
789786
790 def is_supported(self):
791 return uuid is not None
792
793 def test_get_set(self):787 def test_get_set(self):
794 value = uuid.UUID("{0609f76b-878f-4546-baf5-c1b135e8de72}")788 value = uuid.UUID("{0609f76b-878f-4546-baf5-c1b135e8de72}")
795789
@@ -913,7 +907,7 @@
913907
914 def test_unicode_to_db(self):908 def test_unicode_to_db(self):
915 # JSONVariable._dumps() works around unicode/str handling issues in909 # JSONVariable._dumps() works around unicode/str handling issues in
916 # simplejson/json.910 # json.
917 variable = self.variable_type()911 variable = self.variable_type()
918 variable.set({u"a": 1})912 variable.set({u"a": 1})
919 self.assertTrue(isinstance(variable.get(to_db=True), unicode))913 self.assertTrue(isinstance(variable.get(to_db=True), unicode))

Subscribers

People subscribed via source and target branches

to status/vote changes: