diff options
author | Jens Vagelpohl <jens@plyp.com> | 2023-01-03 15:38:02 +0100 |
---|---|---|
committer | Jens Vagelpohl <jens@plyp.com> | 2023-01-03 15:38:02 +0100 |
commit | b2c3f4cc3696ec4a1145ace00482884edffb834c (patch) | |
tree | 38021745ebe7664fb451a161da634acf49e93c56 | |
parent | 348ad7373f2616f044ceb1767c198c9be31b922e (diff) | |
download | zope-proxy-b2c3f4cc3696ec4a1145ace00482884edffb834c.tar.gz |
- Drop support for Python 2.7, 3.5, 3.6.
-rw-r--r-- | .github/workflows/tests.yml | 56 | ||||
-rwxr-xr-x | .manylinux-install.sh | 6 | ||||
-rw-r--r-- | .meta.toml | 3 | ||||
-rw-r--r-- | CHANGES.rst | 2 | ||||
-rw-r--r-- | appveyor.yml | 3 | ||||
-rw-r--r-- | setup.cfg | 2 | ||||
-rw-r--r-- | setup.py | 7 | ||||
-rw-r--r-- | src/zope/proxy/__init__.py | 33 | ||||
-rw-r--r-- | src/zope/proxy/_compat.py | 4 | ||||
-rw-r--r-- | src/zope/proxy/_zope_proxy_proxy.c | 210 | ||||
-rw-r--r-- | src/zope/proxy/proxy.h | 6 | ||||
-rw-r--r-- | src/zope/proxy/tests/test_decorator.py | 20 | ||||
-rw-r--r-- | src/zope/proxy/tests/test_proxy.py | 269 | ||||
-rw-r--r-- | tox.ini | 9 |
14 files changed, 115 insertions, 515 deletions
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ec158db..71ec718 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -96,24 +96,16 @@ jobs: fail-fast: false matrix: python-version: - - "2.7" - - "3.5" - - "pypy-2.7" - "pypy-3.7" - - "3.6" - "3.7" - "3.8" - "3.9" - "3.10" - "3.11" - os: [ubuntu-20.04, macos-latest] + os: [ubuntu-20.04, macos-11] exclude: - - os: macos-latest - python-version: "pypy-2.7" - - os: macos-latest + - os: macos-11 python-version: "pypy-3.7" - - os: macos-latest - python-version: "3.5" steps: - name: checkout @@ -141,15 +133,7 @@ jobs: restore-keys: | ${{ runner.os }}-pip- - - name: Install Build Dependencies (PyPy2) - if: > - startsWith(matrix.python-version, 'pypy-2.7') - run: | - pip install -U pip - pip install -U setuptools wheel twine "cffi != 1.15.1" - - name: Install Build Dependencies (other Python versions) - if: > - !startsWith(matrix.python-version, 'pypy-2.7') + - name: Install Build Dependencies run: | pip install -U pip pip install -U setuptools wheel twine cffi @@ -158,9 +142,6 @@ jobs: if: > startsWith(runner.os, 'Mac') && !(startsWith(matrix.python-version, 'pypy') - || matrix.python-version == '2.7' - || matrix.python-version == '3.5' - || matrix.python-version == '3.6' || matrix.python-version == '3.7') env: MACOSX_DEPLOYMENT_TARGET: 10.9 @@ -175,9 +156,6 @@ jobs: if: > startsWith(runner.os, 'Mac') && !(startsWith(matrix.python-version, 'pypy') - || matrix.python-version == '2.7' - || matrix.python-version == '3.5' - || matrix.python-version == '3.6' || matrix.python-version == '3.7') env: MACOSX_DEPLOYMENT_TARGET: 11.0 @@ -192,9 +170,6 @@ jobs: if: > !startsWith(runner.os, 'Mac') || startsWith(matrix.python-version, 'pypy') - || matrix.python-version == '2.7' - || matrix.python-version == '3.5' - || matrix.python-version == '3.6' || matrix.python-version == '3.7' run: | # Next, build the wheel *in place*. This helps ccache, and also lets us cache the configure @@ -205,7 +180,6 @@ jobs: - name: Install zope.proxy and dependencies run: | # Install to collect dependencies into the (pip) cache. - pip install -U 'faulthandler; python_version == "2.7" and platform_python_implementation == "CPython"' pip install .[test] - name: Check zope.proxy build @@ -223,9 +197,6 @@ jobs: if: > startsWith(runner.os, 'Mac') && !(startsWith(matrix.python-version, 'pypy') - || matrix.python-version == '2.7' - || matrix.python-version == '3.5' - || matrix.python-version == '3.6' || matrix.python-version == '3.7') uses: actions/upload-artifact@v3 with: @@ -262,24 +233,16 @@ jobs: fail-fast: false matrix: python-version: - - "2.7" - - "3.5" - - "pypy-2.7" - "pypy-3.7" - - "3.6" - "3.7" - "3.8" - "3.9" - "3.10" - "3.11" - os: [ubuntu-20.04, macos-latest] + os: [ubuntu-20.04, macos-11] exclude: - - os: macos-latest - python-version: "pypy-2.7" - - os: macos-latest + - os: macos-11 python-version: "pypy-3.7" - - os: macos-latest - python-version: "3.5" steps: - name: checkout @@ -316,7 +279,6 @@ jobs: run: | pip install -U wheel setuptools pip install -U coverage - pip install -U 'faulthandler; python_version == "2.7" and platform_python_implementation == "CPython"' pip install -U 'cffi; platform_python_implementation == "CPython"' # Unzip into src/ so that testrunner can find the .so files # when we ask it to load tests from that directory. This @@ -461,7 +423,7 @@ jobs: strategy: matrix: python-version: ["3.9"] - image: [manylinux2010_x86_64, manylinux2010_i686, manylinux2014_aarch64] + image: [manylinux2014_x86_64, manylinux2014_i686, manylinux2014_aarch64] steps: - name: checkout @@ -492,18 +454,16 @@ jobs: - name: Update pip run: pip install -U pip - name: Build zope.proxy (x86_64) - if: matrix.image == 'manylinux2010_x86_64' + if: matrix.image == 'manylinux2014_x86_64' # An alternate way to do this is to run the container directly with a uses: # and then the script runs inside it. That may work better with caching. # See https://github.com/pyca/bcrypt/blob/f6b5ee2eda76d077c531362ac65e16f045cf1f29/.github/workflows/wheel-builder.yml - # The 2010 image is the most recent spec that comes with Python 2.7, - # and only up through the tag 2021-02-06-3d322a5 env: DOCKER_IMAGE: quay.io/pypa/${{ matrix.image }} run: | bash .manylinux.sh - name: Build zope.proxy (i686) - if: matrix.image == 'manylinux2010_i686' + if: matrix.image == 'manylinux2014_i686' env: DOCKER_IMAGE: quay.io/pypa/${{ matrix.image }} PRE_CMD: linux32 diff --git a/.manylinux-install.sh b/.manylinux-install.sh index c23d663..01b847c 100755 --- a/.manylinux-install.sh +++ b/.manylinux-install.sh @@ -28,9 +28,6 @@ yum -y install libffi-devel tox_env_map() { case $1 in - *"cp27"*) echo 'py27';; - *"cp35"*) echo 'py35';; - *"cp36"*) echo 'py36';; *"cp37"*) echo 'py37';; *"cp38"*) echo 'py38';; *"cp39"*) echo 'py39';; @@ -43,10 +40,7 @@ tox_env_map() { # Compile wheels for PYBIN in /opt/python/*/bin; do if \ - [[ "${PYBIN}" == *"cp27"* ]] || \ - [[ "${PYBIN}" == *"cp35"* ]] || \ [[ "${PYBIN}" == *"cp311"* ]] || \ - [[ "${PYBIN}" == *"cp36"* ]] || \ [[ "${PYBIN}" == *"cp37"* ]] || \ [[ "${PYBIN}" == *"cp38"* ]] || \ [[ "${PYBIN}" == *"cp39"* ]] || \ @@ -2,14 +2,13 @@ # https://github.com/zopefoundation/meta/tree/master/config/c-code [meta] template = "c-code" -commit-id = "342271a70d886e753e5cc629e8a81b3cfab692ac" +commit-id = "3c9d0741" [python] with-appveyor = true with-windows = false with-pypy = true with-future-python = false -with-legacy-python = true with-docs = true with-sphinx-doctests = true with-macos = false diff --git a/CHANGES.rst b/CHANGES.rst index 9a32988..80c8c7d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,9 +5,9 @@ 5.0.0 (unreleased) ================== - - Drop support for Python 2.7, 3.5, 3.6. + 4.6.1 (2022-11-16) ================== diff --git a/appveyor.yml b/appveyor.yml index 68f58e7..fbf5dda 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,9 +9,6 @@ environment: secure: aoZC/+rvJKg8B5GMGIxd1bg9UDShk28EhfPQFKI9zy7kzygdgj0XuaK619sLe3s4B08bIJaIUAThxEvWq13IvdLb5Oyk8B9qubd+NnDiNuw8WCGy4owYnbl+61fUVVKJIf1ETQyGDooYrEuBo798/+ycQbilTpmncAHZb2KyZkmA210fcWr7OhwmlRtC4IiW7GPCaxU6qhzLlP5pnS2Tl+yy/qx2DiW2fKWqUqynrb1ZMsk6ygN4qV72glTY6wV0eYboAGlghrws1x5+Z10Yug== matrix: - - python: 27-x64 - - python: 35-x64 - - python: 36-x64 - python: 37-x64 - python: 38-x64 - python: 39-x64 @@ -1,7 +1,7 @@ # Generated from: # https://github.com/zopefoundation/meta/tree/master/config/c-code [bdist_wheel] -universal = 1 +universal = 0 [zest.releaser] create-wheel = no @@ -18,7 +18,6 @@ ############################################################################## """Setup for zope.proxy package """ -from __future__ import print_function import os import platform @@ -101,11 +100,7 @@ setup(name='zope.proxy', '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', @@ -126,7 +121,7 @@ setup(name='zope.proxy', }, headers=headers, ext_modules=ext_modules, - python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*', + python_requires='>=3.7', install_requires=[ 'zope.interface', 'setuptools', diff --git a/src/zope/proxy/__init__.py b/src/zope/proxy/__init__.py index 3fc4b53..43202b9 100644 --- a/src/zope/proxy/__init__.py +++ b/src/zope/proxy/__init__.py @@ -60,7 +60,7 @@ def _get_wrapped(self): return super(AbstractPyProxyBase, self).__getattribute__('_wrapped') -class _EmptyInterfaceDescriptor(object): +class _EmptyInterfaceDescriptor: """A descriptor for the attributes used on the class by the Python implementation of `zope.interface`. @@ -91,7 +91,7 @@ class _ProxyMetaclass(type): __implemented__ = _EmptyInterfaceDescriptor() -class AbstractPyProxyBase(object): +class AbstractPyProxyBase: """ A reference implementation that cannot be instantiated. Most users will want to use :class:`PyProxyBase`. @@ -123,8 +123,8 @@ class AbstractPyProxyBase(object): def __str__(self): return str(self._wrapped) - def __unicode__(self): # pragma: no cover PY2 - return unicode(self._wrapped) # noqa: F821 undefined name + def __bytes__(self): + return bytes(self._wrapped) def __reduce__(self): # pragma: no cover (__reduce_ex__ prevents normal) raise pickle.PicklingError @@ -251,16 +251,15 @@ class AbstractPyProxyBase(object): # time. return iter(self._wrapped) - def next(self): # pragma: no cover PY2 + def next(self): # Called when we wrap an iterator itself. - return self._wrapped.next() + return next(self._wrapped) def __next__(self): return self._wrapped.__next__() - # Python 2.7 won't let the C wrapper support __reversed__ :( - # def __reversed__(self): - # return reversed(self._wrapped) + def __reversed__(self): + return reversed(self._wrapped) def __contains__(self, item): return item in self._wrapped @@ -285,8 +284,8 @@ class AbstractPyProxyBase(object): def __int__(self): return int(self._wrapped) - def __long__(self): # pragma: no cover PY2 - return long(self._wrapped) # noqa: F821 undefined name + def __long__(self): # Must stick around until zope.security is fixed + return int(self._wrapped) def __float__(self): return float(self._wrapped) @@ -300,14 +299,6 @@ class AbstractPyProxyBase(object): def __index__(self): return operator.index(self._wrapped) - # Numeric protocol: binary coercion - def __coerce__(self, other): # pragma: no cover PY2 - left, right = coerce(self._wrapped, other) # noqa: F821 undefined name - if (left == self._wrapped - and type(left) is type(self._wrapped)): # noqa: E721 - left = self - return left, right - # Numeric protocol: binary arithmetic operators def __add__(self, other): return self._wrapped + other @@ -463,7 +454,7 @@ class AbstractPyProxyBase(object): return self -AbstractPyProxyBase = _ProxyMetaclass(str('AbstractPyProxyBase'), (), +AbstractPyProxyBase = _ProxyMetaclass('AbstractPyProxyBase', (), dict(AbstractPyProxyBase.__dict__)) @@ -537,7 +528,7 @@ if 'PURE_PYTHON' not in os.environ: pass -class PyNonOverridable(object): +class PyNonOverridable: "Deprecated, only for BWC." def __init__(self, method_desc): # pragma: no cover PyPy diff --git a/src/zope/proxy/_compat.py b/src/zope/proxy/_compat.py deleted file mode 100644 index 4f0b0e3..0000000 --- a/src/zope/proxy/_compat.py +++ /dev/null @@ -1,4 +0,0 @@ -import sys - - -PY3 = sys.version_info[0] >= 3 diff --git a/src/zope/proxy/_zope_proxy_proxy.c b/src/zope/proxy/_zope_proxy_proxy.c index f846acc..3bfaa3b 100644 --- a/src/zope/proxy/_zope_proxy_proxy.c +++ b/src/zope/proxy/_zope_proxy_proxy.c @@ -38,34 +38,16 @@ static PyObject * empty_tuple = NULL; -#if PY_VERSION_HEX < 0x02070000 - #define PyCapsule_New(pointer, name, destr) \ - PyCObject_FromVoidPtr(pointer, destr) -#endif - -// Compatibility with Python 2 -#if PY_MAJOR_VERSION < 3 - #define MOD_ERROR_VAL - - #define MOD_SUCCESS_VAL(val) - - #define MOD_INIT(name) void init##name(void) - - #define MOD_DEF(ob, name, doc, methods) \ - ob = Py_InitModule3(name, methods, doc); +#define MOD_ERROR_VAL NULL -#else - #define MOD_ERROR_VAL NULL +#define MOD_SUCCESS_VAL(val) val - #define MOD_SUCCESS_VAL(val) val +#define MOD_INIT(name) PyMODINIT_FUNC PyInit_##name(void) - #define MOD_INIT(name) PyMODINIT_FUNC PyInit_##name(void) - - #define MOD_DEF(ob, name, doc, methods) \ - static struct PyModuleDef moduledef = { \ - PyModuleDef_HEAD_INIT, name, doc, -1, methods, }; \ - ob = PyModule_Create(&moduledef); -#endif +#define MOD_DEF(ob, name, doc, methods) \ + static struct PyModuleDef moduledef = { \ + PyModuleDef_HEAD_INIT, name, doc, -1, methods, }; \ + ob = PyModule_Create(&moduledef); @@ -205,11 +187,6 @@ WrapperType_Lookup(PyTypeObject *type, PyObject *name) base = PyTuple_GET_ITEM(mro, i); if (((PyTypeObject *)base) != &ProxyType) { -#if PY_MAJOR_VERSION < 3 - if (PyClass_Check(base)) - dict = ((PyClassObject *)base)->cl_dict; - else -#endif { assert(PyType_Check(base)); dict = ((PyTypeObject *)base)->tp_dict; @@ -234,11 +211,7 @@ wrap_getattro(PyObject *self, PyObject *name) const char *name_as_string; int maybe_special_name; -#if PY_MAJOR_VERSION < 3 - name_as_string = PyString_AsString(name); -#else name_as_string = PyUnicode_AsUTF8(name); -#endif if (name_as_string == NULL) { return NULL; @@ -262,9 +235,6 @@ wrap_getattro(PyObject *self, PyObject *name) if (descriptor != NULL) { if (descriptor->ob_type->tp_descr_get != NULL -#if PY_MAJOR_VERSION < 3 // Always true in Python 3 - && PyType_HasFeature(descriptor->ob_type, Py_TPFLAGS_HAVE_CLASS) -#endif ){ if (descriptor->ob_type->tp_descr_set == NULL) { @@ -305,11 +275,7 @@ wrap_setattro(PyObject *self, PyObject *name, PyObject *value) const char *name_as_string; int res = -1; -#if PY_MAJOR_VERSION < 3 - name_as_string = PyString_AsString(name); -#else name_as_string = PyUnicode_AsUTF8(name); -#endif if (name_as_string == NULL) { goto finally; @@ -318,9 +284,6 @@ wrap_setattro(PyObject *self, PyObject *name, PyObject *value) descriptor = WrapperType_Lookup(self->ob_type, name); if (descriptor != NULL -#if PY_MAJOR_VERSION < 3 // This is always true in Python 3 (I think) - && PyType_HasFeature(descriptor->ob_type, Py_TPFLAGS_HAVE_CLASS) -#endif && descriptor->ob_type->tp_descr_set != NULL) { res = descriptor->ob_type->tp_descr_set(descriptor, self, value); @@ -340,15 +303,6 @@ finally: return res; } -#if PY_MAJOR_VERSION < 3 -// tp_print slot function; reserved and unused in Python 3 -static int -wrap_print(PyObject *wrapper, FILE *fp, int flags) -{ - return PyObject_Print(Proxy_GET_OBJECT(wrapper), fp, flags); -} -#endif - static PyObject * wrap_str(PyObject *wrapper) { return PyObject_Str(Proxy_GET_OBJECT(wrapper)); @@ -360,14 +314,6 @@ wrap_repr(PyObject *wrapper) return PyObject_Repr(Proxy_GET_OBJECT(wrapper)); } -#if PY_MAJOR_VERSION < 3 -static int -wrap_compare(PyObject *wrapper, PyObject *v) -{ - return PyObject_Compare(Proxy_GET_OBJECT(wrapper), v); -} -#endif - static long wrap_hash(PyObject *self) { @@ -391,45 +337,9 @@ wrap_call(PyObject *self, PyObject *args, PyObject *kw) static PyObject * call_int(PyObject *self) { -#if PY_MAJOR_VERSION < 3 - return PyNumber_Int(self); -#else - return PyNumber_Long(self); -#endif -} - -#if PY_MAJOR_VERSION < 3 // Python 3 has no long, oct or hex methods. -static PyObject * -call_long(PyObject *self) -{ return PyNumber_Long(self); } -static PyObject * -call_oct(PyObject *self) -{ - PyNumberMethods *nb = self->ob_type->tp_as_number; - if (nb == NULL || nb->nb_oct== NULL) { - PyErr_SetString(PyExc_TypeError, - "object can't be converted to oct"); - return NULL; - } - return nb->nb_oct(self); -} - -static PyObject * -call_hex(PyObject *self) -{ - PyNumberMethods *nb = self->ob_type->tp_as_number; - if (nb == NULL || nb->nb_hex == NULL) { - PyErr_SetString(PyExc_TypeError, - "object can't be converted to hex"); - return NULL; - } - return nb->nb_hex(self); -} - -#endif static PyObject * call_index(PyObject *self) @@ -450,14 +360,6 @@ call_ipow(PyObject *self, PyObject *other) return PyNumber_InPlacePower(self, other, Py_None); } -#if PY_MAJOR_VERSION < 3 -static PyObject * -call_unicode(PyObject *self) -{ - return PyObject_Unicode(self); -} -#endif - typedef PyObject *(*function1)(PyObject *); @@ -540,9 +442,6 @@ check2i(ProxyObject *self, PyObject *other, BINOP(add, PyNumber_Add) BINOP(sub, PyNumber_Subtract) BINOP(mul, PyNumber_Multiply) -#if PY_MAJOR_VERSION < 3 // Python 3 doesn't support the old integer division -BINOP(div, PyNumber_Divide) -#endif BINOP(mod, PyNumber_Remainder) BINOP(divmod, PyNumber_Divmod) @@ -577,47 +476,6 @@ BINOP(and, PyNumber_And) BINOP(xor, PyNumber_Xor) BINOP(or, PyNumber_Or) -#if PY_MAJOR_VERSION < 3 // Coercion is gone in Python 3 -static int -wrap_coerce(PyObject **p_self, PyObject **p_other) -{ - PyObject *self = *p_self; - PyObject *other = *p_other; - PyObject *object; - PyObject *left; - PyObject *right; - int r; - - assert(Proxy_Check(self)); - object = Proxy_GET_OBJECT(self); - - left = object; - right = other; - r = PyNumber_CoerceEx(&left, &right); - if (r != 0) - return r; - /* Now left and right have been INCREF'ed. Any new value that - comes out is proxied; any unchanged value is left unchanged. */ - if (left == object) { - /* Keep the old proxy */ - Py_INCREF(self); - Py_DECREF(left); - left = self; - } -#if 0 - else { - /* ??? create proxy for left? */ - } - if (right != other) { - /* ??? create proxy for right? */ - } -#endif - *p_self = left; - *p_other = right; - return 0; -} -#endif - UNOP(neg, PyNumber_Negative) UNOP(pos, PyNumber_Positive) UNOP(abs, PyNumber_Absolute) @@ -625,18 +483,10 @@ UNOP(invert, PyNumber_Invert) UNOP(int, call_int) UNOP(float, call_float) -#if PY_MAJOR_VERSION < 3 // Python 3 has no long, oct or hex methods -UNOP(long, call_long) -UNOP(oct, call_oct) -UNOP(hex, call_hex) -#endif INPLACE(add, PyNumber_InPlaceAdd) INPLACE(sub, PyNumber_InPlaceSubtract) INPLACE(mul, PyNumber_InPlaceMultiply) -#if PY_MAJOR_VERSION < 3 // The old integer division operator is gone in Python 3 -INPLACE(div, PyNumber_InPlaceDivide) -#endif INPLACE(mod, PyNumber_InPlaceRemainder) INPLACE(pow, call_ipow) INPLACE(lshift, PyNumber_InPlaceLshift) @@ -651,9 +501,6 @@ INPLACE(floordiv, PyNumber_InPlaceFloorDivide) INPLACE(truediv, PyNumber_InPlaceTrueDivide) UNOP(index, call_index) -#if PY_MAJOR_VERSION < 3 // Python 3 has no __unicode__ method -UNOP(unicode, call_unicode) -#endif static int wrap_nonzero(PyObject *self) @@ -681,14 +528,6 @@ wrap_slice(PyObject *self, Py_ssize_t start, Py_ssize_t end) * call the slice method the type provides. */ PyObject *obj = Proxy_GET_OBJECT(self); -#if PY_MAJOR_VERSION < 3 - PySequenceMethods *m; - - m = obj->ob_type->tp_as_sequence; - if (m && m->sq_slice) { - return m->sq_slice(obj, start, end); - } -#endif return PySequence_GetSlice(obj, start, end); } @@ -766,9 +605,6 @@ wrap_as_number = { wrap_add, /* nb_add */ wrap_sub, /* nb_subtract */ wrap_mul, /* nb_multiply */ -#if PY_MAJOR_VERSION < 3 - wrap_div, /* nb_divide */ -#endif wrap_mod, /* nb_remainder */ wrap_divmod, /* nb_divmod */ wrap_pow, /* nb_power */ @@ -782,29 +618,15 @@ wrap_as_number = { wrap_and, /* nb_and */ wrap_xor, /* nb_xor */ wrap_or, /* nb_or */ -#if PY_MAJOR_VERSION < 3 - wrap_coerce, /* nb_coerce */ -#endif wrap_int, /* nb_int */ -#if PY_MAJOR_VERSION < 3 - wrap_long, /* nb_long */ -#else 0, /* formerly known as nb_long */ -#endif wrap_float, /* nb_float */ -#if PY_MAJOR_VERSION < 3 - wrap_oct, /* nb_oct */ - wrap_hex, /* nb_hex */ -#endif /* Added in release 2.0 */ /* These require the Py_TPFLAGS_HAVE_INPLACEOPS flag */ wrap_iadd, /* nb_inplace_add */ wrap_isub, /* nb_inplace_subtract */ wrap_imul, /* nb_inplace_multiply */ -#if PY_MAJOR_VERSION < 3 - wrap_idiv, /* nb_inplace_divide */ -#endif wrap_imod, /* nb_inplace_remainder */ (ternaryfunc)wrap_ipow, /* nb_inplace_power */ wrap_ilshift, /* nb_inplace_lshift */ @@ -844,9 +666,6 @@ wrap_as_mapping = { static PyMethodDef wrap_methods[] = { {"__reduce__", (PyCFunction)wrap_reduce, METH_NOARGS, reduce__doc__}, -#if PY_MAJOR_VERSION < 3 - {"__unicode__", (PyCFunction)wrap_unicode, METH_NOARGS, "" }, -#endif {NULL, NULL}, }; @@ -868,18 +687,10 @@ ProxyType = { sizeof(ProxyObject), 0, wrap_dealloc, /* tp_dealloc */ -#if PY_MAJOR_VERSION < 3 - wrap_print, /* tp_print */ -#else 0, /* reserved 3.0--3.7; tp_vectorcall_offset 3.8+ */ -#endif 0, /* tp_getattr */ 0, /* tp_setattr */ -#if PY_MAJOR_VERSION < 3 - wrap_compare, /* tp_compare */ -#else 0, /* tp_reserved */ -#endif wrap_repr, /* tp_repr */ &wrap_as_number, /* tp_as_number */ &wrap_as_sequence, /* tp_as_sequence */ @@ -890,16 +701,9 @@ ProxyType = { wrap_getattro, /* tp_getattro */ wrap_setattro, /* tp_setattro */ 0, /* tp_as_buffer */ -#if PY_MAJOR_VERSION < 3 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_CHECKTYPES | Py_TPFLAGS_BASETYPE, /* tp_flags */ -#else // Py_TPFLAGS_CHECKTYPES is always true in Python 3 and removed. - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE, /* tp_flags */ -#endif 0, /* tp_doc */ wrap_traverse, /* tp_traverse */ wrap_clear, /* tp_clear */ diff --git a/src/zope/proxy/proxy.h b/src/zope/proxy/proxy.h index 509564e..10e5b5b 100644 --- a/src/zope/proxy/proxy.h +++ b/src/zope/proxy/proxy.h @@ -32,15 +32,9 @@ Proxy_Import(void) if (m != NULL) { PyObject *tmp = PyObject_GetAttrString(m, "_CAPI"); if (tmp != NULL) { -#if PY_VERSION_HEX < 0x02070000 - if (PyCObject_Check(tmp)) - _proxy_api = (ProxyInterface *) - PyCObject_AsVoidPtr(tmp); -#else if (PyCapsule_CheckExact(tmp)) _proxy_api = (ProxyInterface *) PyCapsule_GetPointer(tmp, NULL); -#endif Py_DECREF(tmp); } } diff --git a/src/zope/proxy/tests/test_decorator.py b/src/zope/proxy/tests/test_decorator.py index 6d6c8f9..23f228f 100644 --- a/src/zope/proxy/tests/test_decorator.py +++ b/src/zope/proxy/tests/test_decorator.py @@ -38,7 +38,7 @@ class DecoratorSpecificationDescriptorTests(unittest.TestCase): @provider(IContextFactory) @implementer(IContext) - class Context(object): + class Context: pass dsd = self._makeOne() self.assertEqual(list(dsd.__get__(None, Context)), [IContextFactory]) @@ -56,7 +56,7 @@ class DecoratorSpecificationDescriptorTests(unittest.TestCase): @provider(IContextFactory) @implementer(IContext) - class Context(object): + class Context: pass dsd = self._makeOne() self.assertEqual(list(dsd.__get__(Context(), None)), [IContext]) @@ -76,7 +76,7 @@ class DecoratorSpecificationDescriptorTests(unittest.TestCase): @provider(IContextFactory) @implementer(IContext) - class Context(object): + class Context: pass context = Context() proxy = ProxyBase(context) @@ -98,7 +98,7 @@ class DecoratorSpecificationDescriptorTests(unittest.TestCase): @provider(IContextFactory) @implementer(IContext) - class Context(object): + class Context: pass class IProxyFactory(Interface): @@ -125,7 +125,7 @@ class DecoratorSpecificationDescriptorTests(unittest.TestCase): pass @implementer(IFoo) - class Foo(object): + class Foo: pass foo = Foo() dsd = self._makeOne() @@ -150,7 +150,7 @@ class SpecificationDecoratorBaseTests(unittest.TestCase): pass @implementer(IFoo) - class Foo(object): + class Foo: pass foo = Foo() proxy = self._makeOne(foo) @@ -167,7 +167,7 @@ class SpecificationDecoratorBaseTests(unittest.TestCase): pass @implementer(IFoo) - class Foo(object): + class Foo: from_foo = 1 class IWrapper(Interface): @@ -186,6 +186,8 @@ class SpecificationDecoratorBaseTests(unittest.TestCase): def test_suite(): return unittest.TestSuite(( - unittest.makeSuite(DecoratorSpecificationDescriptorTests), - unittest.makeSuite(SpecificationDecoratorBaseTests), + unittest.defaultTestLoader.loadTestsFromTestCase( + DecoratorSpecificationDescriptorTests), + unittest.defaultTestLoader.loadTestsFromTestCase( + SpecificationDecoratorBaseTests), )) diff --git a/src/zope/proxy/tests/test_proxy.py b/src/zope/proxy/tests/test_proxy.py index 973cb2c..2f52ae6 100644 --- a/src/zope/proxy/tests/test_proxy.py +++ b/src/zope/proxy/tests/test_proxy.py @@ -24,8 +24,6 @@ else: _HAVE_ZOPE_SECURITY = True del zope.security -from zope.proxy._compat import PY3 - class ModuleConformanceCase(unittest.TestCase): @@ -40,8 +38,8 @@ class ModuleConformanceCase(unittest.TestCase): class PyProxyBaseTestCase(unittest.TestCase): # Names of special methods - getslice = '__getitem__' if PY3 else '__getslice__' - setslice = '__setitem__' if PY3 else '__setslice__' + getslice = '__getitem__' + setslice = '__setitem__' # Avoid DeprecationWarning for assertRaisesRegexp on Python 3 while # coping with Python 2 not having the Regex spelling variant @@ -65,10 +63,10 @@ class PyProxyBaseTestCase(unittest.TestCase): def test_subclass_constructor(self): class MyProxy(self._getTargetClass()): def __new__(cls, *args, **kwds): - return super(MyProxy, cls).__new__(cls, *args, **kwds) + return super().__new__(cls, *args, **kwds) def __init__(self, *args, **kwds): - super(MyProxy, self).__init__(*args, **kwds) + super().__init__(*args, **kwds) o1 = object() o2 = object() o = MyProxy((o1, o2)) @@ -84,7 +82,7 @@ class PyProxyBaseTestCase(unittest.TestCase): # to __new__(). class MyProxy2(self._getTargetClass()): def __new__(cls, *args, **kwds): - return super(MyProxy2, cls).__new__(cls, 'value') + return super().__new__(cls, 'value') proxy = MyProxy2('splat!') self.assertEqual(list(proxy), list('splat!')) @@ -93,13 +91,13 @@ class PyProxyBaseTestCase(unittest.TestCase): def __init__(self, arg): if list(self) != list('value'): raise AssertionError("list(self) != list('value')") - super(MyProxy3, self).__init__('another') + super().__init__('another') proxy = MyProxy3('notused') self.assertEqual(list(proxy), list('another')) def test_custom_int_to_int(self): - class CustomClass(object): + class CustomClass: def __int__(self): return 42 proxy = self._makeOne(CustomClass()) @@ -118,49 +116,18 @@ class PyProxyBaseTestCase(unittest.TestCase): self.assertRaises(ValueError, float, proxy) def test_custom_float_to_float(self): - class CustomClass(object): + class CustomClass: def __float__(self): return 42.0 proxy = self._makeOne(CustomClass()) self.assertEqual(42.0, float(proxy)) - @unittest.skipIf(PY3, "Gone in Py3") - def test___unicode__of_unicode(self): # pragma: no cover PY2 - s = u'Hello, \u2603' - proxy = self._makeOne(s) - self.assertEqual(unicode(proxy), s) # noqa: F821 undef - - @unittest.skipIf(PY3, "Gone in Py3") - def test___unicode__of_custom_class(self): # pragma: no cover PY2 - class CustomClass(object): - def __unicode__(self): - return u'Hello, \u2603' - cc = CustomClass() - self.assertEqual(unicode(cc), u'Hello, \u2603') # noqa: F821 undef - proxy = self._makeOne(cc) - self.assertEqual(unicode(proxy), u'Hello, \u2603') # noqa: F821 undef - - @unittest.skipIf(PY3, "Gone in Py3") - def test___unicode__of_custom_class_no_unicode(self): # pragma: no cover - class CustomClass(object): - pass - cc = CustomClass() - cc_unicode = unicode(cc) # noqa: F821 undef - self.assertEqual(type(cc_unicode), unicode) # noqa: F821 undef - proxy = self._makeOne(cc) - self.assertEqual(unicode(proxy), cc_unicode) # noqa: F821 undef - def test___call__(self): def _foo(): return 'FOO' proxy = self._makeOne(_foo) self.assertEqual(proxy(), 'FOO') - @unittest.skipIf(PY3, "Gone in Py3") - def test_callable(self): # pragma: no cover PY2 - w = self._makeOne({}.get) - self.assertTrue(callable(w)) - def test___repr__(self): def _foo(): raise AssertionError("Not called") @@ -173,25 +140,6 @@ class PyProxyBaseTestCase(unittest.TestCase): proxy = self._makeOne(_foo) self.assertEqual(str(proxy), str(_foo)) - @unittest.skipIf(PY3, "Gone in Py3") - def test___unicode__(self): # pragma: no cover PY2 - def _foo(): - raise AssertionError("Not called") - proxy = self._makeOne(_foo) - self.assertTrue( - unicode(proxy).startswith('<function _foo')) # noqa: F821 undef - - @unittest.skipIf(PY3, "No old-style classes in Python 3") - def test___reduce___via_pickling(self): # pragma: no cover PY2 - import pickle - - # Proxies of old-style classes can't be pickled. - class Thing: - """This class is expected to be a classic class.""" - w = self._makeOne(Thing()) - self.assertRaises(pickle.PicklingError, - pickle.dumps, w) - def test___eq___and___ne__(self): w = self._makeOne('foo') self.assertEqual(w, 'foo') @@ -253,7 +201,7 @@ class PyProxyBaseTestCase(unittest.TestCase): self.assertEqual(hash(w1), hash(1)) def test___getattr__miss_both(self): - class Foo(object): + class Foo: pass o = Foo() w = self._makeOne(o) @@ -263,7 +211,7 @@ class PyProxyBaseTestCase(unittest.TestCase): self.assertRaises(AttributeError, _try) def test___getattr__delegates_to_wrapped(self): - class Foo(object): + class Foo: pass o = Foo() o.foo = 1 @@ -275,7 +223,7 @@ class PyProxyBaseTestCase(unittest.TestCase): def foo(self): raise AssertionError("Not called") - class Foo(object): + class Foo: def foo(self): return 'FOO' o = Foo() @@ -283,7 +231,7 @@ class PyProxyBaseTestCase(unittest.TestCase): self.assertEqual(w.foo(), 'FOO') def test___setattr__delegates_to_wrapped(self): - class Foo(object): + class Foo: pass o = Foo() w = self._makeOne(o) @@ -297,7 +245,7 @@ class PyProxyBaseTestCase(unittest.TestCase): lambda s, v: s.__dict__.__setitem__('_bar', v) ) - class Foo(object): + class Foo: pass o = Foo() w = Proxy(o) @@ -306,7 +254,7 @@ class PyProxyBaseTestCase(unittest.TestCase): self.assertRaises(AttributeError, getattr, o, 'bar') def test___delattr___wrapped(self): - class Foo(object): + class Foo: pass o = Foo() o.foo = 1 @@ -317,7 +265,7 @@ class PyProxyBaseTestCase(unittest.TestCase): self.assertRaises(AttributeError, _try) def test___delattr__delegates_to_wrapped(self): - class Foo(object): + class Foo: pass o = Foo() o.foo = 1 @@ -373,9 +321,8 @@ class PyProxyBaseTestCase(unittest.TestCase): def test___getitem__w_slice_against_class_w_custom___getslice__(self): import sys - test = self - class Slicer(object): + class Slicer: def __len__(self): return 2 @@ -383,7 +330,6 @@ class PyProxyBaseTestCase(unittest.TestCase): return (start, end) def __getitem__(self, a_slice): - test.assertTrue(PY3) # On Python 3, we basically just return what the test expects. # Mostly that's the computed indices (yay!) but there are # a few special cases. @@ -405,7 +351,7 @@ class PyProxyBaseTestCase(unittest.TestCase): class Missing(Exception): pass - class Get(object): + class Get: def __getitem__(self, x): raise Missing('__getitem__') @@ -415,14 +361,12 @@ class PyProxyBaseTestCase(unittest.TestCase): proxy[1:2] def test___getslice___error_propagates(self): - test = self class Missing(Exception): pass - class Get(object): + class Get: def __getitem__(self, x): - test.assertTrue(PY3) raise Missing('__getitem__') def __getslice__(self, start, stop): # pragma: no cover PY2 @@ -463,7 +407,7 @@ class PyProxyBaseTestCase(unittest.TestCase): class Missing(Exception): pass - class Set(object): + class Set: def __setitem__(self, k, v): raise Missing('__setitem__') @@ -478,7 +422,7 @@ class PyProxyBaseTestCase(unittest.TestCase): class Missing(Exception): pass - class Set(object): + class Set: def __setitem__(self, k, v): raise Missing('__setitem__') @@ -507,7 +451,7 @@ class PyProxyBaseTestCase(unittest.TestCase): def test___iter___returns_self_if_defined(self): # Return the wrapped object itself, if it is an iterator. - class MyIter(object): + class MyIter: def __iter__(self): return self @@ -524,7 +468,7 @@ class PyProxyBaseTestCase(unittest.TestCase): # still to work. PyObject_GetIter() will not be called on the # proxy, so the tp_iter slot won't unwrap it. - class Iterable(object): + class Iterable: def __init__(self, test, data): self.test = test self.data = data @@ -566,8 +510,6 @@ class PyProxyBaseTestCase(unittest.TestCase): "float(x)", "complex(x)", ] - if not PY3: # long is gone in Python 3 - ops.append("long(x)") # pragma: no cover PY2 return ops def test_unops(self): @@ -577,13 +519,11 @@ class PyProxyBaseTestCase(unittest.TestCase): x = self._makeOne(1) z = eval(expr) self.assertEqual(z, y, - "x=%r; expr=%r" % (x, expr)) + "x={!r}; expr={!r}".format(x, expr)) def test_odd_unops(self): # unops that don't return a proxy funcs = (lambda x: not x,) - if not PY3: - funcs += (oct, hex) # pragma: no cover PY2 for func in funcs: self.assertEqual(func(self._makeOne(100)), func(100)) @@ -602,8 +542,8 @@ class PyProxyBaseTestCase(unittest.TestCase): z = eval(expr) first = 0 else: - self.assertEqual(eval(expr), z, - "x=%r; y=%r; expr=%r" % (x, y, expr)) + msg = "x={!r}; y={!r}; expr={!r}".format(x, y, expr) + self.assertEqual(eval(expr), z, msg) def test_pow_w_modulus(self): x = self._makeOne(2) @@ -653,75 +593,6 @@ class PyProxyBaseTestCase(unittest.TestCase): pa ^= 2 self.assertEqual(pa, 20) - @unittest.skipIf(PY3, "No coercion in Py3") - def test_coerce(self): # pragma: no cover PY2 - # Before 2.3, coerce() of two proxies returns them unchanged - - x = self._makeOne(1) - y = self._makeOne(2) - a, b = coerce(x, y) # noqa: F821 undefined name - self.assertTrue(a is x and b is y) - - x = self._makeOne(1) - y = self._makeOne(2.1) - a, b = coerce(x, y) # noqa: F821 undefined name - self.assertTrue(isinstance(a, float)) # a was coerced - self.assertFalse(a is x) - self.assertEqual(a, float(x)) - self.assertTrue(b is y) - - x = self._makeOne(1.1) - y = self._makeOne(2) - a, b = coerce(x, y) # noqa: F821 undefined name - self.assertTrue(a is x) - self.assertTrue(isinstance(b, float)) # b was coerced - self.assertFalse(b is y) - self.assertEqual(b, float(y)) - - x = self._makeOne(1) - y = 2 - a, b = coerce(x, y) # noqa: F821 undefined name - self.assertTrue(a is x) # neither was coerced - self.assertTrue(b is y) - - x = self._makeOne(1) - y = 2.1 - a, b = coerce(x, y) # noqa: F821 undefined name - self.assertTrue(isinstance(a, float)) # a was coerced - self.assertFalse(a is x) - self.assertEqual(a, float(x)) - self.assertTrue(b is y) - - x = self._makeOne(1.1) - y = 2 - a, b = coerce(x, y) # noqa: F821 undefined name - self.assertTrue(a is x) - self.assertTrue(isinstance(b, float)) # b was coerced - self.assertFalse(b is y) - self.assertEqual(b, float(y)) - - x = 1 - y = self._makeOne(2) - a, b = coerce(x, y) # noqa: F821 undefined name - self.assertTrue(a is x) # neither was coerced - self.assertTrue(b is y) - - x = 1.1 - y = self._makeOne(2) - a, b = coerce(x, y) # noqa: F821 undefined name - self.assertTrue(a is x) - self.assertTrue(isinstance(b, float)) # b was coerced - self.assertFalse(b is y) - self.assertEqual(b, float(y)) - - x = 1 - y = self._makeOne(2.1) - a, b = coerce(x, y) # noqa: F821 undefined name - self.assertTrue(isinstance(a, float)) # a was coerced - self.assertFalse(a is x) - self.assertEqual(a, float(x)) - self.assertTrue(b is y) - def test___class__(self): o = object() w = self._makeOne(o) @@ -729,7 +600,7 @@ class PyProxyBaseTestCase(unittest.TestCase): def test_descriptor__set___only_in_proxy_subclass(self): - class Descriptor(object): + class Descriptor: value = None instance = None @@ -751,7 +622,7 @@ class PyProxyBaseTestCase(unittest.TestCase): def test_descriptor__get___set___in_proxy_subclass(self): - class Descriptor(object): + class Descriptor: value = None instance = None cls = None @@ -899,7 +770,7 @@ class Test_py__module(unittest.TestCase): def test__module__in_instance(self): # We can find __module__ in an instance dict - class Module(object): + class Module: def __init__(self): self.__module__ = 'module' @@ -907,14 +778,14 @@ class Test_py__module(unittest.TestCase): def test__module__in_class_instance(self): # We can find module in an instance of a class - class Module(object): + class Module: pass self._check_module(Module(), __name__) def test__module__in_class(self): # We can find module in a class itself - class Module(object): + class Module: pass self._check_module(Module, __name__) @@ -923,7 +794,7 @@ class Test_py__module(unittest.TestCase): # of __eq__ is transitively equal to a proxy of itself. # Seen with zope.interface.interface.Interface - class Module(object): + class Module: def __init__(self): self.__module__ = __name__ @@ -976,20 +847,20 @@ class Test_py_getProxiedObject(unittest.TestCase): return PyProxyBase(obj) def test_no_proxy(self): - class C(object): + class C: pass c = C() self.assertTrue(self._callFUT(c) is c) def test_simple_proxy(self): - class C(object): + class C: pass c = C() proxy = self._makeProxy(c) self.assertTrue(self._callFUT(proxy) is c) def test_nested_proxy(self): - class C(object): + class C: pass c = C() proxy = self._makeProxy(c) @@ -1019,14 +890,14 @@ class Test_py_setProxiedObject(unittest.TestCase): return PyProxyBase(obj) def test_no_proxy(self): - class C(object): + class C: pass c1 = C() c2 = C() self.assertRaises(TypeError, self._callFUT, c1, c2) def test_w_proxy(self): - class C(object): + class C: def __init__(self, name): self.name = name c1 = C('c1') @@ -1038,7 +909,7 @@ class Test_py_setProxiedObject(unittest.TestCase): self.assertEqual(proxy.name, 'c2') def test_w_nested_proxy(self): - class C(object): + class C: def __init__(self, name): self.name = name c1 = C('c1') @@ -1074,7 +945,7 @@ class Test_py_isProxy(unittest.TestCase): return PyProxyBase def test_bare_instance(self): - class C(object): + class C: pass c = C() self.assertFalse(self._callFUT(c)) @@ -1083,7 +954,7 @@ class Test_py_isProxy(unittest.TestCase): class P1(self._proxyClass()): pass - class C(object): + class C: pass c = C() p1 = P1(c) @@ -1093,7 +964,7 @@ class Test_py_isProxy(unittest.TestCase): class P1(self._proxyClass()): pass - class C(object): + class C: pass c = C() p1 = P1(c) @@ -1106,7 +977,7 @@ class Test_py_isProxy(unittest.TestCase): class P2(self._proxyClass()): pass - class C(object): + class C: pass c = C() p1 = P1(c) @@ -1141,13 +1012,13 @@ class Test_py_sameProxiedObjects(unittest.TestCase): return ProxyPy(obj, checker) def test_bare_instance_identical(self): - class C(object): + class C: pass c1 = C() self.assertTrue(self._callFUT(c1, c1)) def test_bare_instances_different(self): - class C(object): + class C: pass c1 = C() c2 = C() @@ -1155,14 +1026,14 @@ class Test_py_sameProxiedObjects(unittest.TestCase): self.assertFalse(self._callFUT(c2, c1)) def test_proxy_and_same_bare(self): - class C(object): + class C: pass c1 = C() self.assertTrue(self._callFUT(self._makeProxy(c1), c1)) self.assertTrue(self._callFUT(c1, self._makeProxy(c1))) def test_proxy_and_other_bare(self): - class C(object): + class C: pass c1 = C() c2 = C() @@ -1172,7 +1043,7 @@ class Test_py_sameProxiedObjects(unittest.TestCase): def test_proxies_w_same_bare(self): _mP = self._makeProxy - class C(object): + class C: pass c1 = C() self.assertTrue(self._callFUT(_mP(c1), _mP(c1))) @@ -1180,7 +1051,7 @@ class Test_py_sameProxiedObjects(unittest.TestCase): def test_proxies_w_other_bare(self): _mP = self._makeProxy - class C(object): + class C: pass c1 = C() c2 = C() @@ -1190,7 +1061,7 @@ class Test_py_sameProxiedObjects(unittest.TestCase): def test_nested_proxy_and_same_bare(self): _mP = self._makeProxy - class C(object): + class C: pass c1 = C() self.assertTrue(self._callFUT(_mP(_mP(c1)), c1)) @@ -1199,7 +1070,7 @@ class Test_py_sameProxiedObjects(unittest.TestCase): def test_nested_proxy_and_other_bare(self): _mP = self._makeProxy - class C(object): + class C: pass c1 = C() c2 = C() @@ -1208,7 +1079,7 @@ class Test_py_sameProxiedObjects(unittest.TestCase): @unittest.skipUnless(_HAVE_ZOPE_SECURITY, 'zope.security missing') def test_security_proxy(self): - class C(object): + class C: pass c1 = C() proxy1 = self._makeSecurityProxy(c1) @@ -1250,7 +1121,7 @@ class Test_py_queryProxy(unittest.TestCase): return PyProxyBase def test_bare_instance(self): - class C(object): + class C: pass c = C() self.assertEqual(self._callFUT(c), None) @@ -1259,7 +1130,7 @@ class Test_py_queryProxy(unittest.TestCase): class P1(self._proxyClass()): pass - class C(object): + class C: pass c = C() p1 = P1(c) @@ -1269,7 +1140,7 @@ class Test_py_queryProxy(unittest.TestCase): class P1(self._proxyClass()): pass - class C(object): + class C: pass c = C() p1 = P1(c) @@ -1283,7 +1154,7 @@ class Test_py_queryProxy(unittest.TestCase): class P2(self._proxyClass()): pass - class C(object): + class C: pass c = C() p1 = P1(c) @@ -1297,7 +1168,7 @@ class Test_py_queryProxy(unittest.TestCase): class P2(self._proxyClass()): pass - class C(object): + class C: pass c = C() p1 = P1(c) @@ -1327,7 +1198,7 @@ class Test_py_queryInnerProxy(unittest.TestCase): return PyProxyBase def test_bare_instance(self): - class C(object): + class C: pass c = C() self.assertEqual(self._callFUT(c), None) @@ -1336,7 +1207,7 @@ class Test_py_queryInnerProxy(unittest.TestCase): class P1(self._proxyClass()): pass - class C(object): + class C: pass c = C() p1 = P1(c) @@ -1346,7 +1217,7 @@ class Test_py_queryInnerProxy(unittest.TestCase): class P1(self._proxyClass()): pass - class C(object): + class C: pass c = C() p1 = P1(c) @@ -1360,7 +1231,7 @@ class Test_py_queryInnerProxy(unittest.TestCase): class P2(self._proxyClass()): pass - class C(object): + class C: pass c = C() p1 = P1(c) @@ -1377,7 +1248,7 @@ class Test_py_queryInnerProxy(unittest.TestCase): class P2(self._proxyClass()): pass - class C(object): + class C: pass c = C() p1 = P1(c) @@ -1416,20 +1287,20 @@ class Test_py_removeAllProxies(unittest.TestCase): return ProxyPy(obj, checker) def test_no_proxy(self): - class C(object): + class C: pass c = C() self.assertTrue(self._callFUT(c) is c) def test_simple_proxy(self): - class C(object): + class C: pass c = C() proxy = self._makeProxy(c) self.assertTrue(self._callFUT(proxy) is c) def test_nested_proxy(self): - class C(object): + class C: pass c = C() proxy = self._makeProxy(c) @@ -1438,7 +1309,7 @@ class Test_py_removeAllProxies(unittest.TestCase): @unittest.skipUnless(_HAVE_ZOPE_SECURITY, 'zope.security missing') def test_security_proxy(self): - class C(object): + class C: pass c = C() proxy = self._makeSecurityProxy(c) @@ -1468,7 +1339,7 @@ class Test_ProxyIterator(unittest.TestCase): return ProxyIterator(*args) def test_no_proxy(self): - class C(object): + class C: pass c = C() self.assertEqual(list(self._callFUT(c)), [c]) @@ -1476,7 +1347,7 @@ class Test_ProxyIterator(unittest.TestCase): def test_w_simple_proxy(self): from zope.proxy import ProxyBase - class C(object): + class C: pass c = C() proxy = ProxyBase(c) @@ -1485,7 +1356,7 @@ class Test_ProxyIterator(unittest.TestCase): def test_w_nested_proxies(self): from zope.proxy import ProxyBase - class C(object): + class C: pass c = C() proxy = ProxyBase(c) @@ -1510,7 +1381,7 @@ class Test_nonOverridable(unittest.TestCase): def what(self): return 'PROXY' - class Foo(object): + class Foo: def who(self): return 'FOO' @@ -1529,7 +1400,7 @@ class TestEmptyInterfaceDescriptor(unittest.TestCase): def _makeOne(self): from zope.proxy import _EmptyInterfaceDescriptor - class It(object): + class It: feature = _EmptyInterfaceDescriptor() return It() @@ -1550,7 +1421,7 @@ class TestEmptyInterfaceDescriptor(unittest.TestCase): self.assertEqual([], list(feature)) -class Comparable(object): +class Comparable: def __init__(self, value): self.value = value @@ -4,15 +4,11 @@ minversion = 3.18 envlist = lint - py27,py27-pure - py35,py35-pure - py36,py36-pure py37,py37-pure py38,py38-pure py39,py39-pure py310,py310-pure py311,py311-pure - pypy pypy3 docs coverage @@ -22,10 +18,10 @@ usedevelop = true deps = setenv = pure: PURE_PYTHON=1 - !pure-!pypy-!pypy3: PURE_PYTHON=0 + !pure-!pypy3: PURE_PYTHON=0 commands = zope-testrunner --test-path=src {posargs:-vc} - !py27-!pypy: sphinx-build -b doctest -d {envdir}/.cache/doctrees docs {envdir}/.cache/doctest + sphinx-build -b doctest -d {envdir}/.cache/doctrees docs {envdir}/.cache/doctest extras = test docs @@ -61,6 +57,7 @@ deps = [testenv:isort-apply] basepython = python3 +skip_install = true commands_pre = deps = isort |