Page MenuHomePhorge

[Python 3] <= between different type error
AbandonedPublic

Authored by ghane on Mar 14 2022, 10:50 AM.
Tags
None
Referenced Files
F12236418: D3448.id9856.diff
Sun, May 19, 2:19 AM
F12236028: D3448.diff
Sun, May 19, 1:23 AM
Unknown Object (File)
Mon, May 13, 5:01 PM
Unknown Object (File)
Mon, May 13, 2:27 PM
Unknown Object (File)
Sat, May 4, 12:52 AM
Unknown Object (File)
Fri, May 3, 11:42 PM
Unknown Object (File)
Fri, Apr 26, 8:21 AM
Unknown Object (File)
Sun, Apr 21, 4:48 PM
Subscribers

Details

Reviewers
None
Group Reviewers
PyKolab Developers
Summary

catch error reason with equal type condition

Diff Detail

Repository
rP pykolab
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

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.

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...

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

Abandoning this in favour of D3944.