[elbe-devel] [PATCH 2/2] debinstaller: move sig=urlopen() out of try: finally: block

Torben Hohn torben.hohn at linutronix.de
Wed Nov 21 13:08:05 CET 2018


when Release.gpg does not exist on the mirror, this backtrace is generated:

   File "/home/manut/Projects/elbe/elbe/elbe", line 55, in <module>
     cmdmod.run_command(sys.argv[2:])
   File "/home/manut/Projects/elbe/elbe/elbepack/commands/init.py", line 168, in run_command
     copy_kinitrd(xml.node("/initvm"), out_path)
   File "/home/manut/Projects/elbe/elbe/elbepack/debinstaller.py", line 231, in copy_kinitrd
     download_kinitrd(tmp, suite, mirror)
   File "/home/manut/Projects/elbe/elbe/elbepack/debinstaller.py", line 169, in download_kinitrd
     download_release(tmp, base_url)
   File "/home/manut/Projects/elbe/elbe/elbepack/debinstaller.py", line 157, in download_release
     sig.close()
 UnboundLocalError: local variable 'sig' referenced before assignment

move urlopen() out of the try: block. it did not catch the exception.
so the bahviour is not changed.

Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
---
 elbepack/debinstaller.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/elbepack/debinstaller.py b/elbepack/debinstaller.py
index baf8d8d4..96d1d841 100644
--- a/elbepack/debinstaller.py
+++ b/elbepack/debinstaller.py
@@ -136,8 +136,8 @@ def download_release(tmp, base_url):
     # open downloaded plaintext file, and
     # use the urlopen object of the Release.gpg
     # directtly.
+    sig = urlopen(base_url + 'Release.gpg', None, 10)
     try:
-        sig = urlopen(base_url + 'Release.gpg', None, 10)
         with tmp.open("Release", "r") as signed:
 
             overall_status = OverallStatus()
-- 
2.11.0




More information about the elbe-devel mailing list