This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients mark.dickinson, paultjuhatwork
Date 2009-09-03.11:44:34
SpamBayes Score 1.2322936e-08
Marked as misclassified No
Message-id <1251978278.05.0.706454716354.issue6833@psf.upfronthosting.co.za>
In-reply-to
Content
This is not a bug.  The behaviour you're seeing is described here:

http://docs.python.org/reference/executionmodel.html#naming-and-binding

"If a name binding operation occurs anywhere within a code block, all
uses of the name within the block are treated as references to the
current block. This can lead to errors when a name is used within a
block before it is bound. This rule is subtle. Python lacks declarations
and allows name binding operations to occur anywhere within a code
block. The local variables of a code block can be determined by scanning
the entire text of the block for name binding operations."

In the failing example, the registerdecorator function contains an
assignment to in_std, so by the rules above in_std is local to the
function.  The 'if in_std' line therefore tries to lookup 'in_std' in
the local namespace;  it doesn't exist (yet), so an UnboundLocalError
exception occurs.
History
Date User Action Args
2009-09-03 11:44:38mark.dickinsonsetrecipients: + mark.dickinson, paultjuhatwork
2009-09-03 11:44:38mark.dickinsonsetmessageid: <1251978278.05.0.706454716354.issue6833@psf.upfronthosting.co.za>
2009-09-03 11:44:35mark.dickinsonlinkissue6833 messages
2009-09-03 11:44:34mark.dickinsoncreate