Skip to content

Remove the dependency on astor for Pythons ≥ 3.9#1999

Merged
Kodiologist merged 5 commits intohylang:masterfrom
Kodiologist:unastor
Mar 17, 2021
Merged

Remove the dependency on astor for Pythons ≥ 3.9#1999
Kodiologist merged 5 commits intohylang:masterfrom
Kodiologist:unastor

Conversation

@Kodiologist
Copy link
Copy Markdown
Member

@Kodiologist Kodiologist commented Mar 16, 2021

Python 3.9 added ast.unparse, which can do most of the work. It has some bugs that I fixed in astor, which I've worked around here, but I've submitted a patch to CPython to fix them for real (python/cpython#24897).

Comment thread hy/core/language.hy
Comment thread hy/_compat.py Outdated
Copy link
Copy Markdown
Member

@scauligi scauligi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from a few more small changes, lgtm

Comment thread hy/_compat.py Outdated

if PY3_9:

import ast, math, cmath
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The math and cmath imports appear irrelevant.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, they're leftovers.

Comment thread hy/_compat.py

import ast, math, cmath
class Unparser(ast._Unparser):
# Work around some limitations of Python's `ast.unparse`.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a reference to python/cpython#24897. Since it's going to be backported to 3.9, we can eventually remove this workaround once it lands.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

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

Successfully merging this pull request may close these issues.

3 participants