Mercurial > hg-stable
changeset 52030:c76c1c948804
zeroconf: use str instead of bytes when indexing `globals()`
I suppose since we set the key to bytes during init that it won't raise a
KeyError, but this was very likely an oversight when mass-byteifying, rather
than purposeful.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Mon, 07 Oct 2024 23:24:28 -0400 |
parents | 997c9b2069d1 |
children | 3af11f3e9980 |
files | hgext/zeroconf/Zeroconf.py |
diffstat | 1 files changed, 8 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/zeroconf/Zeroconf.py Mon Oct 07 23:20:09 2024 -0400 +++ b/hgext/zeroconf/Zeroconf.py Mon Oct 07 23:24:28 2024 -0400 @@ -95,7 +95,7 @@ # hook for threads -globals()[b'_GLOBAL_DONE'] = 0 +globals()['_GLOBAL_DONE'] = 0 # Some timing constants @@ -949,7 +949,7 @@ self.start() def run(self): - while not globals()[b'_GLOBAL_DONE']: + while not globals()['_GLOBAL_DONE']: rs = self.getReaders() if len(rs) == 0: # No sockets to manage, but we wait for the timeout @@ -965,7 +965,7 @@ try: self.readers[sock].handle_read() except Exception: - if not globals()[b'_GLOBAL_DONE']: + if not globals()['_GLOBAL_DONE']: traceback.print_exc() except Exception: pass @@ -1045,7 +1045,7 @@ def run(self): while True: self.zeroconf.wait(10 * 1000) - if globals()[b'_GLOBAL_DONE']: + if globals()['_GLOBAL_DONE']: return now = currentTimeMillis() for record in self.zeroconf.cache.entries(): @@ -1118,7 +1118,7 @@ now = currentTimeMillis() if len(self.list) == 0 and self.nexttime > now: self.zeroconf.wait(self.nexttime - now) - if globals()[b'_GLOBAL_DONE'] or self.done: + if globals()['_GLOBAL_DONE'] or self.done: return now = currentTimeMillis() @@ -1408,7 +1408,7 @@ def __init__(self, bindaddress=None): """Creates an instance of the Zeroconf class, establishing multicast communications, listening and reaping threads.""" - globals()[b'_GLOBAL_DONE'] = 0 + globals()['_GLOBAL_DONE'] = 0 if bindaddress is None: self.intf = socket.gethostbyname(socket.gethostname()) else: @@ -1848,8 +1848,8 @@ def close(self): """Ends the background threads, and prevent this instance from servicing further queries.""" - if globals()[b'_GLOBAL_DONE'] == 0: - globals()[b'_GLOBAL_DONE'] = 1 + if globals()['_GLOBAL_DONE'] == 0: + globals()['_GLOBAL_DONE'] = 1 self.notifyAll() self.engine.notify() self.unregisterAllServices()