Fix for objname referenced before assigned error

Adriaan de Groot <[email protected]> Mon, 26 Dec 2005 02:42:30 +0100
Newsgroups gmane.comp.tools.aap.devel
Message-ID <[email protected]>
--nextPart1148087.CfOB0MuhdJ
Content-Type: multipart/mixed;
  boundary="Boundary-01=_Gq0rDiIcvTOBFFP"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

--Boundary-01=_Gq0rDiIcvTOBFFP
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

While futzing with AAP, I triggered a case where objname is referenced befo=
re=20
it is assigned; looking at the code it's obvious that the assumption is tha=
t=20
unused variables have value None -- but they don't, at least not in python=
=20
2.4. So here's a patch.

=2D-=20
These are your friends - Adem
    GPG: FEA2 A3FE Adriaan de Groot

--Boundary-01=_Gq0rDiIcvTOBFFP
Content-Type: text/x-diff;
  charset="us-ascii";
  name="objname.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="objname.diff"

diff -u --exclude=3D*.pyc aap/Exec-cvs/DoAddDef.py kpilot/kpilot/trunk/aap/=
DoAddDef.py
=2D-- aap/Exec-cvs/DoAddDef.py	Wed Nov 23 23:46:56 2005
+++ kpilot/kpilot/trunk/aap/DoAddDef.py	Sat Dec 24 17:20:48 2005
@@ -309,6 +309,7 @@
                 # the source in the first one that is possible.
                 names =3D ''
=20
+                objname =3D None
                 for objtype in objtypes:
                     if objtype =3D=3D "default":
                         continue
@@ -319,7 +320,7 @@
                         names =3D names + '/'
                     names =3D names + objtype
=20
=2D                if not objname:
+                if objname is None:
                     recipe_error(rpstack, _('Do not know how to make an %s=
 out of "%s"') % (names, si["name"]))
=20
                 build_obj.append({"name" : objname})

--Boundary-01=_Gq0rDiIcvTOBFFP--

--nextPart1148087.CfOB0MuhdJ
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (FreeBSD)

iD8DBQBDr0qGdqzuAf6io/4RAldRAJ9W2IgBvPuZ4MUQaEGF45WPoLCF8gCeN7PR
Gi9Lkamrue5a+B6mU6Umi4E=
=T0/9
-----END PGP SIGNATURE-----

--nextPart1148087.CfOB0MuhdJ--


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click