Loading apt-listchanges.py +10 −11 Original line number Diff line number Diff line Loading @@ -71,10 +71,9 @@ def main(config): # See Debian Bug #343423. (Note: with $APT_HOOK_INFO_FD # support introduced in version 3.2, stdin should point to # a terminal already, so there should be no need to reopen it). tty = open('/dev/tty', 'rb+', buffering=0) with open('/dev/tty', 'rb+', buffering=0) as tty: os.close(0) os.dup2(tty.fileno(), 0) tty.close() except Exception as ex: ALCLog.warning(_("Cannot reopen /dev/tty for stdin: %s") % str(ex)) Loading apt-listchanges/ALCApt.py +4 −5 Original line number Diff line number Diff line Loading @@ -53,11 +53,10 @@ class AptPipeline(object): self._config = config def read(self): fd = self._open_apt_fd() if self._config.debug: ALCLog.debug(_("APT pipeline messages:")) with self._open_apt_fd() as fd: self._read_version(fd) self._read_options(fd) debs = self._read_packages(fd) Loading apt-listchanges/DebianFiles.py +4 −2 Original line number Diff line number Diff line Loading @@ -113,7 +113,8 @@ class ControlParser: def readfile(self, file): try: self.stanzas += [ControlStanza(x) for x in open(file, 'r', encoding='utf-8', errors='replace').read().split('\n\n') if x] with open(file, encoding='utf-8', errors='replace') as f: self.stanzas += [ControlStanza(x) for x in f.read().split('\n\n') if x] except Exception as ex: raise RuntimeError(_("Error processing '%(what)s': %(errmsg)s") % {'what': file, 'errmsg': str(ex)}) from ex Loading Loading @@ -335,6 +336,7 @@ class Package: if not fd: return None with fd: entries, urgency = ChangelogParser().parse(fd, since_version) if urgency is None: Loading apt-listchanges/apt_listchanges.py +4 −4 Original line number Diff line number Diff line Loading @@ -277,8 +277,8 @@ class ttyconfirm(base): if sys.stdin.isatty() and sys.stdout.isatty(): return input(prompt).rstrip() tty = open('/dev/tty', 'rb+', buffering=0) enc = ALChacks.system_encoding() with open('/dev/tty', 'rb+', buffering=0) as tty: tty.write(enc.to_bytes(prompt)) tty.flush() return enc.from_bytes(tty.readline()).rstrip() Loading Loading
apt-listchanges.py +10 −11 Original line number Diff line number Diff line Loading @@ -71,10 +71,9 @@ def main(config): # See Debian Bug #343423. (Note: with $APT_HOOK_INFO_FD # support introduced in version 3.2, stdin should point to # a terminal already, so there should be no need to reopen it). tty = open('/dev/tty', 'rb+', buffering=0) with open('/dev/tty', 'rb+', buffering=0) as tty: os.close(0) os.dup2(tty.fileno(), 0) tty.close() except Exception as ex: ALCLog.warning(_("Cannot reopen /dev/tty for stdin: %s") % str(ex)) Loading
apt-listchanges/ALCApt.py +4 −5 Original line number Diff line number Diff line Loading @@ -53,11 +53,10 @@ class AptPipeline(object): self._config = config def read(self): fd = self._open_apt_fd() if self._config.debug: ALCLog.debug(_("APT pipeline messages:")) with self._open_apt_fd() as fd: self._read_version(fd) self._read_options(fd) debs = self._read_packages(fd) Loading
apt-listchanges/DebianFiles.py +4 −2 Original line number Diff line number Diff line Loading @@ -113,7 +113,8 @@ class ControlParser: def readfile(self, file): try: self.stanzas += [ControlStanza(x) for x in open(file, 'r', encoding='utf-8', errors='replace').read().split('\n\n') if x] with open(file, encoding='utf-8', errors='replace') as f: self.stanzas += [ControlStanza(x) for x in f.read().split('\n\n') if x] except Exception as ex: raise RuntimeError(_("Error processing '%(what)s': %(errmsg)s") % {'what': file, 'errmsg': str(ex)}) from ex Loading Loading @@ -335,6 +336,7 @@ class Package: if not fd: return None with fd: entries, urgency = ChangelogParser().parse(fd, since_version) if urgency is None: Loading
apt-listchanges/apt_listchanges.py +4 −4 Original line number Diff line number Diff line Loading @@ -277,8 +277,8 @@ class ttyconfirm(base): if sys.stdin.isatty() and sys.stdout.isatty(): return input(prompt).rstrip() tty = open('/dev/tty', 'rb+', buffering=0) enc = ALChacks.system_encoding() with open('/dev/tty', 'rb+', buffering=0) as tty: tty.write(enc.to_bytes(prompt)) tty.flush() return enc.from_bytes(tty.readline()).rstrip() Loading