Python NoneType error via ed_set_caret()

Did you find any problems using this software? Please post here...
Post Reply
Random Void User
Posts: 49
Joined: 13.07.2024 21:19

Python NoneType error via ed_set_caret()

Post by Random Void User »

Python 3.13.2 CudaText console is showing this error more than once.

Code: Select all

TypeError: 'NoneType' object cannot be interpreted as an integer

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/redacted/cudatext/py/cuda_hilite_occurrences/__init__.py", line 213, in on_caret
    self.work(ed_self)
    ~~~~~~~~~^^^^^^^^^
  File "/redacted/cudatext/py/cuda_hilite_occurrences/__init__.py", line 184, in work
    res = process_ocurrences(ed_self)
  File "/redacted/cudatext/py/cuda_hilite_occurrences/__init__.py", line 588, in process_ocurrences
    res = _get_occurrences(ed_self)
  File "/redacted/cudatext/py/cuda_hilite_occurrences/__init__.py", line 660, in _get_occurrences
    items = find_visible_occurrences(ed_self, text, case_sensitive, whole_words)
  File "/redacted/cudatext/py/cuda_hilite_occurrences/__init__.py", line 404, in find_visible_occurrences
    ed_self.set_caret(
    ~~~~~~~~~~~~~~~~~^
        0,
        ^^
    ...<4 lines>...
        options=app.CARET_OPTION_NO_SCROLL+CARET_FLAG_NO_EVENT
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        )
        ^
  File "/redacted/cudatext/py/cudatext.py", line 1323, in set_caret
    return ct.ed_set_caret(self.h, x1, y1, x2, y2, id, options)
           ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SystemError: <built-in function ed_set_caret> returned a result with an exception set
ERROR: Exception in CudaText for on_caret: SystemError: <built-in function ed_set_caret> returned a result with an exception set
main Alexey
Posts: 2327
Joined: 25.08.2021 18:15

Re: Python NoneType error via ed_set_caret()

Post by main Alexey »

Line 404 in that file has

Code: Select all

        ed_self.set_caret(
            0,
            line_top,
            ed_self.get_line_len(line_btm),
            line_btm,
            app.CARET_SET_ONE,
            options=app.CARET_OPTION_NO_SCROLL+CARET_FLAG_NO_EVENT
            )
i think that
ed_self.get_line_len(line_btm),
is None here. i changed code for this. pls, try code from Git:
https://github.com/CudaText-addons/cuda ... ccurrences
main Alexey
Posts: 2327
Joined: 25.08.2021 18:15

Re: Python NoneType error via ed_set_caret()

Post by main Alexey »

additionally, if my fix in Git did not help.
near line 404 - operator ed_self.set_caret(..).
add 'print' lines like this:

Code: Select all

   
    else: # wrap=on
        x2 = ed_self.get_line_len(line_btm) or 0
        opt = app.CARET_OPTION_NO_SCROLL+CARET_FLAG_NO_EVENT

        print('line_top', line_top)
        print('line_btm', line_btm)
        print('x2', x2)
        print('opt', opt)
        
        ed_self.set_caret(
            0,
            line_top,
            x2,
            line_btm,
            app.CARET_SET_ONE,
            options=opt
            )
plugin still crashes? what 'print' lines show in console?
Post Reply