Page MenuHomePhorge

[Python 3] <= between different type error
AbandonedPublic

Authored by ghane on Mar 14 2022, 10:50 AM.
Tags
None
Referenced Files
F16550859: D3448.id9856.diff
Tue, Oct 29, 1:54 PM
F16550841: D3448.id.diff
Tue, Oct 29, 1:53 PM
F16550676: D3448.diff
Tue, Oct 29, 1:42 PM
Unknown Object (File)
Sun, Oct 27, 1:49 PM
Unknown Object (File)
Sun, Oct 27, 1:49 PM
Unknown Object (File)
Thu, Oct 24, 8:06 AM
Unknown Object (File)
Sep 7 2024, 4:50 AM
Unknown Object (File)
Sep 7 2024, 4:50 AM
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.