bug in my code?

Discussion in 'Python' started by Duncan Smith, Jul 15, 2003.

  1. Duncan Smith

    Duncan Smith Guest

    Greetings. I am struggling to track down what I presume is a bug in my
    code. The trouble is that it only raises its head occasionally. I have
    managed to prune the code to the following:

    shutTest.py
    --------------------------------------------------------
    import cPickle

    def test2(iterations):
    for i in range(iterations):
    try:
    f = file('C:\\Python22\\(2, 2, 2, 3, 4).shu', 'r')
    try:
    dependencies, nodes = cPickle.load(f)
    finally:
    f.close()
    except IOError:
    pass
    ----------------------------------------------------------------

    Calling the function with a suitable argument (say, 100) doesn't usually
    pose a problem. The file is opened OK and the data unpickled. But
    occasionally (or usually if I call the function with 1000 as argument) I get
    the all too common, on Windows,

    'The instruction at {some memory address} referenced memory at {some other
    (and on one occasion the same) memory address}. The memory could not be
    "read".'

    I just tried to run the function in the interactive window and got the
    following traceback.

    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    File "shutTest.py", line 9, in test2
    dependencies, nodes = cPickle.load(f)
    cPickle.UnpicklingError: invalid load key, 'a'.

    where the 'a' has a grave accent over it.

    I'm guessing that the previous crashes have corrupted the file? Is there
    any reason why my code should have caused the crashes, or is this just
    Windows 2000? The crashes don't seem to be totally random as they always
    occur in this section of code. BTW I am using Python 2.2.2, and I had the
    crashes in PythonWin, IDLE and the interactive window. TIA.

    Duncan
     
    Duncan Smith, Jul 15, 2003
    #1
    1. Advertising

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. John

    Re: BUG? OR NOT A BUG?

    John, Sep 20, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    556
  2. RedEye
    Replies:
    2
    Views:
    588
    Jason Kester
    Dec 13, 2005
  3. Michel Joly de Lotbiniere

    Bug Parade Bug 4953793

    Michel Joly de Lotbiniere, Nov 30, 2003, in forum: Java
    Replies:
    4
    Views:
    649
    Michel
    Dec 2, 2003
  4. DarkSpy
    Replies:
    4
    Views:
    893
    tom_usenet
    Jun 27, 2003
  5. Gus Gassmann

    Bug in code or bug in cl?

    Gus Gassmann, Feb 9, 2010, in forum: C++
    Replies:
    3
    Views:
    359
    Michael Tsang
    Feb 13, 2010
Loading...

Share This Page