catch error reason with equal type condition
Details
Diff Detail
- Repository
- rP pykolab
- Lint
Lint Skipped - Unit
Tests Skipped
Event Timeline
Do you have a backtrace of a call to debug() that triggers this type error? I wonder if it might be preferable to fix the root cause rather than the symptom.
saslauthd.py -d 9
The root cause is that level is set from third party ldap and sqlalchemy logging, which are not of type (int).
pykolab/logger.py:271: DeprecationWarning: comparing unequal types not supported in 3.x
pykolab.auth ERROR [11820] Authentication cache failed: TypeError("'<=' not supported between instances of 'TypeError' and 'int'")
with -d <8 the code runs without the error
Wait - so somewhere, someone tries to call debug() with a level argument that has the type TypeError? That doesn't sound right at all...
Here is my debugging with python2.7 -3 ./saslauthd.py -d 9
and log. INFO before the trouble line:
logger.py
self.log(logging.INFO, "type of level: %s" % (type(level))) if level <= self.debuglevel:
2022-03-20 22:14:09,418 sqlalchemy.pool.NullPool INFO [30232] type of level: <type 'sqlite3.Connection'>
2022-03-20 22:14:09,418 sqlalchemy.pool.NullPool INFO [30232] type of level: <type 'sqlite3.Connection'>
/opt/git/pykolab/pykolab/logger.py:272: DeprecationWarning: comparing unequal types not supported in 3.x
if level <= self.debuglevel:
as I described it is from third party set a "level" and this type is not equal to integer type of self.debuglevel.
same with python3:
2022-03-20 22:24:51,101 sqlalchemy.pool.NullPool INFO [30236] type of level: <class 'sqlite3.Connection'>
2022-03-20 22:24:51,101 sqlalchemy.pool.NullPool INFO [30236] type of level: <class 'sqlite3.Connection'>
2022-03-20 22:24:51,105 sqlalchemy.pool.NullPool INFO [30236] type of level: <class 'TypeError'>
2022-03-20 22:24:51,105 sqlalchemy.pool.NullPool INFO [30236] type of level: <class 'TypeError'>
2022-03-20 22:24:51,108 pykolab.auth.ldap ERROR [30236] Authentication cache failed: TypeError("'<=' not supported between instances of 'TypeError' and 'int'")
2022-03-20 22:24:51,108 pykolab.auth.ldap ERROR [30236] Authentication cache failed: TypeError("'<=' not supported between instances of 'TypeError' and 'int'")
<class 'sqlite3.Connection'> causes TypeError("'<=' not supported between instances of 'TypeError' and 'int'")