Bug 461598 - scripter doesn't work with python 3.11
Summary: scripter doesn't work with python 3.11
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Scripting (other bugs)
Version First Reported In: 5.1.3
Platform: OpenMandriva Linux
: NOR normal
Target Milestone: ---
Assignee: amyspark
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-11-08 16:18 UTC by Bernhard Rosenkränzer
Modified: 2022-11-28 22:39 UTC (History)
3 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bernhard Rosenkränzer 2022-11-08 16:18:12 UTC
SUMMARY
Starting Krita 5.1.3 on a system with python 3.11 results in error messages on stderr:

/usr/lib64/krita-python-libs/krita added to PYTHONPATH
krita.scripting: "Traceback (most recent call last):"
krita.scripting: "  File \"/usr/share/krita/pykrita/scripter/__init__.py\", line 6, in <module>"
krita.scripting: "    from .scripter import *"
krita.scripting: "  File \"/usr/share/krita/pykrita/scripter/scripter.py\", line 8, in <module>"
krita.scripting: "    from . import uicontroller, documentcontroller, debugcontroller"
krita.scripting: "  File \"/usr/share/krita/pykrita/scripter/debugcontroller.py\", line 6, in <module>"
krita.scripting: "    from .debugger_scripter import debugger"
krita.scripting: "  File \"/usr/share/krita/pykrita/scripter/debugger_scripter/debugger.py\", line 16, in <module>"
krita.scripting: "    class Debugger(bdb.Bdb):"
krita.scripting: "  File \"/usr/share/krita/pykrita/scripter/debugger_scripter/debugger.py\", line 86, in Debugger"
krita.scripting: "    @asyncio.coroutine"
krita.scripting: "     ^^^^^^^^^^^^^^^^^"
krita.scripting: "AttributeError: module 'asyncio' has no attribute 'coroutine'"
krita.scripting: "Could not import scripter"
krita.scripting: Error loading plugin "scripter"

@asyncio.coroutine has been deprecated since python 3.5 and finally removed in 3.11.

STEPS TO REPRODUCE
1. Install python 3.11
2. Build scripter's dependencies with python 3.11
3. Build and launch krita

OBSERVED RESULT
Scripter crashes on startup

EXPECTED RESULT
Scripter works

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
KDE Plasma Version: 5.26.3
KDE Frameworks Version: 5.99.0
Qt Version: 5.15.7+KDE patches

ADDITIONAL INFORMATION
The fix is simply replacing @asyncio.coroutine with the async keyword, but that will break some ancient python versions (3.3 and 3.4).
Comment 1 amyspark 2022-11-08 17:26:08 UTC
I'm targeting a Python upgrade to 5.2: https://invent.kde.org/graphics/krita/-/merge_requests/1604

Fixing this would ensure we can safely upgrade the minimum version to at least 3.9, so assigning to myself.
Comment 2 Bernhard Rosenkränzer 2022-11-08 18:21:23 UTC
This patch works for me with 3.11
https://github.com/OpenMandrivaAssociation/krita/blob/master/krita-5.1.3-python-3.11.patch

Haven't tried with any older versions, but don't see why it wouldn't work. (MR 1604 doesn't have anything related to this, @asyncio.coroutine is still present in 3.11)
Comment 3 amyspark 2022-11-08 18:28:29 UTC
(In reply to Bernhard Rosenkränzer from comment #2)
> (MR 1604 doesn't have anything related to this, @asyncio.coroutine is still
> present in 3.11)

I know, I'd not tested with 3.11 as it is clearly stated from the MR. Is it OK if I cherry pick your patches and credit you appropriately?
Comment 4 Bug Janitor Service 2022-11-10 16:40:36 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/1643
Comment 5 amyspark 2022-11-28 22:39:44 UTC
Git commit 03931999a82adb72b16796ffea6cb3b19f4ff65c by L. E. Segovia, on behalf of Bernhard Rosenkränzer.
Committed on 28/11/2022 at 22:39.
Pushed by lsegovia into branch 'krita/5.1'.

Fix scripting with python 3.11

See:
https://github.com/OpenMandrivaAssociation/krita/commit/0267dc56d5d8a321e4397b9caf1644dd936c6f8e

Signed-off-by: L. E. Segovia <amy@amyspark.me>
Part-of: <https://invent.kde.org/graphics/krita/-/merge_requests/1643>
(cherry picked from commit 648fdf1cbb709dd6f775c6fad5acf543d8aaa533)

M  +9    -16   plugins/python/scripter/debugger_scripter/debugger.py

https://invent.kde.org/graphics/krita/commit/03931999a82adb72b16796ffea6cb3b19f4ff65c