New submission from Kay Hayen <kayha...@gmx.de>: There is no way to decide if a string literal should be non-unicode when the default has been set to unicode_literals. Please see:
>>> import ast >>> ast.dump( ast.parse( """c = "d" """ ) ) "Module(body=[Assign(targets=[Name(id='c', ctx=Store())], value=Str(s='d'))])" >>> from __future__ import unicode_literals >>> ast.dump( ast.parse( """c = "d" """ ) ) "Module(body=[Assign(targets=[Name(id='c', ctx=Store())], value=Str(s='d'))])" >>> ast.dump( ast.parse( """c = b"d" """ ) ) "Module(body=[Assign(targets=[Name(id='c', ctx=Store())], value=Str(s='d'))])" >>> ast.dump( ast.parse( """c = u"d" """ ) ) "Module(body=[Assign(targets=[Name(id='c', ctx=Store())], value=Str(s=u'd'))])" I have checked fields, but didn't find anything either. Without an indication of the Str literal type, its type cannot be detected. In either case it is "str" and may or not have to be converted to a unicode value. ---------- components: Library (Lib) messages: 114950 nosy: kayhayen priority: normal severity: normal status: open title: Cannot distinguish b"str" from "str" in ast module. type: behavior versions: Python 2.6, Python 2.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue9690> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com