From 1112c62540df496e25a1075864dd53b62bf31c6e Mon Sep 17 00:00:00 2001
From: Joey Hess <joey@gnu.kitenet.net>
Date: Sun, 19 Jul 2009 16:01:23 +0200
Subject: [PATCH] refactor

---
 .../Debhelper/Buildsystem/python_distutils.pm | 21 +++++++++++--------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/Debian/Debhelper/Buildsystem/python_distutils.pm b/Debian/Debhelper/Buildsystem/python_distutils.pm
index e1b1aef..4838cad 100644
--- a/Debian/Debhelper/Buildsystem/python_distutils.pm
+++ b/Debian/Debhelper/Buildsystem/python_distutils.pm
@@ -124,20 +124,23 @@ sub setup_py {
 		@python_requested = ("python", grep(!/^\Q$python_default\E/,
 					@python_requested));
 	}
+
+	my @python_dbg;
         my @dbg_build_needed = $this->dbg_build_needed();
+	foreach my $python (map { $_."-dbg" } @python_requested) {
+		if (grep /^(python-all-dbg|\Q$python\E)/, @dbg_build_needed) {
+			push @python_dbg, $python;
+		}
+		elsif (($python eq "python-dbg")
+		       and (grep /^\Q$python_default\E/, @dbg_build_needed)) {
+			push @python_dbg, $python_default."-dbg";
+		}
+	}
 
-	foreach my $python (@python_requested) {
+	foreach my $python (@python_requested, @python_dbg) {
 		if (-x "/usr/bin/".$python) {
 			$this->doit_in_sourcedir($python, "setup.py", $act, @_);
 		}
-		$python = $python . "-dbg";
-		if (grep /^(python-all-dbg|\Q$python\E)/, @dbg_build_needed) {
-			$this->doit_in_sourcedir($python, "setup.py", $act, @_);
-		} elsif (($python eq "python-dbg")
-			and (grep /^$python_default/, @dbg_build_needed)) {
-			$this->doit_in_sourcedir($python_default."-dbg",
-				"setup.py", $act, @_);
-		}
 	}
 }
 
-- 
2.39.5