msg254293 - (view) |
Author: (ppperry) |
Date: 2015-11-07 18:53 |
C:\Documents and Settings\Perry>python -U Traceback (most recent call last): File "C:\Python27\lib\site.py", line 548, in main() File "C:\Python27\lib\site.py", line 537, in main aliasmbcs() File "C:\Python27\lib\site.py", line 465, in aliasmbcs import locale, codecs File "C:\Python27\lib\locale.py", line 182, in _percent_re = re.compile(r'%(?:\((?P.*?)\))?' File "C:\Python27\lib\re.py", line 194, in compile return _compile(pattern, flags) File "C:\Python27\lib\re.py", line 249, in _compile p = sre_compile.compile(pattern, flags) File "C:\Python27\lib\sre_compile.py", line 576, in compile code = _code(p, flags) File "C:\Python27\lib\sre_compile.py", line 561, in _code _compile(code, p.data, flags) File "C:\Python27\lib\sre_compile.py", line 151, in _compile _compile(code, av[1], flags) File "C:\Python27\lib\sre_compile.py", line 132, in _compile _compile(code, av[2], flags) File "C:\Python27\lib\sre_compile.py", line 107, in _compile _compile_charset(av, flags, code, fixup, fixes) File "C:\Python27\lib\sre_compile.py", line 232, in _compile_charset flags & SRE_FLAG_UNICODE): File "C:\Python27\lib\sre_compile.py", line 316, in _optimize_charset p = charmap.find(b'\1', q) TypeError: Type unicode doesn't support the buffer API |
|
|
msg254319 - (view) |
Author: R. David Murray (r.david.murray) *  |
Date: 2015-11-08 02:10 |
Interesting, I didn't even know (remember?) about the -U flag, and it isn't documented. I guess we don't test it, and I suppose that it is effectively deprecated. (So others who don't remember don't need to repeat my research: it turns all string literals into unicode literals, which function was added as an experimental tool by Marc Andre in 2000. I believe it was later superseded by 'from __future__ import unicode_literals', but I didn't research that part.) This works fine on linux, and the traceback looks like it involves some windows-specific code. I'm not sure if this is worth bothering to fix. |
|
|
msg254320 - (view) |
Author: Matthew Barnett (mrabarnett) *  |
Date: 2015-11-08 02:53 |
So, you write a string literal without a 'u' (or 'b') prefix, and there's no 'from __future__ import unicode_literals' in the module, so you expect it to be a bytestring, but it's not, it's a Unicode string. I'm not surprised that something breaks! |
|
|
msg254323 - (view) |
Author: R. David Murray (r.david.murray) *  |
Date: 2015-11-08 05:50 |
Well, in this case *he* didn't write the string, it is embedded somewhere in the stdlib. 'python -U' gets you to the python prompt on unix, but apparently not on windows. But this isn't a feature we support any more, so I'm closing this as won't fix. |
|
|
msg254324 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2015-11-08 05:53 |
What is worse, you write a string literal with a 'b' prefix, and you get a Unicode string. >>> b'' u'' I tried to use Python with -U (it could be good way to test compatibility with Python 3), but it is totally broken, and there is no hope to fix it. |
|
|
msg254330 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2015-11-08 08:59 |
Reminder: use Python 3 to get an excellent Unicode support everywhere. |
|
|
msg254331 - (view) |
Author: SilentGhost (SilentGhost) *  |
Date: 2015-11-08 09:13 |
> Interesting, I didn't even know (remember?) about the -U flag, and it isn't documented. https://docs.python.org/2/using/cmdline.html#cmdoption-U It isn't clear when this broken or why, but I think existing documentation could be adjusted to have a bigger warning around this option. |
|
|