[New-bugs-announce] [issue25621] ast.literal_eval() fails on docstrings
Maxime Chambreuil
report at bugs.python.org
Fri Nov 13 15:30:48 EST 2015
New submission from Maxime Chambreuil:
ast.literal_eval fails when there is docstrings in the file.
I used the file attached and this code in our CI server:
def is_installable_module(path):
"""return False if the path doesn't contain an installable odoo module,
and the full path to the module manifest otherwise"""
manifest_path = is_module(path)
if manifest_path:
manifest = ast.literal_eval(open(manifest_path).read())
if manifest.get('installable', True):
return manifest_path
return False
I get the following error message:
Traceback (most recent call last):
File "/home/travis/maintainer-quality-tools/travis/test_flake8", line 14, in <module>
for addon in get_modules(os.path.abspath('.')):
File "/home/travis/maintainer-quality-tools/travis/getaddons.py", line 53, in get_modules
if is_installable_module(os.path.join(path, x))]
File "/home/travis/maintainer-quality-tools/travis/getaddons.py", line 38, in is_installable_module
manifest = ast.literal_eval(open(manifest_path).read())
File "/usr/lib/python2.7/ast.py", line 49, in literal_eval
node_or_string = parse(node_or_string, mode='eval')
File "/usr/lib/python2.7/ast.py", line 37, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "<unknown>", line 22
{
^
SyntaxError: invalid syntax
https://github.com/OCA/knowledge/pull/75
https://github.com/OCA/maintainer-quality-tools/blob/master/travis/getaddons.py#L33
https://travis-ci.org/OCA/knowledge/jobs/90332842
----------
components: Interpreter Core
files: __openerp__.py
messages: 254619
nosy: Maxime Chambreuil
priority: normal
severity: normal
status: open
title: ast.literal_eval() fails on docstrings
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file41033/__openerp__.py
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25621>
_______________________________________
More information about the New-bugs-announce
mailing list