Merge lp:~cjwatson/storm/remove-py2 into lp:storm
- remove-py2
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 582 |
Proposed branch: | lp:~cjwatson/storm/remove-py2 |
Merge into: | lp:storm |
Diff against target: |
2715 lines (+212/-600) 79 files modified
NEWS (+10/-2) README (+10/-11) dev/test (+3/-3) dev/ubuntu-deps (+12/-11) setup.py (+2/-9) storm/__init__.py (+0/-2) storm/base.py (+1/-5) storm/cache.py (+2/-6) storm/cextensions.c (+12/-40) storm/compat.py (+0/-27) storm/database.py (+2/-9) storm/databases/__init__.py (+0/-7) storm/databases/mysql.py (+0/-2) storm/databases/postgres.py (+0/-2) storm/databases/sqlite.py (+2/-24) storm/event.py (+0/-2) storm/exceptions.py (+2/-12) storm/expr.py (+17/-26) storm/info.py (+3/-7) storm/locals.py (+0/-2) storm/properties.py (+3/-7) storm/references.py (+3/-7) storm/schema/__init__.py (+0/-2) storm/schema/patch.py (+4/-10) storm/schema/schema.py (+0/-2) storm/schema/sharding.py (+0/-2) storm/sqlobject.py (+16/-33) storm/store.py (+4/-8) storm/testing.py (+0/-2) storm/tests/__init__.py (+0/-3) storm/tests/base.py (+0/-2) storm/tests/cache.py (+0/-2) storm/tests/database.py (+0/-2) storm/tests/databases/base.py (+2/-6) storm/tests/databases/mysql.py (+1/-4) storm/tests/databases/postgres.py (+3/-10) storm/tests/databases/proxy.py (+2/-6) storm/tests/databases/sqlite.py (+0/-2) storm/tests/event.py (+0/-2) storm/tests/expr.py (+2/-21) storm/tests/helper.py (+2/-5) storm/tests/info.py (+1/-5) storm/tests/mocker.py (+30/-68) storm/tests/properties.py (+2/-6) storm/tests/schema/patch.py (+0/-2) storm/tests/schema/schema.py (+0/-2) storm/tests/schema/sharding.py (+0/-2) storm/tests/sqlobject.py (+2/-10) storm/tests/store/base.py (+12/-16) storm/tests/store/mysql.py (+0/-2) storm/tests/store/postgres.py (+0/-2) storm/tests/store/sqlite.py (+0/-2) storm/tests/tracer.py (+0/-2) storm/tests/twisted/__init__.py (+0/-2) storm/tests/twisted/transact.py (+0/-2) storm/tests/uri.py (+0/-2) storm/tests/variables.py (+12/-25) storm/tests/wsgi.py (+1/-4) storm/tests/zope/__init__.py (+0/-2) storm/tests/zope/adapters.py (+0/-2) storm/tests/zope/testing.py (+1/-5) storm/tests/zope/zstorm.py (+0/-2) storm/tracer.py (+2/-9) storm/twisted/testing.py (+0/-2) storm/twisted/transact.py (+0/-2) storm/tz.py (+3/-7) storm/uri.py (+2/-5) storm/variables.py (+19/-30) storm/wsgi.py (+0/-2) storm/xid.py (+0/-3) storm/zope/__init__.py (+0/-2) storm/zope/adapters.py (+0/-2) storm/zope/interfaces.py (+0/-6) storm/zope/metaconfigure.py (+0/-2) storm/zope/metadirectives.py (+0/-2) storm/zope/schema.py (+0/-2) storm/zope/testing.py (+1/-4) storm/zope/zstorm.py (+1/-4) tox.ini (+3/-4) |
To merge this branch: | bzr merge lp:~cjwatson/storm/remove-py2 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Guruprasad | Approve | ||
Review via email: mp+461675@code.launchpad.net |
Commit message
Remove Python 2 support.
Description of the change
We've offered several releases of overlap (Storm gained Python 3 support in version 0.21, released on 2019-09-20). There are no known users left on Python 2, and if there were any then they'd probably need to pin old versions of quite a few other dependencies anyway.
I considered breaking this up into smaller MPs, but since it's mostly removals it's probably better to just get it over with in one go. To keep the size somewhat under control, I restrained myself from doing further tidy-ups that pyupgrade would take care of for us, and mostly stuck to simple removals of future imports and getting rid of more explicit `six`-based Python 2 compatibility code.
It seems reasonable to bump to 1.0 at this point.
- 582. By Colin Watson
-
Remove Python 2 support.
We've offered several releases of overlap (Storm gained Python 3 support
in version 0.21, released on 2019-09-20). There are no known users left
on Python 2, and if there were any then they'd probably need to pin old
versions of quite a few other dependencies anyway.
Preview Diff
1 | === modified file 'NEWS' |
2 | --- NEWS 2023-12-07 17:04:46 +0000 |
3 | +++ NEWS 2024-03-04 10:59:33 +0000 |
4 | @@ -1,11 +1,19 @@ |
5 | -0.27 |
6 | -==== |
7 | +1.0 |
8 | +=== |
9 | |
10 | Improvements |
11 | ------------ |
12 | |
13 | - Fix several syntax warnings from recent Python versions. |
14 | |
15 | +API changes |
16 | +----------- |
17 | + |
18 | +- Remove support for Python 2. |
19 | +- Remove the storm.compat module. |
20 | +- Deprecate storm.sqlobject.AutoUnicodeVariable and |
21 | + storm.sqlobject.AutoUnicode. |
22 | + |
23 | 0.26 (2023-07-04) |
24 | ================= |
25 | |
26 | |
27 | === modified file 'README' |
28 | --- README 2021-04-06 09:23:02 +0000 |
29 | +++ README 2024-03-04 10:59:33 +0000 |
30 | @@ -116,19 +116,18 @@ |
31 | |
32 | These will take a few minutes to download. |
33 | |
34 | -The Python dependencies for running tests can mostly be installed with |
35 | -apt-get: |
36 | +The Python dependencies for running tests can be installed with apt-get: |
37 | |
38 | $ apt-get install \ |
39 | - python-fixtures python-psycopg2 \ |
40 | - python-testresources python-transaction python-twisted \ |
41 | - python-zope.component python-zope.security |
42 | - |
43 | -Two modules - pgbouncer and timeline - are not yet packaged in |
44 | -Ubuntu. These can be installed from PyPI: |
45 | - |
46 | - http://pypi.python.org/pypi/pgbouncer |
47 | - http://pypi.python.org/pypi/timeline |
48 | + python3-fixtures \ |
49 | + python3-pgbouncer \ |
50 | + python3-psycopg2 \ |
51 | + python3-testresources \ |
52 | + python3-timeline \ |
53 | + python3-transaction \ |
54 | + python3-twisted \ |
55 | + python3-zope.component \ |
56 | + python3-zope.security |
57 | |
58 | Alternatively, dependencies can be downloaded as eggs into the current |
59 | directory with: |
60 | |
61 | === modified file 'dev/test' |
62 | --- dev/test 2021-05-13 23:02:23 +0000 |
63 | +++ dev/test 2024-03-04 10:59:33 +0000 |
64 | @@ -1,4 +1,4 @@ |
65 | -#!/usr/bin/env python |
66 | +#!/usr/bin/env python3 |
67 | # |
68 | # Copyright (c) 2006, 2007 Canonical |
69 | # |
70 | @@ -87,7 +87,7 @@ |
71 | except ImportError: |
72 | return runner_func |
73 | |
74 | - from six.moves.urllib.parse import urlunsplit |
75 | + from urllib.parse import urlunsplit |
76 | from storm.uri import escape |
77 | |
78 | def wrapper(): |
79 | @@ -128,7 +128,7 @@ |
80 | except ImportError: |
81 | return runner_func |
82 | |
83 | - from six.moves.urllib.parse import ( |
84 | + from urllib.parse import ( |
85 | urlencode, |
86 | urlunsplit, |
87 | ) |
88 | |
89 | === modified file 'dev/ubuntu-deps' |
90 | --- dev/ubuntu-deps 2021-04-06 09:23:02 +0000 |
91 | +++ dev/ubuntu-deps 2024-03-04 10:59:33 +0000 |
92 | @@ -12,17 +12,18 @@ |
93 | mysql-server \ |
94 | pgbouncer \ |
95 | postgresql \ |
96 | - python-dev \ |
97 | - python-fixtures \ |
98 | - python-mysqldb \ |
99 | - python-psycopg2 \ |
100 | - python-setuptools \ |
101 | - python-six \ |
102 | - python-testresources \ |
103 | - python-transaction \ |
104 | - python-twisted \ |
105 | - python-zope.component \ |
106 | - python-zope.security \ |
107 | + python3-dev \ |
108 | + python3-fixtures \ |
109 | + python3-mysqldb \ |
110 | + python3-pgbouncer \ |
111 | + python3-psycopg2 \ |
112 | + python3-setuptools \ |
113 | + python3-testresources \ |
114 | + python3-timeline \ |
115 | + python3-transaction \ |
116 | + python3-twisted \ |
117 | + python3-zope.component \ |
118 | + python3-zope.security \ |
119 | tox |
120 | |
121 | |
122 | |
123 | === modified file 'setup.py' |
124 | --- setup.py 2022-10-28 06:26:28 +0000 |
125 | +++ setup.py 2024-03-04 10:59:33 +0000 |
126 | @@ -1,6 +1,4 @@ |
127 | -#!/usr/bin/env python |
128 | - |
129 | -from __future__ import print_function |
130 | +#!/usr/bin/env python3 |
131 | |
132 | import os |
133 | import re |
134 | @@ -26,17 +24,14 @@ |
135 | tests_require = [ |
136 | "fixtures >= 1.3.0", |
137 | "mysqlclient", |
138 | - "mysqlclient < 2.0.0; python_version < '3'", |
139 | "pgbouncer >= 0.0.7", |
140 | "postgresfixture", |
141 | "psycopg2 >= 2.3.0", |
142 | - "setuptools < 45; python_version < '3'", |
143 | "testresources >= 0.2.4", |
144 | "testtools >= 0.9.8", |
145 | "timeline >= 0.0.2", |
146 | "transaction >= 1.0.0", |
147 | "Twisted >= 10.0.0", |
148 | - "Twisted < 21.2.0; python_version < '3'", |
149 | "zope.component >= 3.8.0", |
150 | "zope.configuration", |
151 | "zope.interface >= 4.0.0", |
152 | @@ -67,8 +62,6 @@ |
153 | ("License :: OSI Approved :: GNU Library or " |
154 | "Lesser General Public License (LGPL)"), |
155 | "Programming Language :: Python", |
156 | - "Programming Language :: Python :: 2", |
157 | - "Programming Language :: Python :: 2.7", |
158 | "Programming Language :: Python :: 3", |
159 | "Programming Language :: Python :: 3.5", |
160 | "Programming Language :: Python :: 3.6", |
161 | @@ -87,7 +80,7 @@ |
162 | # warning) by distutils. |
163 | include_package_data=True, |
164 | zip_safe=False, |
165 | - install_requires=["six"], |
166 | + python_requires=">=3.5", |
167 | test_suite="storm.tests.find_tests", |
168 | tests_require=tests_require, |
169 | extras_require={ |
170 | |
171 | === modified file 'storm/__init__.py' |
172 | --- storm/__init__.py 2023-07-04 13:55:37 +0000 |
173 | +++ storm/__init__.py 2024-03-04 10:59:33 +0000 |
174 | @@ -19,8 +19,6 @@ |
175 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
176 | # |
177 | |
178 | -from __future__ import print_function |
179 | - |
180 | import os |
181 | |
182 | |
183 | |
184 | === modified file 'storm/base.py' |
185 | --- storm/base.py 2019-08-11 08:58:54 +0000 |
186 | +++ storm/base.py 2024-03-04 10:59:33 +0000 |
187 | @@ -18,17 +18,13 @@ |
188 | # You should have received a copy of the GNU Lesser General Public License |
189 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
190 | # |
191 | -from __future__ import print_function |
192 | - |
193 | -import six |
194 | - |
195 | from storm.properties import PropertyPublisherMeta |
196 | |
197 | |
198 | __all__ = ["Storm"] |
199 | |
200 | |
201 | -class Storm(six.with_metaclass(PropertyPublisherMeta, object)): |
202 | +class Storm(metaclass=PropertyPublisherMeta): |
203 | """An optional base class for objects stored in a Storm Store. |
204 | |
205 | It causes your subclasses to be associated with a Storm |
206 | |
207 | === modified file 'storm/cache.py' |
208 | --- storm/cache.py 2023-12-07 17:04:46 +0000 |
209 | +++ storm/cache.py 2024-03-04 10:59:33 +0000 |
210 | @@ -1,9 +1,5 @@ |
211 | -from __future__ import print_function |
212 | - |
213 | import itertools |
214 | |
215 | -import six |
216 | - |
217 | |
218 | class Cache(object): |
219 | """Prevents recently used objects from being deallocated. |
220 | @@ -145,8 +141,8 @@ |
221 | """ |
222 | self._size = size |
223 | cache = itertools.islice( |
224 | - itertools.chain(six.iteritems(self._new_cache), |
225 | - six.iteritems(self._old_cache)), |
226 | + itertools.chain(self._new_cache.items(), |
227 | + self._old_cache.items()), |
228 | 0, size) |
229 | self._new_cache = dict(cache) |
230 | self._old_cache.clear() |
231 | |
232 | === modified file 'storm/cextensions.c' |
233 | --- storm/cextensions.c 2022-03-16 16:59:21 +0000 |
234 | +++ storm/cextensions.c 2024-03-04 10:59:33 +0000 |
235 | @@ -24,16 +24,6 @@ |
236 | #include <structmember.h> |
237 | |
238 | |
239 | -#if PY_VERSION_HEX >= 0x03000000 |
240 | -#define PyInt_FromLong PyLong_FromLong |
241 | -#define PyText_AsString _PyUnicode_AsString |
242 | -#define PyString_Check(o) 0 |
243 | -#define PyString_CheckExact(o) 0 |
244 | -#else |
245 | -/* 2.x */ |
246 | -#define PyText_AsString PyString_AsString |
247 | -#endif |
248 | - |
249 | #define CATCH(error_value, expression) \ |
250 | do { \ |
251 | if ((expression) == error_value) {\ |
252 | @@ -1423,7 +1413,7 @@ |
253 | PyObject *result = PyDict_GetItem(self->_precedence, type); |
254 | if (result == NULL && !PyErr_Occurred()) { |
255 | /* That should be MAX_PRECEDENCE, defined in expr.py */ |
256 | - return PyInt_FromLong(1000); |
257 | + return PyLong_FromLong(1000); |
258 | } |
259 | Py_INCREF(result); |
260 | return result; |
261 | @@ -1511,7 +1501,7 @@ |
262 | if (repr) { |
263 | PyErr_Format(CompileError, |
264 | "Don't know how to compile type %s of %s", |
265 | - expr->ob_type->tp_name, PyText_AsString(repr)); |
266 | + expr->ob_type->tp_name, _PyUnicode_AsString(repr)); |
267 | Py_DECREF(repr); |
268 | } |
269 | goto error; |
270 | @@ -1570,24 +1560,20 @@ |
271 | |
272 | /* |
273 | expr_type = type(expr) |
274 | - string_types = (str,) if six.PY3 else (str, unicode) |
275 | - if expr_type is SQLRaw or (raw and expr_type in string_types): |
276 | + if expr_type is SQLRaw or (raw and expr_type is str): |
277 | return expr |
278 | */ |
279 | - /* Note that PyString_CheckExact(o) is defined at the top of this file |
280 | - to 0 on Python 3, so we can safely translate the string_types checks |
281 | - here to PyString_CheckExact || PyUnicode_CheckExact. */ |
282 | if ((PyObject *)expr->ob_type == SQLRaw || |
283 | - (raw && (PyString_CheckExact(expr) || PyUnicode_CheckExact(expr)))) { |
284 | + (raw && PyUnicode_CheckExact(expr))) { |
285 | /* Pass our reference on. */ |
286 | return expr; |
287 | } |
288 | |
289 | /* |
290 | - if token and expr_type in string_types: |
291 | + if token and expr_type is str: |
292 | expr = SQLToken(expr) |
293 | */ |
294 | - if (token && (PyString_CheckExact(expr) || PyUnicode_CheckExact(expr))) { |
295 | + if (token && PyUnicode_CheckExact(expr)) { |
296 | PyObject *tmp; |
297 | CATCH(NULL, tmp = PyObject_CallFunctionObjArgs(SQLToken, expr, NULL)); |
298 | Py_DECREF(expr); |
299 | @@ -1614,12 +1600,10 @@ |
300 | PyObject *subexpr = PySequence_Fast_GET_ITEM(sequence, i); |
301 | /* |
302 | subexpr_type = type(subexpr) |
303 | - if (subexpr_type is SQLRaw or |
304 | - (raw and subexpr_type in string_types)): |
305 | + if subexpr_type is SQLRaw or (raw and subexpr_type is str): |
306 | */ |
307 | if ((PyObject *)subexpr->ob_type == (PyObject *)SQLRaw || |
308 | - (raw && (PyString_CheckExact(subexpr) || |
309 | - PyUnicode_CheckExact(subexpr)))) { |
310 | + (raw && PyUnicode_CheckExact(subexpr))) { |
311 | /* statement = subexpr */ |
312 | Py_INCREF(subexpr); |
313 | statement = subexpr; |
314 | @@ -1636,10 +1620,9 @@ |
315 | /* else: */ |
316 | } else { |
317 | /* |
318 | - if token and subexpr_type in string_types: |
319 | + if token and subexpr_type is str: |
320 | */ |
321 | - if (token && (PyUnicode_CheckExact(subexpr) || |
322 | - PyString_CheckExact(subexpr))) { |
323 | + if (token && PyUnicode_CheckExact(subexpr)) { |
324 | /* subexpr = SQLToken(subexpr) */ |
325 | CATCH(NULL, |
326 | subexpr = PyObject_CallFunctionObjArgs(SQLToken, |
327 | @@ -1713,7 +1696,7 @@ |
328 | &expr, &state, &join, &raw, &token)) { |
329 | return NULL; |
330 | } |
331 | - if (join && (!PyString_Check(join) && !PyUnicode_Check(join))) { |
332 | + if (join && !PyUnicode_Check(join)) { |
333 | PyErr_Format(PyExc_TypeError, |
334 | "'join' argument must be a string, not %.80s", |
335 | Py_TYPE(join)->tp_name); |
336 | @@ -1949,7 +1932,7 @@ |
337 | PyObject *column, *variable, *tmp; |
338 | Py_ssize_t i = 0; |
339 | |
340 | - /* for variable in six.itervalues(self.variables): */ |
341 | + /* for variable in self.variables.values(): */ |
342 | while (PyDict_Next(self->variables, &i, &column, &variable)) { |
343 | /* variable.checkpoint() */ |
344 | CATCH(NULL, tmp = PyObject_CallMethod(variable, "checkpoint", NULL)); |
345 | @@ -2180,16 +2163,6 @@ |
346 | return 0; |
347 | } |
348 | |
349 | -#if PY_VERSION_HEX < 0x03000000 |
350 | -DL_EXPORT(void) |
351 | -initcextensions(void) |
352 | -{ |
353 | - PyObject *module; |
354 | - |
355 | - module = Py_InitModule3("cextensions", cextensions_methods, ""); |
356 | - do_init(module); |
357 | -} |
358 | -#else |
359 | static struct PyModuleDef cextensionsmodule = { |
360 | PyModuleDef_HEAD_INIT, |
361 | "cextensions", |
362 | @@ -2211,7 +2184,6 @@ |
363 | do_init(module); |
364 | return module; |
365 | } |
366 | -#endif |
367 | |
368 | |
369 | /* vim:ts=4:sw=4:et |
370 | |
371 | === removed file 'storm/compat.py' |
372 | --- storm/compat.py 2019-06-05 11:41:07 +0000 |
373 | +++ storm/compat.py 1970-01-01 00:00:00 +0000 |
374 | @@ -1,27 +0,0 @@ |
375 | -# |
376 | -# Copyright (c) 2011 Canonical |
377 | -# |
378 | -# Written by Gustavo Niemeyer <gustavo@niemeyer.net> |
379 | -# |
380 | -# This file is part of Storm Object Relational Mapper. |
381 | -# |
382 | -# Storm is free software; you can redistribute it and/or modify |
383 | -# it under the terms of the GNU Lesser General Public License as |
384 | -# published by the Free Software Foundation; either version 2.1 of |
385 | -# the License, or (at your option) any later version. |
386 | -# |
387 | -# Storm is distributed in the hope that it will be useful, |
388 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of |
389 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
390 | -# GNU Lesser General Public License for more details. |
391 | -# |
392 | -# You should have received a copy of the GNU Lesser General Public License |
393 | -# along with this program. If not, see <http://www.gnu.org/licenses/>. |
394 | -# |
395 | - |
396 | -from __future__ import print_function |
397 | - |
398 | -__all__ = ["json"] |
399 | - |
400 | - |
401 | -import json |
402 | |
403 | === modified file 'storm/database.py' |
404 | --- storm/database.py 2023-12-07 17:04:46 +0000 |
405 | +++ storm/database.py 2024-03-04 10:59:33 +0000 |
406 | @@ -25,16 +25,9 @@ |
407 | supported in modules in L{storm.databases}. |
408 | """ |
409 | |
410 | -from __future__ import print_function |
411 | - |
412 | -try: |
413 | - from collections.abc import Callable |
414 | -except ImportError: |
415 | - from collections import Callable |
416 | +from collections.abc import Callable |
417 | from functools import wraps |
418 | |
419 | -import six |
420 | - |
421 | from storm.expr import Expr, State, compile |
422 | # Circular import: imported at the end of the module. |
423 | # from storm.tracer import trace |
424 | @@ -690,7 +683,7 @@ |
425 | Where 'anything' has previously been registered with |
426 | L{register_scheme}. |
427 | """ |
428 | - if isinstance(uri, six.string_types): |
429 | + if isinstance(uri, str): |
430 | uri = URI(uri) |
431 | if uri.scheme in _database_schemes: |
432 | factory = _database_schemes[uri.scheme] |
433 | |
434 | === modified file 'storm/databases/__init__.py' |
435 | --- storm/databases/__init__.py 2019-08-11 09:07:34 +0000 |
436 | +++ storm/databases/__init__.py 2024-03-04 10:59:33 +0000 |
437 | @@ -19,10 +19,6 @@ |
438 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
439 | # |
440 | |
441 | -from __future__ import print_function |
442 | - |
443 | -import six |
444 | - |
445 | |
446 | class Dummy(object): |
447 | """Magic "infectious" class. |
448 | @@ -43,7 +39,4 @@ |
449 | def __bool__(self): |
450 | return False |
451 | |
452 | - if six.PY2: |
453 | - __nonzero__ = __bool__ |
454 | - |
455 | dummy = Dummy() |
456 | |
457 | === modified file 'storm/databases/mysql.py' |
458 | --- storm/databases/mysql.py 2021-05-13 23:02:23 +0000 |
459 | +++ storm/databases/mysql.py 2024-03-04 10:59:33 +0000 |
460 | @@ -19,8 +19,6 @@ |
461 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
462 | # |
463 | |
464 | -from __future__ import print_function |
465 | - |
466 | from datetime import time, timedelta |
467 | from array import array |
468 | import sys |
469 | |
470 | === modified file 'storm/databases/postgres.py' |
471 | --- storm/databases/postgres.py 2019-09-17 09:35:10 +0000 |
472 | +++ storm/databases/postgres.py 2024-03-04 10:59:33 +0000 |
473 | @@ -19,8 +19,6 @@ |
474 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
475 | # |
476 | |
477 | -from __future__ import print_function |
478 | - |
479 | from datetime import datetime, date, time, timedelta |
480 | import json |
481 | |
482 | |
483 | === modified file 'storm/databases/sqlite.py' |
484 | --- storm/databases/sqlite.py 2020-02-10 15:30:23 +0000 |
485 | +++ storm/databases/sqlite.py 2024-03-04 10:59:33 +0000 |
486 | @@ -18,14 +18,10 @@ |
487 | # You should have received a copy of the GNU Lesser General Public License |
488 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
489 | # |
490 | -from __future__ import print_function |
491 | - |
492 | from datetime import datetime, date, time, timedelta |
493 | from time import sleep, time as now |
494 | import sys |
495 | |
496 | -import six |
497 | - |
498 | from storm.databases import dummy |
499 | |
500 | try: |
501 | @@ -85,26 +81,11 @@ |
502 | |
503 | @staticmethod |
504 | def set_variable(variable, value): |
505 | - if (isinstance(variable, BytesVariable) and |
506 | - isinstance(value, six.text_type)): |
507 | + if isinstance(variable, BytesVariable) and isinstance(value, str): |
508 | # pysqlite2 may return unicode. |
509 | value = value.encode("UTF-8") |
510 | variable.set(value, from_db=True) |
511 | |
512 | - @staticmethod |
513 | - def from_database(row): |
514 | - """Convert SQLite-specific datatypes to "normal" Python types. |
515 | - |
516 | - On Python 2, if there are any C{buffer} instances in the row, |
517 | - convert them to bytes. On Python 3, BLOB types are converted to |
518 | - bytes, which is already what we want. |
519 | - """ |
520 | - for value in row: |
521 | - if six.PY2 and isinstance(value, buffer): |
522 | - yield bytes(value) |
523 | - else: |
524 | - yield value |
525 | - |
526 | |
527 | class SQLiteConnection(Connection): |
528 | |
529 | @@ -116,16 +97,13 @@ |
530 | def to_database(params): |
531 | """ |
532 | Like L{Connection.to_database}, but this also converts |
533 | - instances of L{datetime} types to strings, and (on Python 2) bytes |
534 | - instances to C{buffer} instances. |
535 | + instances of L{datetime} types to strings. |
536 | """ |
537 | for param in params: |
538 | if isinstance(param, Variable): |
539 | param = param.get(to_db=True) |
540 | if isinstance(param, (datetime, date, time, timedelta)): |
541 | yield str(param) |
542 | - elif six.PY2 and isinstance(param, bytes): |
543 | - yield buffer(param) |
544 | else: |
545 | yield param |
546 | |
547 | |
548 | === modified file 'storm/event.py' |
549 | --- storm/event.py 2020-05-29 22:08:47 +0000 |
550 | +++ storm/event.py 2024-03-04 10:59:33 +0000 |
551 | @@ -18,8 +18,6 @@ |
552 | # You should have received a copy of the GNU Lesser General Public License |
553 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
554 | # |
555 | -from __future__ import print_function |
556 | - |
557 | import weakref |
558 | |
559 | from storm import has_cextensions |
560 | |
561 | === modified file 'storm/exceptions.py' |
562 | --- storm/exceptions.py 2021-05-13 23:23:17 +0000 |
563 | +++ storm/exceptions.py 2024-03-04 10:59:33 +0000 |
564 | @@ -18,13 +18,9 @@ |
565 | # You should have received a copy of the GNU Lesser General Public License |
566 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
567 | # |
568 | -from __future__ import print_function |
569 | - |
570 | from contextlib import contextmanager |
571 | import sys |
572 | |
573 | -import six |
574 | - |
575 | |
576 | class StormError(Exception): |
577 | pass |
578 | @@ -171,18 +167,12 @@ |
579 | for wrapper_type in _wrapped_exception_types: |
580 | dbapi_type = getattr(module, wrapper_type.__name__, None) |
581 | if (dbapi_type is not None and |
582 | - isinstance(dbapi_type, six.class_types) and |
583 | + isinstance(dbapi_type, type) and |
584 | isinstance(e, dbapi_type)): |
585 | wrapped = database._wrap_exception(wrapper_type, e) |
586 | tb = sys.exc_info()[2] |
587 | - # As close to "raise wrapped.with_traceback(tb) from e" as |
588 | - # we can manage, but without causing syntax errors on |
589 | - # various versions of Python. |
590 | try: |
591 | - if six.PY2: |
592 | - six.reraise(wrapped, None, tb) |
593 | - else: |
594 | - six.raise_from(wrapped.with_traceback(tb), e) |
595 | + raise wrapped.with_traceback(tb) from e |
596 | finally: |
597 | # Avoid traceback reference cycles. |
598 | del wrapped, tb |
599 | |
600 | === modified file 'storm/expr.py' |
601 | --- storm/expr.py 2022-10-18 17:36:05 +0000 |
602 | +++ storm/expr.py 2024-03-04 10:59:33 +0000 |
603 | @@ -18,16 +18,12 @@ |
604 | # You should have received a copy of the GNU Lesser General Public License |
605 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
606 | # |
607 | -from __future__ import print_function |
608 | - |
609 | from decimal import Decimal |
610 | from datetime import datetime, date, time, timedelta |
611 | from weakref import WeakKeyDictionary |
612 | from copy import copy |
613 | import re |
614 | |
615 | -import six |
616 | - |
617 | from storm.exceptions import CompileError, NoTableError, ExprError |
618 | from storm.variables import ( |
619 | Variable, BytesVariable, UnicodeVariable, LazyValue, |
620 | @@ -157,23 +153,20 @@ |
621 | created internally (and thus can't be accessed). |
622 | @param join: The string token to use to put between |
623 | subexpressions. Defaults to ", ". |
624 | - @param raw: If true, any string (str or unicode on Python 2, str on |
625 | - Python 3) expression or subexpression will not be further |
626 | - compiled. |
627 | - @param token: If true, any string (str or unicode on Python 2, str |
628 | - on Python 3) expression will be considered as a SQLToken, and |
629 | - quoted properly. |
630 | + @param raw: If true, any string expression or subexpression will not |
631 | + be further compiled. |
632 | + @param token: If true, any string expression will be considered as a |
633 | + SQLToken, and quoted properly. |
634 | """ |
635 | # FASTPATH This method is part of the fast path. Be careful when |
636 | # changing it (try to profile any changes). |
637 | |
638 | expr_type = type(expr) |
639 | - string_types = (str,) if six.PY3 else (str, unicode) |
640 | |
641 | - if expr_type is SQLRaw or (raw and expr_type in string_types): |
642 | + if expr_type is SQLRaw or (raw and expr_type is str): |
643 | return expr |
644 | |
645 | - if token and expr_type in string_types: |
646 | + if token and expr_type is str: |
647 | expr = SQLToken(expr) |
648 | |
649 | if state is None: |
650 | @@ -184,14 +177,13 @@ |
651 | compiled = [] |
652 | for subexpr in expr: |
653 | subexpr_type = type(subexpr) |
654 | - if (subexpr_type is SQLRaw or |
655 | - (raw and subexpr_type in string_types)): |
656 | + if subexpr_type is SQLRaw or (raw and subexpr_type is str): |
657 | statement = subexpr |
658 | elif subexpr_type is tuple or subexpr_type is list: |
659 | state.precedence = outer_precedence |
660 | statement = self(subexpr, state, join, raw, token) |
661 | else: |
662 | - if token and subexpr_type in string_types: |
663 | + if token and subexpr_type is str: |
664 | subexpr = SQLToken(subexpr) |
665 | statement = self._compile_single(subexpr, state, |
666 | outer_precedence) |
667 | @@ -313,12 +305,12 @@ |
668 | state.parameters.append(BytesVariable(expr)) |
669 | return "?" |
670 | |
671 | -@compile.when(six.text_type) |
672 | +@compile.when(str) |
673 | def compile_text(compile, expr, state): |
674 | state.parameters.append(UnicodeVariable(expr)) |
675 | return "?" |
676 | |
677 | -@compile.when(*six.integer_types) |
678 | +@compile.when(int) |
679 | def compile_int(compile, expr, state): |
680 | state.parameters.append(IntVariable(expr)) |
681 | return "?" |
682 | @@ -363,8 +355,7 @@ |
683 | return "NULL" |
684 | |
685 | |
686 | -@compile_python.when( |
687 | - bytes, six.text_type, float, type(None), *six.integer_types) |
688 | +@compile_python.when(bytes, str, int, float, type(None)) |
689 | def compile_python_builtin(compile, expr, state): |
690 | return repr(expr) |
691 | |
692 | @@ -518,19 +509,19 @@ |
693 | return Upper(self) |
694 | |
695 | def startswith(self, prefix, case_sensitive=None): |
696 | - if not isinstance(prefix, six.text_type): |
697 | + if not isinstance(prefix, str): |
698 | raise ExprError("Expected text argument, got %r" % type(prefix)) |
699 | pattern = prefix.translate(like_escape) + u"%" |
700 | return Like(self, pattern, u"!", case_sensitive) |
701 | |
702 | def endswith(self, suffix, case_sensitive=None): |
703 | - if not isinstance(suffix, six.text_type): |
704 | + if not isinstance(suffix, str): |
705 | raise ExprError("Expected text argument, got %r" % type(suffix)) |
706 | pattern = u"%" + suffix.translate(like_escape) |
707 | return Like(self, pattern, u"!", case_sensitive) |
708 | |
709 | def contains_string(self, substring, case_sensitive=None): |
710 | - if not isinstance(substring, six.text_type): |
711 | + if not isinstance(substring, str): |
712 | raise ExprError("Expected text argument, got %r" % type(substring)) |
713 | pattern = u"%" + substring.translate(like_escape) + u"%" |
714 | return Like(self, pattern, u"!", case_sensitive) |
715 | @@ -746,7 +737,7 @@ |
716 | state.context = EXPR |
717 | values = insert.values |
718 | if values is Undef: |
719 | - values = [tuple(six.itervalues(insert.map))] |
720 | + values = [tuple(insert.map.values())] |
721 | if isinstance(values, Expr): |
722 | compiled_values = compile(values, state) |
723 | else: |
724 | @@ -1492,7 +1483,7 @@ |
725 | # -------------------------------------------------------------------- |
726 | # Plain SQL expressions. |
727 | |
728 | -class SQLRaw(six.text_type): |
729 | +class SQLRaw(str): |
730 | """Subtype to mark a string as something that shouldn't be compiled. |
731 | |
732 | This is handled internally by the compiler. |
733 | @@ -1500,7 +1491,7 @@ |
734 | __slots__ = () |
735 | |
736 | |
737 | -class SQLToken(six.text_type): |
738 | +class SQLToken(str): |
739 | """Marker for strings that should be considered as a single SQL token. |
740 | |
741 | These strings will be quoted, when needed. |
742 | |
743 | === modified file 'storm/info.py' |
744 | --- storm/info.py 2020-05-26 10:37:54 +0000 |
745 | +++ storm/info.py 2024-03-04 10:59:33 +0000 |
746 | @@ -18,12 +18,8 @@ |
747 | # You should have received a copy of the GNU Lesser General Public License |
748 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
749 | # |
750 | -from __future__ import print_function |
751 | - |
752 | from weakref import ref |
753 | |
754 | -import six |
755 | - |
756 | from storm.exceptions import ClassInfoError |
757 | from storm.expr import Column, Desc, TABLE |
758 | from storm.expr import compile, Table |
759 | @@ -77,7 +73,7 @@ |
760 | |
761 | self.cls = cls |
762 | |
763 | - if isinstance(self.table, six.string_types): |
764 | + if isinstance(self.table, str): |
765 | self.table = Table(self.table) |
766 | |
767 | pairs = [] |
768 | @@ -135,7 +131,7 @@ |
769 | __order__ = (__order__,) |
770 | self.default_order = [] |
771 | for item in __order__: |
772 | - if isinstance(item, six.string_types): |
773 | + if isinstance(item, str): |
774 | if item.startswith("-"): |
775 | prop = Desc(getattr(cls, item[1:])) |
776 | else: |
777 | @@ -198,7 +194,7 @@ |
778 | self.event.emit("object-deleted") |
779 | |
780 | def checkpoint(self): |
781 | - for variable in six.itervalues(self.variables): |
782 | + for variable in self.variables.values(): |
783 | variable.checkpoint() |
784 | |
785 | |
786 | |
787 | === modified file 'storm/locals.py' |
788 | --- storm/locals.py 2020-02-10 15:30:23 +0000 |
789 | +++ storm/locals.py 2024-03-04 10:59:33 +0000 |
790 | @@ -18,8 +18,6 @@ |
791 | # You should have received a copy of the GNU Lesser General Public License |
792 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
793 | # |
794 | -from __future__ import print_function |
795 | - |
796 | from storm.properties import Bool, Int, Float, Bytes, RawStr, Chars, Unicode |
797 | from storm.properties import List, Decimal, DateTime, Date, Time, Enum, UUID |
798 | from storm.properties import TimeDelta, Pickle, JSON |
799 | |
800 | === modified file 'storm/properties.py' |
801 | --- storm/properties.py 2020-05-26 16:14:13 +0000 |
802 | +++ storm/properties.py 2024-03-04 10:59:33 +0000 |
803 | @@ -18,8 +18,6 @@ |
804 | # You should have received a copy of the GNU Lesser General Public License |
805 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
806 | # |
807 | -from __future__ import print_function |
808 | - |
809 | from bisect import insort_left, bisect_left |
810 | import weakref |
811 | import sys |
812 | @@ -211,8 +209,8 @@ |
813 | class Bytes(SimpleProperty): |
814 | """Bytes property. |
815 | |
816 | - This accepts L{bytes}, L{buffer} (Python 2), or L{memoryview} (Python 3) |
817 | - objects, and stores them as byte strings. |
818 | + This accepts L{bytes} or L{memoryview} objects, and stores them as byte |
819 | + strings. |
820 | |
821 | Deprecated aliases: L{Chars}, L{RawStr}. |
822 | """ |
823 | @@ -228,9 +226,7 @@ |
824 | class Unicode(SimpleProperty): |
825 | """Unicode property. |
826 | |
827 | - This accepts L{unicode} (Python 2) or L{str} (Python 3) objects, and |
828 | - stores them as text strings. Note that it does not accept L{str} |
829 | - objects on Python 2. |
830 | + This accepts L{str} objects, and stores them as text strings. |
831 | """ |
832 | variable_class = UnicodeVariable |
833 | |
834 | |
835 | === modified file 'storm/references.py' |
836 | --- storm/references.py 2020-05-26 16:32:10 +0000 |
837 | +++ storm/references.py 2024-03-04 10:59:33 +0000 |
838 | @@ -18,12 +18,8 @@ |
839 | # You should have received a copy of the GNU Lesser General Public License |
840 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
841 | # |
842 | -from __future__ import print_function |
843 | - |
844 | import weakref |
845 | |
846 | -import six |
847 | - |
848 | from storm.exceptions import ( |
849 | ClassInfoError, FeatureError, NoStoreError, WrongStoreError) |
850 | from storm.store import Store, get_where_for_args, LostObjectError |
851 | @@ -985,7 +981,7 @@ |
852 | def resolve_one(self, property): |
853 | if type(property) is tuple: |
854 | return self.resolve(property) |
855 | - elif isinstance(property, six.string_types): |
856 | + elif isinstance(property, str): |
857 | return self._resolve_string(property) |
858 | elif isinstance(property, SuffixExpr): |
859 | # XXX This covers cases like order_by=Desc("Bar.id"), see #620369. |
860 | @@ -1013,14 +1009,14 @@ |
861 | |
862 | def _find_descriptor_class(used_cls, descr): |
863 | for cls in used_cls.__mro__: |
864 | - for attr, _descr in six.iteritems(cls.__dict__): |
865 | + for attr, _descr in cls.__dict__.items(): |
866 | if _descr is descr: |
867 | return cls |
868 | raise RuntimeError("Reference used in an unknown class") |
869 | |
870 | def _find_descriptor_obj(used_cls, descr): |
871 | for cls in used_cls.__mro__: |
872 | - for attr, _descr in six.iteritems(cls.__dict__): |
873 | + for attr, _descr in cls.__dict__.items(): |
874 | if _descr is descr: |
875 | return getattr(cls, attr) |
876 | raise RuntimeError("Reference used in an unknown class") |
877 | |
878 | === modified file 'storm/schema/__init__.py' |
879 | --- storm/schema/__init__.py 2019-06-05 11:41:07 +0000 |
880 | +++ storm/schema/__init__.py 2024-03-04 10:59:33 +0000 |
881 | @@ -18,6 +18,4 @@ |
882 | # You should have received a copy of the GNU Lesser General Public License |
883 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
884 | # |
885 | -from __future__ import print_function |
886 | - |
887 | from storm.schema.schema import Schema |
888 | |
889 | === modified file 'storm/schema/patch.py' |
890 | --- storm/schema/patch.py 2019-08-11 10:08:24 +0000 |
891 | +++ storm/schema/patch.py 2024-03-04 10:59:33 +0000 |
892 | @@ -34,15 +34,11 @@ |
893 | 'patch' table in the given L{Store}, and it won't be applied again. |
894 | """ |
895 | |
896 | -from __future__ import print_function |
897 | - |
898 | import sys |
899 | import os |
900 | import re |
901 | import types |
902 | |
903 | -import six |
904 | - |
905 | from storm.locals import StormError, Int |
906 | |
907 | |
908 | @@ -122,12 +118,10 @@ |
909 | except: |
910 | type, value, traceback = sys.exc_info() |
911 | patch_repr = getattr(module, "__file__", version) |
912 | - six.reraise( |
913 | - BadPatchError, |
914 | - BadPatchError( |
915 | - "Patch %s failed: %s: %s" % |
916 | - (patch_repr, type.__name__, str(value))), |
917 | - traceback) |
918 | + raise BadPatchError( |
919 | + "Patch %s failed: %s: %s" % |
920 | + (patch_repr, type.__name__, str(value)) |
921 | + ).with_traceback(traceback) |
922 | self._committer.commit() |
923 | |
924 | def apply_all(self): |
925 | |
926 | === modified file 'storm/schema/schema.py' |
927 | --- storm/schema/schema.py 2019-06-05 11:41:07 +0000 |
928 | +++ storm/schema/schema.py 2024-03-04 10:59:33 +0000 |
929 | @@ -43,8 +43,6 @@ |
930 | upgrade the schema over time. |
931 | """ |
932 | |
933 | -from __future__ import print_function |
934 | - |
935 | import types |
936 | |
937 | from storm.locals import StormError |
938 | |
939 | === modified file 'storm/schema/sharding.py' |
940 | --- storm/schema/sharding.py 2019-06-05 11:41:07 +0000 |
941 | +++ storm/schema/sharding.py 2024-03-04 10:59:33 +0000 |
942 | @@ -41,8 +41,6 @@ |
943 | be at the same patch level. See L{storm.schema.patch.PatchSet}. |
944 | """ |
945 | |
946 | -from __future__ import print_function |
947 | - |
948 | from storm.schema.schema import SchemaMissingError, UnappliedPatchesError |
949 | |
950 | |
951 | |
952 | === modified file 'storm/sqlobject.py' |
953 | --- storm/sqlobject.py 2020-02-10 15:30:23 +0000 |
954 | +++ storm/sqlobject.py 2024-03-04 10:59:33 +0000 |
955 | @@ -23,18 +23,14 @@ |
956 | L{SQLObjectBase} is the central point of compatibility. |
957 | """ |
958 | |
959 | -from __future__ import print_function |
960 | - |
961 | import re |
962 | import warnings |
963 | |
964 | -import six |
965 | - |
966 | from storm.properties import ( |
967 | Bytes, Int, Bool, Float, DateTime, Date, TimeDelta) |
968 | from storm.references import Reference, ReferenceSet |
969 | from storm.properties import SimpleProperty, PropertyPublisherMeta |
970 | -from storm.variables import Variable |
971 | +from storm.variables import UnicodeVariable |
972 | from storm.exceptions import StormError, NotOneError |
973 | from storm.info import get_cls_info, ClassAlias |
974 | from storm.store import AutoReload, Store |
975 | @@ -166,7 +162,7 @@ |
976 | dict["__storm_table__"] = table_name |
977 | |
978 | attr_to_prop = {} |
979 | - for attr, prop in list(six.iteritems(dict)): |
980 | + for attr, prop in list(dict.items()): |
981 | if attr == "__classcell__": # Python >= 3.6 |
982 | continue |
983 | attr_to_prop[attr] = attr |
984 | @@ -211,7 +207,7 @@ |
985 | |
986 | |
987 | id_type = dict.setdefault("_idType", int) |
988 | - id_cls = {int: Int, bytes: Bytes, six.text_type: AutoUnicode}[id_type] |
989 | + id_cls = {int: Int, bytes: Bytes, str: AutoUnicode}[id_type] |
990 | dict["id"] = id_cls(id_name, primary=True, default=AutoReload) |
991 | attr_to_prop[id_name] = "id" |
992 | |
993 | @@ -228,7 +224,7 @@ |
994 | property_registry.add_property(obj, getattr(obj, "id"), |
995 | "<table %s>" % table_name) |
996 | |
997 | - for fake_name, real_name in list(six.iteritems(attr_to_prop)): |
998 | + for fake_name, real_name in list(attr_to_prop.items()): |
999 | prop = getattr(obj, real_name) |
1000 | if fake_name != real_name: |
1001 | property_registry.add_property(obj, prop, fake_name) |
1002 | @@ -265,7 +261,7 @@ |
1003 | return getattr(self._cls, attr) |
1004 | |
1005 | |
1006 | -class SQLObjectBase(six.with_metaclass(SQLObjectMeta, Storm)): |
1007 | +class SQLObjectBase(Storm, metaclass=SQLObjectMeta): |
1008 | """The root class of all SQLObject-emulating classes in your application. |
1009 | |
1010 | The general strategy for using Storm's SQLObject emulation layer |
1011 | @@ -301,7 +297,7 @@ |
1012 | self._init(None) |
1013 | |
1014 | def set(self, **kwargs): |
1015 | - for attr, value in six.iteritems(kwargs): |
1016 | + for attr, value in kwargs.items(): |
1017 | setattr(self, attr, value) |
1018 | |
1019 | def destroySelf(self): |
1020 | @@ -334,7 +330,7 @@ |
1021 | if not isinstance(orderBy, (tuple, list)): |
1022 | orderBy = (orderBy,) |
1023 | for item in orderBy: |
1024 | - if isinstance(item, six.string_types): |
1025 | + if isinstance(item, str): |
1026 | desc = item.startswith("-") |
1027 | if desc: |
1028 | item = item[1:] |
1029 | @@ -409,7 +405,7 @@ |
1030 | |
1031 | def _copy(self, **kwargs): |
1032 | copy = self.__class__(self._cls, **kwargs) |
1033 | - for name, value in six.iteritems(self.__dict__): |
1034 | + for name, value in self.__dict__.items(): |
1035 | if name[1:] not in kwargs and name != "_finished_result_set": |
1036 | setattr(copy, name, value) |
1037 | return copy |
1038 | @@ -562,9 +558,6 @@ |
1039 | """ |
1040 | return not self.is_empty() |
1041 | |
1042 | - if six.PY2: |
1043 | - __nonzero__ = __bool__ |
1044 | - |
1045 | def is_empty(self): |
1046 | """Return C{True} if this result set doesn't contain any results.""" |
1047 | result_set = self._without_prejoins()._result_set |
1048 | @@ -611,7 +604,7 @@ |
1049 | return self._copy(prejoinClauseTables=prejoinClauseTables) |
1050 | |
1051 | def sum(self, attribute): |
1052 | - if isinstance(attribute, six.string_types): |
1053 | + if isinstance(attribute, str): |
1054 | attribute = SQL(attribute) |
1055 | result_set = self._without_prejoins()._result_set |
1056 | return result_set.sum(attribute) |
1057 | @@ -682,23 +675,13 @@ |
1058 | **self._kwargs) |
1059 | |
1060 | |
1061 | -class AutoUnicodeVariable(Variable): |
1062 | - """A more relaxed version of UnicodeVariable that accepts native strings. |
1063 | - |
1064 | - On Python 2, this will try to convert bytes to text, to make it easier |
1065 | - to port code from SQLObject that expects to be able to set this variable |
1066 | - to a native string. |
1067 | - |
1068 | - On Python 3, this behaves the same way as UnicodeVariable and only |
1069 | - accepts text, since native strings are already Unicode. |
1070 | - """ |
1071 | - __slots__ = () |
1072 | - |
1073 | - def parse_set(self, value, from_db): |
1074 | - if not isinstance(value, six.string_types): |
1075 | - raise TypeError("Expected a string type, found %r" % type(value)) |
1076 | - return six.text_type(value) |
1077 | - |
1078 | +# DEPRECATED: On Python 2, this used to be a more relaxed version of |
1079 | +# UnicodeVariable that accepted both bytes and text. On Python 3, it |
1080 | +# accepts only text and is thus the same as UnicodeVariable. It exists only |
1081 | +# for compatibility. |
1082 | +AutoUnicodeVariable = UnicodeVariable |
1083 | + |
1084 | +# DEPRECATED: Use storm.properties.Unicode instead. |
1085 | class AutoUnicode(SimpleProperty): |
1086 | variable_class = AutoUnicodeVariable |
1087 | |
1088 | |
1089 | === modified file 'storm/store.py' |
1090 | --- storm/store.py 2023-12-07 17:04:46 +0000 |
1091 | +++ storm/store.py 2024-03-04 10:59:33 +0000 |
1092 | @@ -24,14 +24,10 @@ |
1093 | This module contains the highest-level ORM interface in Storm. |
1094 | """ |
1095 | |
1096 | -from __future__ import print_function |
1097 | - |
1098 | from copy import copy |
1099 | from weakref import WeakValueDictionary |
1100 | from operator import itemgetter |
1101 | |
1102 | -import six |
1103 | - |
1104 | from storm.info import get_cls_info, get_obj_info, set_obj_info |
1105 | from storm.variables import Variable, LazyValue |
1106 | from storm.expr import ( |
1107 | @@ -479,7 +475,7 @@ |
1108 | self._dirty = flushing |
1109 | |
1110 | predecessors = {} |
1111 | - for (before_info, after_info), n in six.iteritems(self._order): |
1112 | + for (before_info, after_info), n in self._order.items(): |
1113 | if n > 0: |
1114 | before_set = predecessors.get(after_info) |
1115 | if before_set is None: |
1116 | @@ -858,7 +854,7 @@ |
1117 | del obj_info["primary_vars"] |
1118 | |
1119 | def _iter_alive(self): |
1120 | - return list(six.itervalues(self._alive)) |
1121 | + return list(self._alive.values()) |
1122 | |
1123 | def _enable_change_notification(self, obj_info): |
1124 | obj_info.event.emit("start-tracking-changes", self._event) |
1125 | @@ -1012,7 +1008,7 @@ |
1126 | L{ResultSet} will be returned appropriately modified with |
1127 | C{OFFSET} and C{LIMIT} clauses. |
1128 | """ |
1129 | - if isinstance(index, six.integer_types): |
1130 | + if isinstance(index, int): |
1131 | if index == 0: |
1132 | result_set = self |
1133 | else: |
1134 | @@ -1411,7 +1407,7 @@ |
1135 | for column in changes: |
1136 | obj_info.variables[column].set(AutoReload) |
1137 | else: |
1138 | - changes = list(six.iteritems(changes)) |
1139 | + changes = list(changes.items()) |
1140 | for obj in cached: |
1141 | for column, value in changes: |
1142 | variables = get_obj_info(obj).variables |
1143 | |
1144 | === modified file 'storm/testing.py' |
1145 | --- storm/testing.py 2020-05-26 15:55:53 +0000 |
1146 | +++ storm/testing.py 2024-03-04 10:59:33 +0000 |
1147 | @@ -1,5 +1,3 @@ |
1148 | -from __future__ import print_function |
1149 | - |
1150 | from fixtures import Fixture |
1151 | |
1152 | from storm.tracer import BaseStatementTracer, install_tracer, remove_tracer |
1153 | |
1154 | === modified file 'storm/tests/__init__.py' |
1155 | --- storm/tests/__init__.py 2020-05-26 10:28:24 +0000 |
1156 | +++ storm/tests/__init__.py 2024-03-04 10:59:33 +0000 |
1157 | @@ -19,8 +19,6 @@ |
1158 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1159 | # |
1160 | |
1161 | -from __future__ import print_function |
1162 | - |
1163 | __all__ = [ |
1164 | 'find_tests', |
1165 | 'has_fixtures', |
1166 | @@ -116,7 +114,6 @@ |
1167 | os.path.basename(relpath), |
1168 | module_relative=True, |
1169 | package=parent_module, |
1170 | - globs={"print_function": print_function}, |
1171 | optionflags=doctest.ELLIPSIS)) |
1172 | |
1173 | return suite |
1174 | |
1175 | === modified file 'storm/tests/base.py' |
1176 | --- storm/tests/base.py 2019-11-21 16:06:52 +0000 |
1177 | +++ storm/tests/base.py 2024-03-04 10:59:33 +0000 |
1178 | @@ -18,8 +18,6 @@ |
1179 | # You should have received a copy of the GNU Lesser General Public License |
1180 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1181 | # |
1182 | -from __future__ import print_function |
1183 | - |
1184 | import weakref |
1185 | import gc |
1186 | |
1187 | |
1188 | === modified file 'storm/tests/cache.py' |
1189 | --- storm/tests/cache.py 2019-11-21 16:06:52 +0000 |
1190 | +++ storm/tests/cache.py 2024-03-04 10:59:33 +0000 |
1191 | @@ -1,5 +1,3 @@ |
1192 | -from __future__ import print_function |
1193 | - |
1194 | from unittest import defaultTestLoader |
1195 | |
1196 | from storm.properties import Int |
1197 | |
1198 | === modified file 'storm/tests/database.py' |
1199 | --- storm/tests/database.py 2019-11-21 16:06:52 +0000 |
1200 | +++ storm/tests/database.py 2024-03-04 10:59:33 +0000 |
1201 | @@ -18,8 +18,6 @@ |
1202 | # You should have received a copy of the GNU Lesser General Public License |
1203 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1204 | # |
1205 | -from __future__ import print_function |
1206 | - |
1207 | import sys |
1208 | import types |
1209 | import gc |
1210 | |
1211 | === modified file 'storm/tests/databases/base.py' |
1212 | --- storm/tests/databases/base.py 2021-04-06 09:23:02 +0000 |
1213 | +++ storm/tests/databases/base.py 2024-03-04 10:59:33 +0000 |
1214 | @@ -20,16 +20,12 @@ |
1215 | # You should have received a copy of the GNU Lesser General Public License |
1216 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1217 | # |
1218 | -from __future__ import print_function |
1219 | - |
1220 | from datetime import datetime, date, time, timedelta |
1221 | +import pickle |
1222 | import shutil |
1223 | import sys |
1224 | import os |
1225 | |
1226 | -import six |
1227 | -from six.moves import cPickle as pickle |
1228 | - |
1229 | from storm.uri import URI |
1230 | from storm.expr import Select, Column, SQLToken, SQLRaw, Count, Alias |
1231 | from storm.variables import (Variable, PickleVariable, BytesVariable, |
1232 | @@ -152,7 +148,7 @@ |
1233 | self.assertTrue(isinstance(result, Result)) |
1234 | row = result.get_one() |
1235 | self.assertEqual(row, ("Title 10",)) |
1236 | - self.assertTrue(isinstance(row[0], six.text_type)) |
1237 | + self.assertTrue(isinstance(row[0], str)) |
1238 | |
1239 | def test_execute_params(self): |
1240 | result = self.connection.execute("SELECT one FROM number " |
1241 | |
1242 | === modified file 'storm/tests/databases/mysql.py' |
1243 | --- storm/tests/databases/mysql.py 2021-05-13 23:02:23 +0000 |
1244 | +++ storm/tests/databases/mysql.py 2024-03-04 10:59:33 +0000 |
1245 | @@ -18,11 +18,8 @@ |
1246 | # You should have received a copy of the GNU Lesser General Public License |
1247 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1248 | # |
1249 | -from __future__ import print_function |
1250 | - |
1251 | import os |
1252 | - |
1253 | -from six.moves.urllib.parse import urlunsplit |
1254 | +from urllib.parse import urlunsplit |
1255 | |
1256 | from storm.databases.mysql import MySQL |
1257 | from storm.database import create_database |
1258 | |
1259 | === modified file 'storm/tests/databases/postgres.py' |
1260 | --- storm/tests/databases/postgres.py 2020-02-10 15:30:23 +0000 |
1261 | +++ storm/tests/databases/postgres.py 2024-03-04 10:59:33 +0000 |
1262 | @@ -18,14 +18,10 @@ |
1263 | # You should have received a copy of the GNU Lesser General Public License |
1264 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1265 | # |
1266 | -from __future__ import print_function |
1267 | - |
1268 | from datetime import date, time, timedelta |
1269 | import os |
1270 | import json |
1271 | - |
1272 | -import six |
1273 | -from six.moves.urllib.parse import urlunsplit |
1274 | +from urllib.parse import urlunsplit |
1275 | |
1276 | from storm.databases.postgres import ( |
1277 | Postgres, compile, currval, Returning, Case, PostgresTimeoutTracer, |
1278 | @@ -171,7 +167,7 @@ |
1279 | result = connection.execute("SELECT title FROM test WHERE id=1") |
1280 | title = result.get_one()[0] |
1281 | |
1282 | - self.assertTrue(isinstance(title, six.text_type)) |
1283 | + self.assertTrue(isinstance(title, str)) |
1284 | self.assertEqual(title, uni_str) |
1285 | |
1286 | def test_unicode_array(self): |
1287 | @@ -695,11 +691,8 @@ |
1288 | |
1289 | connection = self.database.connect() |
1290 | value = {"a": 3, "b": "foo", "c": None} |
1291 | - db_value = json.dumps(value) |
1292 | - if six.PY2: |
1293 | - db_value = db_value.decode("utf-8") |
1294 | connection.execute( |
1295 | - "INSERT INTO json_test (json) VALUES (?)", (db_value,)) |
1296 | + "INSERT INTO json_test (json) VALUES (?)", (json.dumps(value),)) |
1297 | connection.commit() |
1298 | |
1299 | store = Store(self.database) |
1300 | |
1301 | === modified file 'storm/tests/databases/proxy.py' |
1302 | --- storm/tests/databases/proxy.py 2019-09-29 14:05:31 +0000 |
1303 | +++ storm/tests/databases/proxy.py 2024-03-04 10:59:33 +0000 |
1304 | @@ -20,17 +20,13 @@ |
1305 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1306 | # |
1307 | |
1308 | -from __future__ import print_function |
1309 | - |
1310 | import errno |
1311 | import os |
1312 | import select |
1313 | import socket |
1314 | +import socketserver |
1315 | import threading |
1316 | |
1317 | -import six |
1318 | -from six.moves import socketserver |
1319 | - |
1320 | |
1321 | TIMEOUT = 0.1 |
1322 | |
1323 | @@ -44,7 +40,7 @@ |
1324 | self, request, client_address, server) |
1325 | |
1326 | def handle(self): |
1327 | - if isinstance(self.server.proxy_dest, (bytes, six.text_type)): |
1328 | + if isinstance(self.server.proxy_dest, (bytes, str)): |
1329 | dst = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) |
1330 | else: |
1331 | dst = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
1332 | |
1333 | === modified file 'storm/tests/databases/sqlite.py' |
1334 | --- storm/tests/databases/sqlite.py 2019-11-21 16:06:52 +0000 |
1335 | +++ storm/tests/databases/sqlite.py 2024-03-04 10:59:33 +0000 |
1336 | @@ -18,8 +18,6 @@ |
1337 | # You should have received a copy of the GNU Lesser General Public License |
1338 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1339 | # |
1340 | -from __future__ import print_function |
1341 | - |
1342 | from datetime import timedelta |
1343 | import time |
1344 | import os |
1345 | |
1346 | === modified file 'storm/tests/event.py' |
1347 | --- storm/tests/event.py 2019-11-21 16:06:52 +0000 |
1348 | +++ storm/tests/event.py 2024-03-04 10:59:33 +0000 |
1349 | @@ -18,8 +18,6 @@ |
1350 | # You should have received a copy of the GNU Lesser General Public License |
1351 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1352 | # |
1353 | -from __future__ import print_function |
1354 | - |
1355 | from storm.event import EventSystem |
1356 | from storm.tests.helper import TestHelper |
1357 | |
1358 | |
1359 | === modified file 'storm/tests/expr.py' |
1360 | --- storm/tests/expr.py 2023-12-07 17:04:46 +0000 |
1361 | +++ storm/tests/expr.py 2024-03-04 10:59:33 +0000 |
1362 | @@ -18,12 +18,7 @@ |
1363 | # You should have received a copy of the GNU Lesser General Public License |
1364 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1365 | # |
1366 | -from __future__ import print_function |
1367 | - |
1368 | from decimal import Decimal |
1369 | -import unittest |
1370 | - |
1371 | -import six |
1372 | |
1373 | from storm.variables import * |
1374 | from storm.expr import * |
1375 | @@ -625,14 +620,6 @@ |
1376 | self.assertEqual(statement, "?") |
1377 | self.assertVariablesEqual(state.parameters, [IntVariable(1)]) |
1378 | |
1379 | - @unittest.skipUnless(six.PY2, "Python 3 has no separate long type") |
1380 | - def test_long(self): |
1381 | - state = State() |
1382 | - # 1L was more idiomatic in Python 2, but is a syntax error in Python 3. |
1383 | - statement = compile(long(1), state) |
1384 | - self.assertEqual(statement, "?") |
1385 | - self.assertVariablesEqual(state.parameters, [IntVariable(1)]) |
1386 | - |
1387 | def test_bool(self): |
1388 | state = State() |
1389 | statement = compile(True, state) |
1390 | @@ -2254,22 +2241,16 @@ |
1391 | |
1392 | def test_bytes(self): |
1393 | py_expr = compile_python(b"str") |
1394 | - self.assertEqual(py_expr, "b'str'" if six.PY3 else "'str'") |
1395 | + self.assertEqual(py_expr, "b'str'") |
1396 | |
1397 | def test_unicode(self): |
1398 | py_expr = compile_python(u"str") |
1399 | - self.assertEqual(py_expr, "'str'" if six.PY3 else "u'str'") |
1400 | + self.assertEqual(py_expr, "'str'") |
1401 | |
1402 | def test_int(self): |
1403 | py_expr = compile_python(1) |
1404 | self.assertEqual(py_expr, "1") |
1405 | |
1406 | - @unittest.skipUnless(six.PY2, "Python 3 has no separate long type") |
1407 | - def test_long(self): |
1408 | - # 1L was more idiomatic in Python 2, but is a syntax error in Python 3. |
1409 | - py_expr = compile_python(long(1)) |
1410 | - self.assertEqual(py_expr, "1L") |
1411 | - |
1412 | def test_bool(self): |
1413 | state = State() |
1414 | py_expr = compile_python(True, state) |
1415 | |
1416 | === modified file 'storm/tests/helper.py' |
1417 | --- storm/tests/helper.py 2019-11-21 16:06:52 +0000 |
1418 | +++ storm/tests/helper.py 2024-03-04 10:59:33 +0000 |
1419 | @@ -18,14 +18,11 @@ |
1420 | # You should have received a copy of the GNU Lesser General Public License |
1421 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1422 | # |
1423 | -from __future__ import print_function |
1424 | - |
1425 | -import tempfile |
1426 | +from io import StringIO |
1427 | import logging |
1428 | import shutil |
1429 | import sys |
1430 | - |
1431 | -from six.moves import cStringIO as StringIO |
1432 | +import tempfile |
1433 | |
1434 | from storm.tests import mocker |
1435 | |
1436 | |
1437 | === modified file 'storm/tests/info.py' |
1438 | --- storm/tests/info.py 2019-11-21 16:06:52 +0000 |
1439 | +++ storm/tests/info.py 2024-03-04 10:59:33 +0000 |
1440 | @@ -18,13 +18,9 @@ |
1441 | # You should have received a copy of the GNU Lesser General Public License |
1442 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1443 | # |
1444 | -from __future__ import print_function |
1445 | - |
1446 | from weakref import ref |
1447 | import gc |
1448 | |
1449 | -import six |
1450 | - |
1451 | from storm.exceptions import ClassInfoError |
1452 | from storm.properties import Property |
1453 | from storm.variables import Variable |
1454 | @@ -572,7 +568,7 @@ |
1455 | cls = type.__new__(meta_cls, name, bases, dict) |
1456 | cls.__storm_table__ = "HAH! GOTCH YA!" |
1457 | return cls |
1458 | - class Class(six.with_metaclass(MetaClass, object)): |
1459 | + class Class(metaclass=MetaClass): |
1460 | __storm_table__ = "table" |
1461 | prop1 = Property("column1", primary=True) |
1462 | Alias = ClassAlias(Class, "USE_THIS") |
1463 | |
1464 | === modified file 'storm/tests/mocker.py' |
1465 | --- storm/tests/mocker.py 2022-03-16 16:59:21 +0000 |
1466 | +++ storm/tests/mocker.py 2024-03-04 10:59:33 +0000 |
1467 | @@ -3,8 +3,7 @@ |
1468 | |
1469 | Graceful platform for test doubles in Python (mocks, stubs, fakes, and dummies). |
1470 | """ |
1471 | -from __future__ import print_function |
1472 | - |
1473 | +import builtins |
1474 | import tempfile |
1475 | import unittest |
1476 | import inspect |
1477 | @@ -13,9 +12,6 @@ |
1478 | import os |
1479 | import gc |
1480 | |
1481 | -import six |
1482 | -from six.moves import builtins |
1483 | - |
1484 | |
1485 | __all__ = ["Mocker", "expect", "IS", "CONTAINS", "IN", "MATCH", |
1486 | "ANY", "ARGS", "KWARGS"] |
1487 | @@ -336,7 +332,7 @@ |
1488 | self._recorders = list(getattr(self, "_recorders", ())) |
1489 | |
1490 | |
1491 | -class MockerBase(six.with_metaclass(MockerMeta, object)): |
1492 | +class MockerBase(metaclass=MockerMeta): |
1493 | """Controller of mock objects. |
1494 | |
1495 | A mocker instance is used to command recording and replay of |
1496 | @@ -563,7 +559,7 @@ |
1497 | explicitly requested via the L{passthrough()} |
1498 | method. |
1499 | """ |
1500 | - if isinstance(object, six.string_types): |
1501 | + if isinstance(object, str): |
1502 | if name is None: |
1503 | name = object |
1504 | import_stack = object.split(".") |
1505 | @@ -1096,9 +1092,6 @@ |
1506 | except MatchError as e: |
1507 | return True |
1508 | |
1509 | - if six.PY2: |
1510 | - __nonzero__ = __bool__ |
1511 | - |
1512 | def __iter__(self): |
1513 | # XXX On py3k, when next() becomes __next__(), we'll be able |
1514 | # to return the mock itself because it will be considered |
1515 | @@ -1119,13 +1112,13 @@ |
1516 | frame = sys._getframe(depth+1) |
1517 | except: |
1518 | return None |
1519 | - for name, frame_obj in six.iteritems(frame.f_locals): |
1520 | + for name, frame_obj in frame.f_locals.items(): |
1521 | if frame_obj is obj: |
1522 | return name |
1523 | self = frame.f_locals.get("self") |
1524 | if self is not None: |
1525 | try: |
1526 | - items = list(six.iteritems(self.__dict__)) |
1527 | + items = list(self.__dict__.items()) |
1528 | except: |
1529 | pass |
1530 | else: |
1531 | @@ -1274,7 +1267,7 @@ |
1532 | result = "del %s.%s" % (result, action.args[0]) |
1533 | elif action.kind == "call": |
1534 | args = [repr(x) for x in action.args] |
1535 | - items = list(six.iteritems(action.kwargs)) |
1536 | + items = list(action.kwargs.items()) |
1537 | items.sort() |
1538 | for pair in items: |
1539 | args.append("%s=%r" % pair) |
1540 | @@ -1394,7 +1387,7 @@ |
1541 | |
1542 | # Either we have the same number of kwargs, or unknown keywords are |
1543 | # accepted (KWARGS was used), so check just the ones in kwargs1. |
1544 | - for key, arg1 in six.iteritems(kwargs1): |
1545 | + for key, arg1 in kwargs1.items(): |
1546 | if key not in kwargs2: |
1547 | return False |
1548 | arg2 = kwargs2[key] |
1549 | @@ -1834,45 +1827,30 @@ |
1550 | |
1551 | if method: |
1552 | try: |
1553 | - if six.PY3: |
1554 | - # On Python 3, inspect.getargspec includes the bound |
1555 | - # first argument (self or similar) for bound methods, |
1556 | - # which confuses matters. The modern signature API |
1557 | - # doesn't have this problem. |
1558 | - self._signature = inspect.signature(method) |
1559 | - # Method descriptors don't have the first argument |
1560 | - # already bound, but we want to skip it anyway. |
1561 | - if getattr(method, "__objclass__", None) is not None: |
1562 | - parameters = list(self._signature.parameters.values()) |
1563 | - # This is positional-only for unbound methods that |
1564 | - # are implemented in C. |
1565 | - if (parameters[0].kind == |
1566 | - inspect.Parameter.POSITIONAL_ONLY): |
1567 | - self._signature = self._signature.replace( |
1568 | - parameters=parameters[1:]) |
1569 | - else: |
1570 | - (self._args, self._varargs, self._varkwargs, |
1571 | - self._defaults) = inspect.getargspec(method) |
1572 | + # On Python 3, inspect.getargspec includes the bound first |
1573 | + # argument (self or similar) for bound methods, which |
1574 | + # confuses matters. The modern signature API doesn't have |
1575 | + # this problem. |
1576 | + self._signature = inspect.signature(method) |
1577 | + # Method descriptors don't have the first argument already |
1578 | + # bound, but we want to skip it anyway. |
1579 | + if getattr(method, "__objclass__", None) is not None: |
1580 | + parameters = list(self._signature.parameters.values()) |
1581 | + # This is positional-only for unbound methods that are |
1582 | + # implemented in C. |
1583 | + if (parameters[0].kind == |
1584 | + inspect.Parameter.POSITIONAL_ONLY): |
1585 | + self._signature = self._signature.replace( |
1586 | + parameters=parameters[1:]) |
1587 | except TypeError: |
1588 | self._unsupported = True |
1589 | - else: |
1590 | - if not six.PY3: |
1591 | - if self._defaults is None: |
1592 | - self._defaults = () |
1593 | - if type(method) is type(self.run): |
1594 | - self._args = self._args[1:] |
1595 | |
1596 | def get_method(self): |
1597 | return self._method |
1598 | |
1599 | def _raise(self, message): |
1600 | - if six.PY3: |
1601 | - spec = str(self._signature) |
1602 | - else: |
1603 | - spec = inspect.formatargspec(self._args, self._varargs, |
1604 | - self._varkwargs, self._defaults) |
1605 | raise AssertionError("Specification is %s%s: %s" % |
1606 | - (self._method.__name__, spec, message)) |
1607 | + (self._method.__name__, self._signature, message)) |
1608 | |
1609 | def verify(self): |
1610 | if not self._method: |
1611 | @@ -1891,26 +1869,10 @@ |
1612 | if self._unsupported: |
1613 | return # Can't check it. Happens with builtin functions. :-( |
1614 | action = path.actions[-1] |
1615 | - if six.PY3: |
1616 | - try: |
1617 | - self._signature.bind(*action.args, **action.kwargs) |
1618 | - except TypeError as e: |
1619 | - self._raise(str(e)) |
1620 | - else: |
1621 | - obtained_len = len(action.args) |
1622 | - obtained_kwargs = action.kwargs.copy() |
1623 | - nodefaults_len = len(self._args) - len(self._defaults) |
1624 | - for i, name in enumerate(self._args): |
1625 | - if i < obtained_len and name in action.kwargs: |
1626 | - self._raise("%r provided twice" % name) |
1627 | - if (i >= obtained_len and i < nodefaults_len and |
1628 | - name not in action.kwargs): |
1629 | - self._raise("%r not provided" % name) |
1630 | - obtained_kwargs.pop(name, None) |
1631 | - if obtained_len > len(self._args) and not self._varargs: |
1632 | - self._raise("too many args provided") |
1633 | - if obtained_kwargs and not self._varkwargs: |
1634 | - self._raise("unknown kwargs: %s" % ", ".join(obtained_kwargs)) |
1635 | + try: |
1636 | + self._signature.bind(*action.args, **action.kwargs) |
1637 | + except TypeError as e: |
1638 | + self._raise(str(e)) |
1639 | |
1640 | def spec_checker_recorder(mocker, event): |
1641 | spec = event.path.root_mock.__mocker_spec__ |
1642 | @@ -1951,7 +1913,7 @@ |
1643 | for referrer in gc.get_referrers(remove): |
1644 | if (type(referrer) is dict and |
1645 | referrer.get("__mocker_replace__", True)): |
1646 | - for key, value in list(six.iteritems(referrer)): |
1647 | + for key, value in list(referrer.items()): |
1648 | if value is remove: |
1649 | referrer[key] = install |
1650 | |
1651 | @@ -2023,7 +1985,7 @@ |
1652 | for kind in self._monitored: |
1653 | attr = self._get_kind_attr(kind) |
1654 | seen = set() |
1655 | - for obj in six.itervalues(self._monitored[kind]): |
1656 | + for obj in self._monitored[kind].values(): |
1657 | cls = type(obj) |
1658 | if issubclass(cls, type): |
1659 | cls = obj |
1660 | @@ -2037,7 +1999,7 @@ |
1661 | self.execute) |
1662 | |
1663 | def restore(self): |
1664 | - for obj, attr, original in six.itervalues(self._patched): |
1665 | + for obj, attr, original in self._patched.values(): |
1666 | if original is Undefined: |
1667 | delattr(obj, attr) |
1668 | else: |
1669 | |
1670 | === modified file 'storm/tests/properties.py' |
1671 | --- storm/tests/properties.py 2022-03-16 16:59:21 +0000 |
1672 | +++ storm/tests/properties.py 2024-03-04 10:59:33 +0000 |
1673 | @@ -18,16 +18,12 @@ |
1674 | # You should have received a copy of the GNU Lesser General Public License |
1675 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1676 | # |
1677 | -from __future__ import print_function |
1678 | - |
1679 | from datetime import datetime, date, time, timedelta |
1680 | from decimal import Decimal as decimal |
1681 | import gc |
1682 | +import json |
1683 | import uuid |
1684 | |
1685 | -import six |
1686 | - |
1687 | -from storm.compat import json |
1688 | from storm.exceptions import NoneError, PropertyPathError |
1689 | from storm.properties import PropertyPublisherMeta |
1690 | from storm.properties import * |
1691 | @@ -996,7 +992,7 @@ |
1692 | def setUp(self): |
1693 | TestHelper.setUp(self) |
1694 | |
1695 | - class Base(six.with_metaclass(PropertyPublisherMeta, object)): |
1696 | + class Base(metaclass=PropertyPublisherMeta): |
1697 | pass |
1698 | |
1699 | class Class(Base): |
1700 | |
1701 | === modified file 'storm/tests/schema/patch.py' |
1702 | --- storm/tests/schema/patch.py 2019-11-21 16:06:52 +0000 |
1703 | +++ storm/tests/schema/patch.py 2024-03-04 10:59:33 +0000 |
1704 | @@ -18,8 +18,6 @@ |
1705 | # You should have received a copy of the GNU Lesser General Public License |
1706 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1707 | # |
1708 | -from __future__ import print_function |
1709 | - |
1710 | import os |
1711 | import shutil |
1712 | import sys |
1713 | |
1714 | === modified file 'storm/tests/schema/schema.py' |
1715 | --- storm/tests/schema/schema.py 2019-11-21 16:06:52 +0000 |
1716 | +++ storm/tests/schema/schema.py 2024-03-04 10:59:33 +0000 |
1717 | @@ -18,8 +18,6 @@ |
1718 | # You should have received a copy of the GNU Lesser General Public License |
1719 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1720 | # |
1721 | -from __future__ import print_function |
1722 | - |
1723 | import os |
1724 | import sys |
1725 | |
1726 | |
1727 | === modified file 'storm/tests/schema/sharding.py' |
1728 | --- storm/tests/schema/sharding.py 2019-08-11 17:51:37 +0000 |
1729 | +++ storm/tests/schema/sharding.py 2024-03-04 10:59:33 +0000 |
1730 | @@ -18,8 +18,6 @@ |
1731 | # You should have received a copy of the GNU Lesser General Public License |
1732 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1733 | # |
1734 | -from __future__ import print_function |
1735 | - |
1736 | from storm.schema.schema import SchemaMissingError, UnappliedPatchesError |
1737 | from storm.schema.sharding import Sharding, PatchLevelMismatchError |
1738 | from storm.tests.mocker import MockerTestCase |
1739 | |
1740 | === modified file 'storm/tests/sqlobject.py' |
1741 | --- storm/tests/sqlobject.py 2019-11-21 16:06:52 +0000 |
1742 | +++ storm/tests/sqlobject.py 2024-03-04 10:59:33 +0000 |
1743 | @@ -18,13 +18,9 @@ |
1744 | # You should have received a copy of the GNU Lesser General Public License |
1745 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1746 | # |
1747 | -from __future__ import print_function |
1748 | - |
1749 | import datetime |
1750 | import operator |
1751 | |
1752 | -import six |
1753 | - |
1754 | from storm.database import create_database |
1755 | from storm.exceptions import NoneError |
1756 | from storm.sqlobject import * |
1757 | @@ -124,7 +120,7 @@ |
1758 | _defaultOrder = "-Person.name" |
1759 | _table = "person" |
1760 | _idName = "name" |
1761 | - _idType = six.text_type |
1762 | + _idType = str |
1763 | age = IntCol() |
1764 | ts = UtcDateTimeCol() |
1765 | |
1766 | @@ -822,12 +818,8 @@ |
1767 | """ |
1768 | result = self.Person.select() |
1769 | self.assertEqual(result.__bool__(), True) |
1770 | - if six.PY2: |
1771 | - self.assertEqual(result.__nonzero__(), True) |
1772 | result = self.Person.select(self.Person.q.name == "No Person") |
1773 | self.assertEqual(result.__bool__(), False) |
1774 | - if six.PY2: |
1775 | - self.assertEqual(result.__nonzero__(), False) |
1776 | |
1777 | def test_result_set_is_empty(self): |
1778 | """ |
1779 | @@ -1190,7 +1182,7 @@ |
1780 | # properties: |
1781 | class Person(self.SQLObject): |
1782 | _idName = "name" |
1783 | - _idType = six.text_type |
1784 | + _idType = str |
1785 | address = ForeignKey(foreignKey="Phone", dbName="address_id", |
1786 | notNull=True) |
1787 | |
1788 | |
1789 | === modified file 'storm/tests/store/base.py' |
1790 | --- storm/tests/store/base.py 2021-05-13 23:02:23 +0000 |
1791 | +++ storm/tests/store/base.py 2024-03-04 10:59:33 +0000 |
1792 | @@ -20,17 +20,14 @@ |
1793 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1794 | # |
1795 | |
1796 | -from __future__ import print_function |
1797 | - |
1798 | import decimal |
1799 | import gc |
1800 | +from io import StringIO |
1801 | import operator |
1802 | +import pickle |
1803 | from uuid import uuid4 |
1804 | import weakref |
1805 | |
1806 | -import six |
1807 | -from six.moves import cPickle as pickle, cStringIO as StringIO |
1808 | - |
1809 | from storm.references import Reference, ReferenceSet, Proxy |
1810 | from storm.database import Result, STATE_DISCONNECTED |
1811 | from storm.properties import ( |
1812 | @@ -1053,7 +1050,7 @@ |
1813 | def test_find_max_unicode(self): |
1814 | title = self.store.find(Foo).max(Foo.title) |
1815 | self.assertEqual(title, "Title 30") |
1816 | - self.assertTrue(isinstance(title, six.text_type)) |
1817 | + self.assertTrue(isinstance(title, str)) |
1818 | |
1819 | def test_find_max_with_empty_result_and_disallow_none(self): |
1820 | class Bar(object): |
1821 | @@ -1074,7 +1071,7 @@ |
1822 | def test_find_min_unicode(self): |
1823 | title = self.store.find(Foo).min(Foo.title) |
1824 | self.assertEqual(title, "Title 10") |
1825 | - self.assertTrue(isinstance(title, six.text_type)) |
1826 | + self.assertTrue(isinstance(title, str)) |
1827 | |
1828 | def test_find_min_with_empty_result_and_disallow_none(self): |
1829 | class Bar(object): |
1830 | @@ -1157,8 +1154,7 @@ |
1831 | values = self.store.find(Foo).order_by(Foo.id).values(Foo.title) |
1832 | values = list(values) |
1833 | self.assertEqual(values, ["Title 30", "Title 20", "Title 10"]) |
1834 | - self.assertEqual([type(value) for value in values], |
1835 | - [six.text_type, six.text_type, six.text_type]) |
1836 | + self.assertEqual([type(value) for value in values], [str, str, str]) |
1837 | |
1838 | def test_find_multiple_values(self): |
1839 | result = self.store.find(Foo).order_by(Foo.id) |
1840 | @@ -4532,7 +4528,7 @@ |
1841 | self.assertRaises(NoStoreError, foo2.bars.remove, object()) |
1842 | |
1843 | def test_string_reference(self): |
1844 | - class Base(six.with_metaclass(PropertyPublisherMeta, object)): |
1845 | + class Base(metaclass=PropertyPublisherMeta): |
1846 | pass |
1847 | |
1848 | class MyBar(Base): |
1849 | @@ -4559,7 +4555,7 @@ |
1850 | metaclass. This makes it possible to work around problems with |
1851 | circular dependencies by delaying property resolution. |
1852 | """ |
1853 | - class Base(six.with_metaclass(PropertyPublisherMeta, object)): |
1854 | + class Base(metaclass=PropertyPublisherMeta): |
1855 | pass |
1856 | |
1857 | class MyFoo(Base): |
1858 | @@ -4599,7 +4595,7 @@ |
1859 | metaclass. This makes it possible to work around problems with |
1860 | circular dependencies by delaying resolution of the order by column. |
1861 | """ |
1862 | - class Base(six.with_metaclass(PropertyPublisherMeta, object)): |
1863 | + class Base(metaclass=PropertyPublisherMeta): |
1864 | pass |
1865 | |
1866 | class MyFoo(Base): |
1867 | @@ -5024,7 +5020,7 @@ |
1868 | foo = self.store.get(DictFoo, 20) |
1869 | foo["a"] = 1 |
1870 | |
1871 | - self.assertEqual(list(six.iteritems(foo)), [("a", 1)]) |
1872 | + self.assertEqual(list(foo.items()), [("a", 1)]) |
1873 | |
1874 | new_obj = DictFoo() |
1875 | new_obj.id = 40 |
1876 | @@ -5358,7 +5354,7 @@ |
1877 | self.store.add(foo) |
1878 | foo.id = AutoReload |
1879 | foo.title = u"New Title" |
1880 | - self.assertTrue(isinstance(foo.id, six.integer_types)) |
1881 | + self.assertTrue(isinstance(foo.id, int)) |
1882 | self.assertEqual(foo.title, "New Title") |
1883 | |
1884 | def test_autoreload_primary_key_doesnt_reload_everything_else(self): |
1885 | @@ -5868,7 +5864,7 @@ |
1886 | self.assertEqual(foo.title, "New Title") |
1887 | |
1888 | def get_bar_proxy_with_string(self): |
1889 | - class Base(six.with_metaclass(PropertyPublisherMeta, object)): |
1890 | + class Base(metaclass=PropertyPublisherMeta): |
1891 | pass |
1892 | |
1893 | class MyBarProxy(Base): |
1894 | @@ -6037,7 +6033,7 @@ |
1895 | try: |
1896 | self.assertEqual(myfoo.title, title) |
1897 | except AssertionError as e: |
1898 | - raise AssertionError(six.text_type(e, 'replace') + |
1899 | + raise AssertionError(str(e, 'replace') + |
1900 | " (ensure your database was created with CREATE DATABASE" |
1901 | " ... CHARACTER SET utf8mb3)") |
1902 | |
1903 | |
1904 | === modified file 'storm/tests/store/mysql.py' |
1905 | --- storm/tests/store/mysql.py 2021-04-06 09:23:02 +0000 |
1906 | +++ storm/tests/store/mysql.py 2024-03-04 10:59:33 +0000 |
1907 | @@ -18,8 +18,6 @@ |
1908 | # You should have received a copy of the GNU Lesser General Public License |
1909 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1910 | # |
1911 | -from __future__ import print_function |
1912 | - |
1913 | import os |
1914 | |
1915 | from storm.database import create_database |
1916 | |
1917 | === modified file 'storm/tests/store/postgres.py' |
1918 | --- storm/tests/store/postgres.py 2019-11-21 16:06:52 +0000 |
1919 | +++ storm/tests/store/postgres.py 2024-03-04 10:59:33 +0000 |
1920 | @@ -18,8 +18,6 @@ |
1921 | # You should have received a copy of the GNU Lesser General Public License |
1922 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1923 | # |
1924 | -from __future__ import print_function |
1925 | - |
1926 | import os |
1927 | import gc |
1928 | |
1929 | |
1930 | === modified file 'storm/tests/store/sqlite.py' |
1931 | --- storm/tests/store/sqlite.py 2019-08-11 17:51:37 +0000 |
1932 | +++ storm/tests/store/sqlite.py 2024-03-04 10:59:33 +0000 |
1933 | @@ -18,8 +18,6 @@ |
1934 | # You should have received a copy of the GNU Lesser General Public License |
1935 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1936 | # |
1937 | -from __future__ import print_function |
1938 | - |
1939 | from storm.databases.sqlite import SQLite |
1940 | from storm.uri import URI |
1941 | from storm.tests.store.base import StoreTest, EmptyResultSetTest |
1942 | |
1943 | === modified file 'storm/tests/tracer.py' |
1944 | --- storm/tests/tracer.py 2019-11-21 16:06:52 +0000 |
1945 | +++ storm/tests/tracer.py 2024-03-04 10:59:33 +0000 |
1946 | @@ -1,5 +1,3 @@ |
1947 | -from __future__ import print_function |
1948 | - |
1949 | import datetime |
1950 | import os |
1951 | import sys |
1952 | |
1953 | === modified file 'storm/tests/twisted/__init__.py' |
1954 | --- storm/tests/twisted/__init__.py 2019-06-05 11:41:07 +0000 |
1955 | +++ storm/tests/twisted/__init__.py 2024-03-04 10:59:33 +0000 |
1956 | @@ -1,5 +1,3 @@ |
1957 | -from __future__ import print_function |
1958 | - |
1959 | __all__ = [ |
1960 | 'has_twisted', |
1961 | ] |
1962 | |
1963 | === modified file 'storm/tests/twisted/transact.py' |
1964 | --- storm/tests/twisted/transact.py 2019-08-11 17:51:37 +0000 |
1965 | +++ storm/tests/twisted/transact.py 2024-03-04 10:59:33 +0000 |
1966 | @@ -1,5 +1,3 @@ |
1967 | -from __future__ import print_function |
1968 | - |
1969 | from storm.tests import has_psycopg |
1970 | from storm.tests.helper import TestHelper |
1971 | from storm.tests.zope import has_transaction, has_zope_component |
1972 | |
1973 | === modified file 'storm/tests/uri.py' |
1974 | --- storm/tests/uri.py 2019-11-21 16:06:52 +0000 |
1975 | +++ storm/tests/uri.py 2024-03-04 10:59:33 +0000 |
1976 | @@ -18,8 +18,6 @@ |
1977 | # You should have received a copy of the GNU Lesser General Public License |
1978 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1979 | # |
1980 | -from __future__ import print_function |
1981 | - |
1982 | from storm.uri import URI, URIError |
1983 | from storm.tests.helper import TestHelper |
1984 | |
1985 | |
1986 | === modified file 'storm/tests/variables.py' |
1987 | --- storm/tests/variables.py 2022-03-16 16:59:21 +0000 |
1988 | +++ storm/tests/variables.py 2024-03-04 10:59:33 +0000 |
1989 | @@ -18,18 +18,14 @@ |
1990 | # You should have received a copy of the GNU Lesser General Public License |
1991 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1992 | # |
1993 | -from __future__ import print_function |
1994 | - |
1995 | from datetime import datetime, date, time, timedelta |
1996 | from decimal import Decimal |
1997 | import gc |
1998 | +import json |
1999 | +import pickle |
2000 | import weakref |
2001 | import uuid |
2002 | |
2003 | -import six |
2004 | -from six.moves import cPickle as pickle |
2005 | - |
2006 | -from storm.compat import json |
2007 | from storm.exceptions import NoneError |
2008 | from storm.variables import * |
2009 | from storm.event import EventSystem |
2010 | @@ -463,8 +459,7 @@ |
2011 | variable = BytesVariable() |
2012 | variable.set(b"str") |
2013 | self.assertEqual(variable.get(), b"str") |
2014 | - buffer_type = memoryview if six.PY3 else buffer |
2015 | - variable.set(buffer_type(b"buffer")) |
2016 | + variable.set(memoryview(b"buffer")) |
2017 | self.assertEqual(variable.get(), b"buffer") |
2018 | self.assertRaises(TypeError, variable.set, u"unicode") |
2019 | |
2020 | @@ -487,18 +482,13 @@ |
2021 | self.assertEqual(variable.get(), epoch) |
2022 | variable.set(0.0) |
2023 | self.assertEqual(variable.get(), epoch) |
2024 | - if six.PY2: |
2025 | - # 1L was more idiomatic in Python 2, but is a syntax error in |
2026 | - # Python 3. |
2027 | - variable.set(long(0)) |
2028 | - self.assertEqual(variable.get(), epoch) |
2029 | variable.set(epoch) |
2030 | self.assertEqual(variable.get(), epoch) |
2031 | self.assertRaises(TypeError, variable.set, marker) |
2032 | |
2033 | def test_get_set_from_database(self): |
2034 | datetime_str = "1977-05-04 12:34:56.78" |
2035 | - datetime_uni = six.text_type(datetime_str) |
2036 | + datetime_uni = str(datetime_str) |
2037 | datetime_obj = datetime(1977, 5, 4, 12, 34, 56, 780000) |
2038 | |
2039 | variable = DateTimeVariable() |
2040 | @@ -511,7 +501,7 @@ |
2041 | self.assertEqual(variable.get(), datetime_obj) |
2042 | |
2043 | datetime_str = "1977-05-04 12:34:56" |
2044 | - datetime_uni = six.text_type(datetime_str) |
2045 | + datetime_uni = str(datetime_str) |
2046 | datetime_obj = datetime(1977, 5, 4, 12, 34, 56) |
2047 | |
2048 | variable.set(datetime_str, from_db=True) |
2049 | @@ -576,7 +566,7 @@ |
2050 | |
2051 | def test_get_set_from_database(self): |
2052 | date_str = "1977-05-04" |
2053 | - date_uni = six.text_type(date_str) |
2054 | + date_uni = str(date_str) |
2055 | date_obj = date(1977, 5, 4) |
2056 | datetime_obj = datetime(1977, 5, 4, 0, 0, 0) |
2057 | |
2058 | @@ -620,7 +610,7 @@ |
2059 | |
2060 | def test_get_set_from_database(self): |
2061 | time_str = "12:34:56.78" |
2062 | - time_uni = six.text_type(time_str) |
2063 | + time_uni = str(time_str) |
2064 | time_obj = time(12, 34, 56, 780000) |
2065 | |
2066 | variable = TimeVariable() |
2067 | @@ -633,7 +623,7 @@ |
2068 | self.assertEqual(variable.get(), time_obj) |
2069 | |
2070 | time_str = "12:34:56" |
2071 | - time_uni = six.text_type(time_str) |
2072 | + time_uni = str(time_str) |
2073 | time_obj = time(12, 34, 56) |
2074 | |
2075 | variable.set(time_str, from_db=True) |
2076 | @@ -690,7 +680,7 @@ |
2077 | |
2078 | def test_get_set_from_database(self): |
2079 | delta_str = "42 days 12:34:56.78" |
2080 | - delta_uni = six.text_type(delta_str) |
2081 | + delta_uni = str(delta_str) |
2082 | delta_obj = timedelta(days=42, hours=12, minutes=34, |
2083 | seconds=56, microseconds=780000) |
2084 | |
2085 | @@ -704,7 +694,7 @@ |
2086 | self.assertEqual(variable.get(), delta_obj) |
2087 | |
2088 | delta_str = "1 day, 12:34:56" |
2089 | - delta_uni = six.text_type(delta_str) |
2090 | + delta_uni = str(delta_str) |
2091 | delta_obj = timedelta(days=1, hours=12, minutes=34, seconds=56) |
2092 | |
2093 | variable.set(delta_str, from_db=True) |
2094 | @@ -919,10 +909,7 @@ |
2095 | |
2096 | class JSONVariableTest(EncodedValueVariableTestMixin, TestHelper): |
2097 | |
2098 | - if six.PY3: |
2099 | - encode = staticmethod(lambda data: json.dumps(data)) |
2100 | - else: |
2101 | - encode = staticmethod(lambda data: json.dumps(data).decode("utf-8")) |
2102 | + encode = staticmethod(lambda data: json.dumps(data)) |
2103 | variable_type = JSONVariable |
2104 | |
2105 | def is_supported(self): |
2106 | @@ -939,7 +926,7 @@ |
2107 | # json. |
2108 | variable = self.variable_type() |
2109 | variable.set({u"a": 1}) |
2110 | - self.assertTrue(isinstance(variable.get(to_db=True), six.text_type)) |
2111 | + self.assertTrue(isinstance(variable.get(to_db=True), str)) |
2112 | |
2113 | |
2114 | class ListVariableTest(TestHelper): |
2115 | |
2116 | === modified file 'storm/tests/wsgi.py' |
2117 | --- storm/tests/wsgi.py 2019-06-07 17:14:33 +0000 |
2118 | +++ storm/tests/wsgi.py 2024-03-04 10:59:33 +0000 |
2119 | @@ -1,11 +1,8 @@ |
2120 | -from __future__ import print_function |
2121 | - |
2122 | +import queue |
2123 | from unittest import TestCase |
2124 | import threading |
2125 | import time |
2126 | |
2127 | -from six.moves import queue |
2128 | - |
2129 | from storm.wsgi import make_app |
2130 | |
2131 | class TestMakeApp(TestCase): |
2132 | |
2133 | === modified file 'storm/tests/zope/__init__.py' |
2134 | --- storm/tests/zope/__init__.py 2019-06-05 11:41:07 +0000 |
2135 | +++ storm/tests/zope/__init__.py 2024-03-04 10:59:33 +0000 |
2136 | @@ -18,8 +18,6 @@ |
2137 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
2138 | # |
2139 | |
2140 | -from __future__ import print_function |
2141 | - |
2142 | __all__ = [ |
2143 | 'has_transaction', |
2144 | 'has_zope_component', |
2145 | |
2146 | === modified file 'storm/tests/zope/adapters.py' |
2147 | --- storm/tests/zope/adapters.py 2019-08-11 17:51:37 +0000 |
2148 | +++ storm/tests/zope/adapters.py 2024-03-04 10:59:33 +0000 |
2149 | @@ -18,8 +18,6 @@ |
2150 | # You should have received a copy of the GNU Lesser General Public License |
2151 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
2152 | # |
2153 | -from __future__ import print_function |
2154 | - |
2155 | from storm.tests.helper import TestHelper |
2156 | from storm.tests.zope import has_zope_component |
2157 | |
2158 | |
2159 | === modified file 'storm/tests/zope/testing.py' |
2160 | --- storm/tests/zope/testing.py 2019-08-12 17:07:08 +0000 |
2161 | +++ storm/tests/zope/testing.py 2024-03-04 10:59:33 +0000 |
2162 | @@ -18,13 +18,9 @@ |
2163 | # You should have received a copy of the GNU Lesser General Public License |
2164 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
2165 | # |
2166 | -from __future__ import print_function |
2167 | - |
2168 | import os |
2169 | import sys |
2170 | |
2171 | -import six |
2172 | - |
2173 | from storm.tests.helper import TestHelper |
2174 | from storm.tests.zope import ( |
2175 | has_testresources, |
2176 | @@ -245,7 +241,7 @@ |
2177 | real_invalidate = store.invalidate |
2178 | |
2179 | def invalidate_proxy(): |
2180 | - self.assertEqual(0, len(list(six.itervalues(store._alive)))) |
2181 | + self.assertEqual(0, len(list(store._alive.values()))) |
2182 | real_invalidate() |
2183 | store.invalidate = invalidate_proxy |
2184 | |
2185 | |
2186 | === modified file 'storm/tests/zope/zstorm.py' |
2187 | --- storm/tests/zope/zstorm.py 2019-11-21 16:06:52 +0000 |
2188 | +++ storm/tests/zope/zstorm.py 2024-03-04 10:59:33 +0000 |
2189 | @@ -18,8 +18,6 @@ |
2190 | # You should have received a copy of the GNU Lesser General Public License |
2191 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
2192 | # |
2193 | -from __future__ import print_function |
2194 | - |
2195 | import threading |
2196 | import weakref |
2197 | import gc |
2198 | |
2199 | === modified file 'storm/tracer.py' |
2200 | --- storm/tracer.py 2020-05-26 10:37:54 +0000 |
2201 | +++ storm/tracer.py 2024-03-04 10:59:33 +0000 |
2202 | @@ -1,12 +1,8 @@ |
2203 | -from __future__ import print_function |
2204 | - |
2205 | from datetime import datetime |
2206 | import re |
2207 | import sys |
2208 | import threading |
2209 | |
2210 | -import six |
2211 | - |
2212 | # Circular import: imported at the end of the module. |
2213 | # from storm.database import convert_param_marks |
2214 | from storm.exceptions import TimeoutError |
2215 | @@ -173,11 +169,8 @@ |
2216 | # string parameters which represent encoded binary data. |
2217 | render_params = [] |
2218 | for param in query_params: |
2219 | - if isinstance(param, six.text_type): |
2220 | - if six.PY3: |
2221 | - render_params.append(ascii(param)) |
2222 | - else: |
2223 | - render_params.append(repr(param.encode('utf8'))) |
2224 | + if isinstance(param, str): |
2225 | + render_params.append(ascii(param)) |
2226 | else: |
2227 | render_params.append(repr(param)) |
2228 | try: |
2229 | |
2230 | === modified file 'storm/twisted/testing.py' |
2231 | --- storm/twisted/testing.py 2020-03-18 16:02:04 +0000 |
2232 | +++ storm/twisted/testing.py 2024-03-04 10:59:33 +0000 |
2233 | @@ -1,5 +1,3 @@ |
2234 | -from __future__ import print_function |
2235 | - |
2236 | from twisted.python.failure import Failure |
2237 | from twisted.internet.defer import execute |
2238 | |
2239 | |
2240 | === modified file 'storm/twisted/transact.py' |
2241 | --- storm/twisted/transact.py 2020-03-18 16:02:04 +0000 |
2242 | +++ storm/twisted/transact.py 2024-03-04 10:59:33 +0000 |
2243 | @@ -1,5 +1,3 @@ |
2244 | -from __future__ import print_function |
2245 | - |
2246 | import time |
2247 | import random |
2248 | import transaction as zope_transaction |
2249 | |
2250 | === modified file 'storm/tz.py' |
2251 | --- storm/tz.py 2020-05-26 10:37:54 +0000 |
2252 | +++ storm/tz.py 2024-03-04 10:59:33 +0000 |
2253 | @@ -4,8 +4,6 @@ |
2254 | This module offers extensions to the standard python 2.3+ |
2255 | datetime module. |
2256 | """ |
2257 | -from __future__ import print_function |
2258 | - |
2259 | __author__ = "Gustavo Niemeyer <gustavo@niemeyer.net>" |
2260 | __license__ = "PSF License" |
2261 | |
2262 | @@ -15,8 +13,6 @@ |
2263 | import sys |
2264 | import os |
2265 | |
2266 | -import six |
2267 | - |
2268 | relativedelta = None |
2269 | parser = None |
2270 | rrule = None |
2271 | @@ -198,7 +194,7 @@ |
2272 | # ftp://elsie.nci.nih.gov/pub/tz*.tar.gz |
2273 | |
2274 | def __init__(self, fileobj): |
2275 | - if isinstance(fileobj, six.string_types): |
2276 | + if isinstance(fileobj, str): |
2277 | self._filename = fileobj |
2278 | fileobj = open(fileobj) |
2279 | elif hasattr(fileobj, "name"): |
2280 | @@ -699,7 +695,7 @@ |
2281 | if not rrule: |
2282 | from dateutil import rrule |
2283 | |
2284 | - if isinstance(fileobj, six.string_types): |
2285 | + if isinstance(fileobj, str): |
2286 | self._s = fileobj |
2287 | fileobj = open(fileobj) |
2288 | elif hasattr(fileobj, "name"): |
2289 | @@ -716,7 +712,7 @@ |
2290 | |
2291 | def get(self, tzid=None): |
2292 | if tzid is None: |
2293 | - keys = list(six.iterkeys(self._vtz)) |
2294 | + keys = list(self._vtz) |
2295 | if len(keys) == 0: |
2296 | raise Exception("no timezones defined") |
2297 | elif len(keys) > 1: |
2298 | |
2299 | === modified file 'storm/uri.py' |
2300 | --- storm/uri.py 2020-05-29 23:02:39 +0000 |
2301 | +++ storm/uri.py 2024-03-04 10:59:33 +0000 |
2302 | @@ -18,10 +18,7 @@ |
2303 | # You should have received a copy of the GNU Lesser General Public License |
2304 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
2305 | # |
2306 | -from __future__ import print_function |
2307 | - |
2308 | -import six |
2309 | -from six.moves.urllib.parse import quote |
2310 | +from urllib.parse import quote |
2311 | |
2312 | from storm.exceptions import URIError |
2313 | |
2314 | @@ -117,7 +114,7 @@ |
2315 | append(escape(self.database, "/")) |
2316 | if self.options: |
2317 | options = ["%s=%s" % (escape(key), escape(value)) |
2318 | - for key, value in sorted(six.iteritems(self.options))] |
2319 | + for key, value in sorted(self.options.items())] |
2320 | append("?") |
2321 | append("&".join(options)) |
2322 | return "".join(tokens) |
2323 | |
2324 | === modified file 'storm/variables.py' |
2325 | --- storm/variables.py 2022-03-16 16:59:21 +0000 |
2326 | +++ storm/variables.py 2024-03-04 10:59:33 +0000 |
2327 | @@ -18,19 +18,15 @@ |
2328 | # You should have received a copy of the GNU Lesser General Public License |
2329 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
2330 | # |
2331 | -from __future__ import print_function |
2332 | - |
2333 | from datetime import datetime, date, time, timedelta |
2334 | from decimal import Decimal |
2335 | from functools import partial |
2336 | +import json |
2337 | +import pickle |
2338 | import re |
2339 | import uuid |
2340 | import weakref |
2341 | |
2342 | -import six |
2343 | -from six.moves import cPickle as pickle |
2344 | - |
2345 | -from storm.compat import json |
2346 | from storm.exceptions import NoneError |
2347 | from storm import Undef, has_cextensions |
2348 | |
2349 | @@ -58,12 +54,6 @@ |
2350 | ] |
2351 | |
2352 | |
2353 | -if six.PY3: |
2354 | - _buffer_type = memoryview |
2355 | -else: |
2356 | - _buffer_type = buffer |
2357 | - |
2358 | - |
2359 | class LazyValue(object): |
2360 | """Marker to be used as a base class on lazily evaluated values.""" |
2361 | __slots__ = () |
2362 | @@ -328,7 +318,7 @@ |
2363 | __slots__ = () |
2364 | |
2365 | def parse_set(self, value, from_db): |
2366 | - if not isinstance(value, (six.integer_types, float, Decimal)): |
2367 | + if not isinstance(value, (int, float, Decimal)): |
2368 | raise TypeError("Expected bool, found %r: %r" |
2369 | % (type(value), value)) |
2370 | return bool(value) |
2371 | @@ -338,7 +328,7 @@ |
2372 | __slots__ = () |
2373 | |
2374 | def parse_set(self, value, from_db): |
2375 | - if not isinstance(value, (six.integer_types, float, Decimal)): |
2376 | + if not isinstance(value, (int, float, Decimal)): |
2377 | raise TypeError("Expected int, found %r: %r" |
2378 | % (type(value), value)) |
2379 | return int(value) |
2380 | @@ -348,7 +338,7 @@ |
2381 | __slots__ = () |
2382 | |
2383 | def parse_set(self, value, from_db): |
2384 | - if not isinstance(value, (six.integer_types, float, Decimal)): |
2385 | + if not isinstance(value, (int, float, Decimal)): |
2386 | raise TypeError("Expected float, found %r: %r" |
2387 | % (type(value), value)) |
2388 | return float(value) |
2389 | @@ -359,8 +349,7 @@ |
2390 | |
2391 | @staticmethod |
2392 | def parse_set(value, from_db): |
2393 | - if (from_db and isinstance(value, six.string_types) or |
2394 | - isinstance(value, six.integer_types)): |
2395 | + if (from_db and isinstance(value, str)) or isinstance(value, int): |
2396 | value = Decimal(value) |
2397 | elif not isinstance(value, Decimal): |
2398 | raise TypeError("Expected Decimal, found %r: %r" |
2399 | @@ -370,7 +359,7 @@ |
2400 | @staticmethod |
2401 | def parse_get(value, to_db): |
2402 | if to_db: |
2403 | - return six.text_type(value) |
2404 | + return str(value) |
2405 | return value |
2406 | |
2407 | |
2408 | @@ -378,7 +367,7 @@ |
2409 | __slots__ = () |
2410 | |
2411 | def parse_set(self, value, from_db): |
2412 | - if isinstance(value, _buffer_type): |
2413 | + if isinstance(value, memoryview): |
2414 | value = bytes(value) |
2415 | elif not isinstance(value, bytes): |
2416 | raise TypeError("Expected bytes, found %r: %r" |
2417 | @@ -394,7 +383,7 @@ |
2418 | __slots__ = () |
2419 | |
2420 | def parse_set(self, value, from_db): |
2421 | - if not isinstance(value, six.text_type): |
2422 | + if not isinstance(value, str): |
2423 | raise TypeError("Expected text, found %r: %r" |
2424 | % (type(value), value)) |
2425 | return value |
2426 | @@ -411,7 +400,7 @@ |
2427 | if from_db: |
2428 | if isinstance(value, datetime): |
2429 | pass |
2430 | - elif isinstance(value, six.string_types): |
2431 | + elif isinstance(value, str): |
2432 | if " " not in value: |
2433 | raise ValueError("Unknown date/time format: %r" % value) |
2434 | date_str, time_str = value.split(" ") |
2435 | @@ -425,7 +414,7 @@ |
2436 | else: |
2437 | value = value.astimezone(self._tzinfo) |
2438 | else: |
2439 | - if type(value) in six.integer_types + (float, ): |
2440 | + if type(value) in (int, float): |
2441 | value = datetime.utcfromtimestamp(value) |
2442 | elif not isinstance(value, datetime): |
2443 | raise TypeError("Expected datetime, found %s" % repr(value)) |
2444 | @@ -456,7 +445,7 @@ |
2445 | return value.date() |
2446 | if isinstance(value, date): |
2447 | return value |
2448 | - if not isinstance(value, six.string_types): |
2449 | + if not isinstance(value, str): |
2450 | raise TypeError("Expected date, found %s" % repr(value)) |
2451 | if " " in value: |
2452 | value, time_str = value.split(" ") |
2453 | @@ -479,7 +468,7 @@ |
2454 | return None |
2455 | if isinstance(value, time): |
2456 | return value |
2457 | - if not isinstance(value, six.string_types): |
2458 | + if not isinstance(value, str): |
2459 | raise TypeError("Expected time, found %s" % repr(value)) |
2460 | if " " in value: |
2461 | date_str, value = value.split(" ") |
2462 | @@ -502,7 +491,7 @@ |
2463 | return None |
2464 | if isinstance(value, timedelta): |
2465 | return value |
2466 | - if not isinstance(value, six.string_types): |
2467 | + if not isinstance(value, str): |
2468 | raise TypeError("Expected timedelta, found %s" % repr(value)) |
2469 | return _parse_interval(value) |
2470 | else: |
2471 | @@ -515,7 +504,7 @@ |
2472 | __slots__ = () |
2473 | |
2474 | def parse_set(self, value, from_db): |
2475 | - if from_db and isinstance(value, six.string_types): |
2476 | + if from_db and isinstance(value, str): |
2477 | value = uuid.UUID(value) |
2478 | elif not isinstance(value, uuid.UUID): |
2479 | raise TypeError("Expected UUID, found %r: %r" |
2480 | @@ -524,7 +513,7 @@ |
2481 | |
2482 | def parse_get(self, value, to_db): |
2483 | if to_db: |
2484 | - return six.text_type(value) |
2485 | + return str(value) |
2486 | return value |
2487 | |
2488 | |
2489 | @@ -607,7 +596,7 @@ |
2490 | |
2491 | def parse_set(self, value, from_db): |
2492 | if from_db: |
2493 | - if isinstance(value, _buffer_type): |
2494 | + if isinstance(value, memoryview): |
2495 | value = bytes(value) |
2496 | return self._loads(value) |
2497 | else: |
2498 | @@ -641,7 +630,7 @@ |
2499 | __slots__ = () |
2500 | |
2501 | def _loads(self, value): |
2502 | - if not isinstance(value, six.text_type): |
2503 | + if not isinstance(value, str): |
2504 | raise TypeError( |
2505 | "Cannot safely assume encoding of byte string %r." % value) |
2506 | return json.loads(value) |
2507 | @@ -651,7 +640,7 @@ |
2508 | # and so we treat it as such here. In other words, this method returns |
2509 | # Unicode text and never bytes. |
2510 | dump = json.dumps(value, ensure_ascii=False) |
2511 | - if not isinstance(dump, six.text_type): |
2512 | + if not isinstance(dump, str): |
2513 | # json.dumps() does not always return unicode. See |
2514 | # http://code.google.com/p/simplejson/issues/detail?id=40 for one |
2515 | # of many discussions of str/unicode handling in simplejson. |
2516 | |
2517 | === modified file 'storm/wsgi.py' |
2518 | --- storm/wsgi.py 2020-05-26 10:37:54 +0000 |
2519 | +++ storm/wsgi.py 2024-03-04 10:59:33 +0000 |
2520 | @@ -21,8 +21,6 @@ |
2521 | |
2522 | """Glue to wire a storm timeline tracer up to a WSGI app.""" |
2523 | |
2524 | -from __future__ import print_function |
2525 | - |
2526 | import threading |
2527 | import weakref |
2528 | |
2529 | |
2530 | === modified file 'storm/xid.py' |
2531 | --- storm/xid.py 2019-06-05 11:41:07 +0000 |
2532 | +++ storm/xid.py 2024-03-04 10:59:33 +0000 |
2533 | @@ -19,9 +19,6 @@ |
2534 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
2535 | # |
2536 | |
2537 | -from __future__ import print_function |
2538 | - |
2539 | - |
2540 | class Xid(object): |
2541 | """ |
2542 | Represent a transaction identifier compliant with the XA specification. |
2543 | |
2544 | === modified file 'storm/zope/__init__.py' |
2545 | --- storm/zope/__init__.py 2019-06-05 11:41:07 +0000 |
2546 | +++ storm/zope/__init__.py 2024-03-04 10:59:33 +0000 |
2547 | @@ -18,8 +18,6 @@ |
2548 | # You should have received a copy of the GNU Lesser General Public License |
2549 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
2550 | # |
2551 | -from __future__ import print_function |
2552 | - |
2553 | from zope.interface import classImplements |
2554 | |
2555 | from storm.info import ObjectInfo |
2556 | |
2557 | === modified file 'storm/zope/adapters.py' |
2558 | --- storm/zope/adapters.py 2019-06-05 11:41:07 +0000 |
2559 | +++ storm/zope/adapters.py 2024-03-04 10:59:33 +0000 |
2560 | @@ -19,8 +19,6 @@ |
2561 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
2562 | # |
2563 | |
2564 | -from __future__ import print_function |
2565 | - |
2566 | from zope.component import adapter |
2567 | from zope.interface import implementer |
2568 | |
2569 | |
2570 | === modified file 'storm/zope/interfaces.py' |
2571 | --- storm/zope/interfaces.py 2019-08-11 09:07:34 +0000 |
2572 | +++ storm/zope/interfaces.py 2024-03-04 10:59:33 +0000 |
2573 | @@ -18,9 +18,6 @@ |
2574 | # You should have received a copy of the GNU Lesser General Public License |
2575 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
2576 | # |
2577 | -from __future__ import print_function |
2578 | - |
2579 | -import six |
2580 | from zope.interface import Interface |
2581 | |
2582 | from storm.expr import Undef |
2583 | @@ -174,9 +171,6 @@ |
2584 | which doesn't have a C{__bool__} implementation. |
2585 | """ |
2586 | |
2587 | - if six.PY2: |
2588 | - __nonzero__ = __bool__ |
2589 | - |
2590 | def __contains__(item): |
2591 | """Support C{if FooObject in Foo.select(query)}.""" |
2592 | |
2593 | |
2594 | === modified file 'storm/zope/metaconfigure.py' |
2595 | --- storm/zope/metaconfigure.py 2019-06-05 11:41:07 +0000 |
2596 | +++ storm/zope/metaconfigure.py 2024-03-04 10:59:33 +0000 |
2597 | @@ -18,8 +18,6 @@ |
2598 | # You should have received a copy of the GNU Lesser General Public License |
2599 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
2600 | # |
2601 | -from __future__ import print_function |
2602 | - |
2603 | from zope import component |
2604 | |
2605 | from storm.zope.interfaces import IZStorm |
2606 | |
2607 | === modified file 'storm/zope/metadirectives.py' |
2608 | --- storm/zope/metadirectives.py 2019-06-05 11:41:07 +0000 |
2609 | +++ storm/zope/metadirectives.py 2024-03-04 10:59:33 +0000 |
2610 | @@ -18,8 +18,6 @@ |
2611 | # You should have received a copy of the GNU Lesser General Public License |
2612 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
2613 | # |
2614 | -from __future__ import print_function |
2615 | - |
2616 | from zope.interface import Interface |
2617 | from zope.schema import TextLine |
2618 | |
2619 | |
2620 | === modified file 'storm/zope/schema.py' |
2621 | --- storm/zope/schema.py 2019-06-05 11:41:07 +0000 |
2622 | +++ storm/zope/schema.py 2024-03-04 10:59:33 +0000 |
2623 | @@ -19,8 +19,6 @@ |
2624 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
2625 | # |
2626 | """ZStorm-aware schema manager.""" |
2627 | -from __future__ import print_function |
2628 | - |
2629 | import transaction |
2630 | |
2631 | from storm.schema import Schema |
2632 | |
2633 | === modified file 'storm/zope/testing.py' |
2634 | --- storm/zope/testing.py 2019-08-11 09:48:05 +0000 |
2635 | +++ storm/zope/testing.py 2024-03-04 10:59:33 +0000 |
2636 | @@ -18,12 +18,9 @@ |
2637 | # You should have received a copy of the GNU Lesser General Public License |
2638 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
2639 | # |
2640 | -from __future__ import print_function |
2641 | - |
2642 | import os |
2643 | import shutil |
2644 | |
2645 | -import six |
2646 | import transaction |
2647 | |
2648 | from testresources import TestResourceManager |
2649 | @@ -102,7 +99,7 @@ |
2650 | if isinstance(databases, dict): |
2651 | databases = [ |
2652 | {"name": name, "uri": uri, "schema": schema} |
2653 | - for name, (uri, schema) in six.iteritems(databases)] |
2654 | + for name, (uri, schema) in databases.items()] |
2655 | |
2656 | # Provide the global IZStorm utility before applying patches, so |
2657 | # patch code can get the ztorm object if needed (e.g. looking up |
2658 | |
2659 | === modified file 'storm/zope/zstorm.py' |
2660 | --- storm/zope/zstorm.py 2019-08-11 09:48:05 +0000 |
2661 | +++ storm/zope/zstorm.py 2024-03-04 10:59:33 +0000 |
2662 | @@ -24,14 +24,11 @@ |
2663 | # You should have received a copy of the GNU Lesser General Public License |
2664 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
2665 | # |
2666 | -from __future__ import print_function |
2667 | - |
2668 | import threading |
2669 | import weakref |
2670 | |
2671 | from uuid import uuid4 |
2672 | |
2673 | -import six |
2674 | from zope.interface import implementer |
2675 | |
2676 | import transaction |
2677 | @@ -211,7 +208,7 @@ |
2678 | # it to avoid the problem where a store is deallocated during |
2679 | # iteration causing RuntimeError: dictionary changed size |
2680 | # during iteration. |
2681 | - for store, name in list(six.iteritems(self._name_index)): |
2682 | + for store, name in list(self._name_index.items()): |
2683 | yield name, store |
2684 | |
2685 | def get_name(self, store): |
2686 | |
2687 | === modified file 'tox.ini' |
2688 | --- tox.ini 2023-02-09 16:28:53 +0000 |
2689 | +++ tox.ini 2024-03-04 10:59:33 +0000 |
2690 | @@ -1,6 +1,5 @@ |
2691 | [tox] |
2692 | envlist = |
2693 | - py27-{cextensions,nocextensions} |
2694 | py35-{cextensions,nocextensions} |
2695 | py36-{cextensions,nocextensions} |
2696 | py37-{cextensions,nocextensions} |
2697 | @@ -12,7 +11,7 @@ |
2698 | |
2699 | [testenv] |
2700 | download = |
2701 | - py27,py35: true |
2702 | + py35: true |
2703 | deps = |
2704 | .[test] |
2705 | passenv = |
2706 | @@ -21,8 +20,8 @@ |
2707 | setenv = |
2708 | cextensions: STORM_CEXTENSIONS = 1 |
2709 | nocextensions: STORM_CEXTENSIONS = 0 |
2710 | - py27,py35: VIRTUALENV_DOWNLOAD = 1 |
2711 | - py27,py35: VIRTUALENV_PIP = 20.3.4 |
2712 | + py35: VIRTUALENV_DOWNLOAD = 1 |
2713 | + py35: VIRTUALENV_PIP = 20.3.4 |
2714 | commands = |
2715 | python dev/test {posargs} |
2716 |
Thank you for this contribution, Colin! I reviewed the changes and they look good to me. 👍