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
1=== modified file 'NEWS'
2--- NEWS 2019-05-31 15:27:10 +0000
3+++ NEWS 2019-06-05 09:49:59 +0000
4@@ -21,6 +21,7 @@
5
6 - Removed Django support, storm.django is no more.
7 - Removed MySQL support.
8+- Removed support for Python < 2.6.
9
10 0.20 (2013-06-28)
11 =================
12
13=== modified file 'storm/cextensions.c'
14--- storm/cextensions.c 2019-04-08 07:36:11 +0000
15+++ storm/cextensions.c 2019-06-05 09:49:59 +0000
16@@ -24,13 +24,6 @@
17 #include <structmember.h>
18
19
20-#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
21-typedef int Py_ssize_t;
22-#define PY_SSIZE_T_MAX INT_MAX
23-#define PY_SSIZE_T_MIN INT_MIN
24-#endif
25-
26-
27 #define CATCH(error_value, expression) \
28 do { \
29 if ((expression) == error_value) {\
30@@ -47,56 +40,6 @@
31 } while(0)
32
33
34-/* Python 2.4 does not include the PySet_* API, so provide a minimal
35- implementation for the calls we care about. */
36-#if PY_VERSION_HEX < 0x02050000 && !defined(PySet_GET_SIZE)
37-# define PySet_GET_SIZE(so) \
38- ((PyDictObject *)((PySetObject *)so)->data)->ma_used
39-static PyObject *
40-PySet_New(PyObject *p)
41-{
42- return PyObject_CallObject((PyObject *)&PySet_Type, NULL);
43-}
44-
45-static int
46-PySet_Add(PyObject *set, PyObject *key)
47-{
48- PyObject *dict;
49-
50- if (!PyType_IsSubtype(set->ob_type, &PySet_Type)) {
51- PyErr_BadInternalCall();
52- return -1;
53- }
54- dict = ((PySetObject *)set)->data;
55- return PyDict_SetItem(dict, key, Py_True);
56-}
57-
58-static int
59-PySet_Discard(PyObject *set, PyObject *key)
60-{
61- PyObject *dict;
62- int result;
63-
64- if (!PyType_IsSubtype(set->ob_type, &PySet_Type)) {
65- PyErr_BadInternalCall();
66- return -1;
67- }
68- dict = ((PySetObject *)set)->data;
69- result = PyDict_DelItem(dict, key);
70- if (result == 0) {
71- /* key found and removed */
72- result = 1;
73- } else {
74- if (PyErr_ExceptionMatches(PyExc_KeyError)) {
75- /* key not found */
76- PyErr_Clear();
77- result = 0;
78- }
79- }
80- return result;
81-}
82-#endif
83-
84 static PyObject *Undef = NULL;
85 static PyObject *LazyValue = NULL;
86 static PyObject *raise_none_error = NULL;
87
88=== modified file 'storm/compat.py'
89--- storm/compat.py 2011-09-07 14:31:09 +0000
90+++ storm/compat.py 2019-06-05 09:49:59 +0000
91@@ -22,10 +22,4 @@
92 __all__ = ["json"]
93
94
95-try:
96- import json
97-except ImportError:
98- try:
99- import simplejson as json
100- except ImportError:
101- json = None
102+import json
103
104=== modified file 'storm/variables.py'
105--- storm/variables.py 2019-04-07 16:20:40 +0000
106+++ storm/variables.py 2019-06-05 09:49:59 +0000
107@@ -20,12 +20,10 @@
108 #
109 from datetime import datetime, date, time, timedelta
110 from decimal import Decimal
111+from functools import partial
112 import cPickle as pickle
113 import re
114-try:
115- import uuid
116-except ImportError:
117- uuid = None
118+import uuid
119 import weakref
120
121 from storm.compat import json
122@@ -75,22 +73,7 @@
123 raise NoneError("None isn't acceptable as a value for %s" % name)
124
125
126-def VariableFactory(cls, **old_kwargs):
127- """Build cls with kwargs of constructor updated by kwargs of call.
128-
129- This is really an implementation of partial/curry functions, and
130- is replaced by 'partial' when 2.5+ is in use.
131- """
132- def variable_factory(**new_kwargs):
133- kwargs = old_kwargs.copy()
134- kwargs.update(new_kwargs)
135- return cls(**kwargs)
136- return variable_factory
137-
138-try:
139- from functools import partial as VariableFactory
140-except ImportError:
141- pass
142+VariableFactory = partial
143
144
145 class Variable(object):
146@@ -502,7 +485,6 @@
147 __slots__ = ()
148
149 def parse_set(self, value, from_db):
150- assert uuid is not None, "The uuid module was not found."
151 if from_db and isinstance(value, basestring):
152 value = uuid.UUID(value)
153 elif not isinstance(value, uuid.UUID):
154@@ -628,11 +610,6 @@
155
156 __slots__ = ()
157
158- def __init__(self, *args, **kwargs):
159- assert json is not None, (
160- "Neither the json nor the simplejson module was found.")
161- super(JSONVariable, self).__init__(*args, **kwargs)
162-
163 def _loads(self, value):
164 if not isinstance(value, unicode):
165 raise TypeError(
166
167=== modified file 'tests/helper.py'
168--- tests/helper.py 2012-04-04 23:42:51 +0000
169+++ tests/helper.py 2019-06-05 09:49:59 +0000
170@@ -52,12 +52,7 @@
171
172 @property
173 def _testMethod(self):
174- try:
175- name = self._testMethodName
176- except AttributeError:
177- # On Python < 2.5
178- name = self._TestCase__testMethodName
179- return getattr(self, name)
180+ return getattr(self, self._testMethodName)
181
182 def run(self, result=None):
183 # Skip if is_supported() does not return True.
184
185=== modified file 'tests/mocker.py'
186--- tests/mocker.py 2019-05-30 13:39:54 +0000
187+++ tests/mocker.py 2019-06-05 09:49:59 +0000
188@@ -8,16 +8,11 @@
189 import unittest
190 import inspect
191 import shutil
192-import types
193 import sys
194 import os
195 import gc
196
197
198-if sys.version_info < (2, 4):
199- from sets import Set as set # pragma: nocover
200-
201-
202 __all__ = ["Mocker", "expect", "IS", "CONTAINS", "IN", "MATCH",
203 "ANY", "ARGS", "KWARGS"]
204
205@@ -305,10 +300,6 @@
206 assertNotApproximates = failIfApproximates
207 assertMethodsMatch = failUnlessMethodsMatch
208
209- # The following are missing in Python < 2.4.
210- assertTrue = unittest.TestCase.failUnless
211- assertFalse = unittest.TestCase.failIf
212-
213 # The following is provided for compatibility with Twisted's trial.
214 assertIdentical = assertIs
215 assertNotIdentical = assertIsNot
216
217=== modified file 'tests/properties.py'
218--- tests/properties.py 2011-09-07 14:04:04 +0000
219+++ tests/properties.py 2019-06-05 09:49:59 +0000
220@@ -21,10 +21,7 @@
221 from datetime import datetime, date, time, timedelta
222 from decimal import Decimal as decimal
223 import gc
224-try:
225- import uuid
226-except ImportError:
227- uuid = None
228+import uuid
229
230 from storm.compat import json
231 from storm.exceptions import NoneError, PropertyPathError
232@@ -556,10 +553,6 @@
233 self.assertRaises(TypeError, setattr, self.obj, "prop1", object())
234
235 def test_uuid(self):
236- # Skip test if uuid module is not available.
237- if uuid is None:
238- return
239-
240 value1 = uuid.UUID("{0609f76b-878f-4546-baf5-c1b135e8de72}")
241 value2 = uuid.UUID("{c9703f9d-0abb-47d7-a793-8f90f1b98d5e}")
242 self.setup(UUID, default=value1, allow_none=False)
243
244=== modified file 'tests/variables.py'
245--- tests/variables.py 2019-05-30 13:39:54 +0000
246+++ tests/variables.py 2019-06-05 09:49:59 +0000
247@@ -23,10 +23,7 @@
248 import cPickle as pickle
249 import gc
250 import weakref
251-try:
252- import uuid
253-except ImportError:
254- uuid = None
255+import uuid
256
257 from storm.compat import json
258 from storm.exceptions import NoneError
259@@ -787,9 +784,6 @@
260
261 class UUIDVariableTest(TestHelper):
262
263- def is_supported(self):
264- return uuid is not None
265-
266 def test_get_set(self):
267 value = uuid.UUID("{0609f76b-878f-4546-baf5-c1b135e8de72}")
268
269@@ -913,7 +907,7 @@
270
271 def test_unicode_to_db(self):
272 # JSONVariable._dumps() works around unicode/str handling issues in
273- # simplejson/json.
274+ # json.
275 variable = self.variable_type()
276 variable.set({u"a": 1})
277 self.assertTrue(isinstance(variable.get(to_db=True), unicode))

Subscribers

People subscribed via source and target branches

to status/vote changes: