On 2014-01-18, Stephen J. Turnbull wrote: > The above are descriptions of current behavior (ie, unchanged by PEPs > 460, 461), and this: [..] > is the content of this proposal, is that right?
The proposal is that -2 enables the following: - %r as an alias for %a (i.e. calls ascii()) - %s will fallback to calling PyObject_Str() and then call _PyUnicode_AsASCIIString(obj, "strict") to convert to bytes That's it. After sleeping on it, I'm not sure that's enough Python 2.x compatibility to help a lot. I haven't ported much code to 3.x yet but I imagine the following are major challenges: - comparisons between str and bytes always returns unequal - indexing/iterating bytes returns integers, not bytes objects - concatenation of str and bytes fails (not so bad since a TypeError is generated right away). Maybe the -2 command line option could revert to Python 2.x behavior for the above but I'm worried it might break working 3.x library code (the %r/%s change is very safe). I think I'll play with the idea and see which unit tests get broken. Ideally, there would be warnings generated when each backwards compatible behavior kicks in, that would greatly help when fixing up code. Neil _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com