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 b534985 commit 092a6cd
Show file tree
Hide file tree
Showing 42 changed files with 681 additions and 1,782 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Expand Up @@ -9,6 +9,11 @@

- Fix test deprecation warning on Python 3.11.

- Drop:

+ `zope.interface.implements`
+ `zope.interface.implementsOnly`
+ `zope.interface.classProvides`

5.5.2 (2022-11-17)
==================
Expand Down
27 changes: 0 additions & 27 deletions docs/api/declarations.rst
Expand Up @@ -515,33 +515,6 @@ When registering an adapter or utility component, the registry looks for the
provided.


Deprecated Functions
--------------------

implements
~~~~~~~~~~

.. caution:: Does not work on Python 3. Use the `implementer` decorator instead.

.. autofunction:: implements


implementsOnly
~~~~~~~~~~~~~~

.. caution:: Does not work on Python 3. Use the `implementer_only` decorator instead.

.. autofunction:: implementsOnly


classProvides
~~~~~~~~~~~~~

.. caution:: Does not work on Python 3. Use the `provider` decorator instead.

.. autofunction:: classProvides


Querying The Interfaces Of Objects
==================================

Expand Down
13 changes: 2 additions & 11 deletions setup.py
Expand Up @@ -113,11 +113,7 @@ def read(*rnames):
"License :: OSI Approved :: Zope Public License",
"Operating System :: OS Independent",
"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 All @@ -139,13 +135,8 @@ def read(*rnames):
zip_safe=False,
tests_require=tests_require,
install_requires=['setuptools'],
python_requires=', '.join([
'>=2.7',
'!=3.0.*',
'!=3.1.*',
'!=3.2.*',
'!=3.3.*',
'!=3.4.*',
python_requires=','.join([
'>=3.7',
]),
extras_require={
'docs': ['Sphinx', 'repoze.sphinx.autointerface'],
Expand Down
3 changes: 0 additions & 3 deletions src/zope/interface/__init__.py
Expand Up @@ -62,14 +62,11 @@ def meth(arg1, arg2):
from zope.interface.declarations import classImplements
from zope.interface.declarations import classImplementsFirst
from zope.interface.declarations import classImplementsOnly
from zope.interface.declarations import classProvides
from zope.interface.declarations import directlyProvidedBy
from zope.interface.declarations import directlyProvides
from zope.interface.declarations import implementedBy
from zope.interface.declarations import implementer
from zope.interface.declarations import implementer_only
from zope.interface.declarations import implements
from zope.interface.declarations import implementsOnly
from zope.interface.declarations import moduleProvides
from zope.interface.declarations import named
from zope.interface.declarations import noLongerProvides
Expand Down
47 changes: 6 additions & 41 deletions src/zope/interface/_compat.py
Expand Up @@ -20,51 +20,16 @@
"""
import os
import sys
import types

if sys.version_info[0] < 3:

def _normalize_name(name):
if isinstance(name, basestring):
return unicode(name)
raise TypeError("name must be a regular or unicode string")

CLASS_TYPES = (type, types.ClassType)
STRING_TYPES = (basestring,)

_BUILTINS = '__builtin__'

PYTHON3 = False
PYTHON2 = True

else:

def _normalize_name(name):
if isinstance(name, bytes):
name = str(name, 'ascii')
if isinstance(name, str):
return name
raise TypeError("name must be a string or ASCII-only bytes")

CLASS_TYPES = (type,)
STRING_TYPES = (str,)

_BUILTINS = 'builtins'

PYTHON3 = True
PYTHON2 = False
def _normalize_name(name):
if isinstance(name, bytes):
name = str(name, 'ascii')
if isinstance(name, str):
return name
raise TypeError("name must be a string or ASCII-only bytes")

PYPY = hasattr(sys, 'pypy_version_info')
PYPY2 = PYTHON2 and PYPY

def _skip_under_py3k(test_method):
import unittest
return unittest.skipIf(sys.version_info[0] >= 3, "Only on Python 2")(test_method)


def _skip_under_py2(test_method):
import unittest
return unittest.skipIf(sys.version_info[0] < 3, "Only on Python 3")(test_method)


def _c_optimizations_required():
Expand Down
21 changes: 0 additions & 21 deletions src/zope/interface/_zope_interface_coptimizations.c
Expand Up @@ -31,12 +31,7 @@
#define Py_TYPE(o) ((o)->ob_type)
#endif

#if PY_MAJOR_VERSION >= 3
#define PY3K
#define PyNative_FromString PyUnicode_FromString
#else
#define PyNative_FromString PyString_FromString
#endif

static PyObject *str__dict__, *str__implemented__, *strextends;
static PyObject *BuiltinImplementationSpecifications, *str__provides__;
Expand Down Expand Up @@ -763,10 +758,6 @@ __adapt__(PyObject *self, PyObject *obj)
return Py_None;
}

#ifndef PY3K
typedef long Py_hash_t;
#endif

typedef struct {
Spec spec;
PyObject* __name__;
Expand Down Expand Up @@ -1255,11 +1246,7 @@ _lookup(lookup *self,
{
PyObject *result, *key, *cache;
result = key = cache = NULL;
#ifdef PY3K
if ( name && !PyUnicode_Check(name) )
#else
if ( name && !PyString_Check(name) && !PyUnicode_Check(name) )
#endif
{
PyErr_SetString(PyExc_ValueError,
"name is not a string or unicode");
Expand Down Expand Up @@ -1351,11 +1338,7 @@ _lookup1(lookup *self,
{
PyObject *result, *cache;

#ifdef PY3K
if ( name && !PyUnicode_Check(name) )
#else
if ( name && !PyString_Check(name) && !PyUnicode_Check(name) )
#endif
{
PyErr_SetString(PyExc_ValueError,
"name is not a string or unicode");
Expand Down Expand Up @@ -1427,11 +1410,7 @@ _adapter_hook(lookup *self,
{
PyObject *required, *factory, *result;

#ifdef PY3K
if ( name && !PyUnicode_Check(name) )
#else
if ( name && !PyString_Check(name) && !PyUnicode_Check(name) )
#endif
{
PyErr_SetString(PyExc_ValueError,
"name is not a string or unicode");
Expand Down

0 comments on commit 092a6cd

Please sign in to comment.