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
Michael Howitz committed Dec 21, 2022
1 parent 3f749d3 commit c708697
Show file tree
Hide file tree
Showing 28 changed files with 159 additions and 273 deletions.
37 changes: 10 additions & 27 deletions setup.py
Expand Up @@ -103,7 +103,7 @@ def header_dirs_for_dep(distname, headername): # 3 and 4
]


class IncludeDirs(object):
class IncludeDirs:
dirs = None

def __getattribute__(self, name):
Expand All @@ -118,19 +118,14 @@ def __iter__(self):
return iter(self.dirs)


if str is bytes and hasattr(sys, 'pypy_version_info'):
# zope.proxy, as of 4.3.5, cannot compile on PyPy2 7.3.0
# because it uses cl_dict in a PyClassObject, which does not exist.
ext_modules = []
else:
ext_modules = [
Extension(
"zope.container._zope_container_contained",
[os.path.join("src", "zope", "container",
"_zope_container_contained.c")],
include_dirs=IncludeDirs(),
),
]
ext_modules = [
Extension(
"zope.container._zope_container_contained",
[os.path.join("src", "zope", "container",
"_zope_container_contained.c")],
include_dirs=IncludeDirs(),
),
]

setup_requires = [
'persistent >= 4.1.0',
Expand All @@ -140,7 +135,6 @@ def __iter__(self):

install_requires = setup_requires + [
'BTrees',
'six',
'zope.cachedescriptors',
'zope.component',
'zope.deferredimport',
Expand Down Expand Up @@ -199,11 +193,7 @@ def __iter__(self):
'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',
Expand Down Expand Up @@ -234,12 +224,5 @@ def __iter__(self):
tests_require=extras['test'],
include_package_data=True,
zip_safe=False,
python_requires=', '.join([
'>=2.7',
'!=3.0.*',
'!=3.1.*',
'!=3.2.*',
'!=3.3.*',
'!=3.4.*',
]),
python_requires='>=3.7',
)
6 changes: 0 additions & 6 deletions src/zope/container/_compat.py

This file was deleted.

8 changes: 4 additions & 4 deletions src/zope/container/_proxy.py
Expand Up @@ -36,13 +36,13 @@ class ContainedProxyBase(AbstractPyProxyBase, Persistent):
__slots__ = ('_wrapped', '__parent__', '__name__', '__weakref__')

def __new__(cls, obj):
inst = super(ContainedProxyBase, cls).__new__(cls, obj)
inst = super().__new__(cls, obj)
inst.__parent__ = None
inst.__name__ = None
return inst

def __init__(self, obj):
super(ContainedProxyBase, self).__init__(obj)
super().__init__(obj)
self.__parent__ = None
self.__name__ = None

Expand Down Expand Up @@ -94,7 +94,7 @@ def __getattribute__(self, name):
):
return object.__getattribute__(self, name)

return super(ContainedProxyBase, self).__getattribute__(name)
return super().__getattribute__(name)

def __setattr__(self, name, value):
if _special_name(name):
Expand All @@ -103,7 +103,7 @@ def __setattr__(self, name, value):
# themselves
return Persistent.__setattr__(self, name, value)

return super(ContainedProxyBase, self).__setattr__(name, value)
return super().__setattr__(name, value)


@use_c_impl
Expand Down
10 changes: 0 additions & 10 deletions src/zope/container/_util.py
Expand Up @@ -157,19 +157,9 @@ def find_impl():
if not isinstance(v, types.FunctionType):
continue

# Somewhat surprisingly, on Python 2, while
# ``Class.function`` results in a
# ``types.UnboundMethodType`` (``instancemethed``) object,
# ``Class.__dict__["function"]`` returns a
# ``types.FunctionType``, just like ``Class.function``
# (and the dictionary access, of course) does on Python 3.
# The upshot is, we don't need different version-dependent
# code. Hooray!
if new_globals is None:
new_globals = v.__globals__.copy()
new_globals[py_impl.__name__] = py_impl
# On Python 2, all arguments are optional, but an Python 3, all
# are required.
v = types.FunctionType(
v.__code__,
new_globals,
Expand Down
18 changes: 4 additions & 14 deletions src/zope/container/_zope_container_contained.c
Expand Up @@ -78,13 +78,8 @@ typedef struct {
/* Incude the proxy C source */
#include "_zope_proxy_proxy.c"

#ifdef PY3K
#define MAKE_PYSTRING(s) PyUnicode_FromString(s)
#define MAKE_STRING(name) PyBytes_AS_STRING(PyUnicode_AsUTF8String(name))
#else
#define MAKE_PYSTRING(s) PyString_FromString(s)
#define MAKE_STRING(name) PyString_AS_STRING(name)
#endif
#define MAKE_PYSTRING(s) PyUnicode_FromString(s)
#define MAKE_STRING(name) PyBytes_AS_STRING(PyUnicode_AsUTF8String(name))

#define SPECIAL(NAME) ( \
*(NAME) == '_' && \
Expand Down Expand Up @@ -316,13 +311,8 @@ MOD_INIT(_zope_container_contained)
empty_tuple = PyTuple_New(0);

/* Initialize the PyPersist_C_API and the type objects. */
#ifdef PY3K
cPersistenceCAPI = (cPersistenceCAPIstruct *)PyCapsule_Import(
"persistent.cPersistence.CAPI", 0);
#else
cPersistenceCAPI = (cPersistenceCAPIstruct *)PyCObject_Import(
"persistent.cPersistence", "CAPI");
#endif
cPersistenceCAPI = (cPersistenceCAPIstruct *)PyCapsule_Import(
"persistent.cPersistence.CAPI", 0);

if (cPersistenceCAPI == NULL)
return MOD_ERROR_VAL;
Expand Down
8 changes: 4 additions & 4 deletions src/zope/container/constraints.py
Expand Up @@ -47,7 +47,7 @@
>>> checkObject(c1, "Zbob", None)
Traceback (most recent call last):
...
Invalid: Names can not start with Z
zope.interface.exceptions.Invalid: Names can not start with Z
We can also express constaints on the containers an object can be
added to. We do this by setting a field constraint on an object's
Expand Down Expand Up @@ -76,7 +76,7 @@
>>> checkObject(c1, "bob", O())
Traceback (most recent call last):
...
ConstraintNotSatisfied: (C1, '__parent__')
zope.schema._bootstrapinterfaces.ConstraintNotSatisfied: (C1, '__parent__')
Note that the validation error isn't very informative. For that
reason, it's better for constraints to raise Invalid errors when they
Expand All @@ -98,7 +98,7 @@
>>> checkObject(c1, "bob", O())
Traceback (most recent call last):
...
Invalid: What, no x?
zope.interface.exceptions.Invalid: What, no x?
>>> c1.x = 1
>>> checkObject(c1, "bob", O())
Expand Down Expand Up @@ -246,7 +246,7 @@ def factory(container, name, factory):
"""


class _TypesBased(object):
class _TypesBased:

@readproperty
def types(self):
Expand Down
6 changes: 3 additions & 3 deletions src/zope/container/constraints.rst
Expand Up @@ -59,15 +59,15 @@ If we try to use other containers or folders, we'll get errors:
>>> checkObject(Container(), 'x', Buddy())
... # doctest: +ELLIPSIS
Traceback (most recent call last):
InvalidContainerType: ...
zope.container.interfaces.InvalidContainerType: ...

>>> checkFactory(Container(), 'x', Factory(Buddy))
False

>>> checkObject(BuddyFolder(), 'x', Contained())
... # doctest: +ELLIPSIS
Traceback (most recent call last):
InvalidItemType: ...
zope.container.interfaces.InvalidItemType: ...

>>> checkFactory(BuddyFolder(), 'x', Factory(Contained))
False
Expand All @@ -90,7 +90,7 @@ could have defined these in the opposite order:
>>> checkObject(Contacts(), 'x', Buddy())
... # doctest: +ELLIPSIS
Traceback (most recent call last):
InvalidItemType: ...
zope.container.interfaces.InvalidItemType: ...

>>> checkFactory(Contacts(), 'x', Factory(Buddy))
False
Expand Down

0 comments on commit c708697

Please sign in to comment.