-
Notifications
You must be signed in to change notification settings - Fork 290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IndexError: string index out of range #759
Labels
Comments
@pmvd |
📝 Example code to be reproduced# target.py
doc, doc2 = ("""
World:
1 + "programming"
+ " pythonあ""",
"""abc"""
) with Python3.12 (3.12.4)
with Python3.11 (3.11.7)
Why?The behaviour of tokenize.generate_tokens in Python 3.12 may have changed. # sample1.py
import tokenize
from io import StringIO
code = """doc, doc2 = (\"\"\"
World:
1 + "programming"
+ " pythonあ\"\"\",
'''abc'''
)
"""
def tokenize_code(code):
tokens = []
for tok in tokenize.generate_tokens(StringIO(code).readline):
tokens.append((tok.type, tok.string, tok.start, tok.end, tok.line))
return tokens
tokens_311 = tokenize_code(code)
for token in tokens_311:
print(token)
print(tokenize.untokenize(tokens_311)) with Python3.11.7
with Python3.12.4
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
autopep8 -i model.py
Traceback (most recent call last):
File "/.venv/bin/autopep8", line 8, in
sys.exit(main())
^^^^^^
File "/.venv/lib/python3.12/site-packages/autopep8.py", line 4590, in main
results = fix_multiple_files(args.files, args, sys.stdout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.12/site-packages/autopep8.py", line 4485, in fix_multiple_files
ret = _fix_file((name, options, output))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.12/site-packages/autopep8.py", line 4455, in _fix_file
return fix_file(*parameters)
^^^^^^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.12/site-packages/autopep8.py", line 3629, in fix_file
fixed_source = fix_lines(fixed_source, options, filename=filename)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.12/site-packages/autopep8.py", line 3609, in fix_lines
fixed_source = fix.fix()
^^^^^^^^^
File "/.venv/lib/python3.12/site-packages/autopep8.py", line 623, in fix
results = _execute_pep8(pep8_options, self.source)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.12/site-packages/autopep8.py", line 3021, in _execute_pep8
checker.check_all()
File "/.venv/lib/python3.12/site-packages/pycodestyle.py", line 2115, in check_all
self.check_logical()
File "/.venv/lib/python3.12/site-packages/pycodestyle.py", line 1973, in check_logical
mapping = self.build_tokens_line()
^^^^^^^^^^^^^^^^^^^^^^^^
File "/.venv/lib/python3.12/site-packages/pycodestyle.py", line 1956, in build_tokens_line
prev_text = self.lines[prev_row - 1][prev_col - 1]
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
IndexError: string index out of range
Python Code
private
Command Line and Configuration
.pep8
,setup.cfg
, ...[pep8]
Command Line
$ autopep8
Your Environment
The text was updated successfully, but these errors were encountered: