[Python-Dev] raw binary data and 2to3

Guido van Rossum guido at python.org
Mon Nov 9 03:42:47 CET 2009


On Sun, Nov 8, 2009 at 5:48 PM, Benjamin Peterson <benjamin at python.org> wrote:
> 2009/11/8  <skip at pobox.com>:
>>
>> SpamBayes has several files which contain raw 8-bit data embedded in
>> string literals.  Before I do manual work to make them parseable by 2to3
>> I thought I would ask if there was either a fixer available which I'm
>> not getting by default or if there is an opportunity to add a new fixer
>> to 2to3.
>>
>> The usage is pretty straightforward.  For example, a string literal
>> might contain the bytes for a GIF image:
>>
>>    data = "GIF89a(..."
>>
>> Is there a potentially automated path from where the code is today to
>> something Python 3 (and 2to3) will like?
>
> Not to my knowledge. I would prefer to not add a fixer for this
> directly to 2to3 because it is not correct for most programs. However,
> I think 2to3 should grow some sort of plugin system, so custom fixers
> can easily be written and used.

But if you're happy with only supporting 2.6, you can use b"..." and
the right thing will happen.

-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-Dev mailing list