diff options
| author | Claudiu Popa <pcmanticore@gmail.com> | 2015-12-01 18:49:47 +0200 |
|---|---|---|
| committer | Claudiu Popa <pcmanticore@gmail.com> | 2015-12-01 18:49:47 +0200 |
| commit | 39bca36401136c3489332b053530b49cef9662e9 (patch) | |
| tree | 601b121b2f1d6949ffd0b132dcc43e435e605ca7 /astroid/as_string.py | |
| parent | 01660061a050c2f0df9c60b91c82f2fe89a651b4 (diff) | |
| download | astroid-git-39bca36401136c3489332b053530b49cef9662e9.tar.gz | |
Use printf-style formatting in as_string, in order
to avoid a potential problem with encodings when using .format.
Closes issue #273.
Diffstat (limited to 'astroid/as_string.py')
| -rw-r--r-- | astroid/as_string.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/astroid/as_string.py b/astroid/as_string.py index b2b2c951..5bd62335 100644 --- a/astroid/as_string.py +++ b/astroid/as_string.py @@ -245,13 +245,11 @@ class AsStringVisitor(object): trailer = return_annotation + ":" else: trailer = ":" - def_format = "\n{decorators}def {name}({args}){trailer}{docs}\n{body}" - return def_format.format(decorators=decorate, - name=node.name, - args=node.args.accept(self), - trailer=trailer, - docs=docs, - body=self._stmt_list(node.body)) + def_format = "\n%sdef %s(%s)%s%s\n%s" + return def_format % (decorate, node.name, + node.args.accept(self), + trailer, docs, + self._stmt_list(node.body)) def visit_generatorexp(self, node): """return an astroid.GeneratorExp node as string""" |
