Re: [Python-Dev] Backporting PEP 3101 to 2.6

2008-02-21 Thread Eric Smith
André Malo wrote: > * Eric Smith wrote: >> But now that I look at time.strftime in py3k, it's converting the entire >> unicode string to a char string with PyUnicode_AsString, then converting >> back with PyUnicode_Decode. > > Looks wrong to me, too... :-) > > nd I don't understand Unicode encod

Re: [Python-Dev] Backporting PEP 3101 to 2.6

2008-02-17 Thread André Malo
* Eric Smith wrote: > André Malo wrote: > > I guess, a clean and complete solution (besides re-implementing the > > whole thing) would be to resolve each single format character with > > strftime, decode according to the locale and re-assemble the result > > string piece by piece. Doh! > > That's

Re: [Python-Dev] Backporting PEP 3101 to 2.6

2008-02-16 Thread Eric Smith
André Malo wrote: > I guess, a clean and complete solution (besides re-implementing the whole > thing) would be to resolve each single format character with strftime, > decode according to the locale and re-assemble the result string piece by > piece. Doh! That's along the lines of what I was

Re: [Python-Dev] Backporting PEP 3101 to 2.6

2008-02-16 Thread André Malo
* Nick Coghlan wrote: > Eric Smith wrote: > > The bad error message is a result of __format__ passing on unicode to > > strftime. > > > > There are, of course, various ugly ways to work around this involving > > nested format calls. > > I don't know if this fits your definition of "ugly workaround

Re: [Python-Dev] Backporting PEP 3101 to 2.6

2008-02-16 Thread Nick Coghlan
Eric Smith wrote: > The bad error message is a result of __format__ passing on unicode to > strftime. > > There are, of course, various ugly ways to work around this involving > nested format calls. I don't know if this fits your definition of "ugly workaround", but what if datetime.__format__

Re: [Python-Dev] Backporting PEP 3101 to 2.6

2008-02-16 Thread Eric Smith
Eric Smith wrote: >> Guido van Rossum wrote: >>> For data types whose output uses only ASCII, would it be acceptable if >>> they always returned an 8-bit string and left it up to the caller to >>> convert it to Unicode? This would apply to all numeric types. (The >>> date/time types have a strftime

Re: [Python-Dev] Backporting PEP 3101 to 2.6

2008-01-11 Thread Eric Smith
Steve Holden wrote: > Nick Coghlan wrote: >> To elaborate on this a bit (and handwaving a lot of important details >> out of the way) do you mean something like the following for the builtin >> format?: >> >> def format(obj, fmt_spec=None): >> if fmt_spec is None: fmt_spec='' >> result

Re: [Python-Dev] Backporting PEP 3101 to 2.6

2008-01-11 Thread Eric Smith
Nick Coghlan wrote: > Guido van Rossum wrote: >> For data types whose output uses only ASCII, would it be acceptable if >> they always returned an 8-bit string and left it up to the caller to >> convert it to Unicode? This would apply to all numeric types. (The >> date/time types have a strftime()

Re: [Python-Dev] Backporting PEP 3101 to 2.6

2008-01-11 Thread Steve Holden
Nick Coghlan wrote: > Guido van Rossum wrote: >> For data types whose output uses only ASCII, would it be acceptable if >> they always returned an 8-bit string and left it up to the caller to >> convert it to Unicode? This would apply to all numeric types. (The >> date/time types have a strftime()

Re: [Python-Dev] Backporting PEP 3101 to 2.6

2008-01-11 Thread Nick Coghlan
Guido van Rossum wrote: > For data types whose output uses only ASCII, would it be acceptable if > they always returned an 8-bit string and left it up to the caller to > convert it to Unicode? This would apply to all numeric types. (The > date/time types have a strftime() style API which means the

Re: [Python-Dev] Backporting PEP 3101 to 2.6

2008-01-10 Thread Eric Smith
Guido van Rossum wrote: > On Jan 10, 2008 9:57 AM, Eric Smith <[EMAIL PROTECTED]> wrote: >> Eric Smith wrote: >>> 1: How should the builtin format() work? It takes 2 parameters, an >>> object o and a string s, and returns o.__format__(s). If s is None, it >>> returns o.__format__(empty_string).

Re: [Python-Dev] Backporting PEP 3101 to 2.6

2008-01-10 Thread Guido van Rossum
On Jan 10, 2008 9:57 AM, Eric Smith <[EMAIL PROTECTED]> wrote: > Eric Smith wrote: > > (I'm posting to python-dev, because this isn't strictly 3.0 related. > > Hopefully most people read it in addition to python-3000). > > > > I'm working on backporting the changes I made for PEP 3101 (Advanced > >

Re: [Python-Dev] Backporting PEP 3101 to 2.6

2008-01-10 Thread Eric Smith
Eric Smith wrote: > (I'm posting to python-dev, because this isn't strictly 3.0 related. > Hopefully most people read it in addition to python-3000). > > I'm working on backporting the changes I made for PEP 3101 (Advanced > String Formatting) to the trunk, in order to meet the pre-PyCon release >

Re: [Python-Dev] Backporting PEP 3101 to 2.6

2008-01-10 Thread Eric Smith
M.-A. Lemburg wrote: > On 2008-01-10 14:31, Eric Smith wrote: >> (I'm posting to python-dev, because this isn't strictly 3.0 related. >> Hopefully most people read it in addition to python-3000). >> >> I'm working on backporting the changes I made for PEP 3101 (Advanced >> String Formatting) to the

Re: [Python-Dev] Backporting PEP 3101 to 2.6

2008-01-10 Thread Barry Warsaw
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Jan 10, 2008, at 9:07 AM, M.-A. Lemburg wrote: > On 2008-01-10 14:31, Eric Smith wrote: >> (I'm posting to python-dev, because this isn't strictly 3.0 related. >> Hopefully most people read it in addition to python-3000). >> >> I'm working on backp

Re: [Python-Dev] Backporting PEP 3101 to 2.6

2008-01-10 Thread M.-A. Lemburg
On 2008-01-10 14:31, Eric Smith wrote: > (I'm posting to python-dev, because this isn't strictly 3.0 related. > Hopefully most people read it in addition to python-3000). > > I'm working on backporting the changes I made for PEP 3101 (Advanced > String Formatting) to the trunk, in order to meet th

[Python-Dev] Backporting PEP 3101 to 2.6

2008-01-10 Thread Eric Smith
(I'm posting to python-dev, because this isn't strictly 3.0 related. Hopefully most people read it in addition to python-3000). I'm working on backporting the changes I made for PEP 3101 (Advanced String Formatting) to the trunk, in order to meet the pre-PyCon release date for 2.6a1. I have a few