diferences between 22 and python 23

Fredrik Lundh fredrik at pythonware.com
Wed Dec 3 16:36:47 EST 2003


Peter Hansen wrote:

> Wait a sec... are you telling me that my code, which has strings containing
> binary data (which I believe has *always* been permitted), and which from
> time to time might, say, produce an error traceback containing the content
> from one such string and write it to a log file, then continue processing
> safely, will now fail with an ugly crash because I haven't changed it to
> specify a default encoding? (!!!)

8-bit strings can still contain 8-bit data.


The only way you'll get a warning is if you use non-ASCII characters in
source code, without specifying a source code encoding.  The warning
is issued by the compiler, not the runtime.

(if you've used non-ASCII characters to embed *binary* string literals
in your program, you deserve to be punished).


The only way you'll get the "crash" the original poster had, is if you're
trying to print Unicode strings containing non-ASCII data to an ASCII-
only output stream.

(if you print 8-bit strings to an ASCII stream, Python assumes you know
what you're doing).

</F>








More information about the Python-list mailing list