[ python-Bugs-1053604 ] Unjustified SyntaxWarning

SourceForge.net noreply at sourceforge.net
Mon Oct 25 11:06:43 CEST 2004


Bugs item #1053604, was opened at 2004-10-25 11:06
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1053604&group_id=5470

Category: Parser/Compiler
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Markus Gritsch (markus_gritsch)
Assigned to: Nobody/Anonymous (nobody)
Summary: Unjustified SyntaxWarning

Initial Comment:
The following short script produces a "SyntaxWarning:
name 'cPickle' is assigned to before global
declaration", which is IMO not correct.


mode = 'pickle'

def main():
    if mode == 'pickle':
        global cPickle
        import cPickle
    elif mode == 'socket':
        global cPickle, socket
        import cPickle, socket
    elif mode == 'sqlite':
        global sqlite
        import sqlite
    else:
        print 'Warning: Unknown mode.'

def test():
    print cPickle.__doc__

if __name__ == '__main__':
    main()
    test()


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1053604&group_id=5470


More information about the Python-bugs-list mailing list