AGProjects / python3-application

Basic building blocks for Python applications
Other
3 stars 10 forks source link

Python 3.12 removed SafeConfigParser #5

Open bsdice opened 3 months ago

bsdice commented 3 months ago

Hi,

since Python 3.2 SafeConfigParser has been deprecated, removed now in Python 3.12. Compare: https://github.com/python/cpython/blob/v3.11.1/Lib/configparser.py#L1242-L1252

$ blink
Traceback (most recent call last):
  File "/usr/bin/blink", line 67, in <module>
    from blink import Blink
  File "/usr/lib/python3.12/site-packages/blink/__init__.py", line 15, in <module>
    from sipsimple.application import SIPApplication
  File "/usr/lib/python3.12/site-packages/sipsimple/application.py", line 27, in <module>
    from sipsimple.account import AccountManager
  File "/usr/lib/python3.12/site-packages/sipsimple/account/__init__.py", line 33, in <module>
    from sipsimple.payloads.messagesummary import MessageSummary
  File "/usr/lib/python3.12/site-packages/sipsimple/payloads/messagesummary.py", line 9, in <module>
    from application.configuration.datatypes import Boolean
  File "/usr/lib/python3.12/site-packages/application/configuration/__init__.py", line 6, in <module>
    from configparser import SafeConfigParser, NoSectionError
ImportError: cannot import name 'SafeConfigParser' from 'configparser' (/usr/lib/python3.12/configparser.py). Did you mean: 'RawConfigParser'?

Possible fix:

diff -Nurp python3-application-release-3.0.6.old/application/configuration/__init__.py python3-application-release-3.0.6/application/configuration/__init__.py
--- python3-application-release-3.0.6.old/application/configuration/__init__.py 2023-03-09 17:34:56.000000000 +0100
+++ python3-application-release-3.0.6/application/configuration/__init__.py 2024-05-12 00:19:22.077135411 +0200
@@ -3,7 +3,7 @@

 import os

-from configparser import SafeConfigParser, NoSectionError
+from configparser import ConfigParser, NoSectionError
 from inspect import isclass
 from itertools import chain
 from types import BuiltinFunctionType
@@ -37,7 +37,7 @@ class ConfigFile(object):
         instance = cls.instances.get(filename, None)
         if instance is None or instance.files != files or instance.timestamp < timestamp:
             instance = object.__new__(cls)
-            instance.parser = SafeConfigParser()
+            instance.parser = ConfigParser()
             instance.parser.optionxform = lambda x: x.replace('-', '_')
             instance.files = instance.parser.read(files)
             instance.filename = filename

Thank you

tijmenNL commented 3 months ago

Hi,

Thanks for the patch. I will check if it can be replaced like this.

bsdice commented 3 months ago

Hi,

I can't open an issue at https://github.com/AGProjects/blink-qt so here just a heads up about another issue:

python-lxml 5.1.0 is the last working version for blink-qt, because as of 5.2.0 you will get:

ImportError: lxml.html.clean module is now a separate project lxml_html_clean

See https://github.com/napari/napari/issues/6798 for more context.

tijmenNL commented 3 months ago

Thanks for the issue. This is not really the place for issues with BlinkQT, ideally you should use the mailing list for reporting such issues.

We package for Debian/Ubuntu. In Debian Trixie/SID a package is available width lxml.html.clean: https://packages.debian.org/search?suite=all&searchon=names&keywords=python3-lxml

Since you're appearing to use Arch, isn't there a package available for this? That would be the easy solution.

Blink uses lxml.html to parse links in sip messages. If you know any alternative that is available in Debian/Ubuntu I can check if we can switch to that.

bsdice commented 3 months ago

Will use the mailing list next time.

Yes there is an Arch package in AUR, the user contribution repository. I do post package fixes to it from time to time: https://aur.archlinux.org/packages/blink

I fixed the Arch package last night by introducing https://github.com/fedora-python/lxml_html_clean/tree/main to within the package and fixing the import line.

User count for Arch should be very low. This will change, should confidentiality of current messengers like Signal be fully subverted by law. People will revert to using their own SIP infrastructure.