Message22594
Logged In: YES
user_id=671362
bcannon write:
> The .lower() call is intended to normalize since
capitalization
> is not standard across OSs. But if it is a Unicode string it
> should be fine. And even if it isn't, it is all lowercased for
> comparison anyway, so as long as it is consistent, shouldn't
it
> still work?
Hmm.
> As for your example of strptime not being able to parse, you
have
> a bug in it; you forgot the format string. It should have
been
> ``time.strptime(time.strftime('%Z'), '%Z')``. Give that a
run
> and let me know what the output is.
Yeah, it's my fault. I forget to specify a format. Even so,
strptime couldn't parse timezone.
> As for this whole multi-byte issue, is it all being returned as
> Unicod e strings, or is it just a regular string? In other
> words, what is ``type(time.tzname[0])`` spitting out? And
what
> character encoding is all of this in (i.e., what should I pass
> to unicode so as to not have it raise UnicodeDecodeError)?
It returns strings(not a unicode), and the encoding is cp932.
This is a default encoding of Japanese Windows.
>>> unicode(time.tzname[0], 'cp932')
u'\u6771\u4eac (\u6a19\u6e96\u6642)'
> And finally, for the regex metacharacter stuff, why the hell
ar
> e there parentheses in a timezone?!? Whoever decided
that wa
> s good did it just to upset me.
Ask M$ Japan :-;
I don't regard 'Tokyo (standard time)' as an acceptable
representation for time zone at all, but this is what Windows
returns as a time zone on my box.
> That does need to be fixed. Apply the patch I just
uploaded and let
> me know if it at least deals with that problem.
With your patch, all tests succeed without any Error or Fail,
and
strftime <-> strptime conversions work well. This is a backport
candidate, so I created a new patch against Python 2.3 with
listcomps instead of genexprs.
But there is one problem left.
On IDLE, strptime still can't parse. I haven't looked into it in
details, but probably patch #590913 has something to do with
it.
This patch sets locale at IDLE's start up time and this can
affect
behaviors of string-related functions and constants.
[PEP 263 support in IDLE]
http://www.python.org/sf/590913
# patch applied
>>> time.strptime(time.strptime('%Z'), '%Z')
Traceback (most recent call last):
File "<pyshell#93>", line 1, in -toplevel-
time.strptime(time.strptime('%Z'), '%Z')
File "C:\Python24\lib\_strptime.py", line 291, in strptime
if not found:
ValueError: time data did not match format: data=%Z fmt=%
a %b %d %H:%M:%S %Y
>>> import locale
>>> locale.getlocale()
['Japanese_Japan', '932'] # culprit?
> Have I mentioned I hate timezones? In case I haven't, I do.
I agree with you one hundred percent.
--George |
|
Date |
User |
Action |
Args |
2007-08-23 14:26:32 | admin | link | issue1039270 messages |
2007-08-23 14:26:32 | admin | create | |
|