Skip to content

Commit

Permalink
Drop support for Python 2.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Howitz committed Sep 28, 2020
1 parent ba40130 commit b43886c
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 237 deletions.
7 changes: 6 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
[run]
branch = True
source = Acquisition
plugins = coverage_python_version

[report]
precision = 2
show_missing = True
exclude_lines =
pragma: no cover
if __name__ == '__main__':
raise NotImplementedError
raise AssertionError
self.fail

[paths]
source =
Expand Down
5 changes: 0 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
language: python
python:
- 2.7
- 3.6
- 3.7
- 3.8
- 3.9-dev
- pypy
- pypy3
matrix:
include:
- name: "2.7-pure"
python: "2.7"
env: PURE_PYTHON=1
- name: "3.8-pure"
python: "3.8"
env: PURE_PYTHON=1
Expand Down
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Changelog

- Add support for Python 3.8 and 3.9.

- Drop support for Python 3.5.
- Drop support for Python 2 and 3.5.


4.6 (2019-04-24)
Expand Down
2 changes: 0 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ environment:
secure: y/k8TP312tLRATkXU5dq+g==

matrix:
- python: 27
- python: 27-x64
- python: 36
- python: 36-x64
- python: 37
Expand Down
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@
"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 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
Expand All @@ -68,7 +67,7 @@
"Programming Language :: Python :: Implementation :: PyPy",
],
ext_modules=ext_modules,
python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*',
python_requires='>=3.6, <4',
install_requires=[
'ExtensionClass >= 4.2.0',
'zope.interface',
Expand Down
110 changes: 0 additions & 110 deletions src/Acquisition/_Acquisition.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,6 @@

static ACQUISITIONCAPI AcquisitionCAPI;

// Py_XSETREF is undefined in Python 3.4 only, it's present in 2.7 and 3.5
#ifndef Py_XSETREF

#define Py_XSETREF(op, op2) \
do { \
PyObject *_py_tmp = (PyObject *)(op); \
(op) = (op2); \
Py_XDECREF(_py_tmp); \
} while (0)

#endif

#define ASSIGN(dst, src) Py_XSETREF(dst, src)
#define OBJECT(O) ((PyObject*)(O))

Expand Down Expand Up @@ -982,11 +970,7 @@ Wrapper_bytes(Wrapper *self)
return r;
} else {
PyErr_Clear();
#ifdef PY3K
return PyBytes_FromObject(self->obj);
#else
return Wrapper_str(self);
#endif
}
}

Expand Down Expand Up @@ -1217,11 +1201,6 @@ static PyMappingMethods Wrapper_as_mapping = {

WRAP_BINOP(sub);
WRAP_BINOP(mul);

#ifndef PY3K
WRAP_BINOP(div);
#endif

WRAP_BINOP(mod);
WRAP_BINOP(divmod);
WRAP_TERNARYOP(pow);
Expand All @@ -1236,26 +1215,11 @@ WRAP_BINOP(xor);
WRAP_BINOP(or);

WRAP_UNARYOP(int);

#ifndef PY3K
WRAP_UNARYOP(long);
#endif

WRAP_UNARYOP(float);

#ifndef PY3K
WRAP_UNARYOP(oct);
WRAP_UNARYOP(hex);
#endif

WRAP_BINOP(iadd);
WRAP_BINOP(isub);
WRAP_BINOP(imul);

#ifndef PY3K
WRAP_BINOP(idiv);
#endif

WRAP_BINOP(imod);
WRAP_TERNARYOP(ipow);
WRAP_BINOP(ilshift);
Expand All @@ -1281,11 +1245,7 @@ Wrapper_nonzero(PyObject *self)
PyObject* result = NULL;
PyObject* callable = NULL;

#ifdef PY3K
callable = PyObject_GetAttr(self, py__bool__);
#else
callable = PyObject_GetAttr(self, py__nonzero__);
#endif

if (callable == NULL) {
PyErr_Clear();
Expand All @@ -1311,43 +1271,11 @@ Wrapper_nonzero(PyObject *self)

}

#ifndef PY3K
static int
Wrapper_coerce(PyObject **self, PyObject **o)
{
PyObject *m;

if ((m=PyObject_GetAttr(*self, py__coerce__)) == NULL) {
PyErr_Clear();
Py_INCREF(*self);
Py_INCREF(*o);
return 0;
}

ASSIGN(m, PyObject_CallFunction(m, "O", *o));
if (m == NULL) {
return -1;
}

if (!PyArg_ParseTuple(m, "OO", self, o)) {
Py_DECREF(m);
return -1;
}

Py_INCREF(*self);
Py_INCREF(*o);
Py_DECREF(m);
return 0;
}
#endif

static PyNumberMethods Wrapper_as_number = {
Wrapper_add, /* nb_add */
Wrapper_sub, /* nb_subtract */
Wrapper_mul, /* nb_multiply */
#ifndef PY3K
Wrapper_div, /* nb_divide */
#endif
Wrapper_mod, /* nb_remainder */
Wrapper_divmod, /* nb_divmod */
Wrapper_pow, /* nb_power */
Expand All @@ -1361,34 +1289,12 @@ static PyNumberMethods Wrapper_as_number = {
Wrapper_and, /* nb_and */
Wrapper_xor, /* nb_xor */
Wrapper_or, /* nb_or */

#ifndef PY3K
Wrapper_coerce, /* nb_coerce */
#endif

Wrapper_int, /* nb_int */

#ifdef PY3K
NULL,
#else
Wrapper_long, /* nb_long */
#endif

Wrapper_float, /* nb_float */

#ifndef PY3K
Wrapper_oct, /* nb_oct*/
Wrapper_hex, /* nb_hex*/
#endif

Wrapper_iadd, /* nb_inplace_add */
Wrapper_isub, /* nb_inplace_subtract */
Wrapper_imul, /* nb_inplace_multiply */

#ifndef PY3K
Wrapper_idiv, /* nb_inplace_divide */
#endif

Wrapper_imod, /* nb_inplace_remainder */
Wrapper_ipow, /* nb_inplace_power */
Wrapper_ilshift, /* nb_inplace_lshift */
Expand Down Expand Up @@ -2003,7 +1909,6 @@ static struct PyMethodDef methods[] = {
{NULL, NULL}
};

#ifdef PY3K
static struct PyModuleDef moduledef =
{
PyModuleDef_HEAD_INIT,
Expand All @@ -2016,7 +1921,6 @@ static struct PyModuleDef moduledef =
NULL, /* m_clear */
NULL, /* m_free */
};
#endif


static PyObject*
Expand Down Expand Up @@ -2044,14 +1948,7 @@ module_init(void)
return NULL;
}

#ifdef PY3K
m = PyModule_Create(&moduledef);
#else
m = Py_InitModule3("_Acquisition",
methods,
"Provide base classes for acquiring objects\n\n");
#endif

d = PyModule_GetDict(m);
init_py_names();
PyExtensionClass_Export(d,"Acquirer", AcquirerType);
Expand Down Expand Up @@ -2081,14 +1978,7 @@ module_init(void)
return m;
}

#ifdef PY3K
PyMODINIT_FUNC PyInit__Acquisition(void)
{
return module_init();
}
#else
PyMODINIT_FUNC init_Acquisition(void)
{
module_init();
}
#endif
Loading

0 comments on commit b43886c

Please sign in to comment.