Page MenuHomekolab.org

[Python 3] <= between different type error
Needs ReviewPublic

Authored by ghane on Mar 14 2022, 10:50 AM.

Details

Reviewers
None
Group Reviewers
PyKolab Developers
Summary

catch error reason with equal type condition

Diff Detail

Repository
rP pykolab
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

ghane requested review of this revision.Mar 14 2022, 10:50 AM
ghane created this revision.
ghane added a reviewer: PyKolab Developers.

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.

ghane added a comment.Mar 15 2022, 2:22 AM

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

In D3448#41491, @ghane wrote:

pykolab.auth ERROR [11820] Authentication cache failed: TypeError("'<=' not supported between instances of 'TypeError' and 'int'")

Wait - so somewhere, someone tries to call debug() with a level argument that has the type TypeError? That doesn't sound right at all...

ghane added a comment.EditedMar 20 2022, 11:23 PM

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'")