Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7e52705

Browse files
Issue #20315: Removed support for backward compatibility with early 2.x versions.
1 parent 6c01e38 commit 7e52705

6 files changed

Lines changed: 3 additions & 93 deletions

File tree

Lib/configparser.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -144,23 +144,6 @@
144144
class Error(Exception):
145145
"""Base class for ConfigParser exceptions."""
146146

147-
def _get_message(self):
148-
"""Getter for 'message'; needed only to override deprecation in
149-
BaseException.
150-
"""
151-
return self.__message
152-
153-
def _set_message(self, value):
154-
"""Setter for 'message'; needed only to override deprecation in
155-
BaseException.
156-
"""
157-
self.__message = value
158-
159-
# BaseException.message has been deprecated since Python 2.6. To prevent
160-
# DeprecationWarning from popping up over this pre-existing attribute, use
161-
# a new property that takes lookup precedence.
162-
message = property(_get_message, _set_message)
163-
164147
def __init__(self, msg=''):
165148
self.message = msg
166149
Exception.__init__(self, msg)

Lib/modulefinder.py

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -332,30 +332,6 @@ def _safe_import_hook(self, name, caller, fromlist, level=-1):
332332
fullname = name + "." + sub
333333
self._add_badmodule(fullname, caller)
334334

335-
def scan_opcodes(self, co,
336-
unpack = struct.unpack):
337-
# Scan the code, and yield 'interesting' opcode combinations
338-
# Version for Python 2.4 and older
339-
code = co.co_code
340-
names = co.co_names
341-
consts = co.co_consts
342-
while code:
343-
c = code[0]
344-
if c in STORE_OPS:
345-
oparg, = unpack('<H', code[1:3])
346-
yield "store", (names[oparg],)
347-
code = code[3:]
348-
continue
349-
if c == LOAD_CONST and code[3] == IMPORT_NAME:
350-
oparg_1, oparg_2 = unpack('<xHxH', code[:6])
351-
yield "import", (consts[oparg_1], names[oparg_2])
352-
code = code[6:]
353-
continue
354-
if c >= HAVE_ARGUMENT:
355-
code = code[3:]
356-
else:
357-
code = code[1:]
358-
359335
def scan_opcodes_25(self, co,
360336
unpack = struct.unpack):
361337
# Scan the code, and yield 'interesting' opcode combinations
@@ -387,10 +363,7 @@ def scan_opcodes_25(self, co,
387363

388364
def scan_code(self, co, m):
389365
code = co.co_code
390-
if sys.version_info >= (2, 5):
391-
scanner = self.scan_opcodes_25
392-
else:
393-
scanner = self.scan_opcodes
366+
scanner = self.scan_opcodes_25
394367
for what, args in scanner(co):
395368
if what == "store":
396369
name, = args

Lib/optparse.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -645,14 +645,8 @@ def _check_type(self):
645645
self.type = "string"
646646
else:
647647
# Allow type objects or builtin type conversion functions
648-
# (int, str, etc.) as an alternative to their names. (The
649-
# complicated check of builtins is only necessary for
650-
# Python 2.1 and earlier, and is short-circuited by the
651-
# first check on modern Pythons.)
652-
import builtins
653-
if ( isinstance(self.type, type) or
654-
(hasattr(self.type, "__name__") and
655-
getattr(builtins, self.type.__name__, None) is self.type) ):
648+
# (int, str, etc.) as an alternative to their names.
649+
if isinstance(self.type, type):
656650
self.type = self.type.__name__
657651

658652
if self.type == "str":

Modules/_lsprof.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,6 @@ profiler_callback(PyObject *self, PyFrameObject *frame, int what,
455455
PyTrace_RETURN event will be generated, so we don't need to
456456
handle it. */
457457

458-
#ifdef PyTrace_C_CALL /* not defined in Python <= 2.3 */
459458
/* the Python function 'frame' is issuing a call to the built-in
460459
function 'arg' */
461460
case PyTrace_C_CALL:
@@ -477,7 +476,6 @@ profiler_callback(PyObject *self, PyFrameObject *frame, int what,
477476
((PyCFunctionObject *)arg)->m_ml);
478477
}
479478
break;
480-
#endif
481479

482480
default:
483481
break;
@@ -667,13 +665,7 @@ setBuiltins(ProfilerObject *pObj, int nvalue)
667665
if (nvalue == 0)
668666
pObj->flags &= ~POF_BUILTINS;
669667
else if (nvalue > 0) {
670-
#ifndef PyTrace_C_CALL
671-
PyErr_SetString(PyExc_ValueError,
672-
"builtins=True requires Python >= 2.4");
673-
return -1;
674-
#else
675668
pObj->flags |= POF_BUILTINS;
676-
#endif
677669
}
678670
return 0;
679671
}
@@ -771,11 +763,7 @@ profiler_init(ProfilerObject *pObj, PyObject *args, PyObject *kw)
771763
PyObject *timer = NULL;
772764
double timeunit = 0.0;
773765
int subcalls = 1;
774-
#ifdef PyTrace_C_CALL
775766
int builtins = 1;
776-
#else
777-
int builtins = 0;
778-
#endif
779767
static char *kwlist[] = {"timer", "timeunit",
780768
"subcalls", "builtins", 0};
781769

Modules/_tkinter.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,6 @@ Copyright (C) 1994 Steen Lumholt.
3333
#include <windows.h>
3434
#endif
3535

36-
/* Allow using this code in Python 2.[12] */
37-
#ifndef PyDoc_STRVAR
38-
#define PyDoc_STRVAR(name,str) static char name[] = str
39-
#endif
40-
41-
#ifndef PyMODINIT_FUNC
42-
#define PyMODINIT_FUNC void
43-
#endif
44-
45-
#ifndef PyBool_Check
46-
#define PyBool_Check(o) 0
47-
#define PyBool_FromLong PyLong_FromLong
48-
#endif
49-
5036
#define CHECK_SIZE(size, elemsize) \
5137
((size_t)(size) <= Py_MAX((size_t)INT_MAX, UINT_MAX / (size_t)(elemsize)))
5238

Modules/gcmodule.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,13 +1534,6 @@ PyObject_GC_Track(void *op)
15341534
_PyObject_GC_TRACK(op);
15351535
}
15361536

1537-
/* for binary compatibility with 2.2 */
1538-
void
1539-
_PyObject_GC_Track(PyObject *op)
1540-
{
1541-
PyObject_GC_Track(op);
1542-
}
1543-
15441537
void
15451538
PyObject_GC_UnTrack(void *op)
15461539
{
@@ -1551,13 +1544,6 @@ PyObject_GC_UnTrack(void *op)
15511544
_PyObject_GC_UNTRACK(op);
15521545
}
15531546

1554-
/* for binary compatibility with 2.2 */
1555-
void
1556-
_PyObject_GC_UnTrack(PyObject *op)
1557-
{
1558-
PyObject_GC_UnTrack(op);
1559-
}
1560-
15611547
PyObject *
15621548
_PyObject_GC_Malloc(size_t basicsize)
15631549
{

0 commit comments

Comments
 (0)