From 92d782f2f7c67d605843d86fa337c09984c6d3a5 Mon Sep 17 00:00:00 2001 From: drevicko Date: Tue, 2 Jun 2015 17:45:43 +1000 Subject: [PATCH] fixed rare FullEvalFormatter problem envolving '!' Formatter.parse returns a single character in `conversion` if '!c:' exists in the format_string for some character 'c'. This edit puts it back. btw: string.Formatter.parse() will throw an exception if an '!' is in the format_string without the 'c:' part. --- IPython/utils/text.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/IPython/utils/text.py b/IPython/utils/text.py index 1a081626e01..cc6dce46ac7 100644 --- a/IPython/utils/text.py +++ b/IPython/utils/text.py @@ -556,6 +556,9 @@ def _vformat(self, format_string, args, kwargs, used_args, recursion_depth): # the formatting if format_spec: + if conversion: + # override conversion spec + field_name = '!'.join([field_name, conversion]) # override format spec, to allow slicing: field_name = ':'.join([field_name, format_spec]) @@ -761,4 +764,4 @@ def get_text_list(list_, last_sep=' and ', sep=", ", wrap_item_with=""): return list_[0] return '%s%s%s' % ( sep.join(i for i in list_[:-1]), - last_sep, list_[-1]) \ No newline at end of file + last_sep, list_[-1])