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