From 85c65903406b4704fac3604c5012fdb867b9dda6 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Wed, 19 Jul 2023 18:33:51 +0200 Subject: [PATCH] Fix import error if bootstrapping is not yet completed Fixes #1644 If package_control injector code has not yet been written (first start with PC4.0 installed), an import error was thown due to missing module. Regressed by 8e1132126b22d56df969809c23a813b4f4936e5f This commit therefore falls back to relative import, in case bootstrapping is not yet completed. --- package_control/package_disabler.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/package_control/package_disabler.py b/package_control/package_disabler.py index 787281f0..49ae7f50 100644 --- a/package_control/package_disabler.py +++ b/package_control/package_disabler.py @@ -5,9 +5,13 @@ import sublime -# Relative import may not work here due to hard loading events -# into global package_control (see bootstrap.py)! -from package_control import events +try: + # Relative import does not work here due to hard loading events + # into global package_control (see bootstrap.py)! + from package_control import events +except ImportError: + # use relative import, if bootstrapping has not yet been completed + from . import events from .console_write import console_write from .package_io import package_file_exists, read_package_file