[issue28590] fstring's '{' from escape sequences does not start an expression

2016-11-06 Thread Eric V. Smith

Eric V. Smith added the comment:

Thanks, Jason. I updated the PEP, so now I think the docs and PEP match the 
implementation.

--
resolution:  -> fixed
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28590] fstring's '{' from escape sequences does not start an expression

2016-11-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 1d8b8a67b657 by Jason R. Coombs in branch '3.6':
Additionally show that a backslash-escaped opening brace is treated as a 
literal and thus triggers the single closing brace error, clarifying #28590.
https://hg.python.org/cpython/rev/1d8b8a67b657

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28590] fstring's '{' from escape sequences does not start an expression

2016-11-06 Thread Jason R. Coombs

Jason R. Coombs added the comment:

The reason that those test_no_escapes_for_braces assertions pass is because 
they're only dealing with opening curly braces and in an f-string, they're 
treated as literal opening braces.

In the example you've given, the error occurs when the f-string handler 
encounters the closing curly brace without an opening one. It's the same as if 
you had written:

>>> f'{{4*10}'
SyntaxError: f-string: single '}' is not allowed

I will add a test to capture this specific case (backslash-escaped unicode 
opening bracken).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28590] fstring's '{' from escape sequences does not start an expression

2016-11-06 Thread Jason R. Coombs

Jason R. Coombs added the comment:

I've got a patch ready for this and will be applying it shortly after we update 
the spec.

--
assignee: docs@python -> jason.coombs
nosy: +jason.coombs

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28590] fstring's '{' from escape sequences does not start an expression

2016-11-02 Thread Eric V. Smith

Eric V. Smith added the comment:

I'm currently working on an update to PEP-498 to address this. I hope to have 
it completed after a sprint this weekend.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28590] fstring's '{' from escape sequences does not start an expression

2016-11-02 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
assignee:  -> docs@python
components: +Documentation -Interpreter Core
nosy: +docs@python

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28590] fstring's '{' from escape sequences does not start an expression

2016-11-02 Thread SilentGhost

Changes by SilentGhost :


--
nosy: +eric.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28590] fstring's '{' from escape sequences does not start an expression

2016-11-02 Thread 尤立宇

New submission from 尤立宇:

PEP 498 says: (https://www.python.org/dev/peps/pep-0498/#escape-sequences)

Scanning an f-string for expressions happens after escape sequences are 
decoded. Because hex(ord('{')) == 0x7b , the f-string f'\u007b4*10}' is decoded 
to f'{4*10}' , which evaluates as the integer 40:

>>> f'\u007b4*10}'
'40'

However, in python3.6.0b3, the '{' from '\u007b4' does not start an expression, 
making the remaining '}' invalid:

>>> f'\u007b4*10}'
  File "", line 1
SyntaxError: f-string: single '}' is not allowed

There's even a test case for it: (Lib/test/test_fstring.py:383)

def test_no_escapes_for_braces(self):
# \x7b is '{'.  Make sure it doesn't start an expression.
self.assertEqual(f'\x7b2}}', '{2}')
self.assertEqual(f'\x7b2', '{2')
self.assertEqual(f'\u007b2', '{2')
self.assertEqual(f'\N{LEFT CURLY BRACKET}2\N{RIGHT CURLY BRACKET}', 
'{2}')

--
components: Interpreter Core
messages: 279927
nosy: 尤立宇
priority: normal
severity: normal
status: open
title: fstring's '{' from escape sequences does not start an expression
type: behavior
versions: Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com