New submission from Janosch Gräf <janosch.gr...@gmx.net>:

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

----------
assignee: docs@python
components: Documentation, Interpreter Core
messages: 147972
nosy: Janosch.Gräf, docs@python
priority: normal
severity: normal
status: open
title: compile() doesn't work on ImportFrom with level=None
type: behavior
versions: Python 3.1

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue13436>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to