Message168418
| Author |
tobin.baker |
| Recipients |
tobin.baker |
| Date |
2012年08月16日.21:33:58 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1345152839.48.0.661799461902.issue15710@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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 |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2012年08月16日 21:33:59 | tobin.baker | set | recipients:
+ tobin.baker |
| 2012年08月16日 21:33:59 | tobin.baker | set | messageid: <1345152839.48.0.661799461902.issue15710@psf.upfronthosting.co.za> |
| 2012年08月16日 21:33:58 | tobin.baker | link | issue15710 messages |
| 2012年08月16日 21:33:58 | tobin.baker | create |
|