Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Dev

raw binary data and 2to3

 

 

Python dev RSS feed   Index | Next | Previous | View Threaded


skip at pobox

Nov 8, 2009, 5:41 PM

Post #1 of 6 (650 views)
Permalink
raw binary data and 2to3

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?

Skip
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


benjamin at python

Nov 8, 2009, 5:48 PM

Post #2 of 6 (609 views)
Permalink
Re: raw binary data and 2to3 [In reply to]

2009/11/8 <skip [at] pobox>:
>
> 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.



--
Regards,
Benjamin
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


guido at python

Nov 8, 2009, 6:42 PM

Post #3 of 6 (600 views)
Permalink
Re: raw binary data and 2to3 [In reply to]

On Sun, Nov 8, 2009 at 5:48 PM, Benjamin Peterson <benjamin [at] python> wrote:
> 2009/11/8  <skip [at] pobox>:
>>
>> 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)
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


skip at pobox

Nov 8, 2009, 6:55 PM

Post #4 of 6 (605 views)
Permalink
Re: raw binary data and 2to3 [In reply to]

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

SpamBayes still supports 2.4...

Thanks for the feedback. I'll update the source manually, then run 2to3.

S
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


martin at v

Nov 8, 2009, 11:46 PM

Post #5 of 6 (599 views)
Permalink
Re: raw binary data and 2to3 [In reply to]

> data = "GIF89a(..."
>
> Is there a potentially automated path from where the code is today to
> something Python 3 (and 2to3) will like?

Not sure how you'll fix these; I personally always provided a b()
function that will do the right thing in both 2.x and 3.x. This can
get eventually replaced by a b prefix.

Regards,
Martin
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


regebro at gmail

Nov 10, 2009, 9:27 AM

Post #6 of 6 (586 views)
Permalink
Re: raw binary data and 2to3 [In reply to]

2009/11/9 Benjamin Peterson <benjamin [at] python>:
> 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.

Well, 2to3 is only plugins, so. :) The difficulty in writing fixers is
understanding the abstract parse tree or whatever it's called and how
to use it. Documentation on that for people who don't have a doctorate
in computer linguistics would probably be a good idea. ;)

--
Lennart Regebro: Python, Zope, Plone, Grok
http://regebro.wordpress.com/
+33 661 58 14 64
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com

Python dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.