Page MenuHomePhorge

[Python 3] <= between different type error
AbandonedPublic

Authored by ghane on Mar 14 2022, 10:50 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Apr 17, 9:16 AM
Unknown Object (File)
Mon, Apr 8, 11:40 AM
Unknown Object (File)
Sun, Apr 7, 9:53 AM
Unknown Object (File)
Wed, Apr 3, 1:09 PM
Unknown Object (File)
Wed, Apr 3, 1:09 PM
Unknown Object (File)
Thu, Mar 28, 7:18 AM
Unknown Object (File)
Mon, Mar 25, 1:27 AM
Unknown Object (File)
Mar 1 2024, 6:42 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.