From f45c1755c32bac80059e463039f7f0a644593189 Mon Sep 17 00:00:00 2001 From: Martin Panter Date: Sat, 14 May 2016 07:25:37 +0000 Subject: [PATCH] Remove PEP 291 compatibility requirements for ctypes and modulefinder https://mail.python.org/pipermail/python-dev/2016-May/144502.html --- Lib/ctypes/__init__.py | 3 --- Lib/ctypes/_endian.py | 3 --- Lib/ctypes/macholib/__init__.py | 3 --- Lib/ctypes/macholib/dyld.py | 3 --- Lib/ctypes/macholib/dylib.py | 3 --- Lib/ctypes/macholib/framework.py | 3 --- Lib/ctypes/test/test_structures.py | 1 + Lib/ctypes/util.py | 3 --- Lib/ctypes/wintypes.py | 4 ---- Lib/modulefinder.py | 3 +-- Misc/NEWS | 3 +++ Modules/_ctypes/_ctypes.c | 3 ++- Modules/_ctypes/_ctypes_test.c | 7 +------ Modules/_ctypes/callbacks.c | 3 ++- Modules/_ctypes/callproc.c | 3 ++- Modules/_ctypes/cfield.c | 3 ++- Modules/_ctypes/ctypes.h | 3 ++- Modules/_ctypes/ctypes_dlfcn.h | 4 ---- Modules/_ctypes/malloc_closure.c | 4 ---- Modules/_ctypes/stgdict.c | 5 +---- 20 files changed, 17 insertions(+), 50 deletions(-) diff --git a/Lib/ctypes/__init__.py b/Lib/ctypes/__init__.py index 77b020a967c..e24cfd2bede 100644 --- a/Lib/ctypes/__init__.py +++ b/Lib/ctypes/__init__.py @@ -1,6 +1,3 @@ -###################################################################### -# This file should be kept compatible with Python 2.3, see PEP 291. # -###################################################################### """create and manipulate C data types in Python""" import os as _os, sys as _sys diff --git a/Lib/ctypes/_endian.py b/Lib/ctypes/_endian.py index f80e675aaf2..c0ba646ffc9 100644 --- a/Lib/ctypes/_endian.py +++ b/Lib/ctypes/_endian.py @@ -1,6 +1,3 @@ -###################################################################### -# This file should be kept compatible with Python 2.3, see PEP 291. # -###################################################################### import sys from ctypes import * diff --git a/Lib/ctypes/macholib/__init__.py b/Lib/ctypes/macholib/__init__.py index 36149d28a15..5621defccd6 100644 --- a/Lib/ctypes/macholib/__init__.py +++ b/Lib/ctypes/macholib/__init__.py @@ -1,6 +1,3 @@ -###################################################################### -# This file should be kept compatible with Python 2.3, see PEP 291. # -###################################################################### """ Enough Mach-O to make your head spin. diff --git a/Lib/ctypes/macholib/dyld.py b/Lib/ctypes/macholib/dyld.py index 9714ec655f0..1fdf8d648f7 100644 --- a/Lib/ctypes/macholib/dyld.py +++ b/Lib/ctypes/macholib/dyld.py @@ -1,6 +1,3 @@ -###################################################################### -# This file should be kept compatible with Python 2.3, see PEP 291. # -###################################################################### """ dyld emulation """ diff --git a/Lib/ctypes/macholib/dylib.py b/Lib/ctypes/macholib/dylib.py index ea3dd38bdfb..aa107507bd4 100644 --- a/Lib/ctypes/macholib/dylib.py +++ b/Lib/ctypes/macholib/dylib.py @@ -1,6 +1,3 @@ -###################################################################### -# This file should be kept compatible with Python 2.3, see PEP 291. # -###################################################################### """ Generic dylib path manipulation """ diff --git a/Lib/ctypes/macholib/framework.py b/Lib/ctypes/macholib/framework.py index dd7fb2f296a..ad6ed554ba0 100644 --- a/Lib/ctypes/macholib/framework.py +++ b/Lib/ctypes/macholib/framework.py @@ -1,6 +1,3 @@ -###################################################################### -# This file should be kept compatible with Python 2.3, see PEP 291. # -###################################################################### """ Generic framework path manipulation """ diff --git a/Lib/ctypes/test/test_structures.py b/Lib/ctypes/test/test_structures.py index 2fa42bd62f7..f983a6b54a8 100644 --- a/Lib/ctypes/test/test_structures.py +++ b/Lib/ctypes/test/test_structures.py @@ -326,6 +326,7 @@ class StructureTestCase(unittest.TestCase): "(Phone) : " "expected string or Unicode object, int found") else: + # Compatibility no longer strictly required self.assertEqual(msg, "(Phone) exceptions.TypeError: " "expected string or Unicode object, int found") diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py index 929a29c4609..bf1b6a012ae 100644 --- a/Lib/ctypes/util.py +++ b/Lib/ctypes/util.py @@ -1,6 +1,3 @@ -###################################################################### -# This file should be kept compatible with Python 2.3, see PEP 291. # -###################################################################### import sys, os # find_library(name) returns the pathname of a library, or None. diff --git a/Lib/ctypes/wintypes.py b/Lib/ctypes/wintypes.py index dafbb78b781..e7f569c9b65 100644 --- a/Lib/ctypes/wintypes.py +++ b/Lib/ctypes/wintypes.py @@ -1,7 +1,3 @@ -###################################################################### -# This file should be kept compatible with Python 2.3, see PEP 291. # -###################################################################### - # The most useful windows datatypes from ctypes import * diff --git a/Lib/modulefinder.py b/Lib/modulefinder.py index 2ffd44854b4..e2fee4189e4 100644 --- a/Lib/modulefinder.py +++ b/Lib/modulefinder.py @@ -1,5 +1,4 @@ """Find modules used by a script, using introspection.""" -# This module should be kept compatible with Python 2.2, see PEP 291. from __future__ import generators import dis @@ -13,7 +12,7 @@ import struct if hasattr(sys.__stdout__, "newlines"): READ_MODE = "U" # universal line endings else: - # remain compatible with Python < 2.3 + # Python < 2.3 compatibility, no longer strictly required READ_MODE = "r" LOAD_CONST = dis.opmap['LOAD_CONST'] diff --git a/Misc/NEWS b/Misc/NEWS index 025fa3e9477..b1a1d28ce53 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -77,6 +77,9 @@ Core and Builtins Library ------- +- Removed the requirements for the ctypes and modulefinder modules to be + compatible with earlier Python versions. + - Issue #22274: In the subprocess module, allow stderr to be redirected to stdout even when stdout is not redirected. Patch by Akira Li. diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index fe79b08c004..9baf4b36ff7 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -1,5 +1,6 @@ /***************************************************************** - This file should be kept compatible with Python 2.3, see PEP 291. + This file contains remnant Python 2.3 compatibility code that is no longer + strictly required. *****************************************************************/ diff --git a/Modules/_ctypes/_ctypes_test.c b/Modules/_ctypes/_ctypes_test.c index a52f650a2b5..57628b89939 100644 --- a/Modules/_ctypes/_ctypes_test.c +++ b/Modules/_ctypes/_ctypes_test.c @@ -1,12 +1,7 @@ -/***************************************************************** - This file should be kept compatible with Python 2.3, see PEP 291. - *****************************************************************/ - - #include /* - Backwards compatibility: + Backwards compatibility, no longer strictly required: Python2.2 used LONG_LONG instead of PY_LONG_LONG */ #if defined(HAVE_LONG_LONG) && !defined(PY_LONG_LONG) diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c index 47dbe05a515..b1e85ced8ea 100644 --- a/Modules/_ctypes/callbacks.c +++ b/Modules/_ctypes/callbacks.c @@ -1,5 +1,6 @@ /***************************************************************** - This file should be kept compatible with Python 2.3, see PEP 291. + This file contains remnant Python 2.3 compatibility code that is no longer + strictly required. *****************************************************************/ #include "Python.h" diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c index 7007b7cebd4..280a3158281 100644 --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -1,5 +1,6 @@ /***************************************************************** - This file should be kept compatible with Python 2.3, see PEP 291. + This file contains remnant Python 2.3 compatibility code that is no longer + strictly required. *****************************************************************/ diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c index 85b5ad28903..0585ed28dd9 100644 --- a/Modules/_ctypes/cfield.c +++ b/Modules/_ctypes/cfield.c @@ -1,5 +1,6 @@ /***************************************************************** - This file should be kept compatible with Python 2.3, see PEP 291. + This file contains remnant Python 2.3 compatibility code that is no longer + strictly required. *****************************************************************/ #include "Python.h" diff --git a/Modules/_ctypes/ctypes.h b/Modules/_ctypes/ctypes.h index b88cf4f4695..a61ce5f3264 100644 --- a/Modules/_ctypes/ctypes.h +++ b/Modules/_ctypes/ctypes.h @@ -1,5 +1,6 @@ /***************************************************************** - This file should be kept compatible with Python 2.3, see PEP 291. + This file contains remnant Python 2.3 compatibility code that is no longer + strictly required. *****************************************************************/ #if defined (__SVR4) && defined (__sun) diff --git a/Modules/_ctypes/ctypes_dlfcn.h b/Modules/_ctypes/ctypes_dlfcn.h index d8bf904be20..54cdde9a4fd 100644 --- a/Modules/_ctypes/ctypes_dlfcn.h +++ b/Modules/_ctypes/ctypes_dlfcn.h @@ -1,7 +1,3 @@ -/***************************************************************** - This file should be kept compatible with Python 2.3, see PEP 291. - *****************************************************************/ - #ifndef _CTYPES_DLFCN_H_ #define _CTYPES_DLFCN_H_ diff --git a/Modules/_ctypes/malloc_closure.c b/Modules/_ctypes/malloc_closure.c index b98d43b6d05..248c6a67022 100644 --- a/Modules/_ctypes/malloc_closure.c +++ b/Modules/_ctypes/malloc_closure.c @@ -1,7 +1,3 @@ -/***************************************************************** - This file should be kept compatible with Python 2.3, see PEP 291. - *****************************************************************/ - #include #include #ifdef MS_WIN32 diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c index 17b97601436..31528af0f7c 100644 --- a/Modules/_ctypes/stgdict.c +++ b/Modules/_ctypes/stgdict.c @@ -1,7 +1,3 @@ -/***************************************************************** - This file should be kept compatible with Python 2.3, see PEP 291. - *****************************************************************/ - #include "Python.h" #include #ifdef MS_WIN32 @@ -449,6 +445,7 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct Py_DECREF(pair); PyErr_Format(PyExc_TypeError, #if (PY_VERSION_HEX < 0x02050000) + /* Compatibility no longer strictly required */ "second item in _fields_ tuple (index %d) must be a C type", #else "second item in _fields_ tuple (index %zd) must be a C type",