From 572f94eb871a522c63b842e4211d8901867f0633 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Wed, 30 Nov 2016 21:25:10 -0600 Subject: [PATCH] Fix shadowing of dnf module when module is executed directly --- i3pystatus/updates/dnf.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/i3pystatus/updates/dnf.py b/i3pystatus/updates/dnf.py index e860b18..fcd4d80 100644 --- a/i3pystatus/updates/dnf.py +++ b/i3pystatus/updates/dnf.py @@ -1,9 +1,17 @@ from i3pystatus.updates import Backend +import sys + +# Remove first dir from sys.path to avoid shadowing dnf module from +# site-packages dir when this module executed directly on the CLI. +__module_dir = sys.path.pop(0) try: import dnf HAS_DNF_BINDINGS = True except ImportError: HAS_DNF_BINDINGS = False +finally: + # Replace the directory we popped earlier + sys.path.insert(0, __module_dir) class Dnf(Backend):