Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: '<=' not supported between instances of 'int' and 'NoneType' #90

Open
dima74 opened this issue May 19, 2022 · 3 comments
Open

Comments

@dima74
Copy link

dima74 commented May 19, 2022

Python 3.10, hanging_threads-2.0.5

Exception in thread Thread-1 (monitor):
Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1009, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.10/threading.py", line 946, in run
    self._target(*self._args, **self._kwargs)
  File "/home/dima/PycharmProjects/flats/venv/lib/python3.10/site-packages/hanging_threads.py", line 97, in monitor
    new_threads = get_current_frames()
  File "/home/dima/PycharmProjects/flats/venv/lib/python3.10/site-packages/hanging_threads.py", line 140, in get_current_frames
    return dict(
  File "/home/dima/PycharmProjects/flats/venv/lib/python3.10/site-packages/hanging_threads.py", line 142, in <genexpr>
    'frame': thread2list(frame),
  File "/home/dima/PycharmProjects/flats/venv/lib/python3.10/site-packages/hanging_threads.py", line 180, in thread2list
    l.insert(0, frame2string(frame))
  File "/home/dima/PycharmProjects/flats/venv/lib/python3.10/site-packages/hanging_threads.py", line 170, in frame2string
    line = linecache.getline(filename, lineno, frame.f_globals).lstrip()
  File "/usr/lib/python3.10/linecache.py", line 31, in getline
    if 1 <= lineno <= len(lines):
TypeError: '<=' not supported between instances of 'int' and 'NoneType'
@niccokunzmann
Copy link
Owner

niccokunzmann commented May 20, 2022 via email

@TheLizzard
Copy link

I believe that this happens when python code execution goes into C code in libraries - in my case pillow.

Adding if lineno is None: lineno = -1 in frame2string in hanging_threads.py should fix the problem. It doesn't raise an error as linecache just returns an empty string if the lineno is less than 1.

@niccokunzmann
Copy link
Owner

niccokunzmann commented Aug 26, 2022 via email

@berkorbay berkorbay mentioned this issue Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants