Re: [Python-Dev] issue2180 and using 'tokenize' with Python 3 'str's

2010-09-28 Thread Michael Foord
On 29 Sep 2010, at 00:22, "Martin v. Löwis" wrote: >> I certainly wouldn't be opposed to an API that accepts a string as well >> though. > > Notice that this can't really work for Python 2 source code (but of > course, it doesn't need to). > > In Python 2, if you have a string literal in the s

Re: [Python-Dev] issue2180 and using 'tokenize' with Python 3 'str's

2010-09-28 Thread Martin v. Löwis
> I certainly wouldn't be opposed to an API that accepts a string as well > though. Notice that this can't really work for Python 2 source code (but of course, it doesn't need to). In Python 2, if you have a string literal in the source code, you need to know the source encoding in order to get t

Re: [Python-Dev] issue2180 and using 'tokenize' with Python 3 'str's

2010-09-28 Thread Martin v. Löwis
Am 28.09.2010 05:45, schrieb Steve Holden: > On 9/27/2010 11:27 PM, Benjamin Peterson wrote: >> 2010/9/27 Meador Inge : >>> which, as seen in the trace, is because the 'detect_encoding' function in >>> 'Lib/tokenize.py' searches for 'BOM_UTF8' (a 'bytes' object) in the string >>> to tokenize 'first

Re: [Python-Dev] issue2180 and using 'tokenize' with Python 3 'str's

2010-09-28 Thread Meador Inge
On Tue, Sep 28, 2010 at 7:09 AM, Nick Coghlan wrote: > A feature request on the tracker is the best way to make that happen. > Done - http://bugs.python.org/issue9969. Thanks for the feedback everyone. -- Meador ___ Python-Dev mailing list Python-Dev

Re: [Python-Dev] issue2180 and using 'tokenize' with Python 3 'str's

2010-09-28 Thread Nick Coghlan
On Tue, Sep 28, 2010 at 9:29 PM, Michael Foord wrote: >  On 28/09/2010 12:19, Antoine Pitrou wrote: >> On Mon, 27 Sep 2010 23:45:45 -0400 >> Steve Holden  wrote: >>> On 9/27/2010 11:27 PM, Benjamin Peterson wrote: Tokenize only works on bytes. You can open a feature request if you desire

Re: [Python-Dev] issue2180 and using 'tokenize' with Python 3 'str's

2010-09-28 Thread Michael Foord
On 28 September 2010 12:29, Michael Foord wrote: > On 28/09/2010 12:19, Antoine Pitrou wrote: > >> On Mon, 27 Sep 2010 23:45:45 -0400 >> Steve Holden wrote: >> >>> On 9/27/2010 11:27 PM, Benjamin Peterson wrote: >>> 2010/9/27 Meador Inge: > which, as seen in the trace, is because

Re: [Python-Dev] issue2180 and using 'tokenize' with Python 3 'str's

2010-09-28 Thread Michael Foord
On 28/09/2010 12:19, Antoine Pitrou wrote: On Mon, 27 Sep 2010 23:45:45 -0400 Steve Holden wrote: On 9/27/2010 11:27 PM, Benjamin Peterson wrote: 2010/9/27 Meador Inge: which, as seen in the trace, is because the 'detect_encoding' function in 'Lib/tokenize.py' searches for 'BOM_UTF8' (a 'byt

Re: [Python-Dev] issue2180 and using 'tokenize' with Python 3 'str's

2010-09-28 Thread Antoine Pitrou
On Mon, 27 Sep 2010 23:45:45 -0400 Steve Holden wrote: > On 9/27/2010 11:27 PM, Benjamin Peterson wrote: > > 2010/9/27 Meador Inge : > >> which, as seen in the trace, is because the 'detect_encoding' function in > >> 'Lib/tokenize.py' searches for 'BOM_UTF8' (a 'bytes' object) in the string > >> t

Re: [Python-Dev] issue2180 and using 'tokenize' with Python 3 'str's

2010-09-27 Thread Steve Holden
On 9/27/2010 11:27 PM, Benjamin Peterson wrote: > 2010/9/27 Meador Inge : >> which, as seen in the trace, is because the 'detect_encoding' function in >> 'Lib/tokenize.py' searches for 'BOM_UTF8' (a 'bytes' object) in the string >> to tokenize 'first' (a 'str' object). It seems to me that strings

Re: [Python-Dev] issue2180 and using 'tokenize' with Python 3 'str's

2010-09-27 Thread Benjamin Peterson
2010/9/27 Meador Inge : > which, as seen in the trace, is because the 'detect_encoding' function in > 'Lib/tokenize.py' searches for 'BOM_UTF8' (a 'bytes' object) in the string > to tokenize 'first' (a 'str' object).  It seems to me that strings should > still be able to be tokenized, but maybe I a

[Python-Dev] issue2180 and using 'tokenize' with Python 3 'str's

2010-09-27 Thread Meador Inge
Hi All, I was going through some of the open issues related to 'tokenize' and ran across 'issue2180'. The reproduction case for this issue is along the lines of: >>> tokenize.tokenize(io.StringIO("if 1:\n \\\n #hey\n print 1").readline) but, with 'py3k' I get: >>> tokenize.tokenize(io.Str