From 39b952af53a1630a47593027206672d26a39d5d9 Mon Sep 17 00:00:00 2001 From: Ilja Honkonen Date: Mon, 22 Mar 2021 16:35:22 +0200 Subject: [PATCH] Fix imports of ConfigParser for python3. --- src/api.py | 6 +++++- src/bitmessagecurses/__init__.py | 6 +++++- src/bmconfigparser.py | 6 +++++- src/debug.py | 6 +++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/api.py b/src/api.py index 9c0c18a7..c66c4a72 100644 --- a/src/api.py +++ b/src/api.py @@ -58,7 +58,11 @@ For further examples please reference `.tests.test_api`. """ import base64 -import ConfigParser +try: + import ConfigParser +except ModuleNotFoundError: + import configparser as ConfigParser + ConfigParser.SafeConfigParser = ConfigParser.ConfigParser import errno import hashlib import httplib diff --git a/src/bitmessagecurses/__init__.py b/src/bitmessagecurses/__init__.py index 7c2ed733..3cbb3eaa 100644 --- a/src/bitmessagecurses/__init__.py +++ b/src/bitmessagecurses/__init__.py @@ -10,7 +10,11 @@ Bitmessage commandline interface # * python2-pythondialog # * dialog -import ConfigParser +try: + import ConfigParser +except ModuleNotFoundError: + import configparser as ConfigParser + ConfigParser.SafeConfigParser = ConfigParser.ConfigParser import curses import os import sys diff --git a/src/bmconfigparser.py b/src/bmconfigparser.py index ff43fd7c..06305f20 100644 --- a/src/bmconfigparser.py +++ b/src/bmconfigparser.py @@ -2,7 +2,11 @@ BMConfigParser class definition and default configuration settings """ -import ConfigParser +try: + import ConfigParser +except ModuleNotFoundError: + import configparser as ConfigParser + ConfigParser.SafeConfigParser = ConfigParser.ConfigParser import os import shutil from datetime import datetime diff --git a/src/debug.py b/src/debug.py index cab07275..0e3eb42c 100644 --- a/src/debug.py +++ b/src/debug.py @@ -35,7 +35,11 @@ Logging is thread-safe so you don't have to worry about locks, just import and log. """ -import ConfigParser +try: + import ConfigParser +except ModuleNotFoundError: + import configparser as ConfigParser + ConfigParser.SafeConfigParser = ConfigParser.ConfigParser import logging import logging.config import os