Skip to content
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

Rename variable crashes when there isn't a blank line is in the end of the .py file #99

Open
iddobergersf opened this issue Jul 22, 2019 · 1 comment

Comments

@iddobergersf
Copy link

iddobergersf commented Jul 22, 2019

target file "bowler_bug.py":
def foo():
bar = 1
return bar(EOF)

code to run:
from bowler import Query
path = "bowler_bug.py"
Query(path).select_var("bar").rename("new_bar").execute(write=True, silent=True)

result:
hunks failed to apply, rejects saved to bowler_bug.py.rej
Traceback (most recent call last):
File "/Users/iddoberger/.virtualenvs/dev_research_venv/lib/python3.7/site-packages/bowler/tool.py", line 348, in apply_hunks
sh.patch(*args[1:], _in=accepted_hunks.encode("utf-8")) # type: ignore
File "/Users/iddoberger/.virtualenvs/dev_research_venv/lib/python3.7/site-packages/sh.py", line 1427, in call
return RunningCommand(cmd, call_args, stdin, stdout, stderr)
File "/Users/iddoberger/.virtualenvs/dev_research_venv/lib/python3.7/site-packages/sh.py", line 774, in init
self.wait()
File "/Users/iddoberger/.virtualenvs/dev_research_venv/lib/python3.7/site-packages/sh.py", line 792, in wait
self.handle_command_exit_code(exit_code)
File "/Users/iddoberger/.virtualenvs/dev_research_venv/lib/python3.7/site-packages/sh.py", line 815, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:

RAN: /usr/bin/patch -u bowler_bug.py

STDOUT:
patching file bowler_bug.py
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file bowler_bug.py.rej

STDERR:


When a new line is added, the renaming works

@iddobergersf iddobergersf changed the title Rename variable with no blank line in end of file crashes Rename variable crashes when no blank line is in the end of the .py file Jul 22, 2019
@iddobergersf iddobergersf changed the title Rename variable crashes when no blank line is in the end of the .py file Rename variable crashes when there isn't a blank line is in the end of the .py file Jul 22, 2019
@thatch
Copy link
Contributor

thatch commented Aug 13, 2019

I will take a look, the .rej file is probably missing the "no newline at end of file" line. If so this is likely https://bugs.python.org/issue2142 which is still open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants