]> git.cworth.org Git - notmuch/commitdiff
python: adjust legacy bindings to py 3.12
authorMichael J Gruber <git@grubix.eu>
Fri, 16 Jun 2023 11:19:26 +0000 (13:19 +0200)
committerDavid Bremner <david@tethera.net>
Sun, 9 Jul 2023 14:43:21 +0000 (11:43 -0300)
Py 3.12 finally pulled the plug on the `SafeConfigParser` class which
has been deprecated since py 3.2.

We use it in the legacy bindings only, so take the easy route of
importing `ConfigParser` as `SafeConfigParser` and monkey-patching so
that the class has the expected interface.

bindings/python/notmuch/compat.py

index c931329e96972237d5f380ba2270a9dcc2d28d56..4a94e05c805d1a9fc28d035fbde09f3b404ff202 100644 (file)
@@ -47,7 +47,10 @@ if sys.version_info[0] == 2:
 
         return value
 else:
-    from configparser import SafeConfigParser
+    from configparser import ConfigParser as SafeConfigParser
+
+    if not hasattr(SafeConfigParser, 'readfp'):   # py >= 3.12
+        SafeConfigParser.readfp = SafeConfigParser.read_file
 
     class Python3StringMixIn(object):
         def __str__(self):