[PATCH] python/osmo-python-tests[master]: debug_tcp_sockets: clearly mark as global var

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Thu Mar 2 15:06:07 UTC 2017


Hello Holger Freyther,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/1919

to look at the new patch set (#2).

debug_tcp_sockets: clearly mark as global var

Usually python implicitly takes a global var if no local var is present.
But it's easy to create a local var by accident that would then shadow
the global one, e.g. with an assignment.

Marking it as global ensures that we always use the one global var and
avoid local shadows.

Change-Id: I56e26590ea380c7deab7ce132d688b37eb2d11a3
---
M osmopy/obscvty.py
1 file changed, 3 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/19/1919/2

diff --git a/osmopy/obscvty.py b/osmopy/obscvty.py
index a517a5f..b09d108 100755
--- a/osmopy/obscvty.py
+++ b/osmopy/obscvty.py
@@ -39,6 +39,7 @@
     sys.stdout.flush()
 
 def print_used_tcp_sockets():
+    global debug_tcp_sockets
     if not debug_tcp_sockets:
         return
     cmd('ls /proc/self/fd');
@@ -68,6 +69,7 @@
         self.last_node = ''
 
     def _close_socket(self):
+        global debug_tcp_sockets
         if self.socket:
             if debug_tcp_sockets:
                 VTYInteract.all_sockets.remove(self.socket)
@@ -131,6 +133,7 @@
         return 0
 
     def _common_command(self, request, close=False, ends=None):
+        global debug_tcp_sockets
         if not ends:
             ends = [self.norm_end, self.priv_end]
         if not self.socket:

-- 
To view, visit https://gerrit.osmocom.org/1919
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I56e26590ea380c7deab7ce132d688b37eb2d11a3
Gerrit-PatchSet: 2
Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Holger Freyther <holger at freyther.de>
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list