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

fix trailing newline parse bug #2412

Merged
merged 1 commit into from
Aug 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion vyper/cli/vyper_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ def compile_files(
except ValueError:
file_str = file_path.as_posix()
with file_path.open() as fh:
contract_sources[file_str] = fh.read()
# trailing newline fixes python parsing bug when source ends in a comment
# https://bugs.python.org/issue35107
contract_sources[file_str] = fh.read() + "\n"

show_version = False
if "combined_json" in output_formats:
Expand Down
4 changes: 1 addition & 3 deletions vyper/compiler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ def compile_codes(

out: OrderedDict = OrderedDict()
for source_id, contract_name in enumerate(sorted(contract_sources), start=initial_id):
# trailing newline fixes python parsing bug when source ends in a comment
# https://bugs.python.org/issue35107
source_code = f"{contract_sources[contract_name]}\n"
source_code = contract_sources[contract_name]
interfaces: Any = interface_codes
if (
isinstance(interfaces, dict)
Expand Down