progval / Limnoria

A robust, full-featured, and user/programmer-friendly Python IRC bot, with many existing plugins.
https://docs.limnoria.net/
Other
622 stars 173 forks source link

TypeError: '>=' not supported between instances of 'AttributeError' and 'int' in traceback.py #1584

Closed elieux closed 3 months ago

elieux commented 3 months ago

Hey. While I was upgrading my plugins, I encountered this (during handling an AttributeError from the plugin). This is on Limnoria v2024.5.30 and Python v3.12.3. I couldn't find any report of this. Let me know if you need more details.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/lsiopy/lib/python3.12/site-packages/supybot/schedule.py", line 150, in run
    f(*args, **kwargs)
  File "/config/plugins/Git/plugin.py", line 421, in _poll
    traceback.print_exc(e)
  File "/usr/lib/python3.12/traceback.py", line 180, in print_exc
    print_exception(sys.exception(), limit=limit, file=file, chain=chain)
  File "/usr/lib/python3.12/traceback.py", line 124, in print_exception
    te = TracebackException(type(value), value, tb, limit=limit, compact=True)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/traceback.py", line 733, in __init__
    self.stack = StackSummary._extract_from_extended_frame_gen(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/traceback.py", line 411, in _extract_from_extended_frame_gen
    if limit >= 0:
       ^^^^^^^^^^
TypeError: '>=' not supported between instances of 'AttributeError' and 'int'
progval commented 3 months ago

Where did you get this Git plugin?

elieux commented 3 months ago

It's a fork on which I did some maintenance, see here: https://github.com/elieux/supybot-git

elieux commented 3 months ago

Oh, damn, I didn't notice the traceback call was in the plugin's code. I'm sorry, this is not an issue in Limnoria.

progval commented 3 months ago

yeah, you need to replace traceback.print_exc(e) with either traceback.print_exception(e) or traceback.print_exc().

Or, even better, remove the line entirely and replace log_error('Exception in _poll(): %s' % str(e)) with self.log.exception('Exception in _poll() which will take care of printing the exception too.