Release Notes

0.6.2 - 2017-11-11

Bug fixes

  • Restore backwards compatibility that was broken after 0.6.1. You can now continue to use the following pattern:

    import astor
    class SpamCodeGenerator(astor.codegen.SourceGenerator):

    (Reported by Dan Moldovan and fixed by Berker Peksag in Issue 87.)

0.6.1 - 2017-11-11

New features

  • Added astor.parse_file() as an alias to astor.code_to_ast.parsefile(). (Contributed by Berker Peksag.)

Bug fixes

  • Fix compatibility layer for the astor.codegen submodule. Importing astor.codegen now succeeds and raises a DeprecationWarning instead of ImportError. (Contributed by Berker Peksag.)

0.6 - 2017-10-31

New features

  • New astor.rtrip command-line tool to test round-tripping of Python source to AST and back to source. (Contributed by Patrick Maupin.)

  • New pretty printer outputs much better looking code:

    • Remove parentheses where not necessary
    • Use triple-quoted strings where it makes sense
    • Add placeholder for function to do nice line wrapping on output

    (Contributed by Patrick Maupin.)

  • Additional Python 3.5 support: - Additional unpacking generalizations (PEP 448)

    (Contributed by Zack M. Davis.)

    • Async and await (PEP 492) (Contributed by Zack M. Davis.)
  • Added Python 3.6 feature support:

    (Contributed by Ryan Gonzalez.)

  • Code cleanup, including renaming for PEP8 and deprecation of old names. See Deprecations for more information. (Contributed by Leonard Truong in issue #36.)

Bug fixes

  • Don’t put trailing comma-spaces in dictionaries. astor will now create {'three': 3} instead of {'three': 3, }. (Contributed by Zack M. Davis.)

  • Fixed several bugs in code generation:

    1. Keyword-only arguments should come before **
    2. from .. import <member> with no trailing module name did not work
    3. Support from .. import foo as bar syntax
    4. Support with foo: ..., with foo as bar: ... and with foo, bar as baz: ... syntax
    5. Support 1eNNNN syntax
    6. Support return (yield foo) syntax
    7. Support unary operations such as -(1) + ~(2) + +(3)
    8. Support if (yield): pass
    9. Support if (yield from foo): pass
    10. try...finally block needs to come after the try...else clause
    11. Wrap integers with parentheses where applicable (e.g. (0).real should generated)
    12. When the yield keyword is an expression rather than a statement, it can be a syntax error if it is not enclosed in parentheses
    13. Remove extraneous parentheses around yield from

    (Contributed by Patrick Maupin in issue 27.)

0.5 - 2015-04-18

New features

  • Added support for Python 3.5 infix matrix multiplication (PEP 465) (Contributed by Zack M. Davis.)

0.4.1 - 2015-03-15

Bug fixes

  • Added missing SourceGenerator.visit_arguments()

0.4 - 2014-06-29

New features

  • Added initial test suite and documentation

Bug fixes

  • Added a visitor for NameConstant

0.3 - 2013-12-10

New features

  • Added support for Python 3.3.
    • Added YieldFrom
    • Updated Try and With.

Bug fixes

  • Fixed a packaging bug on Python 3 – see pull requests #1 and #2 for more information.

0.2.1 – 2012-09-20


  • Modified TreeWalk to add _name suffix for functions that work on attribute names

0.2 – 2012-09-19


  • Initial Python 3 support
  • Test of treewalk

0.1 – 2012-09-19

  • Initial release
  • Based on Armin Ronacher’s codegen
  • Several bug fixes to that and new tree walker