This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Janosch.Gräf
Recipients Janosch.Gräf, docs@python
Date 2011-11-20.00:04:38
SpamBayes Score 3.3347895e-08
Marked as misclassified No
Message-id <1321747479.31.0.688458511993.issue13436@psf.upfronthosting.co.za>
In-reply-to
Content
The documentation for ast says that arguments that are marked with a '?' in the abstract grammar are optional and can therefore be None.
When I try to compile a Module node which contains an ImportFrom node with attribute level=None compile() throws an exception:

Module(body=[ImportFrom(module='time', names=[alias(name='sleep', asname=None), alias(name='time', asname=None)], level=None, lineno=0, col_offset=0)])

Traceback (most recent call last):
  File "g0.py", line 423, in <module>
    p.main()
  File "g0.py", line 65, in main
    self.reproduce("g1.pyc")
  File "g0.py", line 85, in reproduce
    co = self.generate_bytecode(st, genome)
  File "g0.py", line 243, in generate_bytecode
    co = compile(st, id, "exec")
ValueError: invalid integer value: ��������

So, I tried to set level=0:
Module(body=[ImportFrom(module='time', names=[alias(name='sleep', asname=None), alias(name='time', asname=None)], level=0, lineno=0, col_offset=0)])

and everything worked fine.

BTW: The unprintable bytes in the error message are:
ef bf bd ef bf bd ef bf bd ef bf bd ef bf bd ef bf bd ef bf bd ef bf bd
History
Date User Action Args
2011-11-20 00:04:39Janosch.Gräfsetrecipients: + Janosch.Gräf, docs@python
2011-11-20 00:04:39Janosch.Gräfsetmessageid: <1321747479.31.0.688458511993.issue13436@psf.upfronthosting.co.za>
2011-11-20 00:04:38Janosch.Gräflinkissue13436 messages
2011-11-20 00:04:38Janosch.Gräfcreate