Bug 456824 - TypeError in Scripter while attempting to debug program
Summary: TypeError in Scripter while attempting to debug program
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Scripting (show other bugs)
Version: 5.0.2
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-07-17 15:42 UTC by Emily Grace Seville
Modified: 2022-08-04 09:50 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Emily Grace Seville 2022-07-17 15:42:12 UTC
SUMMARY
***
NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols.
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***
Scripter fails to debug programs with a long stacktrace.

STEPS TO REPRODUCE
1. Open any .py file in Scripter
2. Press on Debug button
3. Obtain the error

OBSERVED RESULT
TypeError
Python 3.10.4: /usr/bin/python3
Mon Jul 18 01:34:26 2022

A problem occurred in a Python script.  Here is the sequence of
function calls leading up to the error, in the order they occurred.

 /usr/share/krita/pykrita/scripter/ui_scripter/actions/debugaction/debugaction.py in debug(self=<scripter.ui_scripter.actions.debugaction.debugaction.DebugAction object>)
   31         if self.scripter.uicontroller.invokeAction('save'):
   32             self.scripter.uicontroller.setActiveWidget(i18n('Debugger'))
   33             self.scripter.debugcontroller.start(self.scripter.documentcontroller.activeDocument)
   34             widget = self.scripter.uicontroller.findTabWidget(i18n('Debugger'))
   35             widget.startDebugger()
self = <scripter.ui_scripter.actions.debugaction.debugaction.DebugAction object>
self.scripter = <scripter.scripter.ScripterExtension object>
self.scripter.debugcontroller = <scripter.debugcontroller.DebugController object>
self.scripter.debugcontroller.start = <bound method DebugController.start of <scripter.debugcontroller.DebugController object>>
self.scripter.documentcontroller = <scripter.documentcontroller.DocumentController object>
self.scripter.documentcontroller.activeDocument = <scripter.document_scripter.document.Document object>

 /usr/share/krita/pykrita/scripter/debugcontroller.py in start(self=<scripter.debugcontroller.DebugController object>, document=<scripter.document_scripter.document.Document object>)
   25         self._debugger.debugprocess.start()
   26         loop = asyncio.get_event_loop()
   27         loop.run_until_complete(self._debugger.start())
   28         self.updateUIDebugger()
   29 
loop = <_UnixSelectorEventLoop running=False closed=False debug=False>
loop.run_until_complete = <bound method BaseEventLoop.run_until_complete o...ventLoop running=False closed=False debug=False>>
self = <scripter.debugcontroller.DebugController object>
self._debugger = <scripter.debugger_scripter.debugger.Debugger object>
self._debugger.start = <bound method Debugger.start of <scripter.debugger_scripter.debugger.Debugger object>>

 /usr/lib/python3.10/asyncio/base_events.py in run_until_complete(self=<_UnixSelectorEventLoop running=False closed=False debug=False>, future=<Task finished name='Task-7' coro=<Debugger.star...=TypeError("'coroutine' object is not iterable")>)
  644             raise RuntimeError('Event loop stopped before Future completed.')
  645 
  646         return future.result()
  647 
  648     def stop(self):
future = <Task finished name='Task-7' coro=<Debugger.star...=TypeError("'coroutine' object is not iterable")>
future.result = <built-in method result of _asyncio.Task object>

 /usr/share/krita/pykrita/scripter/debugger_scripter/debugger.py in start(self=<scripter.debugger_scripter.debugger.Debugger object>)
  101     @asyncio.coroutine
  102     def start(self):
  103         yield from self.display()
  104 
  105     @asyncio.coroutine
self = <scripter.debugger_scripter.debugger.Debugger object>
self.display = <bound method Debugger.display of <scripter.debugger_scripter.debugger.Debugger object>>

 /usr/share/krita/pykrita/scripter/debugger_scripter/debugger.py in display(self=<scripter.debugger_scripter.debugger.Debugger object>)
   91             if self.applicationq.empty():
   92                 # 'yield from' is not available in Python 2.
   93                 for i in asyncio.sleep(0.3):
   94                     yield i
   95             else:
i undefined
global asyncio = <module 'asyncio' from '/usr/lib/python3.10/asyncio/__init__.py'>
asyncio.sleep = <function sleep>
TypeError: 'coroutine' object is not iterable
    __cause__ = None
    __class__ = <class 'TypeError'>
    __context__ = None
    __delattr__ = <method-wrapper '__delattr__' of TypeError object>
    __dict__ = {}
    __dir__ = <built-in method __dir__ of TypeError object>
    __doc__ = 'Inappropriate argument type.'
    __eq__ = <method-wrapper '__eq__' of TypeError object>
    __format__ = <built-in method __format__ of TypeError object>
    __ge__ = <method-wrapper '__ge__' of TypeError object>
    __getattribute__ = <method-wrapper '__getattribute__' of TypeError object>
    __gt__ = <method-wrapper '__gt__' of TypeError object>
    __hash__ = <method-wrapper '__hash__' of TypeError object>
    __init__ = <method-wrapper '__init__' of TypeError object>
    __init_subclass__ = <built-in method __init_subclass__ of type object>
    __le__ = <method-wrapper '__le__' of TypeError object>
    __lt__ = <method-wrapper '__lt__' of TypeError object>
    __ne__ = <method-wrapper '__ne__' of TypeError object>
    __new__ = <built-in method __new__ of type object>
    __reduce__ = <built-in method __reduce__ of TypeError object>
    __reduce_ex__ = <built-in method __reduce_ex__ of TypeError object>
    __repr__ = <method-wrapper '__repr__' of TypeError object>
    __setattr__ = <method-wrapper '__setattr__' of TypeError object>
    __setstate__ = <built-in method __setstate__ of TypeError object>
    __sizeof__ = <built-in method __sizeof__ of TypeError object>
    __str__ = <method-wrapper '__str__' of TypeError object>
    __subclasshook__ = <built-in method __subclasshook__ of type object>
    __suppress_context__ = False
    __traceback__ = <traceback object>
    args = ("'coroutine' object is not iterable",)
    with_traceback = <built-in method with_traceback of TypeError object>

The above is a description of an error in a Python program.  Here is
the original traceback:

Traceback (most recent call last):
  File "/usr/share/krita/pykrita/scripter/ui_scripter/actions/debugaction/debugaction.py", line 33, in debug
    self.scripter.debugcontroller.start(self.scripter.documentcontroller.activeDocument)
  File "/usr/share/krita/pykrita/scripter/debugcontroller.py", line 27, in start
    loop.run_until_complete(self._debugger.start())
  File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/usr/share/krita/pykrita/scripter/debugger_scripter/debugger.py", line 103, in start
    yield from self.display()
  File "/usr/share/krita/pykrita/scripter/debugger_scripter/debugger.py", line 93, in display
    for i in asyncio.sleep(0.3):
TypeError: 'coroutine' object is not iterable



EXPECTED RESULT
Turned on debug mode

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 Halla Rempt 2022-07-20 08:16:57 UTC
That's strange -- that is code that only should be executed if Krita is built to use Python 2. Does the appimage work for you?
Comment 2 Bug Janitor Service 2022-08-04 04:35:30 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 3 Emily Grace Seville 2022-08-04 09:34:45 UTC
> That's strange -- that is code that only should be executed if Krita is built to use Python 2. Does the appimage work for you?

No, I obtained the same error with appimage (5.0.6 version):

TypeError
Python 3.8.1: /usr/bin/python3
Thu Aug  4 19:31:22 2022

A problem occurred in a Python script.  Here is the sequence of
function calls leading up to the error, in the order they occurred.

 /tmp/.mount_krita-isMnvT/usr/share/krita/pykrita/scripter/ui_scripter/actions/debugaction/debugaction.py in debug(self=<scripter.ui_scripter.actions.debugaction.debugaction.DebugAction object>)
   31         if self.scripter.uicontroller.invokeAction('save'):
   32             self.scripter.uicontroller.setActiveWidget(i18n('Debugger'))
   33             self.scripter.debugcontroller.start(self.scripter.documentcontroller.activeDocument)
   34             widget = self.scripter.uicontroller.findTabWidget(i18n('Debugger'))
   35             widget.startDebugger()
self = <scripter.ui_scripter.actions.debugaction.debugaction.DebugAction object>
self.scripter = <scripter.scripter.ScripterExtension object>
self.scripter.debugcontroller = <scripter.debugcontroller.DebugController object>
self.scripter.debugcontroller.start = <bound method DebugController.start of <scripter.debugcontroller.DebugController object>>
self.scripter.documentcontroller = <scripter.documentcontroller.DocumentController object>
self.scripter.documentcontroller.activeDocument = <scripter.document_scripter.document.Document object>

 /tmp/.mount_krita-isMnvT/usr/share/krita/pykrita/scripter/debugcontroller.py in start(self=<scripter.debugcontroller.DebugController object>, document=<scripter.document_scripter.document.Document object>)
   25         self._debugger.debugprocess.start()
   26         loop = asyncio.get_event_loop()
   27         loop.run_until_complete(self._debugger.start())
   28         self.updateUIDebugger()
   29 
loop = <_UnixSelectorEventLoop running=False closed=False debug=False>
loop.run_until_complete = <bound method BaseEventLoop.run_until_complete o...ventLoop running=False closed=False debug=False>>
self = <scripter.debugcontroller.DebugController object>
self._debugger = <scripter.debugger_scripter.debugger.Debugger object>
self._debugger.start = <bound method Debugger.start of <scripter.debugger_scripter.debugger.Debugger object>>

 /tmp/.mount_krita-isMnvT/usr/lib/python3.8/asyncio/base_events.py in run_until_complete(self=<_UnixSelectorEventLoop running=False closed=False debug=False>, future=<Task finished name='Task-1' coro=<Debugger.star...=TypeError("'coroutine' object is not iterable")>)
  610             raise RuntimeError('Event loop stopped before Future completed.')
  611 
  612         return future.result()
  613 
  614     def stop(self):
future = <Task finished name='Task-1' coro=<Debugger.star...=TypeError("'coroutine' object is not iterable")>
future.result = <built-in method result of _asyncio.Task object>

 /tmp/.mount_krita-isMnvT/usr/share/krita/pykrita/scripter/debugger_scripter/debugger.py in start(self=<scripter.debugger_scripter.debugger.Debugger object>)
  101     @asyncio.coroutine
  102     def start(self):
  103         yield from self.display()
  104 
  105     @asyncio.coroutine
self = <scripter.debugger_scripter.debugger.Debugger object>
self.display = <bound method Debugger.display of <scripter.debugger_scripter.debugger.Debugger object>>

 /tmp/.mount_krita-isMnvT/usr/share/krita/pykrita/scripter/debugger_scripter/debugger.py in display(self=<scripter.debugger_scripter.debugger.Debugger object>)
   91             if self.applicationq.empty():
   92                 # 'yield from' is not available in Python 2.
   93                 for i in asyncio.sleep(0.3):
   94                     yield i
   95             else:
i undefined
global asyncio = <module 'asyncio' from '/tmp/.mount_krita-isMnvT/usr/lib/python3.8/asyncio/__init__.py'>
asyncio.sleep = <function sleep>
TypeError: 'coroutine' object is not iterable
    __cause__ = None
    __class__ = <class 'TypeError'>
    __context__ = None
    __delattr__ = <method-wrapper '__delattr__' of TypeError object>
    __dict__ = {}
    __dir__ = <built-in method __dir__ of TypeError object>
    __doc__ = 'Inappropriate argument type.'
    __eq__ = <method-wrapper '__eq__' of TypeError object>
    __format__ = <built-in method __format__ of TypeError object>
    __ge__ = <method-wrapper '__ge__' of TypeError object>
    __getattribute__ = <method-wrapper '__getattribute__' of TypeError object>
    __gt__ = <method-wrapper '__gt__' of TypeError object>
    __hash__ = <method-wrapper '__hash__' of TypeError object>
    __init__ = <method-wrapper '__init__' of TypeError object>
    __init_subclass__ = <built-in method __init_subclass__ of type object>
    __le__ = <method-wrapper '__le__' of TypeError object>
    __lt__ = <method-wrapper '__lt__' of TypeError object>
    __ne__ = <method-wrapper '__ne__' of TypeError object>
    __new__ = <built-in method __new__ of type object>
    __reduce__ = <built-in method __reduce__ of TypeError object>
    __reduce_ex__ = <built-in method __reduce_ex__ of TypeError object>
    __repr__ = <method-wrapper '__repr__' of TypeError object>
    __setattr__ = <method-wrapper '__setattr__' of TypeError object>
    __setstate__ = <built-in method __setstate__ of TypeError object>
    __sizeof__ = <built-in method __sizeof__ of TypeError object>
    __str__ = <method-wrapper '__str__' of TypeError object>
    __subclasshook__ = <built-in method __subclasshook__ of type object>
    __suppress_context__ = False
    __traceback__ = <traceback object>
    args = ("'coroutine' object is not iterable",)
    with_traceback = <built-in method with_traceback of TypeError object>

The above is a description of an error in a Python program.  Here is
the original traceback:

Traceback (most recent call last):
  File "/tmp/.mount_krita-isMnvT/usr/share/krita/pykrita/scripter/ui_scripter/actions/debugaction/debugaction.py", line 33, in debug
    self.scripter.debugcontroller.start(self.scripter.documentcontroller.activeDocument)
  File "/tmp/.mount_krita-isMnvT/usr/share/krita/pykrita/scripter/debugcontroller.py", line 27, in start
    loop.run_until_complete(self._debugger.start())
  File "/tmp/.mount_krita-isMnvT/usr/lib/python3.8/asyncio/base_events.py", line 612, in run_until_complete
    return future.result()
  File "/tmp/.mount_krita-isMnvT/usr/share/krita/pykrita/scripter/debugger_scripter/debugger.py", line 103, in start
    yield from self.display()
  File "/tmp/.mount_krita-isMnvT/usr/share/krita/pykrita/scripter/debugger_scripter/debugger.py", line 93, in display
    for i in asyncio.sleep(0.3):
TypeError: 'coroutine' object is not iterable

Also GUI in appimage is very small.
Comment 4 Halla Rempt 2022-08-04 09:49:46 UTC
Git commit e2fb1409b1c61aa381aad5b3c9c425a5b108aa88 by Halla Rempt.
Committed on 04/08/2022 at 09:49.
Pushed by rempt into branch 'master'.

Fix syntax error in scripter

This makes the scripter incompatible with Python 2, but even the
VFX platform now has abandoned Python 2.

M  +1    -1    plugins/python/scripter/kritapykrita_scripter.desktop

https://invent.kde.org/graphics/krita/commit/e2fb1409b1c61aa381aad5b3c9c425a5b108aa88
Comment 5 Halla Rempt 2022-08-04 09:50:07 UTC
Git commit 92d043ab5cec57efdd6127979e0f399da4ad1077 by Halla Rempt.
Committed on 04/08/2022 at 09:49.
Pushed by rempt into branch 'krita/5.1'.

Fix syntax error in scripter

This makes the scripter incompatible with Python 2, but even the
VFX platform now has abandoned Python 2.
(cherry picked from commit e2fb1409b1c61aa381aad5b3c9c425a5b108aa88)

M  +1    -1    plugins/python/scripter/kritapykrita_scripter.desktop

https://invent.kde.org/graphics/krita/commit/92d043ab5cec57efdd6127979e0f399da4ad1077
Comment 6 Halla Rempt 2022-08-04 09:50:18 UTC
Ah, I misread the comment there...