Re: Puzzling error msg.

Discussion in 'Python' started by Ian Kelly, Dec 3, 2012.

  1. Ian Kelly

    Ian Kelly Guest

    On Mon, Dec 3, 2012 at 10:37 AM, <> wrote:

    > if found_0 == True or found_1 == True:
    >


    Not related to your problem, but this line would be more pythonic as:

    if found_0 or found_1:

    My puzzle two-fold. First: how could that code generate an "index our of
    > range" error, and second: line 101 (the one fingered by the error message)
    > is the line following the return statement, the one that contains the #
    > character. I've seen that sort of line slippage when I forgot a ":", but
    > that doesn't seem to be the case here.
    >


    It may indicate a discrepancy between the source and the code that is
    actually running. Python doesn't keep the source in memory; when a
    traceback needs to be generated it opens the relevant files and reads the
    designated lines at run-time. If that source is incorrect, then you get
    inaccurate tracebacks. This could happen in a couple of ways.

    1) Your .pyc or .pyo files are out-of-date, and Python doesn't realize it
    due to incorrect file modification times. Try deleting the cached bytecode
    files and recompiling and see if your problem goes away (or at least gives
    you a better stack trace).

    2) It sounds like this is a long-running process, so perhaps the source
    code has been changed at some point since the process started. In that
    case, merely restarting the process should be sufficient to fix the stack
    trace.

    As for the actual error, assuming that the method's source accurately
    reflects what was running, the only code I see there that I think could
    generate the error is the ".communicate()[0]" bit. As far as I know,
    Popen.communicate should always return a 2-tuple, but perhaps you've
    somehow run into a case where it returned an empty tuple instead. If you
    can reproduce the error, you might try logging the result of the
    ..communicate() call to see what is actually returned when the error occurs.
    Ian Kelly, Dec 3, 2012
    #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. Steven D'Aprano

    Re: Puzzling error msg.

    Steven D'Aprano, Dec 3, 2012, in forum: Python
    Replies:
    0
    Views:
    161
    Steven D'Aprano
    Dec 3, 2012
  2. Chris Angelico

    Re: Puzzling error msg.

    Chris Angelico, Dec 3, 2012, in forum: Python
    Replies:
    0
    Views:
    181
    Chris Angelico
    Dec 3, 2012
  3. Dave Angel

    Re: Puzzling error msg.

    Dave Angel, Dec 4, 2012, in forum: Python
    Replies:
    0
    Views:
    142
    Dave Angel
    Dec 4, 2012
  4. Chris Angelico

    Re: Puzzling error msg.

    Chris Angelico, Dec 4, 2012, in forum: Python
    Replies:
    0
    Views:
    151
    Chris Angelico
    Dec 4, 2012
  5. Dave Angel

    Re: Puzzling error msg.

    Dave Angel, Dec 4, 2012, in forum: Python
    Replies:
    0
    Views:
    152
    Dave Angel
    Dec 4, 2012
Loading...

Share This Page