Skip to content

Commit

Permalink
Drop support for Python 2.7 up to 3.6.
Browse files Browse the repository at this point in the history
  • Loading branch information
icemac authored and Michael Howitz committed Jul 17, 2023
1 parent 7fbfae1 commit 536cdfc
Show file tree
Hide file tree
Showing 118 changed files with 901 additions and 1,395 deletions.
48 changes: 20 additions & 28 deletions setup.py
Expand Up @@ -17,29 +17,6 @@

version = '6.0.dev0'

classifiers = """\
Intended Audience :: Developers
License :: OSI Approved :: Zope Public License
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: Implementation :: PyPy
Topic :: Database
Topic :: Software Development :: Libraries :: Python Modules
Operating System :: Microsoft :: Windows
Operating System :: Unix
Framework :: ZODB
"""


def read(path):
with open(path) as f:
Expand All @@ -50,7 +27,6 @@ def read(path):

tests_require = [
'manuel',
'mock; python_version == "2.7"',
'zope.testing',
'zope.testrunner >= 4.4.6',
]
Expand All @@ -61,14 +37,31 @@ def read(path):
author="Jim Fulton",
author_email="jim@zope.com",
maintainer="Zope Foundation and Contributors",
maintainer_email="zodb-dev@zope.org",
maintainer_email="zodb-dev@zope.dev",
keywords="database nosql python zope",
packages=find_packages('src'),
package_dir={'': 'src'},
url='http://zodb-docs.readthedocs.io',
license="ZPL 2.1",
platforms=["any"],
classifiers=list(filter(None, classifiers.split("\n"))),
classifiers=[
"Intended Audience :: Developers",
"License :: OSI Approved :: Zope Public License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Database",
"Topic :: Software Development :: Libraries :: Python Modules",
"Operating System :: Microsoft :: Windows",
"Operating System :: Unix",
"Framework :: ZODB",
],
description=long_description.split('\n', 2)[1],
long_description=long_description,
tests_require=tests_require,
Expand All @@ -87,7 +80,6 @@ def read(path):
'BTrees >= 4.2.0',
'ZConfig',
'transaction >= 2.4',
'six',
'zc.lockfile',
'zope.interface',
'zodbpickle >= 1.0.1',
Expand All @@ -102,5 +94,5 @@ def read(path):
repozo = ZODB.scripts.repozo:main
""",
include_package_data=True,
python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*',
python_requires='>=3.7',
)
2 changes: 1 addition & 1 deletion src/ZODB/ActivityMonitor.py
Expand Up @@ -19,7 +19,7 @@
from . import utils


class ActivityMonitor(object):
class ActivityMonitor:
"""ZODB load/store activity monitor
This simple implementation just keeps a small log in memory
Expand Down
15 changes: 9 additions & 6 deletions src/ZODB/BaseStorage.py
Expand Up @@ -16,7 +16,6 @@
The base class here is tightly coupled with its subclasses and
its use is not recommended. It's still here for historical reasons.
"""
from __future__ import print_function

import logging
import time
Expand All @@ -30,7 +29,6 @@

from . import POSException
from . import utils
from ._compat import py2_hasattr
from .Connection import TransactionMetaData
from .UndoLogCompatible import UndoLogCompatible
from .utils import byte_chr
Expand Down Expand Up @@ -310,7 +308,12 @@ def copy(source, dest, verbose=0):
# using store(). However, if we use store, then
# copyTransactionsFrom() may fail with VersionLockError or
# ConflictError.
restoring = py2_hasattr(dest, 'restore')
try:
getattr(dest, 'restore')
except: # noqa: E722 do not use bare 'except'
restoring = False
else:
restoring = True
fiter = source.iterator()
for transaction in fiter:
tid = transaction.tid
Expand All @@ -320,14 +323,14 @@ def copy(source, dest, verbose=0):
t = TimeStamp(tid)
if t <= _ts:
if ok:
print(('Time stamps out of order %s, %s' % (_ts, t)))
print('Time stamps out of order {}, {}'.format(_ts, t))
ok = 0
_ts = t.laterThan(_ts)
tid = _ts.raw()
else:
_ts = t
if not ok:
print(('Time stamps back in order %s' % (t)))
print('Time stamps back in order %s' % (t))
ok = 1

if verbose:
Expand Down Expand Up @@ -376,7 +379,7 @@ def __init__(self, tid, status, user, description, extension):


@zope.interface.implementer(ZODB.interfaces.IStorageRecordInformation)
class DataRecord(object):
class DataRecord:
"""Abstract base class for iterator protocol"""

version = ''
Expand Down
27 changes: 10 additions & 17 deletions src/ZODB/ConflictResolution.py
Expand Up @@ -13,16 +13,11 @@
##############################################################################

import logging
# Subtle: Python 2.x has pickle.PicklingError and cPickle.PicklingError,
# and these are unrelated classes! So we shouldn't use pickle.PicklingError,
# since on Python 2, ZODB._compat.pickle is cPickle.
from io import BytesIO
from pickle import PicklingError

import six

import zope.interface

from ZODB._compat import BytesIO
from ZODB._compat import PersistentPickler
from ZODB._compat import PersistentUnpickler
from ZODB._compat import _protocol
Expand All @@ -37,7 +32,7 @@ class BadClassName(Exception):
pass


class BadClass(object):
class BadClass:

def __init__(self, *args):
self.args = args
Expand Down Expand Up @@ -68,8 +63,8 @@ def find_global(*args):
if cls == 1:
# Not importable
if (isinstance(args, tuple) and len(args) == 2 and
isinstance(args[0], six.string_types) and
isinstance(args[1], six.string_types)):
isinstance(args[0], str) and
isinstance(args[1], str)):
return BadClass(*args)
else:
raise BadClassName(*args)
Expand Down Expand Up @@ -125,7 +120,7 @@ class may have its own comparison, and we have no idea what it is.


@zope.interface.implementer(IPersistentReference)
class PersistentReference(object):
class PersistentReference:

weak = False
oid = database_name = klass = None
Expand Down Expand Up @@ -169,7 +164,7 @@ def __init__(self, data):
self.weak = True
if not isinstance(self.oid, (bytes, type(None))):
assert isinstance(self.oid, str)
# this happens on Python 3 when all bytes in the oid are < 0x80
# this happens when all bytes in the oid are < 0x80
self.oid = self.oid.encode('ascii')

def __cmp__(self, other):
Expand All @@ -185,8 +180,6 @@ def __cmp__(self, other):
"can't reliably compare against different "
"PersistentReferences")

# Python 3 dropped __cmp__

def __eq__(self, other):
return self.__cmp__(other) == 0

Expand All @@ -206,7 +199,7 @@ def __ge__(self, other):
return self.__cmp__(other) >= 0

def __repr__(self):
return "PR(%s %s)" % (id(self), self.data)
return "PR({} {})".format(id(self), self.data)

def __getstate__(self):
raise PicklingError("Can't pickle PersistentReference")
Expand All @@ -221,7 +214,7 @@ def klass(self):
return data[1][2]


class PersistentReferenceFactory(object):
class PersistentReferenceFactory:

data = None

Expand Down Expand Up @@ -311,7 +304,7 @@ def tryToResolveConflict(self, oid, committedSerial, oldSerial, newpickle,
data=newpickle)


class ConflictResolvingStorage(object):
class ConflictResolvingStorage:
"Mix-in class that provides conflict resolution handling for storages"

tryToResolveConflict = tryToResolveConflict
Expand All @@ -323,7 +316,7 @@ def registerDB(self, wrapper):
self._crs_untransform_record_data = wrapper.untransform_record_data
self._crs_transform_record_data = wrapper.transform_record_data
try:
m = super(ConflictResolvingStorage, self).registerDB
m = super().registerDB
except AttributeError:
pass
else:
Expand Down
20 changes: 10 additions & 10 deletions src/ZODB/ConflictResolution.rst
Expand Up @@ -231,7 +231,7 @@ And now we will make a conflict.
>>> tm_A.commit() # doctest: +ELLIPSIS
Traceback (most recent call last):
...
ConflictError: database conflict error...
ZODB.POSException.ConflictError: database conflict error...

oops!

Expand Down Expand Up @@ -352,7 +352,7 @@ resolution.
>>> tm_A.commit() # doctest: +ELLIPSIS
Traceback (most recent call last):
...
ConflictError: database conflict error...
ZODB.POSException.ConflictError: database conflict error...
>>> tm_A.abort()

Third, note that, even if the persistent object to which the reference refers
Expand Down Expand Up @@ -395,7 +395,7 @@ the situation above.
>>> tm_A.commit() # doctest: +ELLIPSIS
Traceback (most recent call last):
...
ConflictError: database conflict error...
ZODB.POSException.ConflictError: database conflict error...
>>> tm_A.abort()

However, the story highlights the kinds of subtle problems that units
Expand Down Expand Up @@ -479,7 +479,7 @@ integrity issues.
>>> ref1 = PersistentReference(b'my_oid')
>>> ref1.oid
'my_oid'
b'my_oid'
>>> print(ref1.klass)
None
>>> print(ref1.database_name)
Expand All @@ -489,7 +489,7 @@ integrity issues.
>>> ref2 = PersistentReference((b'my_oid', 'my_class'))
>>> ref2.oid
'my_oid'
b'my_oid'
>>> ref2.klass
'my_class'
>>> print(ref2.database_name)
Expand All @@ -499,7 +499,7 @@ integrity issues.
>>> ref3 = PersistentReference(['w', (b'my_oid',)])
>>> ref3.oid
'my_oid'
b'my_oid'
>>> print(ref3.klass)
None
>>> print(ref3.database_name)
Expand All @@ -509,7 +509,7 @@ integrity issues.
>>> ref3a = PersistentReference(['w', (b'my_oid', 'other_db')])
>>> ref3a.oid
'my_oid'
b'my_oid'
>>> print(ref3a.klass)
None
>>> ref3a.database_name
Expand All @@ -519,7 +519,7 @@ integrity issues.
>>> ref4 = PersistentReference(['m', ('other_db', b'my_oid', 'my_class')])
>>> ref4.oid
'my_oid'
b'my_oid'
>>> ref4.klass
'my_class'
>>> ref4.database_name
Expand All @@ -529,7 +529,7 @@ integrity issues.
>>> ref5 = PersistentReference(['n', ('other_db', b'my_oid')])
>>> ref5.oid
'my_oid'
b'my_oid'
>>> print(ref5.klass)
None
>>> ref5.database_name
Expand All @@ -539,7 +539,7 @@ integrity issues.
>>> ref6 = PersistentReference([b'my_oid']) # legacy
>>> ref6.oid
'my_oid'
b'my_oid'
>>> print(ref6.klass)
None
>>> print(ref6.database_name)
Expand Down

0 comments on commit 536cdfc

Please sign in to comment.