naitoh / py2rb

A code translator using AST from Python to Ruby.
MIT License
134 stars 17 forks source link

Support for Python 3.8 #6

Closed ankane closed 2 years ago

ankane commented 4 years ago

Hi, thanks for this great project!

When trying to translate a simple script with Python 3.8, the constants are missing.

print(1 + 2)

outputs

Warning : syntax not supported (<_ast.Constant object at 0x10c4da040>)
Warning : syntax not supported (<_ast.Constant object at 0x10c4da2e0>)
print( + )

It looks like there were changes in ast for Python 3.8. From the docs:

Changed in version 3.8: Class ast.Constant is now used for all constants.

Deprecated since version 3.8: Old classes ast.Num, ast.Str, ast.Bytes, ast.NameConstant and ast.Ellipsis are still available, > but they will be removed in future Python releases. In the meanwhile, instantiating them will return an instance of a different > class.

There's also an unrelated warning about YAML.

/usr/local/lib/python3.8/site-packages/py2rb/__init__.py:29: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
  module_map.update(yaml.load(f))