question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

six.reraise: IndexError: list index out of range

See original GitHub issue

pyupgrade 1.26.0

Minimal test case. Requires using the --py3-plus argument.

def foo(func, arg):
    et, ev, _ = sys.exc_info()
    six.reraise(et, (ev[0], ev[1] + (" %s %s" % (func, arg))))
Traceback (most recent call last):
  File ".../venv/bin/pyupgrade", line 10, in <module>
    sys.exit(main())
  File ".../venv/lib64/python3.8/site-packages/pyupgrade.py", line 2318, in main
    ret |= _fix_file(filename, args)
  File ".../venv/lib64/python3.8/site-packages/pyupgrade.py", line 2280, in _fix_file
    contents_text = _fix_py3_plus(contents_text)
  File ".../venv/lib64/python3.8/site-packages/pyupgrade.py", line 1984, in _fix_py3_plus
    _replace_call(tokens, i, end, func_args, template)
  File ".../venv/lib64/python3.8/site-packages/pyupgrade.py", line 1849, in _replace_call
    src = tmpl.format(args=arg_strs, rest=rest)
IndexError: list index out of range

Discovered by running on setuptools:

https://github.com/pypa/setuptools/blob/682b6511ac67e021b542e74ce30e13fe52bc2da9/setuptools/command/easy_install.py#L1730-L1735

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
asottilecommented, Jan 18, 2020

I suspect you’ll want to change that code to raise et(...) instead fwiw

0reactions
jdufresnecommented, Jan 18, 2020

Thanks for quick response!

Read more comments on GitHub >

github_iconTop Results From Across the Web

List Index Out of Range – Python Error Message Solved
You'll get the Indexerror: list index out of range error when iterating through a list and trying to access an item that doesn't...
Read more >
How to Fix IndexError in Python - Rollbar
The IndexError in Python occurs when an item from a list is attempted to be accessed that is outside the index range of...
Read more >
Python IndexError: List Index Out of Range [Easy Fix] - Finxter
To solve the “IndexError: list index out of range”, avoid do not access a non-existing list index. For example, my_list[5] causes an error...
Read more >
Python - Index Error - list index out of range - Stack Overflow
I am parsing data from a website but getting the error "IndexError: list index out of range". But ...
Read more >
IndexError: list index out of range #562 - fizyr/keras-retinanet
I don't know, where is error? plz help me again.... Epoch 1/50 Traceback (most recent call last): File "keras_retinanet/bin/train.py", ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found