[Python-checkins] cpython (3.3): Issue #20315: Removed support for backward compatibility with early 2.x

serhiy.storchaka python-checkins at python.org
Mon Jan 20 20:35:41 CET 2014


http://hg.python.org/cpython/rev/5f754f1e3194
changeset:   88586:5f754f1e3194
branch:      3.3
parent:      88580:f82b6ec1ae6e
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Mon Jan 20 21:29:31 2014 +0200
summary:
  Issue #20315: Removed support for backward compatibility with early 2.x versions.

files:
  Lib/configparser.py |  17 -----------------
  Lib/modulefinder.py |  29 +----------------------------
  Lib/optparse.py     |  10 ++--------
  Modules/_lsprof.c   |  12 ------------
  Modules/_tkinter.c  |  14 --------------
  Modules/gcmodule.c  |  14 --------------
  6 files changed, 3 insertions(+), 93 deletions(-)


diff --git a/Lib/configparser.py b/Lib/configparser.py
--- a/Lib/configparser.py
+++ b/Lib/configparser.py
@@ -144,23 +144,6 @@
 class Error(Exception):
     """Base class for ConfigParser exceptions."""
 
-    def _get_message(self):
-        """Getter for 'message'; needed only to override deprecation in
-        BaseException.
-        """
-        return self.__message
-
-    def _set_message(self, value):
-        """Setter for 'message'; needed only to override deprecation in
-        BaseException.
-        """
-        self.__message = value
-
-    # BaseException.message has been deprecated since Python 2.6.  To prevent
-    # DeprecationWarning from popping up over this pre-existing attribute, use
-    # a new property that takes lookup precedence.
-    message = property(_get_message, _set_message)
-
     def __init__(self, msg=''):
         self.message = msg
         Exception.__init__(self, msg)
diff --git a/Lib/modulefinder.py b/Lib/modulefinder.py
--- a/Lib/modulefinder.py
+++ b/Lib/modulefinder.py
@@ -332,30 +332,6 @@
                         fullname = name + "." + sub
                         self._add_badmodule(fullname, caller)
 
-    def scan_opcodes(self, co,
-                     unpack = struct.unpack):
-        # Scan the code, and yield 'interesting' opcode combinations
-        # Version for Python 2.4 and older
-        code = co.co_code
-        names = co.co_names
-        consts = co.co_consts
-        while code:
-            c = code[0]
-            if c in STORE_OPS:
-                oparg, = unpack('<H', code[1:3])
-                yield "store", (names[oparg],)
-                code = code[3:]
-                continue
-            if c == LOAD_CONST and code[3] == IMPORT_NAME:
-                oparg_1, oparg_2 = unpack('<xHxH', code[:6])
-                yield "import", (consts[oparg_1], names[oparg_2])
-                code = code[6:]
-                continue
-            if c >= HAVE_ARGUMENT:
-                code = code[3:]
-            else:
-                code = code[1:]
-
     def scan_opcodes_25(self, co,
                      unpack = struct.unpack):
         # Scan the code, and yield 'interesting' opcode combinations
@@ -387,10 +363,7 @@
 
     def scan_code(self, co, m):
         code = co.co_code
-        if sys.version_info >= (2, 5):
-            scanner = self.scan_opcodes_25
-        else:
-            scanner = self.scan_opcodes
+        scanner = self.scan_opcodes_25
         for what, args in scanner(co):
             if what == "store":
                 name, = args
diff --git a/Lib/optparse.py b/Lib/optparse.py
--- a/Lib/optparse.py
+++ b/Lib/optparse.py
@@ -645,14 +645,8 @@
                     self.type = "string"
         else:
             # Allow type objects or builtin type conversion functions
-            # (int, str, etc.) as an alternative to their names.  (The
-            # complicated check of builtins is only necessary for
-            # Python 2.1 and earlier, and is short-circuited by the
-            # first check on modern Pythons.)
-            import builtins
-            if ( isinstance(self.type, type) or
-                 (hasattr(self.type, "__name__") and
-                  getattr(builtins, self.type.__name__, None) is self.type) ):
+            # (int, str, etc.) as an alternative to their names.
+            if isinstance(self.type, type):
                 self.type = self.type.__name__
 
             if self.type == "str":
diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c
--- a/Modules/_lsprof.c
+++ b/Modules/_lsprof.c
@@ -455,7 +455,6 @@
         PyTrace_RETURN event will be generated, so we don't need to
         handle it. */
 
-#ifdef PyTrace_C_CALL   /* not defined in Python <= 2.3 */
     /* the Python function 'frame' is issuing a call to the built-in
        function 'arg' */
     case PyTrace_C_CALL:
@@ -477,7 +476,6 @@
                               ((PyCFunctionObject *)arg)->m_ml);
         }
         break;
-#endif
 
     default:
         break;
@@ -667,13 +665,7 @@
     if (nvalue == 0)
         pObj->flags &= ~POF_BUILTINS;
     else if (nvalue > 0) {
-#ifndef PyTrace_C_CALL
-        PyErr_SetString(PyExc_ValueError,
-                        "builtins=True requires Python >= 2.4");
-        return -1;
-#else
         pObj->flags |=  POF_BUILTINS;
-#endif
     }
     return 0;
 }
@@ -771,11 +763,7 @@
     PyObject *timer = NULL;
     double timeunit = 0.0;
     int subcalls = 1;
-#ifdef PyTrace_C_CALL
     int builtins = 1;
-#else
-    int builtins = 0;
-#endif
     static char *kwlist[] = {"timer", "timeunit",
                                    "subcalls", "builtins", 0};
 
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
--- a/Modules/_tkinter.c
+++ b/Modules/_tkinter.c
@@ -33,20 +33,6 @@
 #include <windows.h>
 #endif
 
-/* Allow using this code in Python 2.[12] */
-#ifndef PyDoc_STRVAR
-#define PyDoc_STRVAR(name,str) static char name[] = str
-#endif
-
-#ifndef PyMODINIT_FUNC
-#define PyMODINIT_FUNC void
-#endif
-
-#ifndef PyBool_Check
-#define PyBool_Check(o)       0
-#define PyBool_FromLong       PyLong_FromLong
-#endif
-
 #define CHECK_SIZE(size, elemsize) \
     ((size_t)(size) <= Py_MAX((size_t)INT_MAX, UINT_MAX / (size_t)(elemsize)))
 
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c
--- a/Modules/gcmodule.c
+++ b/Modules/gcmodule.c
@@ -1534,13 +1534,6 @@
     _PyObject_GC_TRACK(op);
 }
 
-/* for binary compatibility with 2.2 */
-void
-_PyObject_GC_Track(PyObject *op)
-{
-    PyObject_GC_Track(op);
-}
-
 void
 PyObject_GC_UnTrack(void *op)
 {
@@ -1551,13 +1544,6 @@
         _PyObject_GC_UNTRACK(op);
 }
 
-/* for binary compatibility with 2.2 */
-void
-_PyObject_GC_UnTrack(PyObject *op)
-{
-    PyObject_GC_UnTrack(op);
-}
-
 PyObject *
 _PyObject_GC_Malloc(size_t basicsize)
 {

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list