Re: Re/Unresolved bug?

Discussion in 'Python' started by Steven Taschuk, Jun 29, 2003.

  1. Quoth Xavier:
    [top-posting fixed]
    > From: "Steven Taschuk" <>
    > > Could you post a minimal example of code which provokes this
    > > behaviour?

    [...]
    > Thanks for your reply. Here is the exact, waiting to be fixed code:
    > http://sabu.net/routekill.py


    That is very far from a minimal example. What you should do is
    cut out some code, verify that the problem still exists, and
    repeat until you can't cut out anything without making the problem
    go away. Doing so has two advantages: first, a short example is
    much more likely to provoke responses here, and second, the
    process itself might teach you what the problem is.

    Having had some spare time today, I've done this for you. Here's
    the (not *quite* minimal, actually) result:

    def addroutes(IP, METHOD):
    global METHOD

    def main():
    global VERBOSE
    VERBOSE = '1'
    global VERBOSE

    print 'foo'

    On my machine, with 2.2.2 this code issues the SyntaxWarning and
    then segfaults, and on 2.3 issues the SyntaxWarning and dies
    without printing 'foo'.

    There are two things wrong with this code. To get it running,
    first remove the second global statement for VERBOSE. Once that's
    done, the code will start producing
    SyntaxError: name 'METHOD' is local and global
    Thus the second thing you need to do is to decide whether you want
    METHOD to be an argument to addroutes() or a global variable to
    that function, and then either remove the global statement or
    emend the argument list.

    Once you've done these two things the code will run; I leave
    determining whether it works to you.

    (Python's reaction to this code *is* buggy -- it seems that the
    SyntaxWarning interferes with the SyntaxError somehow. (My
    original suspicion that the SyntaxWarning was irrelevant was
    wrong.) I'll be looking into this today.)

    --
    Steven Taschuk
    "What I find most baffling about that song is that it was not a hit."
    -- Tony Dylan Davis (CKUA)
     
    Steven Taschuk, Jun 29, 2003
    #1
    1. Advertisements

  2. Steven Taschuk

    John Machin Guest

    Steven Taschuk <> wrote in message news:<>...

    > Having had some spare time today, I've done this for you. Here's
    > the (not *quite* minimal, actually) result:
    >
    > def addroutes(IP, METHOD):
    > global METHOD
    >
    > def main():
    > global VERBOSE
    > VERBOSE = '1'
    > global VERBOSE
    >
    > print 'foo'
    >
    > On my machine, with 2.2.2 this code issues the SyntaxWarning and
    > then segfaults, and on 2.3 issues the SyntaxWarning and dies
    > without printing 'foo'.


    With the above code in a file called fugly.py, here are some perhaps
    illuminating results from the Win32 2.2.3 Python:

    C:\junk>python fugly.py
    fugly.py:4: SyntaxWarning: name 'VERBOSE' is assigned to before global
    declaration
    def main():

    C:\junk>python
    Python 2.2.3 (#42, May 30 2003, 18:12:08) [MSC 32 bit (Intel)] on
    win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import fugly

    XXX rd_object called with exception set
    warning: name 'VERBOSE' is assigned to before global declaration
    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    File "fugly.py", line 1
    def addroutes(IP, METHOD):
    SyntaxError: name 'METHOD' is local and global
    >>>


    N.B. no crashes.

    Hope this helps,
    John
     
    John Machin, Jun 30, 2003
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jozo
    Replies:
    1
    Views:
    2,763
    Ralf Hildebrandt
    May 16, 2004
  2. Andrew Mayo
    Replies:
    1
    Views:
    1,587
    Ryan Stewart
    Jan 31, 2005
  3. Replies:
    4
    Views:
    2,003
  4. Jay Steiner

    Unresolved Symbol: __rtaccess

    Jay Steiner, Aug 27, 2003, in forum: C++
    Replies:
    1
    Views:
    374
    Shane Beasley
    Aug 28, 2003
  5. Izak Pretorius
    Replies:
    2
    Views:
    1,902
    Christopher
    Sep 14, 2003
  6. Rodolphe
    Replies:
    4
    Views:
    1,308
    Rodolphe
    Oct 3, 2003
  7. Scott Brady Drummonds

    Unresolved Symbols from C++ Code

    Scott Brady Drummonds, Oct 8, 2003, in forum: C++
    Replies:
    3
    Views:
    684
    Jonathan Mcdougall
    Oct 9, 2003
  8. Xavier

    Re: Re/Unresolved bug?

    Xavier, Jun 29, 2003, in forum: Python
    Replies:
    1
    Views:
    820
    Terry Reedy
    Jun 29, 2003
Loading...