From 575f8c1fffb7d3a0610f877882d6c6e6f5acaca7 Mon Sep 17 00:00:00 2001 From: Norberto Arrieta Date: Fri, 13 Oct 2023 10:56:16 -0700 Subject: [PATCH] Fix for "local variable _COLLECT_NOEXEC_ERRORS referenced before assignment" (#2935) (#2944) * Fix for "local variable _COLLECT_NOEXEC_ERRORS referenced before assignment" * pylint --------- Co-authored-by: narrieta (cherry picked from commit c5181c05024e6bb03caccf877b82004db8b7ac09) --- azurelinuxagent/common/utils/extensionprocessutil.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/azurelinuxagent/common/utils/extensionprocessutil.py b/azurelinuxagent/common/utils/extensionprocessutil.py index c24ebf194..d2b37551b 100644 --- a/azurelinuxagent/common/utils/extensionprocessutil.py +++ b/azurelinuxagent/common/utils/extensionprocessutil.py @@ -107,6 +107,10 @@ def _check_noexec(): """ Check if /var is mounted with the noexec flag. """ + # W0603: Using the global statement (global-statement) + # OK to disable; _COLLECT_NOEXEC_ERRORS is used only within _check_noexec, but needs to persist across calls. + global _COLLECT_NOEXEC_ERRORS # pylint: disable=W0603 + try: agent_dir = conf.get_lib_dir() with open('/proc/mounts', 'r') as f: