Commit c00c7de7 authored by scoder's avatar scoder Committed by GitHub

Merge pull request #1844 from cython/dropPy32

Remove support and special handling code for Py3.2.
parents 10f7df92 1f1bb012
......@@ -11,7 +11,6 @@ python:
- 2.7
- 3.6
- 2.6
- 3.2
- 3.3
- 3.4
- 3.5
......@@ -53,7 +52,6 @@ matrix:
allow_failures:
- python: pypy
- python: pypy3
- python: 3.2
- python: 3.6-dev
- python: 3.7-dev
exclude:
......
lib2to3.fixes.fix_unicode
......@@ -50,6 +50,11 @@ Bugs fixed
* abs(signed int) now returns a signed rather than unsigned int.
(Github issue #1837)
Other changes
-------------
* This release no longer supports Python 3.2.
0.26.1 (2017-08-28)
===================
......
......@@ -9,8 +9,8 @@ import re
import sys
import io
if sys.version_info[:2] < (2, 6) or (3, 0) <= sys.version_info[:2] < (3, 2):
sys.stderr.write("Sorry, Cython requires Python 2.6+ or 3.2+, found %d.%d\n" % tuple(sys.version_info[:2]))
if sys.version_info[:2] < (2, 6) or (3, 0) <= sys.version_info[:2] < (3, 3):
sys.stderr.write("Sorry, Cython requires Python 2.6+ or 3.3+, found %d.%d\n" % tuple(sys.version_info[:2]))
sys.exit(1)
try:
......
......@@ -619,8 +619,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln(" #error Python headers needed to compile C extensions, "
"please install development version of Python.")
code.putln("#elif PY_VERSION_HEX < 0x02060000 || "
"(0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000)")
code.putln(" #error Cython requires Python 2.6+ or Python 3.2+.")
"(0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)")
code.putln(" #error Cython requires Python 2.6+ or Python 3.3+.")
code.putln("#else")
code.globalstate["end"].putln("#endif /* Py_PYTHON_H */")
......
......@@ -1127,7 +1127,7 @@ static void __Pyx_Coroutine_del(PyObject *self) {
{
// untrack dead object as we are executing Python code (which might trigger GC)
PyObject_GC_UnTrack(self);
#if PY_VERSION_HEX >= 0x03030000 || defined(PyErr_WarnFormat)
#if PY_MAJOR_VERSION >= 3 /* PY_VERSION_HEX >= 0x03030000*/ || defined(PyErr_WarnFormat)
if (unlikely(PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname) < 0))
PyErr_WriteUnraisable(self);
#else
......@@ -1139,35 +1139,15 @@ static void __Pyx_Coroutine_del(PyObject *self) {
#else
char *cname;
PyObject *qualname;
#if PY_MAJOR_VERSION >= 3
qualname = PyUnicode_AsUTF8String(gen->gi_qualname);
if (likely(qualname)) {
cname = PyBytes_AS_STRING(qualname);
} else {
PyErr_Clear();
cname = (char*) "?";
}
msg = PyBytes_FromFormat(
#else
qualname = gen->gi_qualname;
cname = PyString_AS_STRING(qualname);
msg = PyString_FromFormat(
#endif
"coroutine '%.50s' was never awaited", cname);
#if PY_MAJOR_VERSION >= 3
Py_XDECREF(qualname);
#endif
msg = PyString_FromFormat("coroutine '%.50s' was never awaited", cname);
if (unlikely(!msg)) {
PyErr_Clear();
cmsg = (char*) "coroutine was never awaited";
} else {
#if PY_MAJOR_VERSION >= 3
cmsg = PyBytes_AS_STRING(msg);
#else
cmsg = PyString_AS_STRING(msg);
#endif
}
#endif
if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, cmsg, 1) < 0))
......@@ -1827,11 +1807,11 @@ static int __Pyx_patch_abc(void) {
static int abc_patched = 0;
if (CYTHON_REGISTER_ABCS && !abc_patched) {
PyObject *module;
module = PyImport_ImportModule((PY_VERSION_HEX >= 0x03030000) ? "collections.abc" : "collections");
module = PyImport_ImportModule((PY_MAJOR_VERSION >= 3) ? "collections.abc" : "collections");
if (!module) {
PyErr_WriteUnraisable(NULL);
if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning,
((PY_VERSION_HEX >= 0x03030000) ?
((PY_MAJOR_VERSION >= 3) ?
"Cython module failed to register with collections.abc module" :
"Cython module failed to register with collections module"), 1) < 0)) {
return -1;
......
......@@ -257,11 +257,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject
goto bad;
}
#if PY_VERSION_HEX >= 0x03030000
if (cause) {
#else
if (cause && cause != Py_None) {
#endif
PyObject *fixed_cause;
if (cause == Py_None) {
// raise ... from None
......
......@@ -23,7 +23,7 @@ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
PyObject *global_dict = 0;
PyObject *empty_dict = 0;
PyObject *list;
#if PY_VERSION_HEX < 0x03030000
#if PY_MAJOR_VERSION < 3
PyObject *py_import;
py_import = __Pyx_PyObject_GetAttrStr($builtins_cname, PYIDENT("__import__"));
if (!py_import)
......@@ -48,17 +48,8 @@ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
if (level == -1) {
if (strchr(__Pyx_MODULE_NAME, '.')) {
/* try package relative import first */
#if PY_VERSION_HEX < 0x03030000
PyObject *py_level = PyInt_FromLong(1);
if (!py_level)
goto bad;
module = PyObject_CallFunctionObjArgs(py_import,
name, global_dict, empty_dict, list, py_level, NULL);
Py_DECREF(py_level);
#else
module = PyImport_ImportModuleLevelObject(
name, global_dict, empty_dict, list, 1);
#endif
if (!module) {
if (!PyErr_ExceptionMatches(PyExc_ImportError))
goto bad;
......@@ -69,7 +60,7 @@ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
}
#endif
if (!module) {
#if PY_VERSION_HEX < 0x03030000
#if PY_MAJOR_VERSION < 3
PyObject *py_level = PyInt_FromLong(level);
if (!py_level)
goto bad;
......@@ -83,7 +74,7 @@ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
}
}
bad:
#if PY_VERSION_HEX < 0x03030000
#if PY_MAJOR_VERSION < 3
Py_XDECREF(py_import);
#endif
Py_XDECREF(empty_list);
......@@ -259,7 +250,8 @@ bad:
/////////////// SetPackagePathFromImportLib.proto ///////////////
#if PY_VERSION_HEX >= 0x03030000
// PY_VERSION_HEX >= 0x03030000
#if PY_MAJOR_VERSION >= 3 && !CYTHON_PEP489_MULTI_PHASE_INIT
static int __Pyx_SetPackagePathFromImportLib(const char* parent_package_name, PyObject *module_name);
#else
#define __Pyx_SetPackagePathFromImportLib(a, b) 0
......@@ -269,7 +261,8 @@ static int __Pyx_SetPackagePathFromImportLib(const char* parent_package_name, Py
//@requires: ObjectHandling.c::PyObjectGetAttrStr
//@substitute: naming
#if PY_VERSION_HEX >= 0x03030000
// PY_VERSION_HEX >= 0x03030000
#if PY_MAJOR_VERSION >= 3 && !CYTHON_PEP489_MULTI_PHASE_INIT
static int __Pyx_SetPackagePathFromImportLib(const char* parent_package_name, PyObject *module_name) {
PyObject *importlib, *loader, *osmod, *ossep, *parts, *package_path;
PyObject *path = NULL, *file_path = NULL;
......
......@@ -29,7 +29,7 @@
#ifndef HAVE_LONG_LONG
// CPython has required PY_LONG_LONG support for years, even if HAVE_LONG_LONG is not defined for us
#if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000)
#if PY_VERSION_HEX >= 0x02070000
#define HAVE_LONG_LONG
#endif
#endif
......
......@@ -833,7 +833,7 @@ static PyObject* __Pyx_PyUnicode_Join(PyObject* value_tuple, Py_ssize_t value_co
if (!CYTHON_PEP393_ENABLED || ukind == result_ukind) {
memcpy((char *)result_udata + char_pos * result_ukind, udata, ulength * result_ukind);
} else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030300F0
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030300F0 || defined(_PyUnicode_FastCopyCharacters)
_PyUnicode_FastCopyCharacters(result_uval, char_pos, uval, 0, ulength);
#else
Py_ssize_t j;
......
......@@ -205,7 +205,7 @@ static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
}
#if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
#if PY_VERSION_HEX < 0x03030000
#if !CYTHON_PEP393_ENABLED
static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
char* defenc_c;
// borrowed reference, cached internally in 'o' by CPython
......@@ -229,7 +229,7 @@ static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *leng
return defenc_c;
}
#else /* PY_VERSION_HEX < 0x03030000 */
#else /* CYTHON_PEP393_ENABLED: */
static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
......@@ -247,7 +247,7 @@ static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py
return PyUnicode_AsUTF8AndSize(o, length);
#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */
}
#endif /* PY_VERSION_HEX < 0x03030000 */
#endif /* CYTHON_PEP393_ENABLED */
#endif
// Py3.7 returns a "const char*" for unicode strings
......
......@@ -315,10 +315,6 @@ EXT_EXTRAS = {
}
def _is_py3_before_32(excluded, version):
return version[0] >= 3 and version < (3,2)
# TODO: use tags
VER_DEP_MODULES = {
# tests are excluded if 'CurrentPythonVersion OP VersionTuple', i.e.
......@@ -341,8 +337,6 @@ VER_DEP_MODULES = {
'compile.extdelslice',
'run.special_methods_T561_py2'
]),
(3,1): (_is_py3_before_32, lambda x: x in ['run.pyclass_special_methods',
]),
(3,3) : (operator.lt, lambda x: x in ['build.package_compilation',
'run.yield_from_py33',
]),
......@@ -1343,7 +1337,7 @@ class CythonPyregrTestCase(CythonRunTestCase):
run_forked_test(result, run_test, self.shortDescription(), self.fork)
include_debugger = IS_CPYTHON and sys.version_info[:2] > (2, 5)
include_debugger = IS_CPYTHON
def collect_unittests(path, module_prefix, suite, selectors, exclude_selectors):
......@@ -1868,21 +1862,6 @@ def main():
if options.with_cython and sys.version_info[0] >= 3:
sys.path.insert(0, options.cython_dir)
if sys.version_info[:2] == (3, 2):
try:
# try if Cython is installed in a Py3 version
import Cython.Compiler.Main
except Exception:
# back out anything the import process loaded, then
# 2to3 the Cython sources to make them re-importable
cy_modules = [ name for name in sys.modules
if name == 'Cython' or name.startswith('Cython.') ]
for name in cy_modules:
del sys.modules[name]
# hasn't been refactored yet - do it now
global CY3_DIR
CY3_DIR = cy3_dir = os.path.join(WORKDIR, 'Cy3')
refactor_for_py3(DISTDIR, cy3_dir)
if options.watermark:
import Cython.Compiler.Version
......@@ -2074,9 +2053,6 @@ def runtests(options, cmd_args, coverage=None):
for bugs_file_name, condition in bug_files if condition
]
if sys.platform in ['win32', 'cygwin'] and sys.version_info < (2,6):
exclude_selectors += [ lambda x: x == "run.specialfloat" ]
global COMPILER
if options.compiler:
COMPILER = options.compiler
......
......@@ -34,16 +34,6 @@ class sdist(sdist_orig):
sdist_orig.run(self)
add_command_class('sdist', sdist)
if sys.version_info[:2] == (3, 2):
import lib2to3.refactor
from distutils.command.build_py \
import build_py_2to3 as build_py
# need to convert sources to Py3 on installation
with open('2to3-fixers.txt') as f:
fixers = [line.strip() for line in f if line.strip()]
build_py.fixer_names = fixers
add_command_class("build_py", build_py)
pxd_include_dirs = [
directory for directory, dirs, files
in os.walk(os.path.join('Cython', 'Includes'))
......@@ -61,15 +51,13 @@ setup_args['package_data'] = {
'Cython.Runtime' : ['*.pyx', '*.pxd'],
'Cython.Utility' : ['*.pyx', '*.pxd', '*.c', '*.h', '*.cpp'],
'Cython' : [ p[7:] for p in pxd_include_patterns ],
}
'Cython.Debugger.Tests': ['codefile', 'cfuncs.c'],
}
# This dict is used for passing extra arguments that are setuptools
# specific to setup
setuptools_extra_args = {}
# tells whether to include cygdb (the script and the Cython.Debugger package
include_debugger = sys.version_info[:2] > (2, 5)
if 'setuptools' in sys.modules:
setuptools_extra_args['zip_safe'] = False
setuptools_extra_args['entry_points'] = {
......@@ -85,11 +73,10 @@ else:
else:
scripts = ["cython.py", "cythonize.py"]
if include_debugger:
if 'setuptools' in sys.modules:
if 'setuptools' in sys.modules:
setuptools_extra_args['entry_points']['console_scripts'].append(
'cygdb = Cython.Debugger.Cygdb:main')
else:
else:
if os.name == "posix":
scripts.append('bin/cygdb')
else:
......@@ -169,10 +156,6 @@ def compile_cython_modules(profile=False, compile_more=False, cython_with_refnan
# XXX hack around setuptools quirk for '*.pyx' sources
extensions[-1].sources[0] = pyx_source_file
if sys.version_info[:2] == (3, 2):
# Python 3.2: can only run Cython *after* running 2to3
build_ext = _defer_cython_import_in_py32(source_root, profile)
else:
from Cython.Distutils import build_ext
if profile:
from Cython.Compiler.Options import get_directive_defaults
......@@ -184,46 +167,6 @@ def compile_cython_modules(profile=False, compile_more=False, cython_with_refnan
setup_args['ext_modules'] = extensions
def _defer_cython_import_in_py32(source_root, profile=False):
# Python 3.2: can only run Cython *after* running 2to3
# => re-import Cython inside of build_ext
from distutils.command.build_ext import build_ext as build_ext_orig
class build_ext(build_ext_orig):
# we must keep the original modules alive to make sure
# their code keeps working when we remove them from
# sys.modules
dead_modules = []
def __reimport(self):
if self.dead_modules:
return
# add path where 2to3 installed the transformed sources
# and make sure Python (re-)imports them from there
already_imported = [
module for module in sys.modules
if module == 'Cython' or module.startswith('Cython.')
]
keep_alive = self.dead_modules.append
for module in already_imported:
keep_alive(sys.modules[module])
del sys.modules[module]
sys.path.insert(0, os.path.join(source_root, self.build_lib))
def build_extensions(self):
self.__reimport()
if profile:
from Cython.Compiler.Options import directive_defaults
directive_defaults['profile'] = True
print("Enabled profiling for the Cython binary modules")
from Cython.Build.Dependencies import cythonize
self.distribution.ext_modules[:] = cythonize(
self.distribution.ext_modules)
build_ext_orig.build_extensions(self)
return build_ext
cython_profile = '--cython-profile' in sys.argv
if cython_profile:
sys.argv.remove('--cython-profile')
......@@ -271,6 +214,8 @@ packages = [
'Cython.Compiler',
'Cython.Runtime',
'Cython.Distutils',
'Cython.Debugger',
'Cython.Debugger.Tests',
'Cython.Plex',
'Cython.Tests',
'Cython.Build.Tests',
......@@ -280,12 +225,6 @@ packages = [
'pyximport',
]
if include_debugger:
packages.append('Cython.Debugger')
packages.append('Cython.Debugger.Tests')
# it's enough to do this for Py2.5+:
setup_args['package_data']['Cython.Debugger.Tests'] = ['codefile', 'cfuncs.c']
setup(
name='Cython',
version=version,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment