Merge lp:~cjwatson/storm/remove-py2 into lp:storm

Proposed by Colin Watson
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
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.

To post a comment you must log in.
Revision history for this message
Guruprasad (lgp171188) wrote :

Thank you for this contribution, Colin! I reviewed the changes and they look good to me. 👍

review: Approve
lp:~cjwatson/storm/remove-py2 updated
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

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'NEWS'
--- NEWS 2023-12-07 17:04:46 +0000
+++ NEWS 2024-03-04 10:59:33 +0000
@@ -1,11 +1,19 @@
10.2711.0
2====2===
33
4Improvements4Improvements
5------------5------------
66
7- Fix several syntax warnings from recent Python versions.7- Fix several syntax warnings from recent Python versions.
88
9API changes
10-----------
11
12- Remove support for Python 2.
13- Remove the storm.compat module.
14- Deprecate storm.sqlobject.AutoUnicodeVariable and
15 storm.sqlobject.AutoUnicode.
16
90.26 (2023-07-04)170.26 (2023-07-04)
10=================18=================
1119
1220
=== modified file 'README'
--- README 2021-04-06 09:23:02 +0000
+++ README 2024-03-04 10:59:33 +0000
@@ -116,19 +116,18 @@
116116
117These will take a few minutes to download.117These will take a few minutes to download.
118118
119The Python dependencies for running tests can mostly be installed with119The Python dependencies for running tests can be installed with apt-get:
120apt-get:
121120
122 $ apt-get install \121 $ apt-get install \
123 python-fixtures python-psycopg2 \122 python3-fixtures \
124 python-testresources python-transaction python-twisted \123 python3-pgbouncer \
125 python-zope.component python-zope.security124 python3-psycopg2 \
126125 python3-testresources \
127Two modules - pgbouncer and timeline - are not yet packaged in126 python3-timeline \
128Ubuntu. These can be installed from PyPI:127 python3-transaction \
129128 python3-twisted \
130 http://pypi.python.org/pypi/pgbouncer129 python3-zope.component \
131 http://pypi.python.org/pypi/timeline130 python3-zope.security
132131
133Alternatively, dependencies can be downloaded as eggs into the current132Alternatively, dependencies can be downloaded as eggs into the current
134directory with:133directory with:
135134
=== modified file 'dev/test'
--- dev/test 2021-05-13 23:02:23 +0000
+++ dev/test 2024-03-04 10:59:33 +0000
@@ -1,4 +1,4 @@
1#!/usr/bin/env python1#!/usr/bin/env python3
2#2#
3# Copyright (c) 2006, 2007 Canonical3# Copyright (c) 2006, 2007 Canonical
4#4#
@@ -87,7 +87,7 @@
87 except ImportError:87 except ImportError:
88 return runner_func88 return runner_func
8989
90 from six.moves.urllib.parse import urlunsplit90 from urllib.parse import urlunsplit
91 from storm.uri import escape91 from storm.uri import escape
9292
93 def wrapper():93 def wrapper():
@@ -128,7 +128,7 @@
128 except ImportError:128 except ImportError:
129 return runner_func129 return runner_func
130130
131 from six.moves.urllib.parse import (131 from urllib.parse import (
132 urlencode,132 urlencode,
133 urlunsplit,133 urlunsplit,
134 )134 )
135135
=== modified file 'dev/ubuntu-deps'
--- dev/ubuntu-deps 2021-04-06 09:23:02 +0000
+++ dev/ubuntu-deps 2024-03-04 10:59:33 +0000
@@ -12,17 +12,18 @@
12 mysql-server \12 mysql-server \
13 pgbouncer \13 pgbouncer \
14 postgresql \14 postgresql \
15 python-dev \15 python3-dev \
16 python-fixtures \16 python3-fixtures \
17 python-mysqldb \17 python3-mysqldb \
18 python-psycopg2 \18 python3-pgbouncer \
19 python-setuptools \19 python3-psycopg2 \
20 python-six \20 python3-setuptools \
21 python-testresources \21 python3-testresources \
22 python-transaction \22 python3-timeline \
23 python-twisted \23 python3-transaction \
24 python-zope.component \24 python3-twisted \
25 python-zope.security \25 python3-zope.component \
26 python3-zope.security \
26 tox27 tox
2728
2829
2930
=== modified file 'setup.py'
--- setup.py 2022-10-28 06:26:28 +0000
+++ setup.py 2024-03-04 10:59:33 +0000
@@ -1,6 +1,4 @@
1#!/usr/bin/env python1#!/usr/bin/env python3
2
3from __future__ import print_function
42
5import os3import os
6import re4import re
@@ -26,17 +24,14 @@
26tests_require = [24tests_require = [
27 "fixtures >= 1.3.0",25 "fixtures >= 1.3.0",
28 "mysqlclient",26 "mysqlclient",
29 "mysqlclient < 2.0.0; python_version < '3'",
30 "pgbouncer >= 0.0.7",27 "pgbouncer >= 0.0.7",
31 "postgresfixture",28 "postgresfixture",
32 "psycopg2 >= 2.3.0",29 "psycopg2 >= 2.3.0",
33 "setuptools < 45; python_version < '3'",
34 "testresources >= 0.2.4",30 "testresources >= 0.2.4",
35 "testtools >= 0.9.8",31 "testtools >= 0.9.8",
36 "timeline >= 0.0.2",32 "timeline >= 0.0.2",
37 "transaction >= 1.0.0",33 "transaction >= 1.0.0",
38 "Twisted >= 10.0.0",34 "Twisted >= 10.0.0",
39 "Twisted < 21.2.0; python_version < '3'",
40 "zope.component >= 3.8.0",35 "zope.component >= 3.8.0",
41 "zope.configuration",36 "zope.configuration",
42 "zope.interface >= 4.0.0",37 "zope.interface >= 4.0.0",
@@ -67,8 +62,6 @@
67 ("License :: OSI Approved :: GNU Library or "62 ("License :: OSI Approved :: GNU Library or "
68 "Lesser General Public License (LGPL)"),63 "Lesser General Public License (LGPL)"),
69 "Programming Language :: Python",64 "Programming Language :: Python",
70 "Programming Language :: Python :: 2",
71 "Programming Language :: Python :: 2.7",
72 "Programming Language :: Python :: 3",65 "Programming Language :: Python :: 3",
73 "Programming Language :: Python :: 3.5",66 "Programming Language :: Python :: 3.5",
74 "Programming Language :: Python :: 3.6",67 "Programming Language :: Python :: 3.6",
@@ -87,7 +80,7 @@
87 # warning) by distutils.80 # warning) by distutils.
88 include_package_data=True,81 include_package_data=True,
89 zip_safe=False,82 zip_safe=False,
90 install_requires=["six"],83 python_requires=">=3.5",
91 test_suite="storm.tests.find_tests",84 test_suite="storm.tests.find_tests",
92 tests_require=tests_require,85 tests_require=tests_require,
93 extras_require={86 extras_require={
9487
=== modified file 'storm/__init__.py'
--- storm/__init__.py 2023-07-04 13:55:37 +0000
+++ storm/__init__.py 2024-03-04 10:59:33 +0000
@@ -19,8 +19,6 @@
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/>.
20#20#
2121
22from __future__ import print_function
23
24import os22import os
2523
2624
2725
=== modified file 'storm/base.py'
--- storm/base.py 2019-08-11 08:58:54 +0000
+++ storm/base.py 2024-03-04 10:59:33 +0000
@@ -18,17 +18,13 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23import six
24
25from storm.properties import PropertyPublisherMeta21from storm.properties import PropertyPublisherMeta
2622
2723
28__all__ = ["Storm"]24__all__ = ["Storm"]
2925
3026
31class Storm(six.with_metaclass(PropertyPublisherMeta, object)):27class Storm(metaclass=PropertyPublisherMeta):
32 """An optional base class for objects stored in a Storm Store.28 """An optional base class for objects stored in a Storm Store.
3329
34 It causes your subclasses to be associated with a Storm30 It causes your subclasses to be associated with a Storm
3531
=== modified file 'storm/cache.py'
--- storm/cache.py 2023-12-07 17:04:46 +0000
+++ storm/cache.py 2024-03-04 10:59:33 +0000
@@ -1,9 +1,5 @@
1from __future__ import print_function
2
3import itertools1import itertools
42
5import six
6
73
8class Cache(object):4class Cache(object):
9 """Prevents recently used objects from being deallocated.5 """Prevents recently used objects from being deallocated.
@@ -145,8 +141,8 @@
145 """141 """
146 self._size = size142 self._size = size
147 cache = itertools.islice(143 cache = itertools.islice(
148 itertools.chain(six.iteritems(self._new_cache),144 itertools.chain(self._new_cache.items(),
149 six.iteritems(self._old_cache)),145 self._old_cache.items()),
150 0, size)146 0, size)
151 self._new_cache = dict(cache)147 self._new_cache = dict(cache)
152 self._old_cache.clear()148 self._old_cache.clear()
153149
=== modified file 'storm/cextensions.c'
--- storm/cextensions.c 2022-03-16 16:59:21 +0000
+++ storm/cextensions.c 2024-03-04 10:59:33 +0000
@@ -24,16 +24,6 @@
24#include <structmember.h>24#include <structmember.h>
2525
2626
27#if PY_VERSION_HEX >= 0x03000000
28#define PyInt_FromLong PyLong_FromLong
29#define PyText_AsString _PyUnicode_AsString
30#define PyString_Check(o) 0
31#define PyString_CheckExact(o) 0
32#else
33/* 2.x */
34#define PyText_AsString PyString_AsString
35#endif
36
37#define CATCH(error_value, expression) \27#define CATCH(error_value, expression) \
38 do { \28 do { \
39 if ((expression) == error_value) {\29 if ((expression) == error_value) {\
@@ -1423,7 +1413,7 @@
1423 PyObject *result = PyDict_GetItem(self->_precedence, type);1413 PyObject *result = PyDict_GetItem(self->_precedence, type);
1424 if (result == NULL && !PyErr_Occurred()) {1414 if (result == NULL && !PyErr_Occurred()) {
1425 /* That should be MAX_PRECEDENCE, defined in expr.py */1415 /* That should be MAX_PRECEDENCE, defined in expr.py */
1426 return PyInt_FromLong(1000);1416 return PyLong_FromLong(1000);
1427 }1417 }
1428 Py_INCREF(result);1418 Py_INCREF(result);
1429 return result;1419 return result;
@@ -1511,7 +1501,7 @@
1511 if (repr) {1501 if (repr) {
1512 PyErr_Format(CompileError,1502 PyErr_Format(CompileError,
1513 "Don't know how to compile type %s of %s",1503 "Don't know how to compile type %s of %s",
1514 expr->ob_type->tp_name, PyText_AsString(repr));1504 expr->ob_type->tp_name, _PyUnicode_AsString(repr));
1515 Py_DECREF(repr);1505 Py_DECREF(repr);
1516 }1506 }
1517 goto error;1507 goto error;
@@ -1570,24 +1560,20 @@
15701560
1571 /*1561 /*
1572 expr_type = type(expr)1562 expr_type = type(expr)
1573 string_types = (str,) if six.PY3 else (str, unicode)1563 if expr_type is SQLRaw or (raw and expr_type is str):
1574 if expr_type is SQLRaw or (raw and expr_type in string_types):
1575 return expr1564 return expr
1576 */1565 */
1577 /* Note that PyString_CheckExact(o) is defined at the top of this file
1578 to 0 on Python 3, so we can safely translate the string_types checks
1579 here to PyString_CheckExact || PyUnicode_CheckExact. */
1580 if ((PyObject *)expr->ob_type == SQLRaw ||1566 if ((PyObject *)expr->ob_type == SQLRaw ||
1581 (raw && (PyString_CheckExact(expr) || PyUnicode_CheckExact(expr)))) {1567 (raw && PyUnicode_CheckExact(expr))) {
1582 /* Pass our reference on. */1568 /* Pass our reference on. */
1583 return expr;1569 return expr;
1584 }1570 }
15851571
1586 /*1572 /*
1587 if token and expr_type in string_types:1573 if token and expr_type is str:
1588 expr = SQLToken(expr)1574 expr = SQLToken(expr)
1589 */1575 */
1590 if (token && (PyString_CheckExact(expr) || PyUnicode_CheckExact(expr))) {1576 if (token && PyUnicode_CheckExact(expr)) {
1591 PyObject *tmp;1577 PyObject *tmp;
1592 CATCH(NULL, tmp = PyObject_CallFunctionObjArgs(SQLToken, expr, NULL));1578 CATCH(NULL, tmp = PyObject_CallFunctionObjArgs(SQLToken, expr, NULL));
1593 Py_DECREF(expr);1579 Py_DECREF(expr);
@@ -1614,12 +1600,10 @@
1614 PyObject *subexpr = PySequence_Fast_GET_ITEM(sequence, i);1600 PyObject *subexpr = PySequence_Fast_GET_ITEM(sequence, i);
1615 /*1601 /*
1616 subexpr_type = type(subexpr)1602 subexpr_type = type(subexpr)
1617 if (subexpr_type is SQLRaw or1603 if subexpr_type is SQLRaw or (raw and subexpr_type is str):
1618 (raw and subexpr_type in string_types)):
1619 */1604 */
1620 if ((PyObject *)subexpr->ob_type == (PyObject *)SQLRaw ||1605 if ((PyObject *)subexpr->ob_type == (PyObject *)SQLRaw ||
1621 (raw && (PyString_CheckExact(subexpr) ||1606 (raw && PyUnicode_CheckExact(subexpr))) {
1622 PyUnicode_CheckExact(subexpr)))) {
1623 /* statement = subexpr */1607 /* statement = subexpr */
1624 Py_INCREF(subexpr);1608 Py_INCREF(subexpr);
1625 statement = subexpr;1609 statement = subexpr;
@@ -1636,10 +1620,9 @@
1636 /* else: */1620 /* else: */
1637 } else {1621 } else {
1638 /*1622 /*
1639 if token and subexpr_type in string_types:1623 if token and subexpr_type is str:
1640 */1624 */
1641 if (token && (PyUnicode_CheckExact(subexpr) ||1625 if (token && PyUnicode_CheckExact(subexpr)) {
1642 PyString_CheckExact(subexpr))) {
1643 /* subexpr = SQLToken(subexpr) */1626 /* subexpr = SQLToken(subexpr) */
1644 CATCH(NULL,1627 CATCH(NULL,
1645 subexpr = PyObject_CallFunctionObjArgs(SQLToken,1628 subexpr = PyObject_CallFunctionObjArgs(SQLToken,
@@ -1713,7 +1696,7 @@
1713 &expr, &state, &join, &raw, &token)) {1696 &expr, &state, &join, &raw, &token)) {
1714 return NULL;1697 return NULL;
1715 }1698 }
1716 if (join && (!PyString_Check(join) && !PyUnicode_Check(join))) {1699 if (join && !PyUnicode_Check(join)) {
1717 PyErr_Format(PyExc_TypeError,1700 PyErr_Format(PyExc_TypeError,
1718 "'join' argument must be a string, not %.80s",1701 "'join' argument must be a string, not %.80s",
1719 Py_TYPE(join)->tp_name);1702 Py_TYPE(join)->tp_name);
@@ -1949,7 +1932,7 @@
1949 PyObject *column, *variable, *tmp;1932 PyObject *column, *variable, *tmp;
1950 Py_ssize_t i = 0;1933 Py_ssize_t i = 0;
19511934
1952 /* for variable in six.itervalues(self.variables): */1935 /* for variable in self.variables.values(): */
1953 while (PyDict_Next(self->variables, &i, &column, &variable)) {1936 while (PyDict_Next(self->variables, &i, &column, &variable)) {
1954 /* variable.checkpoint() */1937 /* variable.checkpoint() */
1955 CATCH(NULL, tmp = PyObject_CallMethod(variable, "checkpoint", NULL));1938 CATCH(NULL, tmp = PyObject_CallMethod(variable, "checkpoint", NULL));
@@ -2180,16 +2163,6 @@
2180 return 0;2163 return 0;
2181}2164}
21822165
2183#if PY_VERSION_HEX < 0x03000000
2184DL_EXPORT(void)
2185initcextensions(void)
2186{
2187 PyObject *module;
2188
2189 module = Py_InitModule3("cextensions", cextensions_methods, "");
2190 do_init(module);
2191}
2192#else
2193static struct PyModuleDef cextensionsmodule = {2166static struct PyModuleDef cextensionsmodule = {
2194 PyModuleDef_HEAD_INIT,2167 PyModuleDef_HEAD_INIT,
2195 "cextensions",2168 "cextensions",
@@ -2211,7 +2184,6 @@
2211 do_init(module);2184 do_init(module);
2212 return module;2185 return module;
2213}2186}
2214#endif
22152187
22162188
2217/* vim:ts=4:sw=4:et2189/* vim:ts=4:sw=4:et
22182190
=== removed file 'storm/compat.py'
--- storm/compat.py 2019-06-05 11:41:07 +0000
+++ storm/compat.py 1970-01-01 00:00:00 +0000
@@ -1,27 +0,0 @@
1#
2# Copyright (c) 2011 Canonical
3#
4# Written by Gustavo Niemeyer <gustavo@niemeyer.net>
5#
6# This file is part of Storm Object Relational Mapper.
7#
8# Storm is free software; you can redistribute it and/or modify
9# it under the terms of the GNU Lesser General Public License as
10# published by the Free Software Foundation; either version 2.1 of
11# the License, or (at your option) any later version.
12#
13# Storm is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Lesser General Public License for more details.
17#
18# You should have received a copy of the GNU Lesser General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21
22from __future__ import print_function
23
24__all__ = ["json"]
25
26
27import json
280
=== modified file 'storm/database.py'
--- storm/database.py 2023-12-07 17:04:46 +0000
+++ storm/database.py 2024-03-04 10:59:33 +0000
@@ -25,16 +25,9 @@
25supported in modules in L{storm.databases}.25supported in modules in L{storm.databases}.
26"""26"""
2727
28from __future__ import print_function28from collections.abc import Callable
29
30try:
31 from collections.abc import Callable
32except ImportError:
33 from collections import Callable
34from functools import wraps29from functools import wraps
3530
36import six
37
38from storm.expr import Expr, State, compile31from storm.expr import Expr, State, compile
39# Circular import: imported at the end of the module.32# Circular import: imported at the end of the module.
40# from storm.tracer import trace33# from storm.tracer import trace
@@ -690,7 +683,7 @@
690 Where 'anything' has previously been registered with683 Where 'anything' has previously been registered with
691 L{register_scheme}.684 L{register_scheme}.
692 """685 """
693 if isinstance(uri, six.string_types):686 if isinstance(uri, str):
694 uri = URI(uri)687 uri = URI(uri)
695 if uri.scheme in _database_schemes:688 if uri.scheme in _database_schemes:
696 factory = _database_schemes[uri.scheme]689 factory = _database_schemes[uri.scheme]
697690
=== modified file 'storm/databases/__init__.py'
--- storm/databases/__init__.py 2019-08-11 09:07:34 +0000
+++ storm/databases/__init__.py 2024-03-04 10:59:33 +0000
@@ -19,10 +19,6 @@
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/>.
20#20#
2121
22from __future__ import print_function
23
24import six
25
2622
27class Dummy(object):23class Dummy(object):
28 """Magic "infectious" class.24 """Magic "infectious" class.
@@ -43,7 +39,4 @@
43 def __bool__(self):39 def __bool__(self):
44 return False40 return False
4541
46 if six.PY2:
47 __nonzero__ = __bool__
48
49dummy = Dummy()42dummy = Dummy()
5043
=== modified file 'storm/databases/mysql.py'
--- storm/databases/mysql.py 2021-05-13 23:02:23 +0000
+++ storm/databases/mysql.py 2024-03-04 10:59:33 +0000
@@ -19,8 +19,6 @@
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/>.
20#20#
2121
22from __future__ import print_function
23
24from datetime import time, timedelta22from datetime import time, timedelta
25from array import array23from array import array
26import sys24import sys
2725
=== modified file 'storm/databases/postgres.py'
--- storm/databases/postgres.py 2019-09-17 09:35:10 +0000
+++ storm/databases/postgres.py 2024-03-04 10:59:33 +0000
@@ -19,8 +19,6 @@
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/>.
20#20#
2121
22from __future__ import print_function
23
24from datetime import datetime, date, time, timedelta22from datetime import datetime, date, time, timedelta
25import json23import json
2624
2725
=== modified file 'storm/databases/sqlite.py'
--- storm/databases/sqlite.py 2020-02-10 15:30:23 +0000
+++ storm/databases/sqlite.py 2024-03-04 10:59:33 +0000
@@ -18,14 +18,10 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23from datetime import datetime, date, time, timedelta21from datetime import datetime, date, time, timedelta
24from time import sleep, time as now22from time import sleep, time as now
25import sys23import sys
2624
27import six
28
29from storm.databases import dummy25from storm.databases import dummy
3026
31try:27try:
@@ -85,26 +81,11 @@
8581
86 @staticmethod82 @staticmethod
87 def set_variable(variable, value):83 def set_variable(variable, value):
88 if (isinstance(variable, BytesVariable) and84 if isinstance(variable, BytesVariable) and isinstance(value, str):
89 isinstance(value, six.text_type)):
90 # pysqlite2 may return unicode.85 # pysqlite2 may return unicode.
91 value = value.encode("UTF-8")86 value = value.encode("UTF-8")
92 variable.set(value, from_db=True)87 variable.set(value, from_db=True)
9388
94 @staticmethod
95 def from_database(row):
96 """Convert SQLite-specific datatypes to "normal" Python types.
97
98 On Python 2, if there are any C{buffer} instances in the row,
99 convert them to bytes. On Python 3, BLOB types are converted to
100 bytes, which is already what we want.
101 """
102 for value in row:
103 if six.PY2 and isinstance(value, buffer):
104 yield bytes(value)
105 else:
106 yield value
107
10889
109class SQLiteConnection(Connection):90class SQLiteConnection(Connection):
11091
@@ -116,16 +97,13 @@
116 def to_database(params):97 def to_database(params):
117 """98 """
118 Like L{Connection.to_database}, but this also converts99 Like L{Connection.to_database}, but this also converts
119 instances of L{datetime} types to strings, and (on Python 2) bytes100 instances of L{datetime} types to strings.
120 instances to C{buffer} instances.
121 """101 """
122 for param in params:102 for param in params:
123 if isinstance(param, Variable):103 if isinstance(param, Variable):
124 param = param.get(to_db=True)104 param = param.get(to_db=True)
125 if isinstance(param, (datetime, date, time, timedelta)):105 if isinstance(param, (datetime, date, time, timedelta)):
126 yield str(param)106 yield str(param)
127 elif six.PY2 and isinstance(param, bytes):
128 yield buffer(param)
129 else:107 else:
130 yield param108 yield param
131109
132110
=== modified file 'storm/event.py'
--- storm/event.py 2020-05-29 22:08:47 +0000
+++ storm/event.py 2024-03-04 10:59:33 +0000
@@ -18,8 +18,6 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23import weakref21import weakref
2422
25from storm import has_cextensions23from storm import has_cextensions
2624
=== modified file 'storm/exceptions.py'
--- storm/exceptions.py 2021-05-13 23:23:17 +0000
+++ storm/exceptions.py 2024-03-04 10:59:33 +0000
@@ -18,13 +18,9 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23from contextlib import contextmanager21from contextlib import contextmanager
24import sys22import sys
2523
26import six
27
2824
29class StormError(Exception):25class StormError(Exception):
30 pass26 pass
@@ -171,18 +167,12 @@
171 for wrapper_type in _wrapped_exception_types:167 for wrapper_type in _wrapped_exception_types:
172 dbapi_type = getattr(module, wrapper_type.__name__, None)168 dbapi_type = getattr(module, wrapper_type.__name__, None)
173 if (dbapi_type is not None and169 if (dbapi_type is not None and
174 isinstance(dbapi_type, six.class_types) and170 isinstance(dbapi_type, type) and
175 isinstance(e, dbapi_type)):171 isinstance(e, dbapi_type)):
176 wrapped = database._wrap_exception(wrapper_type, e)172 wrapped = database._wrap_exception(wrapper_type, e)
177 tb = sys.exc_info()[2]173 tb = sys.exc_info()[2]
178 # As close to "raise wrapped.with_traceback(tb) from e" as
179 # we can manage, but without causing syntax errors on
180 # various versions of Python.
181 try:174 try:
182 if six.PY2:175 raise wrapped.with_traceback(tb) from e
183 six.reraise(wrapped, None, tb)
184 else:
185 six.raise_from(wrapped.with_traceback(tb), e)
186 finally:176 finally:
187 # Avoid traceback reference cycles.177 # Avoid traceback reference cycles.
188 del wrapped, tb178 del wrapped, tb
189179
=== modified file 'storm/expr.py'
--- storm/expr.py 2022-10-18 17:36:05 +0000
+++ storm/expr.py 2024-03-04 10:59:33 +0000
@@ -18,16 +18,12 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23from decimal import Decimal21from decimal import Decimal
24from datetime import datetime, date, time, timedelta22from datetime import datetime, date, time, timedelta
25from weakref import WeakKeyDictionary23from weakref import WeakKeyDictionary
26from copy import copy24from copy import copy
27import re25import re
2826
29import six
30
31from storm.exceptions import CompileError, NoTableError, ExprError27from storm.exceptions import CompileError, NoTableError, ExprError
32from storm.variables import (28from storm.variables import (
33 Variable, BytesVariable, UnicodeVariable, LazyValue,29 Variable, BytesVariable, UnicodeVariable, LazyValue,
@@ -157,23 +153,20 @@
157 created internally (and thus can't be accessed).153 created internally (and thus can't be accessed).
158 @param join: The string token to use to put between154 @param join: The string token to use to put between
159 subexpressions. Defaults to ", ".155 subexpressions. Defaults to ", ".
160 @param raw: If true, any string (str or unicode on Python 2, str on156 @param raw: If true, any string expression or subexpression will not
161 Python 3) expression or subexpression will not be further157 be further compiled.
162 compiled.158 @param token: If true, any string expression will be considered as a
163 @param token: If true, any string (str or unicode on Python 2, str159 SQLToken, and quoted properly.
164 on Python 3) expression will be considered as a SQLToken, and
165 quoted properly.
166 """160 """
167 # FASTPATH This method is part of the fast path. Be careful when161 # FASTPATH This method is part of the fast path. Be careful when
168 # changing it (try to profile any changes).162 # changing it (try to profile any changes).
169163
170 expr_type = type(expr)164 expr_type = type(expr)
171 string_types = (str,) if six.PY3 else (str, unicode)
172165
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):
174 return expr167 return expr
175168
176 if token and expr_type in string_types:169 if token and expr_type is str:
177 expr = SQLToken(expr)170 expr = SQLToken(expr)
178171
179 if state is None:172 if state is None:
@@ -184,14 +177,13 @@
184 compiled = []177 compiled = []
185 for subexpr in expr:178 for subexpr in expr:
186 subexpr_type = type(subexpr)179 subexpr_type = type(subexpr)
187 if (subexpr_type is SQLRaw or180 if subexpr_type is SQLRaw or (raw and subexpr_type is str):
188 (raw and subexpr_type in string_types)):
189 statement = subexpr181 statement = subexpr
190 elif subexpr_type is tuple or subexpr_type is list:182 elif subexpr_type is tuple or subexpr_type is list:
191 state.precedence = outer_precedence183 state.precedence = outer_precedence
192 statement = self(subexpr, state, join, raw, token)184 statement = self(subexpr, state, join, raw, token)
193 else:185 else:
194 if token and subexpr_type in string_types:186 if token and subexpr_type is str:
195 subexpr = SQLToken(subexpr)187 subexpr = SQLToken(subexpr)
196 statement = self._compile_single(subexpr, state,188 statement = self._compile_single(subexpr, state,
197 outer_precedence)189 outer_precedence)
@@ -313,12 +305,12 @@
313 state.parameters.append(BytesVariable(expr))305 state.parameters.append(BytesVariable(expr))
314 return "?"306 return "?"
315307
316@compile.when(six.text_type)308@compile.when(str)
317def compile_text(compile, expr, state):309def compile_text(compile, expr, state):
318 state.parameters.append(UnicodeVariable(expr))310 state.parameters.append(UnicodeVariable(expr))
319 return "?"311 return "?"
320312
321@compile.when(*six.integer_types)313@compile.when(int)
322def compile_int(compile, expr, state):314def compile_int(compile, expr, state):
323 state.parameters.append(IntVariable(expr))315 state.parameters.append(IntVariable(expr))
324 return "?"316 return "?"
@@ -363,8 +355,7 @@
363 return "NULL"355 return "NULL"
364356
365357
366@compile_python.when(358@compile_python.when(bytes, str, int, float, type(None))
367 bytes, six.text_type, float, type(None), *six.integer_types)
368def compile_python_builtin(compile, expr, state):359def compile_python_builtin(compile, expr, state):
369 return repr(expr)360 return repr(expr)
370361
@@ -518,19 +509,19 @@
518 return Upper(self)509 return Upper(self)
519510
520 def startswith(self, prefix, case_sensitive=None):511 def startswith(self, prefix, case_sensitive=None):
521 if not isinstance(prefix, six.text_type):512 if not isinstance(prefix, str):
522 raise ExprError("Expected text argument, got %r" % type(prefix))513 raise ExprError("Expected text argument, got %r" % type(prefix))
523 pattern = prefix.translate(like_escape) + u"%"514 pattern = prefix.translate(like_escape) + u"%"
524 return Like(self, pattern, u"!", case_sensitive)515 return Like(self, pattern, u"!", case_sensitive)
525516
526 def endswith(self, suffix, case_sensitive=None):517 def endswith(self, suffix, case_sensitive=None):
527 if not isinstance(suffix, six.text_type):518 if not isinstance(suffix, str):
528 raise ExprError("Expected text argument, got %r" % type(suffix))519 raise ExprError("Expected text argument, got %r" % type(suffix))
529 pattern = u"%" + suffix.translate(like_escape)520 pattern = u"%" + suffix.translate(like_escape)
530 return Like(self, pattern, u"!", case_sensitive)521 return Like(self, pattern, u"!", case_sensitive)
531522
532 def contains_string(self, substring, case_sensitive=None):523 def contains_string(self, substring, case_sensitive=None):
533 if not isinstance(substring, six.text_type):524 if not isinstance(substring, str):
534 raise ExprError("Expected text argument, got %r" % type(substring))525 raise ExprError("Expected text argument, got %r" % type(substring))
535 pattern = u"%" + substring.translate(like_escape) + u"%"526 pattern = u"%" + substring.translate(like_escape) + u"%"
536 return Like(self, pattern, u"!", case_sensitive)527 return Like(self, pattern, u"!", case_sensitive)
@@ -746,7 +737,7 @@
746 state.context = EXPR737 state.context = EXPR
747 values = insert.values738 values = insert.values
748 if values is Undef:739 if values is Undef:
749 values = [tuple(six.itervalues(insert.map))]740 values = [tuple(insert.map.values())]
750 if isinstance(values, Expr):741 if isinstance(values, Expr):
751 compiled_values = compile(values, state)742 compiled_values = compile(values, state)
752 else:743 else:
@@ -1492,7 +1483,7 @@
1492# --------------------------------------------------------------------1483# --------------------------------------------------------------------
1493# Plain SQL expressions.1484# Plain SQL expressions.
14941485
1495class SQLRaw(six.text_type):1486class SQLRaw(str):
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.
14971488
1498 This is handled internally by the compiler.1489 This is handled internally by the compiler.
@@ -1500,7 +1491,7 @@
1500 __slots__ = ()1491 __slots__ = ()
15011492
15021493
1503class SQLToken(six.text_type):1494class SQLToken(str):
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.
15051496
1506 These strings will be quoted, when needed.1497 These strings will be quoted, when needed.
15071498
=== modified file 'storm/info.py'
--- storm/info.py 2020-05-26 10:37:54 +0000
+++ storm/info.py 2024-03-04 10:59:33 +0000
@@ -18,12 +18,8 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23from weakref import ref21from weakref import ref
2422
25import six
26
27from storm.exceptions import ClassInfoError23from storm.exceptions import ClassInfoError
28from storm.expr import Column, Desc, TABLE24from storm.expr import Column, Desc, TABLE
29from storm.expr import compile, Table25from storm.expr import compile, Table
@@ -77,7 +73,7 @@
7773
78 self.cls = cls74 self.cls = cls
7975
80 if isinstance(self.table, six.string_types):76 if isinstance(self.table, str):
81 self.table = Table(self.table)77 self.table = Table(self.table)
8278
83 pairs = []79 pairs = []
@@ -135,7 +131,7 @@
135 __order__ = (__order__,)131 __order__ = (__order__,)
136 self.default_order = []132 self.default_order = []
137 for item in __order__:133 for item in __order__:
138 if isinstance(item, six.string_types):134 if isinstance(item, str):
139 if item.startswith("-"):135 if item.startswith("-"):
140 prop = Desc(getattr(cls, item[1:]))136 prop = Desc(getattr(cls, item[1:]))
141 else:137 else:
@@ -198,7 +194,7 @@
198 self.event.emit("object-deleted")194 self.event.emit("object-deleted")
199195
200 def checkpoint(self):196 def checkpoint(self):
201 for variable in six.itervalues(self.variables):197 for variable in self.variables.values():
202 variable.checkpoint()198 variable.checkpoint()
203199
204200
205201
=== modified file 'storm/locals.py'
--- storm/locals.py 2020-02-10 15:30:23 +0000
+++ storm/locals.py 2024-03-04 10:59:33 +0000
@@ -18,8 +18,6 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23from storm.properties import Bool, Int, Float, Bytes, RawStr, Chars, Unicode21from storm.properties import Bool, Int, Float, Bytes, RawStr, Chars, Unicode
24from storm.properties import List, Decimal, DateTime, Date, Time, Enum, UUID22from storm.properties import List, Decimal, DateTime, Date, Time, Enum, UUID
25from storm.properties import TimeDelta, Pickle, JSON23from storm.properties import TimeDelta, Pickle, JSON
2624
=== modified file 'storm/properties.py'
--- storm/properties.py 2020-05-26 16:14:13 +0000
+++ storm/properties.py 2024-03-04 10:59:33 +0000
@@ -18,8 +18,6 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23from bisect import insort_left, bisect_left21from bisect import insort_left, bisect_left
24import weakref22import weakref
25import sys23import sys
@@ -211,8 +209,8 @@
211class Bytes(SimpleProperty):209class Bytes(SimpleProperty):
212 """Bytes property.210 """Bytes property.
213211
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
215 objects, and stores them as byte strings.213 strings.
216214
217 Deprecated aliases: L{Chars}, L{RawStr}.215 Deprecated aliases: L{Chars}, L{RawStr}.
218 """216 """
@@ -228,9 +226,7 @@
228class Unicode(SimpleProperty):226class Unicode(SimpleProperty):
229 """Unicode property.227 """Unicode property.
230228
231 This accepts L{unicode} (Python 2) or L{str} (Python 3) objects, and229 This accepts L{str} objects, and stores them as text strings.
232 stores them as text strings. Note that it does not accept L{str}
233 objects on Python 2.
234 """230 """
235 variable_class = UnicodeVariable231 variable_class = UnicodeVariable
236232
237233
=== modified file 'storm/references.py'
--- storm/references.py 2020-05-26 16:32:10 +0000
+++ storm/references.py 2024-03-04 10:59:33 +0000
@@ -18,12 +18,8 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23import weakref21import weakref
2422
25import six
26
27from storm.exceptions import (23from storm.exceptions import (
28 ClassInfoError, FeatureError, NoStoreError, WrongStoreError)24 ClassInfoError, FeatureError, NoStoreError, WrongStoreError)
29from storm.store import Store, get_where_for_args, LostObjectError25from storm.store import Store, get_where_for_args, LostObjectError
@@ -985,7 +981,7 @@
985 def resolve_one(self, property):981 def resolve_one(self, property):
986 if type(property) is tuple:982 if type(property) is tuple:
987 return self.resolve(property)983 return self.resolve(property)
988 elif isinstance(property, six.string_types):984 elif isinstance(property, str):
989 return self._resolve_string(property)985 return self._resolve_string(property)
990 elif isinstance(property, SuffixExpr):986 elif isinstance(property, SuffixExpr):
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.
@@ -1013,14 +1009,14 @@
10131009
1014def _find_descriptor_class(used_cls, descr):1010def _find_descriptor_class(used_cls, descr):
1015 for cls in used_cls.__mro__:1011 for cls in used_cls.__mro__:
1016 for attr, _descr in six.iteritems(cls.__dict__):1012 for attr, _descr in cls.__dict__.items():
1017 if _descr is descr:1013 if _descr is descr:
1018 return cls1014 return cls
1019 raise RuntimeError("Reference used in an unknown class")1015 raise RuntimeError("Reference used in an unknown class")
10201016
1021def _find_descriptor_obj(used_cls, descr):1017def _find_descriptor_obj(used_cls, descr):
1022 for cls in used_cls.__mro__:1018 for cls in used_cls.__mro__:
1023 for attr, _descr in six.iteritems(cls.__dict__):1019 for attr, _descr in cls.__dict__.items():
1024 if _descr is descr:1020 if _descr is descr:
1025 return getattr(cls, attr)1021 return getattr(cls, attr)
1026 raise RuntimeError("Reference used in an unknown class")1022 raise RuntimeError("Reference used in an unknown class")
10271023
=== modified file 'storm/schema/__init__.py'
--- storm/schema/__init__.py 2019-06-05 11:41:07 +0000
+++ storm/schema/__init__.py 2024-03-04 10:59:33 +0000
@@ -18,6 +18,4 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23from storm.schema.schema import Schema21from storm.schema.schema import Schema
2422
=== modified file 'storm/schema/patch.py'
--- storm/schema/patch.py 2019-08-11 10:08:24 +0000
+++ storm/schema/patch.py 2024-03-04 10:59:33 +0000
@@ -34,15 +34,11 @@
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.
35"""35"""
3636
37from __future__ import print_function
38
39import sys37import sys
40import os38import os
41import re39import re
42import types40import types
4341
44import six
45
46from storm.locals import StormError, Int42from storm.locals import StormError, Int
4743
4844
@@ -122,12 +118,10 @@
122 except:118 except:
123 type, value, traceback = sys.exc_info()119 type, value, traceback = sys.exc_info()
124 patch_repr = getattr(module, "__file__", version)120 patch_repr = getattr(module, "__file__", version)
125 six.reraise(121 raise BadPatchError(
126 BadPatchError,122 "Patch %s failed: %s: %s" %
127 BadPatchError(123 (patch_repr, type.__name__, str(value))
128 "Patch %s failed: %s: %s" %124 ).with_traceback(traceback)
129 (patch_repr, type.__name__, str(value))),
130 traceback)
131 self._committer.commit()125 self._committer.commit()
132126
133 def apply_all(self):127 def apply_all(self):
134128
=== modified file 'storm/schema/schema.py'
--- storm/schema/schema.py 2019-06-05 11:41:07 +0000
+++ storm/schema/schema.py 2024-03-04 10:59:33 +0000
@@ -43,8 +43,6 @@
43upgrade the schema over time.43upgrade the schema over time.
44"""44"""
4545
46from __future__ import print_function
47
48import types46import types
4947
50from storm.locals import StormError48from storm.locals import StormError
5149
=== modified file 'storm/schema/sharding.py'
--- storm/schema/sharding.py 2019-06-05 11:41:07 +0000
+++ storm/schema/sharding.py 2024-03-04 10:59:33 +0000
@@ -41,8 +41,6 @@
41be at the same patch level. See L{storm.schema.patch.PatchSet}.41be at the same patch level. See L{storm.schema.patch.PatchSet}.
42"""42"""
4343
44from __future__ import print_function
45
46from storm.schema.schema import SchemaMissingError, UnappliedPatchesError44from storm.schema.schema import SchemaMissingError, UnappliedPatchesError
4745
4846
4947
=== modified file 'storm/sqlobject.py'
--- storm/sqlobject.py 2020-02-10 15:30:23 +0000
+++ storm/sqlobject.py 2024-03-04 10:59:33 +0000
@@ -23,18 +23,14 @@
23L{SQLObjectBase} is the central point of compatibility.23L{SQLObjectBase} is the central point of compatibility.
24"""24"""
2525
26from __future__ import print_function
27
28import re26import re
29import warnings27import warnings
3028
31import six
32
33from storm.properties import (29from storm.properties import (
34 Bytes, Int, Bool, Float, DateTime, Date, TimeDelta)30 Bytes, Int, Bool, Float, DateTime, Date, TimeDelta)
35from storm.references import Reference, ReferenceSet31from storm.references import Reference, ReferenceSet
36from storm.properties import SimpleProperty, PropertyPublisherMeta32from storm.properties import SimpleProperty, PropertyPublisherMeta
37from storm.variables import Variable33from storm.variables import UnicodeVariable
38from storm.exceptions import StormError, NotOneError34from storm.exceptions import StormError, NotOneError
39from storm.info import get_cls_info, ClassAlias35from storm.info import get_cls_info, ClassAlias
40from storm.store import AutoReload, Store36from storm.store import AutoReload, Store
@@ -166,7 +162,7 @@
166 dict["__storm_table__"] = table_name162 dict["__storm_table__"] = table_name
167163
168 attr_to_prop = {}164 attr_to_prop = {}
169 for attr, prop in list(six.iteritems(dict)):165 for attr, prop in list(dict.items()):
170 if attr == "__classcell__": # Python >= 3.6166 if attr == "__classcell__": # Python >= 3.6
171 continue167 continue
172 attr_to_prop[attr] = attr168 attr_to_prop[attr] = attr
@@ -211,7 +207,7 @@
211207
212208
213 id_type = dict.setdefault("_idType", int)209 id_type = dict.setdefault("_idType", int)
214 id_cls = {int: Int, bytes: Bytes, six.text_type: AutoUnicode}[id_type]210 id_cls = {int: Int, bytes: Bytes, str: AutoUnicode}[id_type]
215 dict["id"] = id_cls(id_name, primary=True, default=AutoReload)211 dict["id"] = id_cls(id_name, primary=True, default=AutoReload)
216 attr_to_prop[id_name] = "id"212 attr_to_prop[id_name] = "id"
217213
@@ -228,7 +224,7 @@
228 property_registry.add_property(obj, getattr(obj, "id"),224 property_registry.add_property(obj, getattr(obj, "id"),
229 "<table %s>" % table_name)225 "<table %s>" % table_name)
230226
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()):
232 prop = getattr(obj, real_name)228 prop = getattr(obj, real_name)
233 if fake_name != real_name:229 if fake_name != real_name:
234 property_registry.add_property(obj, prop, fake_name)230 property_registry.add_property(obj, prop, fake_name)
@@ -265,7 +261,7 @@
265 return getattr(self._cls, attr)261 return getattr(self._cls, attr)
266262
267263
268class SQLObjectBase(six.with_metaclass(SQLObjectMeta, Storm)):264class SQLObjectBase(Storm, metaclass=SQLObjectMeta):
269 """The root class of all SQLObject-emulating classes in your application.265 """The root class of all SQLObject-emulating classes in your application.
270266
271 The general strategy for using Storm's SQLObject emulation layer267 The general strategy for using Storm's SQLObject emulation layer
@@ -301,7 +297,7 @@
301 self._init(None)297 self._init(None)
302298
303 def set(self, **kwargs):299 def set(self, **kwargs):
304 for attr, value in six.iteritems(kwargs):300 for attr, value in kwargs.items():
305 setattr(self, attr, value)301 setattr(self, attr, value)
306302
307 def destroySelf(self):303 def destroySelf(self):
@@ -334,7 +330,7 @@
334 if not isinstance(orderBy, (tuple, list)):330 if not isinstance(orderBy, (tuple, list)):
335 orderBy = (orderBy,)331 orderBy = (orderBy,)
336 for item in orderBy:332 for item in orderBy:
337 if isinstance(item, six.string_types):333 if isinstance(item, str):
338 desc = item.startswith("-")334 desc = item.startswith("-")
339 if desc:335 if desc:
340 item = item[1:]336 item = item[1:]
@@ -409,7 +405,7 @@
409405
410 def _copy(self, **kwargs):406 def _copy(self, **kwargs):
411 copy = self.__class__(self._cls, **kwargs)407 copy = self.__class__(self._cls, **kwargs)
412 for name, value in six.iteritems(self.__dict__):408 for name, value in self.__dict__.items():
413 if name[1:] not in kwargs and name != "_finished_result_set":409 if name[1:] not in kwargs and name != "_finished_result_set":
414 setattr(copy, name, value)410 setattr(copy, name, value)
415 return copy411 return copy
@@ -562,9 +558,6 @@
562 """558 """
563 return not self.is_empty()559 return not self.is_empty()
564560
565 if six.PY2:
566 __nonzero__ = __bool__
567
568 def is_empty(self):561 def is_empty(self):
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."""
570 result_set = self._without_prejoins()._result_set563 result_set = self._without_prejoins()._result_set
@@ -611,7 +604,7 @@
611 return self._copy(prejoinClauseTables=prejoinClauseTables)604 return self._copy(prejoinClauseTables=prejoinClauseTables)
612605
613 def sum(self, attribute):606 def sum(self, attribute):
614 if isinstance(attribute, six.string_types):607 if isinstance(attribute, str):
615 attribute = SQL(attribute)608 attribute = SQL(attribute)
616 result_set = self._without_prejoins()._result_set609 result_set = self._without_prejoins()._result_set
617 return result_set.sum(attribute)610 return result_set.sum(attribute)
@@ -682,23 +675,13 @@
682 **self._kwargs)675 **self._kwargs)
683676
684677
685class AutoUnicodeVariable(Variable):678# DEPRECATED: On Python 2, this used to be a more relaxed version of
686 """A more relaxed version of UnicodeVariable that accepts native strings.679# UnicodeVariable that accepted both bytes and text. On Python 3, it
687680# accepts only text and is thus the same as UnicodeVariable. It exists only
688 On Python 2, this will try to convert bytes to text, to make it easier681# for compatibility.
689 to port code from SQLObject that expects to be able to set this variable682AutoUnicodeVariable = UnicodeVariable
690 to a native string.683
691684# DEPRECATED: Use storm.properties.Unicode instead.
692 On Python 3, this behaves the same way as UnicodeVariable and only
693 accepts text, since native strings are already Unicode.
694 """
695 __slots__ = ()
696
697 def parse_set(self, value, from_db):
698 if not isinstance(value, six.string_types):
699 raise TypeError("Expected a string type, found %r" % type(value))
700 return six.text_type(value)
701
702class AutoUnicode(SimpleProperty):685class AutoUnicode(SimpleProperty):
703 variable_class = AutoUnicodeVariable686 variable_class = AutoUnicodeVariable
704687
705688
=== modified file 'storm/store.py'
--- storm/store.py 2023-12-07 17:04:46 +0000
+++ storm/store.py 2024-03-04 10:59:33 +0000
@@ -24,14 +24,10 @@
24This module contains the highest-level ORM interface in Storm.24This module contains the highest-level ORM interface in Storm.
25"""25"""
2626
27from __future__ import print_function
28
29from copy import copy27from copy import copy
30from weakref import WeakValueDictionary28from weakref import WeakValueDictionary
31from operator import itemgetter29from operator import itemgetter
3230
33import six
34
35from storm.info import get_cls_info, get_obj_info, set_obj_info31from storm.info import get_cls_info, get_obj_info, set_obj_info
36from storm.variables import Variable, LazyValue32from storm.variables import Variable, LazyValue
37from storm.expr import (33from storm.expr import (
@@ -479,7 +475,7 @@
479 self._dirty = flushing475 self._dirty = flushing
480476
481 predecessors = {}477 predecessors = {}
482 for (before_info, after_info), n in six.iteritems(self._order):478 for (before_info, after_info), n in self._order.items():
483 if n > 0:479 if n > 0:
484 before_set = predecessors.get(after_info)480 before_set = predecessors.get(after_info)
485 if before_set is None:481 if before_set is None:
@@ -858,7 +854,7 @@
858 del obj_info["primary_vars"]854 del obj_info["primary_vars"]
859855
860 def _iter_alive(self):856 def _iter_alive(self):
861 return list(six.itervalues(self._alive))857 return list(self._alive.values())
862858
863 def _enable_change_notification(self, obj_info):859 def _enable_change_notification(self, obj_info):
864 obj_info.event.emit("start-tracking-changes", self._event)860 obj_info.event.emit("start-tracking-changes", self._event)
@@ -1012,7 +1008,7 @@
1012 L{ResultSet} will be returned appropriately modified with1008 L{ResultSet} will be returned appropriately modified with
1013 C{OFFSET} and C{LIMIT} clauses.1009 C{OFFSET} and C{LIMIT} clauses.
1014 """1010 """
1015 if isinstance(index, six.integer_types):1011 if isinstance(index, int):
1016 if index == 0:1012 if index == 0:
1017 result_set = self1013 result_set = self
1018 else:1014 else:
@@ -1411,7 +1407,7 @@
1411 for column in changes:1407 for column in changes:
1412 obj_info.variables[column].set(AutoReload)1408 obj_info.variables[column].set(AutoReload)
1413 else:1409 else:
1414 changes = list(six.iteritems(changes))1410 changes = list(changes.items())
1415 for obj in cached:1411 for obj in cached:
1416 for column, value in changes:1412 for column, value in changes:
1417 variables = get_obj_info(obj).variables1413 variables = get_obj_info(obj).variables
14181414
=== modified file 'storm/testing.py'
--- storm/testing.py 2020-05-26 15:55:53 +0000
+++ storm/testing.py 2024-03-04 10:59:33 +0000
@@ -1,5 +1,3 @@
1from __future__ import print_function
2
3from fixtures import Fixture1from fixtures import Fixture
42
5from storm.tracer import BaseStatementTracer, install_tracer, remove_tracer3from storm.tracer import BaseStatementTracer, install_tracer, remove_tracer
64
=== modified file 'storm/tests/__init__.py'
--- storm/tests/__init__.py 2020-05-26 10:28:24 +0000
+++ storm/tests/__init__.py 2024-03-04 10:59:33 +0000
@@ -19,8 +19,6 @@
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/>.
20#20#
2121
22from __future__ import print_function
23
24__all__ = [22__all__ = [
25 'find_tests',23 'find_tests',
26 'has_fixtures',24 'has_fixtures',
@@ -116,7 +114,6 @@
116 os.path.basename(relpath),114 os.path.basename(relpath),
117 module_relative=True,115 module_relative=True,
118 package=parent_module,116 package=parent_module,
119 globs={"print_function": print_function},
120 optionflags=doctest.ELLIPSIS))117 optionflags=doctest.ELLIPSIS))
121118
122 return suite119 return suite
123120
=== modified file 'storm/tests/base.py'
--- storm/tests/base.py 2019-11-21 16:06:52 +0000
+++ storm/tests/base.py 2024-03-04 10:59:33 +0000
@@ -18,8 +18,6 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23import weakref21import weakref
24import gc22import gc
2523
2624
=== modified file 'storm/tests/cache.py'
--- storm/tests/cache.py 2019-11-21 16:06:52 +0000
+++ storm/tests/cache.py 2024-03-04 10:59:33 +0000
@@ -1,5 +1,3 @@
1from __future__ import print_function
2
3from unittest import defaultTestLoader1from unittest import defaultTestLoader
42
5from storm.properties import Int3from storm.properties import Int
64
=== modified file 'storm/tests/database.py'
--- storm/tests/database.py 2019-11-21 16:06:52 +0000
+++ storm/tests/database.py 2024-03-04 10:59:33 +0000
@@ -18,8 +18,6 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23import sys21import sys
24import types22import types
25import gc23import gc
2624
=== modified file 'storm/tests/databases/base.py'
--- storm/tests/databases/base.py 2021-04-06 09:23:02 +0000
+++ storm/tests/databases/base.py 2024-03-04 10:59:33 +0000
@@ -20,16 +20,12 @@
20# You should have received a copy of the GNU Lesser General Public License20# You should have received a copy of the GNU Lesser General Public License
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/>.
22#22#
23from __future__ import print_function
24
25from datetime import datetime, date, time, timedelta23from datetime import datetime, date, time, timedelta
24import pickle
26import shutil25import shutil
27import sys26import sys
28import os27import os
2928
30import six
31from six.moves import cPickle as pickle
32
33from storm.uri import URI29from storm.uri import URI
34from storm.expr import Select, Column, SQLToken, SQLRaw, Count, Alias30from storm.expr import Select, Column, SQLToken, SQLRaw, Count, Alias
35from storm.variables import (Variable, PickleVariable, BytesVariable,31from storm.variables import (Variable, PickleVariable, BytesVariable,
@@ -152,7 +148,7 @@
152 self.assertTrue(isinstance(result, Result))148 self.assertTrue(isinstance(result, Result))
153 row = result.get_one()149 row = result.get_one()
154 self.assertEqual(row, ("Title 10",))150 self.assertEqual(row, ("Title 10",))
155 self.assertTrue(isinstance(row[0], six.text_type))151 self.assertTrue(isinstance(row[0], str))
156152
157 def test_execute_params(self):153 def test_execute_params(self):
158 result = self.connection.execute("SELECT one FROM number "154 result = self.connection.execute("SELECT one FROM number "
159155
=== modified file 'storm/tests/databases/mysql.py'
--- storm/tests/databases/mysql.py 2021-05-13 23:02:23 +0000
+++ storm/tests/databases/mysql.py 2024-03-04 10:59:33 +0000
@@ -18,11 +18,8 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23import os21import os
2422from urllib.parse import urlunsplit
25from six.moves.urllib.parse import urlunsplit
2623
27from storm.databases.mysql import MySQL24from storm.databases.mysql import MySQL
28from storm.database import create_database25from storm.database import create_database
2926
=== modified file 'storm/tests/databases/postgres.py'
--- storm/tests/databases/postgres.py 2020-02-10 15:30:23 +0000
+++ storm/tests/databases/postgres.py 2024-03-04 10:59:33 +0000
@@ -18,14 +18,10 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23from datetime import date, time, timedelta21from datetime import date, time, timedelta
24import os22import os
25import json23import json
2624from urllib.parse import urlunsplit
27import six
28from six.moves.urllib.parse import urlunsplit
2925
30from storm.databases.postgres import (26from storm.databases.postgres import (
31 Postgres, compile, currval, Returning, Case, PostgresTimeoutTracer,27 Postgres, compile, currval, Returning, Case, PostgresTimeoutTracer,
@@ -171,7 +167,7 @@
171 result = connection.execute("SELECT title FROM test WHERE id=1")167 result = connection.execute("SELECT title FROM test WHERE id=1")
172 title = result.get_one()[0]168 title = result.get_one()[0]
173169
174 self.assertTrue(isinstance(title, six.text_type))170 self.assertTrue(isinstance(title, str))
175 self.assertEqual(title, uni_str)171 self.assertEqual(title, uni_str)
176172
177 def test_unicode_array(self):173 def test_unicode_array(self):
@@ -695,11 +691,8 @@
695691
696 connection = self.database.connect()692 connection = self.database.connect()
697 value = {"a": 3, "b": "foo", "c": None}693 value = {"a": 3, "b": "foo", "c": None}
698 db_value = json.dumps(value)
699 if six.PY2:
700 db_value = db_value.decode("utf-8")
701 connection.execute(694 connection.execute(
702 "INSERT INTO json_test (json) VALUES (?)", (db_value,))695 "INSERT INTO json_test (json) VALUES (?)", (json.dumps(value),))
703 connection.commit()696 connection.commit()
704697
705 store = Store(self.database)698 store = Store(self.database)
706699
=== modified file 'storm/tests/databases/proxy.py'
--- storm/tests/databases/proxy.py 2019-09-29 14:05:31 +0000
+++ storm/tests/databases/proxy.py 2024-03-04 10:59:33 +0000
@@ -20,17 +20,13 @@
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/>.
21#21#
2222
23from __future__ import print_function
24
25import errno23import errno
26import os24import os
27import select25import select
28import socket26import socket
27import socketserver
29import threading28import threading
3029
31import six
32from six.moves import socketserver
33
3430
35TIMEOUT = 0.131TIMEOUT = 0.1
3632
@@ -44,7 +40,7 @@
44 self, request, client_address, server)40 self, request, client_address, server)
4541
46 def handle(self):42 def handle(self):
47 if isinstance(self.server.proxy_dest, (bytes, six.text_type)):43 if isinstance(self.server.proxy_dest, (bytes, str)):
48 dst = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)44 dst = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
49 else:45 else:
50 dst = socket.socket(socket.AF_INET, socket.SOCK_STREAM)46 dst = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
5147
=== modified file 'storm/tests/databases/sqlite.py'
--- storm/tests/databases/sqlite.py 2019-11-21 16:06:52 +0000
+++ storm/tests/databases/sqlite.py 2024-03-04 10:59:33 +0000
@@ -18,8 +18,6 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23from datetime import timedelta21from datetime import timedelta
24import time22import time
25import os23import os
2624
=== modified file 'storm/tests/event.py'
--- storm/tests/event.py 2019-11-21 16:06:52 +0000
+++ storm/tests/event.py 2024-03-04 10:59:33 +0000
@@ -18,8 +18,6 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23from storm.event import EventSystem21from storm.event import EventSystem
24from storm.tests.helper import TestHelper22from storm.tests.helper import TestHelper
2523
2624
=== modified file 'storm/tests/expr.py'
--- storm/tests/expr.py 2023-12-07 17:04:46 +0000
+++ storm/tests/expr.py 2024-03-04 10:59:33 +0000
@@ -18,12 +18,7 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23from decimal import Decimal21from decimal import Decimal
24import unittest
25
26import six
2722
28from storm.variables import *23from storm.variables import *
29from storm.expr import *24from storm.expr import *
@@ -625,14 +620,6 @@
625 self.assertEqual(statement, "?")620 self.assertEqual(statement, "?")
626 self.assertVariablesEqual(state.parameters, [IntVariable(1)])621 self.assertVariablesEqual(state.parameters, [IntVariable(1)])
627622
628 @unittest.skipUnless(six.PY2, "Python 3 has no separate long type")
629 def test_long(self):
630 state = State()
631 # 1L was more idiomatic in Python 2, but is a syntax error in Python 3.
632 statement = compile(long(1), state)
633 self.assertEqual(statement, "?")
634 self.assertVariablesEqual(state.parameters, [IntVariable(1)])
635
636 def test_bool(self):623 def test_bool(self):
637 state = State()624 state = State()
638 statement = compile(True, state)625 statement = compile(True, state)
@@ -2254,22 +2241,16 @@
22542241
2255 def test_bytes(self):2242 def test_bytes(self):
2256 py_expr = compile_python(b"str")2243 py_expr = compile_python(b"str")
2257 self.assertEqual(py_expr, "b'str'" if six.PY3 else "'str'")2244 self.assertEqual(py_expr, "b'str'")
22582245
2259 def test_unicode(self):2246 def test_unicode(self):
2260 py_expr = compile_python(u"str")2247 py_expr = compile_python(u"str")
2261 self.assertEqual(py_expr, "'str'" if six.PY3 else "u'str'")2248 self.assertEqual(py_expr, "'str'")
22622249
2263 def test_int(self):2250 def test_int(self):
2264 py_expr = compile_python(1)2251 py_expr = compile_python(1)
2265 self.assertEqual(py_expr, "1")2252 self.assertEqual(py_expr, "1")
22662253
2267 @unittest.skipUnless(six.PY2, "Python 3 has no separate long type")
2268 def test_long(self):
2269 # 1L was more idiomatic in Python 2, but is a syntax error in Python 3.
2270 py_expr = compile_python(long(1))
2271 self.assertEqual(py_expr, "1L")
2272
2273 def test_bool(self):2254 def test_bool(self):
2274 state = State()2255 state = State()
2275 py_expr = compile_python(True, state)2256 py_expr = compile_python(True, state)
22762257
=== modified file 'storm/tests/helper.py'
--- storm/tests/helper.py 2019-11-21 16:06:52 +0000
+++ storm/tests/helper.py 2024-03-04 10:59:33 +0000
@@ -18,14 +18,11 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function21from io import StringIO
22
23import tempfile
24import logging22import logging
25import shutil23import shutil
26import sys24import sys
2725import tempfile
28from six.moves import cStringIO as StringIO
2926
30from storm.tests import mocker27from storm.tests import mocker
3128
3229
=== modified file 'storm/tests/info.py'
--- storm/tests/info.py 2019-11-21 16:06:52 +0000
+++ storm/tests/info.py 2024-03-04 10:59:33 +0000
@@ -18,13 +18,9 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23from weakref import ref21from weakref import ref
24import gc22import gc
2523
26import six
27
28from storm.exceptions import ClassInfoError24from storm.exceptions import ClassInfoError
29from storm.properties import Property25from storm.properties import Property
30from storm.variables import Variable26from storm.variables import Variable
@@ -572,7 +568,7 @@
572 cls = type.__new__(meta_cls, name, bases, dict)568 cls = type.__new__(meta_cls, name, bases, dict)
573 cls.__storm_table__ = "HAH! GOTCH YA!"569 cls.__storm_table__ = "HAH! GOTCH YA!"
574 return cls570 return cls
575 class Class(six.with_metaclass(MetaClass, object)):571 class Class(metaclass=MetaClass):
576 __storm_table__ = "table"572 __storm_table__ = "table"
577 prop1 = Property("column1", primary=True)573 prop1 = Property("column1", primary=True)
578 Alias = ClassAlias(Class, "USE_THIS")574 Alias = ClassAlias(Class, "USE_THIS")
579575
=== modified file 'storm/tests/mocker.py'
--- storm/tests/mocker.py 2022-03-16 16:59:21 +0000
+++ storm/tests/mocker.py 2024-03-04 10:59:33 +0000
@@ -3,8 +3,7 @@
33
4Graceful platform for test doubles in Python (mocks, stubs, fakes, and dummies).4Graceful platform for test doubles in Python (mocks, stubs, fakes, and dummies).
5"""5"""
6from __future__ import print_function6import builtins
7
8import tempfile7import tempfile
9import unittest8import unittest
10import inspect9import inspect
@@ -13,9 +12,6 @@
13import os12import os
14import gc13import gc
1514
16import six
17from six.moves import builtins
18
1915
20__all__ = ["Mocker", "expect", "IS", "CONTAINS", "IN", "MATCH",16__all__ = ["Mocker", "expect", "IS", "CONTAINS", "IN", "MATCH",
21 "ANY", "ARGS", "KWARGS"]17 "ANY", "ARGS", "KWARGS"]
@@ -336,7 +332,7 @@
336 self._recorders = list(getattr(self, "_recorders", ()))332 self._recorders = list(getattr(self, "_recorders", ()))
337333
338334
339class MockerBase(six.with_metaclass(MockerMeta, object)):335class MockerBase(metaclass=MockerMeta):
340 """Controller of mock objects.336 """Controller of mock objects.
341337
342 A mocker instance is used to command recording and replay of338 A mocker instance is used to command recording and replay of
@@ -563,7 +559,7 @@
563 explicitly requested via the L{passthrough()}559 explicitly requested via the L{passthrough()}
564 method.560 method.
565 """561 """
566 if isinstance(object, six.string_types):562 if isinstance(object, str):
567 if name is None:563 if name is None:
568 name = object564 name = object
569 import_stack = object.split(".")565 import_stack = object.split(".")
@@ -1096,9 +1092,6 @@
1096 except MatchError as e:1092 except MatchError as e:
1097 return True1093 return True
10981094
1099 if six.PY2:
1100 __nonzero__ = __bool__
1101
1102 def __iter__(self):1095 def __iter__(self):
1103 # XXX On py3k, when next() becomes __next__(), we'll be able1096 # XXX On py3k, when next() becomes __next__(), we'll be able
1104 # to return the mock itself because it will be considered1097 # to return the mock itself because it will be considered
@@ -1119,13 +1112,13 @@
1119 frame = sys._getframe(depth+1)1112 frame = sys._getframe(depth+1)
1120 except:1113 except:
1121 return None1114 return None
1122 for name, frame_obj in six.iteritems(frame.f_locals):1115 for name, frame_obj in frame.f_locals.items():
1123 if frame_obj is obj:1116 if frame_obj is obj:
1124 return name1117 return name
1125 self = frame.f_locals.get("self")1118 self = frame.f_locals.get("self")
1126 if self is not None:1119 if self is not None:
1127 try:1120 try:
1128 items = list(six.iteritems(self.__dict__))1121 items = list(self.__dict__.items())
1129 except:1122 except:
1130 pass1123 pass
1131 else:1124 else:
@@ -1274,7 +1267,7 @@
1274 result = "del %s.%s" % (result, action.args[0])1267 result = "del %s.%s" % (result, action.args[0])
1275 elif action.kind == "call":1268 elif action.kind == "call":
1276 args = [repr(x) for x in action.args]1269 args = [repr(x) for x in action.args]
1277 items = list(six.iteritems(action.kwargs))1270 items = list(action.kwargs.items())
1278 items.sort()1271 items.sort()
1279 for pair in items:1272 for pair in items:
1280 args.append("%s=%r" % pair)1273 args.append("%s=%r" % pair)
@@ -1394,7 +1387,7 @@
13941387
1395 # Either we have the same number of kwargs, or unknown keywords are1388 # Either we have the same number of kwargs, or unknown keywords are
1396 # accepted (KWARGS was used), so check just the ones in kwargs1.1389 # accepted (KWARGS was used), so check just the ones in kwargs1.
1397 for key, arg1 in six.iteritems(kwargs1):1390 for key, arg1 in kwargs1.items():
1398 if key not in kwargs2:1391 if key not in kwargs2:
1399 return False1392 return False
1400 arg2 = kwargs2[key]1393 arg2 = kwargs2[key]
@@ -1834,45 +1827,30 @@
18341827
1835 if method:1828 if method:
1836 try:1829 try:
1837 if six.PY3:1830 # On Python 3, inspect.getargspec includes the bound first
1838 # On Python 3, inspect.getargspec includes the bound1831 # argument (self or similar) for bound methods, which
1839 # first argument (self or similar) for bound methods,1832 # confuses matters. The modern signature API doesn't have
1840 # which confuses matters. The modern signature API1833 # this problem.
1841 # doesn't have this problem.1834 self._signature = inspect.signature(method)
1842 self._signature = inspect.signature(method)1835 # Method descriptors don't have the first argument already
1843 # Method descriptors don't have the first argument1836 # bound, but we want to skip it anyway.
1844 # already bound, but we want to skip it anyway.1837 if getattr(method, "__objclass__", None) is not None:
1845 if getattr(method, "__objclass__", None) is not None:1838 parameters = list(self._signature.parameters.values())
1846 parameters = list(self._signature.parameters.values())1839 # This is positional-only for unbound methods that are
1847 # This is positional-only for unbound methods that1840 # implemented in C.
1848 # are implemented in C.1841 if (parameters[0].kind ==
1849 if (parameters[0].kind ==1842 inspect.Parameter.POSITIONAL_ONLY):
1850 inspect.Parameter.POSITIONAL_ONLY):1843 self._signature = self._signature.replace(
1851 self._signature = self._signature.replace(1844 parameters=parameters[1:])
1852 parameters=parameters[1:])
1853 else:
1854 (self._args, self._varargs, self._varkwargs,
1855 self._defaults) = inspect.getargspec(method)
1856 except TypeError:1845 except TypeError:
1857 self._unsupported = True1846 self._unsupported = True
1858 else:
1859 if not six.PY3:
1860 if self._defaults is None:
1861 self._defaults = ()
1862 if type(method) is type(self.run):
1863 self._args = self._args[1:]
18641847
1865 def get_method(self):1848 def get_method(self):
1866 return self._method1849 return self._method
18671850
1868 def _raise(self, message):1851 def _raise(self, message):
1869 if six.PY3:
1870 spec = str(self._signature)
1871 else:
1872 spec = inspect.formatargspec(self._args, self._varargs,
1873 self._varkwargs, self._defaults)
1874 raise AssertionError("Specification is %s%s: %s" %1852 raise AssertionError("Specification is %s%s: %s" %
1875 (self._method.__name__, spec, message))1853 (self._method.__name__, self._signature, message))
18761854
1877 def verify(self):1855 def verify(self):
1878 if not self._method:1856 if not self._method:
@@ -1891,26 +1869,10 @@
1891 if self._unsupported:1869 if self._unsupported:
1892 return # Can't check it. Happens with builtin functions. :-(1870 return # Can't check it. Happens with builtin functions. :-(
1893 action = path.actions[-1]1871 action = path.actions[-1]
1894 if six.PY3:1872 try:
1895 try:1873 self._signature.bind(*action.args, **action.kwargs)
1896 self._signature.bind(*action.args, **action.kwargs)1874 except TypeError as e:
1897 except TypeError as e:1875 self._raise(str(e))
1898 self._raise(str(e))
1899 else:
1900 obtained_len = len(action.args)
1901 obtained_kwargs = action.kwargs.copy()
1902 nodefaults_len = len(self._args) - len(self._defaults)
1903 for i, name in enumerate(self._args):
1904 if i < obtained_len and name in action.kwargs:
1905 self._raise("%r provided twice" % name)
1906 if (i >= obtained_len and i < nodefaults_len and
1907 name not in action.kwargs):
1908 self._raise("%r not provided" % name)
1909 obtained_kwargs.pop(name, None)
1910 if obtained_len > len(self._args) and not self._varargs:
1911 self._raise("too many args provided")
1912 if obtained_kwargs and not self._varkwargs:
1913 self._raise("unknown kwargs: %s" % ", ".join(obtained_kwargs))
19141876
1915def spec_checker_recorder(mocker, event):1877def spec_checker_recorder(mocker, event):
1916 spec = event.path.root_mock.__mocker_spec__1878 spec = event.path.root_mock.__mocker_spec__
@@ -1951,7 +1913,7 @@
1951 for referrer in gc.get_referrers(remove):1913 for referrer in gc.get_referrers(remove):
1952 if (type(referrer) is dict and1914 if (type(referrer) is dict and
1953 referrer.get("__mocker_replace__", True)):1915 referrer.get("__mocker_replace__", True)):
1954 for key, value in list(six.iteritems(referrer)):1916 for key, value in list(referrer.items()):
1955 if value is remove:1917 if value is remove:
1956 referrer[key] = install1918 referrer[key] = install
19571919
@@ -2023,7 +1985,7 @@
2023 for kind in self._monitored:1985 for kind in self._monitored:
2024 attr = self._get_kind_attr(kind)1986 attr = self._get_kind_attr(kind)
2025 seen = set()1987 seen = set()
2026 for obj in six.itervalues(self._monitored[kind]):1988 for obj in self._monitored[kind].values():
2027 cls = type(obj)1989 cls = type(obj)
2028 if issubclass(cls, type):1990 if issubclass(cls, type):
2029 cls = obj1991 cls = obj
@@ -2037,7 +1999,7 @@
2037 self.execute)1999 self.execute)
20382000
2039 def restore(self):2001 def restore(self):
2040 for obj, attr, original in six.itervalues(self._patched):2002 for obj, attr, original in self._patched.values():
2041 if original is Undefined:2003 if original is Undefined:
2042 delattr(obj, attr)2004 delattr(obj, attr)
2043 else:2005 else:
20442006
=== modified file 'storm/tests/properties.py'
--- storm/tests/properties.py 2022-03-16 16:59:21 +0000
+++ storm/tests/properties.py 2024-03-04 10:59:33 +0000
@@ -18,16 +18,12 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23from datetime import datetime, date, time, timedelta21from datetime import datetime, date, time, timedelta
24from decimal import Decimal as decimal22from decimal import Decimal as decimal
25import gc23import gc
24import json
26import uuid25import uuid
2726
28import six
29
30from storm.compat import json
31from storm.exceptions import NoneError, PropertyPathError27from storm.exceptions import NoneError, PropertyPathError
32from storm.properties import PropertyPublisherMeta28from storm.properties import PropertyPublisherMeta
33from storm.properties import *29from storm.properties import *
@@ -996,7 +992,7 @@
996 def setUp(self):992 def setUp(self):
997 TestHelper.setUp(self)993 TestHelper.setUp(self)
998994
999 class Base(six.with_metaclass(PropertyPublisherMeta, object)):995 class Base(metaclass=PropertyPublisherMeta):
1000 pass996 pass
1001997
1002 class Class(Base):998 class Class(Base):
1003999
=== modified file 'storm/tests/schema/patch.py'
--- storm/tests/schema/patch.py 2019-11-21 16:06:52 +0000
+++ storm/tests/schema/patch.py 2024-03-04 10:59:33 +0000
@@ -18,8 +18,6 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23import os21import os
24import shutil22import shutil
25import sys23import sys
2624
=== modified file 'storm/tests/schema/schema.py'
--- storm/tests/schema/schema.py 2019-11-21 16:06:52 +0000
+++ storm/tests/schema/schema.py 2024-03-04 10:59:33 +0000
@@ -18,8 +18,6 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23import os21import os
24import sys22import sys
2523
2624
=== modified file 'storm/tests/schema/sharding.py'
--- storm/tests/schema/sharding.py 2019-08-11 17:51:37 +0000
+++ storm/tests/schema/sharding.py 2024-03-04 10:59:33 +0000
@@ -18,8 +18,6 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23from storm.schema.schema import SchemaMissingError, UnappliedPatchesError21from storm.schema.schema import SchemaMissingError, UnappliedPatchesError
24from storm.schema.sharding import Sharding, PatchLevelMismatchError22from storm.schema.sharding import Sharding, PatchLevelMismatchError
25from storm.tests.mocker import MockerTestCase23from storm.tests.mocker import MockerTestCase
2624
=== modified file 'storm/tests/sqlobject.py'
--- storm/tests/sqlobject.py 2019-11-21 16:06:52 +0000
+++ storm/tests/sqlobject.py 2024-03-04 10:59:33 +0000
@@ -18,13 +18,9 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23import datetime21import datetime
24import operator22import operator
2523
26import six
27
28from storm.database import create_database24from storm.database import create_database
29from storm.exceptions import NoneError25from storm.exceptions import NoneError
30from storm.sqlobject import *26from storm.sqlobject import *
@@ -124,7 +120,7 @@
124 _defaultOrder = "-Person.name"120 _defaultOrder = "-Person.name"
125 _table = "person"121 _table = "person"
126 _idName = "name"122 _idName = "name"
127 _idType = six.text_type123 _idType = str
128 age = IntCol()124 age = IntCol()
129 ts = UtcDateTimeCol()125 ts = UtcDateTimeCol()
130126
@@ -822,12 +818,8 @@
822 """818 """
823 result = self.Person.select()819 result = self.Person.select()
824 self.assertEqual(result.__bool__(), True)820 self.assertEqual(result.__bool__(), True)
825 if six.PY2:
826 self.assertEqual(result.__nonzero__(), True)
827 result = self.Person.select(self.Person.q.name == "No Person")821 result = self.Person.select(self.Person.q.name == "No Person")
828 self.assertEqual(result.__bool__(), False)822 self.assertEqual(result.__bool__(), False)
829 if six.PY2:
830 self.assertEqual(result.__nonzero__(), False)
831823
832 def test_result_set_is_empty(self):824 def test_result_set_is_empty(self):
833 """825 """
@@ -1190,7 +1182,7 @@
1190 # properties:1182 # properties:
1191 class Person(self.SQLObject):1183 class Person(self.SQLObject):
1192 _idName = "name"1184 _idName = "name"
1193 _idType = six.text_type1185 _idType = str
1194 address = ForeignKey(foreignKey="Phone", dbName="address_id",1186 address = ForeignKey(foreignKey="Phone", dbName="address_id",
1195 notNull=True)1187 notNull=True)
11961188
11971189
=== modified file 'storm/tests/store/base.py'
--- storm/tests/store/base.py 2021-05-13 23:02:23 +0000
+++ storm/tests/store/base.py 2024-03-04 10:59:33 +0000
@@ -20,17 +20,14 @@
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/>.
21#21#
2222
23from __future__ import print_function
24
25import decimal23import decimal
26import gc24import gc
25from io import StringIO
27import operator26import operator
27import pickle
28from uuid import uuid428from uuid import uuid4
29import weakref29import weakref
3030
31import six
32from six.moves import cPickle as pickle, cStringIO as StringIO
33
34from storm.references import Reference, ReferenceSet, Proxy31from storm.references import Reference, ReferenceSet, Proxy
35from storm.database import Result, STATE_DISCONNECTED32from storm.database import Result, STATE_DISCONNECTED
36from storm.properties import (33from storm.properties import (
@@ -1053,7 +1050,7 @@
1053 def test_find_max_unicode(self):1050 def test_find_max_unicode(self):
1054 title = self.store.find(Foo).max(Foo.title)1051 title = self.store.find(Foo).max(Foo.title)
1055 self.assertEqual(title, "Title 30")1052 self.assertEqual(title, "Title 30")
1056 self.assertTrue(isinstance(title, six.text_type))1053 self.assertTrue(isinstance(title, str))
10571054
1058 def test_find_max_with_empty_result_and_disallow_none(self):1055 def test_find_max_with_empty_result_and_disallow_none(self):
1059 class Bar(object):1056 class Bar(object):
@@ -1074,7 +1071,7 @@
1074 def test_find_min_unicode(self):1071 def test_find_min_unicode(self):
1075 title = self.store.find(Foo).min(Foo.title)1072 title = self.store.find(Foo).min(Foo.title)
1076 self.assertEqual(title, "Title 10")1073 self.assertEqual(title, "Title 10")
1077 self.assertTrue(isinstance(title, six.text_type))1074 self.assertTrue(isinstance(title, str))
10781075
1079 def test_find_min_with_empty_result_and_disallow_none(self):1076 def test_find_min_with_empty_result_and_disallow_none(self):
1080 class Bar(object):1077 class Bar(object):
@@ -1157,8 +1154,7 @@
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)
1158 values = list(values)1155 values = list(values)
1159 self.assertEqual(values, ["Title 30", "Title 20", "Title 10"])1156 self.assertEqual(values, ["Title 30", "Title 20", "Title 10"])
1160 self.assertEqual([type(value) for value in values],1157 self.assertEqual([type(value) for value in values], [str, str, str])
1161 [six.text_type, six.text_type, six.text_type])
11621158
1163 def test_find_multiple_values(self):1159 def test_find_multiple_values(self):
1164 result = self.store.find(Foo).order_by(Foo.id)1160 result = self.store.find(Foo).order_by(Foo.id)
@@ -4532,7 +4528,7 @@
4532 self.assertRaises(NoStoreError, foo2.bars.remove, object())4528 self.assertRaises(NoStoreError, foo2.bars.remove, object())
45334529
4534 def test_string_reference(self):4530 def test_string_reference(self):
4535 class Base(six.with_metaclass(PropertyPublisherMeta, object)):4531 class Base(metaclass=PropertyPublisherMeta):
4536 pass4532 pass
45374533
4538 class MyBar(Base):4534 class MyBar(Base):
@@ -4559,7 +4555,7 @@
4559 metaclass. This makes it possible to work around problems with4555 metaclass. This makes it possible to work around problems with
4560 circular dependencies by delaying property resolution.4556 circular dependencies by delaying property resolution.
4561 """4557 """
4562 class Base(six.with_metaclass(PropertyPublisherMeta, object)):4558 class Base(metaclass=PropertyPublisherMeta):
4563 pass4559 pass
45644560
4565 class MyFoo(Base):4561 class MyFoo(Base):
@@ -4599,7 +4595,7 @@
4599 metaclass. This makes it possible to work around problems with4595 metaclass. This makes it possible to work around problems with
4600 circular dependencies by delaying resolution of the order by column.4596 circular dependencies by delaying resolution of the order by column.
4601 """4597 """
4602 class Base(six.with_metaclass(PropertyPublisherMeta, object)):4598 class Base(metaclass=PropertyPublisherMeta):
4603 pass4599 pass
46044600
4605 class MyFoo(Base):4601 class MyFoo(Base):
@@ -5024,7 +5020,7 @@
5024 foo = self.store.get(DictFoo, 20)5020 foo = self.store.get(DictFoo, 20)
5025 foo["a"] = 15021 foo["a"] = 1
50265022
5027 self.assertEqual(list(six.iteritems(foo)), [("a", 1)])5023 self.assertEqual(list(foo.items()), [("a", 1)])
50285024
5029 new_obj = DictFoo()5025 new_obj = DictFoo()
5030 new_obj.id = 405026 new_obj.id = 40
@@ -5358,7 +5354,7 @@
5358 self.store.add(foo)5354 self.store.add(foo)
5359 foo.id = AutoReload5355 foo.id = AutoReload
5360 foo.title = u"New Title"5356 foo.title = u"New Title"
5361 self.assertTrue(isinstance(foo.id, six.integer_types))5357 self.assertTrue(isinstance(foo.id, int))
5362 self.assertEqual(foo.title, "New Title")5358 self.assertEqual(foo.title, "New Title")
53635359
5364 def test_autoreload_primary_key_doesnt_reload_everything_else(self):5360 def test_autoreload_primary_key_doesnt_reload_everything_else(self):
@@ -5868,7 +5864,7 @@
5868 self.assertEqual(foo.title, "New Title")5864 self.assertEqual(foo.title, "New Title")
58695865
5870 def get_bar_proxy_with_string(self):5866 def get_bar_proxy_with_string(self):
5871 class Base(six.with_metaclass(PropertyPublisherMeta, object)):5867 class Base(metaclass=PropertyPublisherMeta):
5872 pass5868 pass
58735869
5874 class MyBarProxy(Base):5870 class MyBarProxy(Base):
@@ -6037,7 +6033,7 @@
6037 try:6033 try:
6038 self.assertEqual(myfoo.title, title)6034 self.assertEqual(myfoo.title, title)
6039 except AssertionError as e:6035 except AssertionError as e:
6040 raise AssertionError(six.text_type(e, 'replace') +6036 raise AssertionError(str(e, 'replace') +
6041 " (ensure your database was created with CREATE DATABASE"6037 " (ensure your database was created with CREATE DATABASE"
6042 " ... CHARACTER SET utf8mb3)")6038 " ... CHARACTER SET utf8mb3)")
60436039
60446040
=== modified file 'storm/tests/store/mysql.py'
--- storm/tests/store/mysql.py 2021-04-06 09:23:02 +0000
+++ storm/tests/store/mysql.py 2024-03-04 10:59:33 +0000
@@ -18,8 +18,6 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23import os21import os
2422
25from storm.database import create_database23from storm.database import create_database
2624
=== modified file 'storm/tests/store/postgres.py'
--- storm/tests/store/postgres.py 2019-11-21 16:06:52 +0000
+++ storm/tests/store/postgres.py 2024-03-04 10:59:33 +0000
@@ -18,8 +18,6 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23import os21import os
24import gc22import gc
2523
2624
=== modified file 'storm/tests/store/sqlite.py'
--- storm/tests/store/sqlite.py 2019-08-11 17:51:37 +0000
+++ storm/tests/store/sqlite.py 2024-03-04 10:59:33 +0000
@@ -18,8 +18,6 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23from storm.databases.sqlite import SQLite21from storm.databases.sqlite import SQLite
24from storm.uri import URI22from storm.uri import URI
25from storm.tests.store.base import StoreTest, EmptyResultSetTest23from storm.tests.store.base import StoreTest, EmptyResultSetTest
2624
=== modified file 'storm/tests/tracer.py'
--- storm/tests/tracer.py 2019-11-21 16:06:52 +0000
+++ storm/tests/tracer.py 2024-03-04 10:59:33 +0000
@@ -1,5 +1,3 @@
1from __future__ import print_function
2
3import datetime1import datetime
4import os2import os
5import sys3import sys
64
=== modified file 'storm/tests/twisted/__init__.py'
--- storm/tests/twisted/__init__.py 2019-06-05 11:41:07 +0000
+++ storm/tests/twisted/__init__.py 2024-03-04 10:59:33 +0000
@@ -1,5 +1,3 @@
1from __future__ import print_function
2
3__all__ = [1__all__ = [
4 'has_twisted',2 'has_twisted',
5 ]3 ]
64
=== modified file 'storm/tests/twisted/transact.py'
--- storm/tests/twisted/transact.py 2019-08-11 17:51:37 +0000
+++ storm/tests/twisted/transact.py 2024-03-04 10:59:33 +0000
@@ -1,5 +1,3 @@
1from __future__ import print_function
2
3from storm.tests import has_psycopg1from storm.tests import has_psycopg
4from storm.tests.helper import TestHelper2from storm.tests.helper import TestHelper
5from storm.tests.zope import has_transaction, has_zope_component3from storm.tests.zope import has_transaction, has_zope_component
64
=== modified file 'storm/tests/uri.py'
--- storm/tests/uri.py 2019-11-21 16:06:52 +0000
+++ storm/tests/uri.py 2024-03-04 10:59:33 +0000
@@ -18,8 +18,6 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23from storm.uri import URI, URIError21from storm.uri import URI, URIError
24from storm.tests.helper import TestHelper22from storm.tests.helper import TestHelper
2523
2624
=== modified file 'storm/tests/variables.py'
--- storm/tests/variables.py 2022-03-16 16:59:21 +0000
+++ storm/tests/variables.py 2024-03-04 10:59:33 +0000
@@ -18,18 +18,14 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23from datetime import datetime, date, time, timedelta21from datetime import datetime, date, time, timedelta
24from decimal import Decimal22from decimal import Decimal
25import gc23import gc
24import json
25import pickle
26import weakref26import weakref
27import uuid27import uuid
2828
29import six
30from six.moves import cPickle as pickle
31
32from storm.compat import json
33from storm.exceptions import NoneError29from storm.exceptions import NoneError
34from storm.variables import *30from storm.variables import *
35from storm.event import EventSystem31from storm.event import EventSystem
@@ -463,8 +459,7 @@
463 variable = BytesVariable()459 variable = BytesVariable()
464 variable.set(b"str")460 variable.set(b"str")
465 self.assertEqual(variable.get(), b"str")461 self.assertEqual(variable.get(), b"str")
466 buffer_type = memoryview if six.PY3 else buffer462 variable.set(memoryview(b"buffer"))
467 variable.set(buffer_type(b"buffer"))
468 self.assertEqual(variable.get(), b"buffer")463 self.assertEqual(variable.get(), b"buffer")
469 self.assertRaises(TypeError, variable.set, u"unicode")464 self.assertRaises(TypeError, variable.set, u"unicode")
470465
@@ -487,18 +482,13 @@
487 self.assertEqual(variable.get(), epoch)482 self.assertEqual(variable.get(), epoch)
488 variable.set(0.0)483 variable.set(0.0)
489 self.assertEqual(variable.get(), epoch)484 self.assertEqual(variable.get(), epoch)
490 if six.PY2:
491 # 1L was more idiomatic in Python 2, but is a syntax error in
492 # Python 3.
493 variable.set(long(0))
494 self.assertEqual(variable.get(), epoch)
495 variable.set(epoch)485 variable.set(epoch)
496 self.assertEqual(variable.get(), epoch)486 self.assertEqual(variable.get(), epoch)
497 self.assertRaises(TypeError, variable.set, marker)487 self.assertRaises(TypeError, variable.set, marker)
498488
499 def test_get_set_from_database(self):489 def test_get_set_from_database(self):
500 datetime_str = "1977-05-04 12:34:56.78"490 datetime_str = "1977-05-04 12:34:56.78"
501 datetime_uni = six.text_type(datetime_str)491 datetime_uni = str(datetime_str)
502 datetime_obj = datetime(1977, 5, 4, 12, 34, 56, 780000)492 datetime_obj = datetime(1977, 5, 4, 12, 34, 56, 780000)
503493
504 variable = DateTimeVariable()494 variable = DateTimeVariable()
@@ -511,7 +501,7 @@
511 self.assertEqual(variable.get(), datetime_obj)501 self.assertEqual(variable.get(), datetime_obj)
512502
513 datetime_str = "1977-05-04 12:34:56"503 datetime_str = "1977-05-04 12:34:56"
514 datetime_uni = six.text_type(datetime_str)504 datetime_uni = str(datetime_str)
515 datetime_obj = datetime(1977, 5, 4, 12, 34, 56)505 datetime_obj = datetime(1977, 5, 4, 12, 34, 56)
516506
517 variable.set(datetime_str, from_db=True)507 variable.set(datetime_str, from_db=True)
@@ -576,7 +566,7 @@
576566
577 def test_get_set_from_database(self):567 def test_get_set_from_database(self):
578 date_str = "1977-05-04"568 date_str = "1977-05-04"
579 date_uni = six.text_type(date_str)569 date_uni = str(date_str)
580 date_obj = date(1977, 5, 4)570 date_obj = date(1977, 5, 4)
581 datetime_obj = datetime(1977, 5, 4, 0, 0, 0)571 datetime_obj = datetime(1977, 5, 4, 0, 0, 0)
582572
@@ -620,7 +610,7 @@
620610
621 def test_get_set_from_database(self):611 def test_get_set_from_database(self):
622 time_str = "12:34:56.78"612 time_str = "12:34:56.78"
623 time_uni = six.text_type(time_str)613 time_uni = str(time_str)
624 time_obj = time(12, 34, 56, 780000)614 time_obj = time(12, 34, 56, 780000)
625615
626 variable = TimeVariable()616 variable = TimeVariable()
@@ -633,7 +623,7 @@
633 self.assertEqual(variable.get(), time_obj)623 self.assertEqual(variable.get(), time_obj)
634624
635 time_str = "12:34:56"625 time_str = "12:34:56"
636 time_uni = six.text_type(time_str)626 time_uni = str(time_str)
637 time_obj = time(12, 34, 56)627 time_obj = time(12, 34, 56)
638628
639 variable.set(time_str, from_db=True)629 variable.set(time_str, from_db=True)
@@ -690,7 +680,7 @@
690680
691 def test_get_set_from_database(self):681 def test_get_set_from_database(self):
692 delta_str = "42 days 12:34:56.78"682 delta_str = "42 days 12:34:56.78"
693 delta_uni = six.text_type(delta_str)683 delta_uni = str(delta_str)
694 delta_obj = timedelta(days=42, hours=12, minutes=34,684 delta_obj = timedelta(days=42, hours=12, minutes=34,
695 seconds=56, microseconds=780000)685 seconds=56, microseconds=780000)
696686
@@ -704,7 +694,7 @@
704 self.assertEqual(variable.get(), delta_obj)694 self.assertEqual(variable.get(), delta_obj)
705695
706 delta_str = "1 day, 12:34:56"696 delta_str = "1 day, 12:34:56"
707 delta_uni = six.text_type(delta_str)697 delta_uni = str(delta_str)
708 delta_obj = timedelta(days=1, hours=12, minutes=34, seconds=56)698 delta_obj = timedelta(days=1, hours=12, minutes=34, seconds=56)
709699
710 variable.set(delta_str, from_db=True)700 variable.set(delta_str, from_db=True)
@@ -919,10 +909,7 @@
919909
920class JSONVariableTest(EncodedValueVariableTestMixin, TestHelper):910class JSONVariableTest(EncodedValueVariableTestMixin, TestHelper):
921911
922 if six.PY3:912 encode = staticmethod(lambda data: json.dumps(data))
923 encode = staticmethod(lambda data: json.dumps(data))
924 else:
925 encode = staticmethod(lambda data: json.dumps(data).decode("utf-8"))
926 variable_type = JSONVariable913 variable_type = JSONVariable
927914
928 def is_supported(self):915 def is_supported(self):
@@ -939,7 +926,7 @@
939 # json.926 # json.
940 variable = self.variable_type()927 variable = self.variable_type()
941 variable.set({u"a": 1})928 variable.set({u"a": 1})
942 self.assertTrue(isinstance(variable.get(to_db=True), six.text_type))929 self.assertTrue(isinstance(variable.get(to_db=True), str))
943930
944931
945class ListVariableTest(TestHelper):932class ListVariableTest(TestHelper):
946933
=== modified file 'storm/tests/wsgi.py'
--- storm/tests/wsgi.py 2019-06-07 17:14:33 +0000
+++ storm/tests/wsgi.py 2024-03-04 10:59:33 +0000
@@ -1,11 +1,8 @@
1from __future__ import print_function1import queue
2
3from unittest import TestCase2from unittest import TestCase
4import threading3import threading
5import time4import time
65
7from six.moves import queue
8
9from storm.wsgi import make_app6from storm.wsgi import make_app
107
11class TestMakeApp(TestCase):8class TestMakeApp(TestCase):
129
=== modified file 'storm/tests/zope/__init__.py'
--- storm/tests/zope/__init__.py 2019-06-05 11:41:07 +0000
+++ storm/tests/zope/__init__.py 2024-03-04 10:59:33 +0000
@@ -18,8 +18,6 @@
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/>.
19#19#
2020
21from __future__ import print_function
22
23__all__ = [21__all__ = [
24 'has_transaction',22 'has_transaction',
25 'has_zope_component',23 'has_zope_component',
2624
=== modified file 'storm/tests/zope/adapters.py'
--- storm/tests/zope/adapters.py 2019-08-11 17:51:37 +0000
+++ storm/tests/zope/adapters.py 2024-03-04 10:59:33 +0000
@@ -18,8 +18,6 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23from storm.tests.helper import TestHelper21from storm.tests.helper import TestHelper
24from storm.tests.zope import has_zope_component22from storm.tests.zope import has_zope_component
2523
2624
=== modified file 'storm/tests/zope/testing.py'
--- storm/tests/zope/testing.py 2019-08-12 17:07:08 +0000
+++ storm/tests/zope/testing.py 2024-03-04 10:59:33 +0000
@@ -18,13 +18,9 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23import os21import os
24import sys22import sys
2523
26import six
27
28from storm.tests.helper import TestHelper24from storm.tests.helper import TestHelper
29from storm.tests.zope import (25from storm.tests.zope import (
30 has_testresources,26 has_testresources,
@@ -245,7 +241,7 @@
245 real_invalidate = store.invalidate241 real_invalidate = store.invalidate
246242
247 def invalidate_proxy():243 def invalidate_proxy():
248 self.assertEqual(0, len(list(six.itervalues(store._alive))))244 self.assertEqual(0, len(list(store._alive.values())))
249 real_invalidate()245 real_invalidate()
250 store.invalidate = invalidate_proxy246 store.invalidate = invalidate_proxy
251247
252248
=== modified file 'storm/tests/zope/zstorm.py'
--- storm/tests/zope/zstorm.py 2019-11-21 16:06:52 +0000
+++ storm/tests/zope/zstorm.py 2024-03-04 10:59:33 +0000
@@ -18,8 +18,6 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23import threading21import threading
24import weakref22import weakref
25import gc23import gc
2624
=== modified file 'storm/tracer.py'
--- storm/tracer.py 2020-05-26 10:37:54 +0000
+++ storm/tracer.py 2024-03-04 10:59:33 +0000
@@ -1,12 +1,8 @@
1from __future__ import print_function
2
3from datetime import datetime1from datetime import datetime
4import re2import re
5import sys3import sys
6import threading4import threading
75
8import six
9
10# Circular import: imported at the end of the module.6# Circular import: imported at the end of the module.
11# from storm.database import convert_param_marks7# from storm.database import convert_param_marks
12from storm.exceptions import TimeoutError8from storm.exceptions import TimeoutError
@@ -173,11 +169,8 @@
173 # string parameters which represent encoded binary data.169 # string parameters which represent encoded binary data.
174 render_params = []170 render_params = []
175 for param in query_params:171 for param in query_params:
176 if isinstance(param, six.text_type):172 if isinstance(param, str):
177 if six.PY3:173 render_params.append(ascii(param))
178 render_params.append(ascii(param))
179 else:
180 render_params.append(repr(param.encode('utf8')))
181 else:174 else:
182 render_params.append(repr(param))175 render_params.append(repr(param))
183 try:176 try:
184177
=== modified file 'storm/twisted/testing.py'
--- storm/twisted/testing.py 2020-03-18 16:02:04 +0000
+++ storm/twisted/testing.py 2024-03-04 10:59:33 +0000
@@ -1,5 +1,3 @@
1from __future__ import print_function
2
3from twisted.python.failure import Failure1from twisted.python.failure import Failure
4from twisted.internet.defer import execute2from twisted.internet.defer import execute
53
64
=== modified file 'storm/twisted/transact.py'
--- storm/twisted/transact.py 2020-03-18 16:02:04 +0000
+++ storm/twisted/transact.py 2024-03-04 10:59:33 +0000
@@ -1,5 +1,3 @@
1from __future__ import print_function
2
3import time1import time
4import random2import random
5import transaction as zope_transaction3import transaction as zope_transaction
64
=== modified file 'storm/tz.py'
--- storm/tz.py 2020-05-26 10:37:54 +0000
+++ storm/tz.py 2024-03-04 10:59:33 +0000
@@ -4,8 +4,6 @@
4This module offers extensions to the standard python 2.3+4This module offers extensions to the standard python 2.3+
5datetime module.5datetime module.
6"""6"""
7from __future__ import print_function
8
9__author__ = "Gustavo Niemeyer <gustavo@niemeyer.net>"7__author__ = "Gustavo Niemeyer <gustavo@niemeyer.net>"
10__license__ = "PSF License"8__license__ = "PSF License"
119
@@ -15,8 +13,6 @@
15import sys13import sys
16import os14import os
1715
18import six
19
20relativedelta = None16relativedelta = None
21parser = None17parser = None
22rrule = None18rrule = None
@@ -198,7 +194,7 @@
198 # ftp://elsie.nci.nih.gov/pub/tz*.tar.gz194 # ftp://elsie.nci.nih.gov/pub/tz*.tar.gz
199195
200 def __init__(self, fileobj):196 def __init__(self, fileobj):
201 if isinstance(fileobj, six.string_types):197 if isinstance(fileobj, str):
202 self._filename = fileobj198 self._filename = fileobj
203 fileobj = open(fileobj)199 fileobj = open(fileobj)
204 elif hasattr(fileobj, "name"):200 elif hasattr(fileobj, "name"):
@@ -699,7 +695,7 @@
699 if not rrule:695 if not rrule:
700 from dateutil import rrule696 from dateutil import rrule
701697
702 if isinstance(fileobj, six.string_types):698 if isinstance(fileobj, str):
703 self._s = fileobj699 self._s = fileobj
704 fileobj = open(fileobj)700 fileobj = open(fileobj)
705 elif hasattr(fileobj, "name"):701 elif hasattr(fileobj, "name"):
@@ -716,7 +712,7 @@
716712
717 def get(self, tzid=None):713 def get(self, tzid=None):
718 if tzid is None:714 if tzid is None:
719 keys = list(six.iterkeys(self._vtz))715 keys = list(self._vtz)
720 if len(keys) == 0:716 if len(keys) == 0:
721 raise Exception("no timezones defined")717 raise Exception("no timezones defined")
722 elif len(keys) > 1:718 elif len(keys) > 1:
723719
=== modified file 'storm/uri.py'
--- storm/uri.py 2020-05-29 23:02:39 +0000
+++ storm/uri.py 2024-03-04 10:59:33 +0000
@@ -18,10 +18,7 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function21from urllib.parse import quote
22
23import six
24from six.moves.urllib.parse import quote
2522
26from storm.exceptions import URIError23from storm.exceptions import URIError
2724
@@ -117,7 +114,7 @@
117 append(escape(self.database, "/"))114 append(escape(self.database, "/"))
118 if self.options:115 if self.options:
119 options = ["%s=%s" % (escape(key), escape(value))116 options = ["%s=%s" % (escape(key), escape(value))
120 for key, value in sorted(six.iteritems(self.options))]117 for key, value in sorted(self.options.items())]
121 append("?")118 append("?")
122 append("&".join(options))119 append("&".join(options))
123 return "".join(tokens)120 return "".join(tokens)
124121
=== modified file 'storm/variables.py'
--- storm/variables.py 2022-03-16 16:59:21 +0000
+++ storm/variables.py 2024-03-04 10:59:33 +0000
@@ -18,19 +18,15 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23from datetime import datetime, date, time, timedelta21from datetime import datetime, date, time, timedelta
24from decimal import Decimal22from decimal import Decimal
25from functools import partial23from functools import partial
24import json
25import pickle
26import re26import re
27import uuid27import uuid
28import weakref28import weakref
2929
30import six
31from six.moves import cPickle as pickle
32
33from storm.compat import json
34from storm.exceptions import NoneError30from storm.exceptions import NoneError
35from storm import Undef, has_cextensions31from storm import Undef, has_cextensions
3632
@@ -58,12 +54,6 @@
58]54]
5955
6056
61if six.PY3:
62 _buffer_type = memoryview
63else:
64 _buffer_type = buffer
65
66
67class LazyValue(object):57class LazyValue(object):
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."""
69 __slots__ = ()59 __slots__ = ()
@@ -328,7 +318,7 @@
328 __slots__ = ()318 __slots__ = ()
329319
330 def parse_set(self, value, from_db):320 def parse_set(self, value, from_db):
331 if not isinstance(value, (six.integer_types, float, Decimal)):321 if not isinstance(value, (int, float, Decimal)):
332 raise TypeError("Expected bool, found %r: %r"322 raise TypeError("Expected bool, found %r: %r"
333 % (type(value), value))323 % (type(value), value))
334 return bool(value)324 return bool(value)
@@ -338,7 +328,7 @@
338 __slots__ = ()328 __slots__ = ()
339329
340 def parse_set(self, value, from_db):330 def parse_set(self, value, from_db):
341 if not isinstance(value, (six.integer_types, float, Decimal)):331 if not isinstance(value, (int, float, Decimal)):
342 raise TypeError("Expected int, found %r: %r"332 raise TypeError("Expected int, found %r: %r"
343 % (type(value), value))333 % (type(value), value))
344 return int(value)334 return int(value)
@@ -348,7 +338,7 @@
348 __slots__ = ()338 __slots__ = ()
349339
350 def parse_set(self, value, from_db):340 def parse_set(self, value, from_db):
351 if not isinstance(value, (six.integer_types, float, Decimal)):341 if not isinstance(value, (int, float, Decimal)):
352 raise TypeError("Expected float, found %r: %r"342 raise TypeError("Expected float, found %r: %r"
353 % (type(value), value))343 % (type(value), value))
354 return float(value)344 return float(value)
@@ -359,8 +349,7 @@
359349
360 @staticmethod350 @staticmethod
361 def parse_set(value, from_db):351 def parse_set(value, from_db):
362 if (from_db and isinstance(value, six.string_types) or352 if (from_db and isinstance(value, str)) or isinstance(value, int):
363 isinstance(value, six.integer_types)):
364 value = Decimal(value)353 value = Decimal(value)
365 elif not isinstance(value, Decimal):354 elif not isinstance(value, Decimal):
366 raise TypeError("Expected Decimal, found %r: %r"355 raise TypeError("Expected Decimal, found %r: %r"
@@ -370,7 +359,7 @@
370 @staticmethod359 @staticmethod
371 def parse_get(value, to_db):360 def parse_get(value, to_db):
372 if to_db:361 if to_db:
373 return six.text_type(value)362 return str(value)
374 return value363 return value
375364
376365
@@ -378,7 +367,7 @@
378 __slots__ = ()367 __slots__ = ()
379368
380 def parse_set(self, value, from_db):369 def parse_set(self, value, from_db):
381 if isinstance(value, _buffer_type):370 if isinstance(value, memoryview):
382 value = bytes(value)371 value = bytes(value)
383 elif not isinstance(value, bytes):372 elif not isinstance(value, bytes):
384 raise TypeError("Expected bytes, found %r: %r"373 raise TypeError("Expected bytes, found %r: %r"
@@ -394,7 +383,7 @@
394 __slots__ = ()383 __slots__ = ()
395384
396 def parse_set(self, value, from_db):385 def parse_set(self, value, from_db):
397 if not isinstance(value, six.text_type):386 if not isinstance(value, str):
398 raise TypeError("Expected text, found %r: %r"387 raise TypeError("Expected text, found %r: %r"
399 % (type(value), value))388 % (type(value), value))
400 return value389 return value
@@ -411,7 +400,7 @@
411 if from_db:400 if from_db:
412 if isinstance(value, datetime):401 if isinstance(value, datetime):
413 pass402 pass
414 elif isinstance(value, six.string_types):403 elif isinstance(value, str):
415 if " " not in value:404 if " " not in value:
416 raise ValueError("Unknown date/time format: %r" % value)405 raise ValueError("Unknown date/time format: %r" % value)
417 date_str, time_str = value.split(" ")406 date_str, time_str = value.split(" ")
@@ -425,7 +414,7 @@
425 else:414 else:
426 value = value.astimezone(self._tzinfo)415 value = value.astimezone(self._tzinfo)
427 else:416 else:
428 if type(value) in six.integer_types + (float, ):417 if type(value) in (int, float):
429 value = datetime.utcfromtimestamp(value)418 value = datetime.utcfromtimestamp(value)
430 elif not isinstance(value, datetime):419 elif not isinstance(value, datetime):
431 raise TypeError("Expected datetime, found %s" % repr(value))420 raise TypeError("Expected datetime, found %s" % repr(value))
@@ -456,7 +445,7 @@
456 return value.date()445 return value.date()
457 if isinstance(value, date):446 if isinstance(value, date):
458 return value447 return value
459 if not isinstance(value, six.string_types):448 if not isinstance(value, str):
460 raise TypeError("Expected date, found %s" % repr(value))449 raise TypeError("Expected date, found %s" % repr(value))
461 if " " in value:450 if " " in value:
462 value, time_str = value.split(" ")451 value, time_str = value.split(" ")
@@ -479,7 +468,7 @@
479 return None468 return None
480 if isinstance(value, time):469 if isinstance(value, time):
481 return value470 return value
482 if not isinstance(value, six.string_types):471 if not isinstance(value, str):
483 raise TypeError("Expected time, found %s" % repr(value))472 raise TypeError("Expected time, found %s" % repr(value))
484 if " " in value:473 if " " in value:
485 date_str, value = value.split(" ")474 date_str, value = value.split(" ")
@@ -502,7 +491,7 @@
502 return None491 return None
503 if isinstance(value, timedelta):492 if isinstance(value, timedelta):
504 return value493 return value
505 if not isinstance(value, six.string_types):494 if not isinstance(value, str):
506 raise TypeError("Expected timedelta, found %s" % repr(value))495 raise TypeError("Expected timedelta, found %s" % repr(value))
507 return _parse_interval(value)496 return _parse_interval(value)
508 else:497 else:
@@ -515,7 +504,7 @@
515 __slots__ = ()504 __slots__ = ()
516505
517 def parse_set(self, value, from_db):506 def parse_set(self, value, from_db):
518 if from_db and isinstance(value, six.string_types):507 if from_db and isinstance(value, str):
519 value = uuid.UUID(value)508 value = uuid.UUID(value)
520 elif not isinstance(value, uuid.UUID):509 elif not isinstance(value, uuid.UUID):
521 raise TypeError("Expected UUID, found %r: %r"510 raise TypeError("Expected UUID, found %r: %r"
@@ -524,7 +513,7 @@
524513
525 def parse_get(self, value, to_db):514 def parse_get(self, value, to_db):
526 if to_db:515 if to_db:
527 return six.text_type(value)516 return str(value)
528 return value517 return value
529518
530519
@@ -607,7 +596,7 @@
607596
608 def parse_set(self, value, from_db):597 def parse_set(self, value, from_db):
609 if from_db:598 if from_db:
610 if isinstance(value, _buffer_type):599 if isinstance(value, memoryview):
611 value = bytes(value)600 value = bytes(value)
612 return self._loads(value)601 return self._loads(value)
613 else:602 else:
@@ -641,7 +630,7 @@
641 __slots__ = ()630 __slots__ = ()
642631
643 def _loads(self, value):632 def _loads(self, value):
644 if not isinstance(value, six.text_type):633 if not isinstance(value, str):
645 raise TypeError(634 raise TypeError(
646 "Cannot safely assume encoding of byte string %r." % value)635 "Cannot safely assume encoding of byte string %r." % value)
647 return json.loads(value)636 return json.loads(value)
@@ -651,7 +640,7 @@
651 # and so we treat it as such here. In other words, this method returns640 # and so we treat it as such here. In other words, this method returns
652 # Unicode text and never bytes.641 # Unicode text and never bytes.
653 dump = json.dumps(value, ensure_ascii=False)642 dump = json.dumps(value, ensure_ascii=False)
654 if not isinstance(dump, six.text_type):643 if not isinstance(dump, str):
655 # json.dumps() does not always return unicode. See644 # json.dumps() does not always return unicode. See
656 # http://code.google.com/p/simplejson/issues/detail?id=40 for one645 # http://code.google.com/p/simplejson/issues/detail?id=40 for one
657 # of many discussions of str/unicode handling in simplejson.646 # of many discussions of str/unicode handling in simplejson.
658647
=== modified file 'storm/wsgi.py'
--- storm/wsgi.py 2020-05-26 10:37:54 +0000
+++ storm/wsgi.py 2024-03-04 10:59:33 +0000
@@ -21,8 +21,6 @@
2121
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."""
2323
24from __future__ import print_function
25
26import threading24import threading
27import weakref25import weakref
2826
2927
=== modified file 'storm/xid.py'
--- storm/xid.py 2019-06-05 11:41:07 +0000
+++ storm/xid.py 2024-03-04 10:59:33 +0000
@@ -19,9 +19,6 @@
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/>.
20#20#
2121
22from __future__ import print_function
23
24
25class Xid(object):22class Xid(object):
26 """23 """
27 Represent a transaction identifier compliant with the XA specification.24 Represent a transaction identifier compliant with the XA specification.
2825
=== modified file 'storm/zope/__init__.py'
--- storm/zope/__init__.py 2019-06-05 11:41:07 +0000
+++ storm/zope/__init__.py 2024-03-04 10:59:33 +0000
@@ -18,8 +18,6 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23from zope.interface import classImplements21from zope.interface import classImplements
2422
25from storm.info import ObjectInfo23from storm.info import ObjectInfo
2624
=== modified file 'storm/zope/adapters.py'
--- storm/zope/adapters.py 2019-06-05 11:41:07 +0000
+++ storm/zope/adapters.py 2024-03-04 10:59:33 +0000
@@ -19,8 +19,6 @@
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/>.
20#20#
2121
22from __future__ import print_function
23
24from zope.component import adapter22from zope.component import adapter
25from zope.interface import implementer23from zope.interface import implementer
2624
2725
=== modified file 'storm/zope/interfaces.py'
--- storm/zope/interfaces.py 2019-08-11 09:07:34 +0000
+++ storm/zope/interfaces.py 2024-03-04 10:59:33 +0000
@@ -18,9 +18,6 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23import six
24from zope.interface import Interface21from zope.interface import Interface
2522
26from storm.expr import Undef23from storm.expr import Undef
@@ -174,9 +171,6 @@
174 which doesn't have a C{__bool__} implementation.171 which doesn't have a C{__bool__} implementation.
175 """172 """
176173
177 if six.PY2:
178 __nonzero__ = __bool__
179
180 def __contains__(item):174 def __contains__(item):
181 """Support C{if FooObject in Foo.select(query)}."""175 """Support C{if FooObject in Foo.select(query)}."""
182176
183177
=== modified file 'storm/zope/metaconfigure.py'
--- storm/zope/metaconfigure.py 2019-06-05 11:41:07 +0000
+++ storm/zope/metaconfigure.py 2024-03-04 10:59:33 +0000
@@ -18,8 +18,6 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23from zope import component21from zope import component
2422
25from storm.zope.interfaces import IZStorm23from storm.zope.interfaces import IZStorm
2624
=== modified file 'storm/zope/metadirectives.py'
--- storm/zope/metadirectives.py 2019-06-05 11:41:07 +0000
+++ storm/zope/metadirectives.py 2024-03-04 10:59:33 +0000
@@ -18,8 +18,6 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23from zope.interface import Interface21from zope.interface import Interface
24from zope.schema import TextLine22from zope.schema import TextLine
2523
2624
=== modified file 'storm/zope/schema.py'
--- storm/zope/schema.py 2019-06-05 11:41:07 +0000
+++ storm/zope/schema.py 2024-03-04 10:59:33 +0000
@@ -19,8 +19,6 @@
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/>.
20#20#
21"""ZStorm-aware schema manager."""21"""ZStorm-aware schema manager."""
22from __future__ import print_function
23
24import transaction22import transaction
2523
26from storm.schema import Schema24from storm.schema import Schema
2725
=== modified file 'storm/zope/testing.py'
--- storm/zope/testing.py 2019-08-11 09:48:05 +0000
+++ storm/zope/testing.py 2024-03-04 10:59:33 +0000
@@ -18,12 +18,9 @@
18# You should have received a copy of the GNU Lesser General Public License18# You should have received a copy of the GNU Lesser General Public License
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/>.
20#20#
21from __future__ import print_function
22
23import os21import os
24import shutil22import shutil
2523
26import six
27import transaction24import transaction
2825
29from testresources import TestResourceManager26from testresources import TestResourceManager
@@ -102,7 +99,7 @@
102 if isinstance(databases, dict):99 if isinstance(databases, dict):
103 databases = [100 databases = [
104 {"name": name, "uri": uri, "schema": schema}101 {"name": name, "uri": uri, "schema": schema}
105 for name, (uri, schema) in six.iteritems(databases)]102 for name, (uri, schema) in databases.items()]
106103
107 # Provide the global IZStorm utility before applying patches, so104 # Provide the global IZStorm utility before applying patches, so
108 # patch code can get the ztorm object if needed (e.g. looking up105 # patch code can get the ztorm object if needed (e.g. looking up
109106
=== modified file 'storm/zope/zstorm.py'
--- storm/zope/zstorm.py 2019-08-11 09:48:05 +0000
+++ storm/zope/zstorm.py 2024-03-04 10:59:33 +0000
@@ -24,14 +24,11 @@
24# You should have received a copy of the GNU Lesser General Public License24# You should have received a copy of the GNU Lesser General Public License
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/>.
26#26#
27from __future__ import print_function
28
29import threading27import threading
30import weakref28import weakref
3129
32from uuid import uuid430from uuid import uuid4
3331
34import six
35from zope.interface import implementer32from zope.interface import implementer
3633
37import transaction34import transaction
@@ -211,7 +208,7 @@
211 # it to avoid the problem where a store is deallocated during208 # it to avoid the problem where a store is deallocated during
212 # iteration causing RuntimeError: dictionary changed size209 # iteration causing RuntimeError: dictionary changed size
213 # during iteration.210 # during iteration.
214 for store, name in list(six.iteritems(self._name_index)):211 for store, name in list(self._name_index.items()):
215 yield name, store212 yield name, store
216213
217 def get_name(self, store):214 def get_name(self, store):
218215
=== modified file 'tox.ini'
--- tox.ini 2023-02-09 16:28:53 +0000
+++ tox.ini 2024-03-04 10:59:33 +0000
@@ -1,6 +1,5 @@
1[tox]1[tox]
2envlist =2envlist =
3 py27-{cextensions,nocextensions}
4 py35-{cextensions,nocextensions}3 py35-{cextensions,nocextensions}
5 py36-{cextensions,nocextensions}4 py36-{cextensions,nocextensions}
6 py37-{cextensions,nocextensions}5 py37-{cextensions,nocextensions}
@@ -12,7 +11,7 @@
1211
13[testenv]12[testenv]
14download =13download =
15 py27,py35: true14 py35: true
16deps =15deps =
17 .[test]16 .[test]
18passenv =17passenv =
@@ -21,8 +20,8 @@
21setenv =20setenv =
22 cextensions: STORM_CEXTENSIONS = 121 cextensions: STORM_CEXTENSIONS = 1
23 nocextensions: STORM_CEXTENSIONS = 022 nocextensions: STORM_CEXTENSIONS = 0
24 py27,py35: VIRTUALENV_DOWNLOAD = 123 py35: VIRTUALENV_DOWNLOAD = 1
25 py27,py35: VIRTUALENV_PIP = 20.3.424 py35: VIRTUALENV_PIP = 20.3.4
26commands =25commands =
27 python dev/test {posargs}26 python dev/test {posargs}
2827

Subscribers

People subscribed via source and target branches

to status/vote changes: