diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2021-12-21 15:53:38 -0800 |
---|---|---|
committer | Greg Becker <becker33@llnl.gov> | 2022-01-12 06:14:18 -0800 |
commit | 2badd6500e88b56c76f301af86f6c233b296f726 (patch) | |
tree | 5e4ed90b06460b6eed16a63fd0f67c95b86f9f2c /pyproject.toml | |
parent | b324fe5d95ebe67a2103e1603cbe0bf6e01f1cab (diff) | |
download | spack-2badd6500e88b56c76f301af86f6c233b296f726.tar.gz spack-2badd6500e88b56c76f301af86f6c233b296f726.tar.bz2 spack-2badd6500e88b56c76f301af86f6c233b296f726.tar.xz spack-2badd6500e88b56c76f301af86f6c233b296f726.zip |
unparse: Make unparsing consistent for 2.7 and 3.5-3.10
Previously, there were differences in the unparsed code for Python 2.7 and for 3.5-3.10.
This makes unparsed code the same across these Python versions by:
1. Ensuring there are no spaces between unary operators and
their operands.
2. Ensuring that *args and **kwargs are always the last arguments,
regardless of the python version.
3. Always unparsing print as a function.
4. Not putting an extra comma after Python 2 class definitions.
Without these changes, the same source can generate different code for different
Python versions, depending on subtle AST differences.
One place where single source will generate an inconsistent AST is with
multi-argument print statements, e.g.:
```
print("foo", "bar", "baz")
```
In Python 2, this prints a tuple; in Python 3, it is the print function with
multiple arguments. Use `from __future__ import print_function` to avoid
this inconsistency.
Diffstat (limited to 'pyproject.toml')
0 files changed, 0 insertions, 0 deletions