-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup a few other legacy Python 2 try/except imports
- Loading branch information
Showing
6 changed files
with
17 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,8 +60,6 @@ def __init__(self): | |
|
||
# Check Python version | ||
import sys | ||
if sys.version < '2.4': | ||
raise UnsupportedPythonVersionError(sys.version) | ||
|
||
|
||
# Import directives | ||
|
@@ -85,10 +83,7 @@ def __init__(self): | |
import asyncore | ||
import glob | ||
|
||
try: | ||
from functools import reduce | ||
except ImportError: | ||
pass # Will fail on Python 2.4 which has reduce() builtin anyway. | ||
from functools import reduce | ||
|
||
__author__ = "[email protected] (Sebastien Martini)" | ||
|
||
|
@@ -117,15 +112,11 @@ def load_libc(): | |
except (OSError, IOError): | ||
pass # Will attemp to load it with None anyway. | ||
|
||
if sys.version_info[0] >= 2 and sys.version_info[1] >= 6: | ||
LIBC = ctypes.CDLL(libc, use_errno=True) | ||
def _strerrno(): | ||
code = ctypes.get_errno() | ||
return ' Errno=%s (%s)' % (os.strerror(code), errno.errorcode[code]) | ||
strerrno = _strerrno | ||
else: | ||
LIBC = ctypes.CDLL(libc) | ||
strerrno = lambda : '' | ||
LIBC = ctypes.CDLL(libc, use_errno=True) | ||
def _strerrno(): | ||
code = ctypes.get_errno() | ||
return ' Errno=%s (%s)' % (os.strerror(code), errno.errorcode[code]) | ||
strerrno = _strerrno | ||
|
||
# Check that libc has needed functions inside. | ||
if (not hasattr(LIBC, 'inotify_init') or | ||
|
@@ -155,14 +146,8 @@ def makeRecord(self, name, level, fn, lno, msg, args, exc_info, func=None, | |
class UnicodeLogRecord(logging.LogRecord): | ||
def __init__(self, name, level, pathname, lineno, | ||
msg, args, exc_info, func=None): | ||
py_version = sys.version_info | ||
# func argument was added in Python 2.5, just ignore it otherwise. | ||
if py_version[0] >= 2 and py_version[1] >= 5: | ||
logging.LogRecord.__init__(self, name, level, pathname, lineno, | ||
msg, args, exc_info, func) | ||
else: | ||
logging.LogRecord.__init__(self, name, level, pathname, lineno, | ||
msg, args, exc_info) | ||
logging.LogRecord.__init__(self, name, level, pathname, lineno, | ||
msg, args, exc_info, func) | ||
|
||
def getMessage(self): | ||
msg = self.msg | ||
|