PEP263 (Specifying encoding) and bytecode strings

Terry Reedy tjreedy at udel.edu
Mon May 5 20:56:55 EDT 2003


"Mike C. Fletcher" <mcfletch at rogers.com> wrote in message
news:mailman.1052166614.10808.python-list at python.org...
> Terry Reedy wrote:
>
> >I am a little puzzled by some of the questions and comments in this
> >thread.  Am I missing something?
> >
> Probably the purpose of resource-package :) , namely automatically
> embedding sets of binary resources in Python source-code files.

You're right.  I've never done this (yet ;-) and did not think of it.

> What I'd like from Pep 263 is a way to make the declaration "this
file
> has no encoding" or "these strings are byte-sequences, *not* Unicode

This is what I asking about with

> >.  If there is not yet a way to say encoding = None or encoding =
bytes, ...

> >So?  This should only matter if you are putting zlib.compress()
output or
> >decompress() input into source code, such as for testing each
function
> >separately.

> Which is exactly what resource-package does (though for portable
access
> to the files during package embedding/deployment, not necessarily
> testing).

Now I understand better.  Using the Python interpreter beyond its
defined limits is attractive but slightly dangerous.  Multiplying half
the compresser output by 4 (for net expansion about 2) is certainly
not inviting.  I see these possible courses of action.

* Get a null encoding option into PEP263 and its implementation.
There should be a way to tell the interpreter to handle the sequence
of bytes the same way it currently does after escape processing.

* Do nothing now and ignore the warning or adjust now to suppress
them, and wait for future hammers to fall when they do.

3. Write your own importer.  (One halfway tack would be to readin,
expand 'illegal' bytes, and explicitly feed to eval or compile.)

4. Investigate the new import-from-zipfile facility.  If  you are zlib
compressing large ascii texts, compress the entire file instead of
just the quoted text.  If you have inherently binary data, expand the
hi-bit bytes (expanding file by 2 if half are such) and, again,
compress the whole file, not just the data strings.

Terry J. Reedy






More information about the Python-list mailing list