New submission from Tobin Baker:
I'm using a 3rd-party library (ESAPI) which defines a log level as the literal
-2**31. This worked fine until I upgraded to Python 2.7.3, which, unlike all
previous versions of Python, coerces that literal to long rather than int. The
following code in the logging module then throws a TypeError:
def _checkLevel(level):
if isinstance(level, int):
rv = level
elif str(level) == level:
if level not in _levelNames:
raise ValueError("Unknown level: %r" % level)
rv = _levelNames[level]
else:
raise TypeError("Level not an integer or a valid string: %r" % level)
return rv
Although this is certainly an unusual use case, it seems that as just a matter
of principle, the module should be using the check isinstance(level, (int,
long)) rather than just isinstance(level, int).
Here's the relevant part of the traceback:
File "/usr/lib/python2.7/logging/__init__.py", line 710, in setLevel
self.level = _checkLevel(level)
File "/usr/lib/python2.7/logging/__init__.py", line 190, in _checkLevel
raise TypeError("Level not an integer or a valid string: %r" % level)
TypeError: Level not an integer or a valid string: -2147483648L
----------
components: Library (Lib)
messages: 168418
nosy: tobin.baker
priority: normal
severity: normal
status: open
title: logging module crashes in Python 2.7.3 for handler.setLevel(long)
type: crash
versions: Python 2.7
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue15710>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com