Subject: debpartial-mirror: InvalidSection exception not caught in the case of 
invalid 'resolve_deps_using' option
Package: debpartial-mirror
Version: 0.2.93
Severity: normal
Tags: patch

Every time a Config instance is created, debpartial-mirror catches
InvalidSection exceptions, that's ok. But when the configuration file
lists an invalid backend in 'resolve_deps_using', debpartial-mirror
crashes like this:

[EMAIL PROTECTED]:~/hacking/src/debpartial-mirror/debpartial-mirror-0.2.93$ 
./debpartial-mirror -c mirror.conf all
Traceback (most recent call last):
  File "./debpartial-mirror", line 246, in ?
    main()
  File "./debpartial-mirror", line 208, in main
    (cnf_mirrors, cnf_merges) = cnf.get_backends()
  File 
"/home/terceiro/hacking/src/debpartial-mirror/debpartial-mirror-0.2.93/debpartial_mirror/Config.py",
 line 342, in get_backends
    self.check_dependencies(backend)
  File 
"/home/terceiro/hacking/src/debpartial-mirror/debpartial-mirror-0.2.93/debpartial_mirror/Config.py",
 line 336, in check_dependencies
    raise InvalidSection(section)
NameError: global name 'section' is not defined

The solution I found is to check dependency section straight in the
constructor, instead doing that when get_backends is called. The
attached patch fixes the problem.


-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.16-2-em64t-p4-smp
Locale: LANG=pt_BR.utf8, LC_CTYPE=pt_BR.utf8 (charmap=UTF-8)


-- 
Antonio S. de A. Terceiro <[EMAIL PROTECTED]>
http://people.softwarelivre.org/~terceiro/
GnuPG ID: E6F73C30


Index: debpartial_mirror/Config.py
===================================================================
--- debpartial_mirror/Config.py (revisão 740)
+++ debpartial_mirror/Config.py (cópia de trabalho)
@@ -297,6 +297,10 @@
             if not isinstance(section, ConfigGlobal):
                 self.backends[section.section] = section
 
+        # Check backend dependencies
+        for backend in self.backends.keys():
+            self.check_dependencies(backend)
+
     def __get_section_type(self, section):
         # detect which config type this is
         if section == 'GLOBAL':
@@ -337,10 +341,6 @@
 
     def get_backends(self):
 
-        # Check backend dependencies
-        for backend in self.backends.keys():
-            self.check_dependencies(backend)
-
         # Sort backends
         unsorted = self.backends.values()
         sorted = []

Reply via email to