[issue39601] brace escapes are not working in formatted string literal format specifications

2020-02-12 Thread JitterMan
JitterMan added the comment: Ah, that make sense. Thanks! -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue39601] brace escapes are not working in formatted string literal format specifications

2020-02-12 Thread Vedran Čačić
Vedran Čačić added the comment: I can't help with the issue itself (though I must say that I philosophically don't believe in "sailed off ships" -- in the limit, Python must be the best it can be, though it can take decades to get there), but I can help you with the error message. It simply t

[issue39601] brace escapes are not working in formatted string literal format specifications

2020-02-11 Thread JitterMan
JitterMan added the comment: Okay, I get it. Someone might be using two braces in the format specifier because they found that it is a way to both evaluate a sub-expression and get braces in the formatted result. I was thinking that they would just use three braces, but that does not appear

[issue39601] brace escapes are not working in formatted string literal format specifications

2020-02-11 Thread Eric V. Smith
Change by Eric V. Smith : -- assignee: -> eric.smith ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https:/

[issue39601] brace escapes are not working in formatted string literal format specifications

2020-02-11 Thread Eric V. Smith
Eric V. Smith added the comment: But you can't just change it without breaking the code of anyone who's relying on the current behavior. If we could say "no one relies on that", that's would let us move forward with such a breaking change. But I don't think we can make that determination. An

[issue39601] brace escapes are not working in formatted string literal format specifications

2020-02-11 Thread JitterMan
JitterMan added the comment: I believe it is worth fixing as it clears up some rather glaring inconsistencies␣ and enables a useful capability. Specifically, 1. Formatted string literals and the string format method are currently inconsistent in the way that they handle double braces in th

[issue39601] brace escapes are not working in formatted string literal format specifications

2020-02-11 Thread Chris Wilcox
Chris Wilcox added the comment: Thanks Eric. That is very handy. I had made a test case earlier on a branch. Attached as a patch here if helpful. I haven't tried to fix this yet, but would be interested if it is something that makes sense to address. -- keywords: +patch Added file:

[issue39601] brace escapes are not working in formatted string literal format specifications

2020-02-10 Thread Eric V. Smith
Eric V. Smith added the comment: I always use datetime for testing such things. Its __format__() returns its argument, as long as you don't have '%' in it. I do agree that it's odd that the doubled braces cause the expression to be evaluated, but are still kept as single braces in the result

[issue39601] brace escapes are not working in formatted string literal format specifications

2020-02-10 Thread Zachary Ware
Change by Zachary Ware : -- nosy: +eric.smith ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.py

[issue39601] brace escapes are not working in formatted string literal format specifications

2020-02-10 Thread Zachary Ware
Change by Zachary Ware : -- components: -2to3 (2.x to 3.x conversion tool) ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue39601] brace escapes are not working in formatted string literal format specifications

2020-02-10 Thread Chris Wilcox
Chris Wilcox added the comment: Double curly braces do not indicate to not process the inner content. They indicate to include a literal curly brace. That said, I think there may be something not quite correct. I came up with an example based on the example in the format specifiers section

[issue39601] brace escapes are not working in formatted string literal format specifications

2020-02-10 Thread JitterMan
JitterMan added the comment: My expectation is that doubling up the braces acts to escape them, meaning that characters between the braces is treated as simple text and passed to the __format__ method as is. The only processing that should occur on the format specification is to convert the

[issue39601] brace escapes are not working in formatted string literal format specifications

2020-02-10 Thread Chris Wilcox
Chris Wilcox added the comment: The attached code implements `__format__` on the `Collections` class. In case 1, the template passed to `__format__` is "{v.name}: {v.email}|". In case 2, a name error will occur while processing the f string and v will not be found as no object 'v' exists in

[issue39601] brace escapes are not working in formatted string literal format specifications

2020-02-10 Thread Zachary Ware
Zachary Ware added the comment: What result are you expecting here? -- nosy: +zach.ware ___ Python tracker ___ ___ Python-bugs-list

[issue39601] brace escapes are not working in formatted string literal format specifications

2020-02-10 Thread JitterMan
JitterMan added the comment: It appears as if escaping the braces by doubling them up is not working properly if the braces are in a format specification within a f-string. >>> print(f'Email:\n{C:{{v.name}} {{v.email}}|\n}') >>> Traceback (most recent call la

[issue39601] brace escapes are not working in formatted string literal format specifications

2020-02-10 Thread JitterMan
New submission from JitterMan : It appears as if escaping the braces by doubling them up is not working properly if the braces are in a format specification within a f-string. >>> print(f'Email:\n{C:{{v.name}} {{v.email}}|\n}') >>> Traceback (most recent call