[ python-Bugs-1278906 ] invalid syntax in os.walk() first example
Bugs item #1278906, was opened at 2005-09-01 13:55
Message generated for change (Comment added) made by yohell
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1278906&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: Python 2.5
Status: Closed
Resolution: Works For Me
Priority: 5
Submitted By: YoHell (yohell)
Assigned to: Nobody/Anonymous (nobody)
Summary: invalid syntax in os.walk() first example
Initial Comment:
Hi!
The first example code block in the documentation for
os.walk() has invalid syntax in it.
The docs are available here:
http://www.python.org/doc/current/lib/os-file-dir.html#l2h-1466
This is the example code block:
import os
from os.path import join, getsize
for root, dirs, files in os.walk('python/Lib/email'):
print root, "consumes",
print sum(getsize(join(root, name)) for name in files),
print "bytes in", len(files), "non-directory files"
if 'CVS' in dirs:
dirs.remove('CVS') # don't visit CVS directories
Line 5 has the the invalid syntax:
print sum(getsize(join(root, name)) for name in files),
The example works if brackets are added like so:
print sum([getsize(join(root, name)) for name in
files]),
I recommend that someone responsible should make this
update in the docs.
You guys are brilliant. Thanks for a splendid language
with docs to match!
Cheers!
/Joel Hedlund
PhD student,
IFM Bioinfomatics, Linköping University
--
>Comment By: YoHell (yohell)
Date: 2005-09-02 10:43
Message:
Logged In: YES
user_id=1008220
Yes, you are very correct. ;-)
Can I suggest putting a note on the updated syntax somewhere
in the vicinity?
Thanks again!
/Joel
--
Comment By: Raymond Hettinger (rhettinger)
Date: 2005-09-01 14:44
Message:
Logged In: YES
user_id=80475
I suspect you are using Py2.4 documentation while running
Py2.3 or earlier. In Py2.4, the bracketless syntax was
introduced with new semantics which produce a similar result
but run with a generator instead of a list comprehension,
resulting in a significant savings in memory.
--
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1278906&group_id=5470
___
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1267884 ] crash recursive __getattr__
Bugs item #1267884, was opened at 2005-08-24 10:22 Message generated for change (Comment added) made by arigo You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1267884&group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Interpreter Core Group: Python 2.4 Status: Closed Resolution: Duplicate Priority: 5 Submitted By: pinzo (rodrigo_rc) Assigned to: Nobody/Anonymous (nobody) Summary: crash recursive __getattr__ Initial Comment: The following code eats all stack space and crashes, both in Windows and Linux: 8<- class C: def __getattr__(self, a): return object.__getattribute__(self, a) c = C() str(c) 8<- It shoud probably raise "RuntimeError: maximum recursion depth exceeded" or similar instead. -- >Comment By: Armin Rigo (arigo) Date: 2005-09-02 09:40 Message: Logged In: YES user_id=4771 This is indeed a bug similar to 1202533: the infinite recursion is in C, and doesn't go through the user-defined __getattr__(). The sample code snippet is definitely strange: it mixes object.__getattribute__() with an old-style class, i.e. one that doesn't inherit from 'object'. This code would work as expected if C were inheriting from 'object'. Instead, what occurs in this crash is that the __str__ of InstanceType calls __getattr__, which calls object.__getattribute__(c, '__str__'); the latter returns a so-called method wrapper object, which means essentially a method object bound to a C function. In this case the C function is again the __str__ of InstanceType. So this __str__ ends up calling itself infinitely. A more direct way to expose the bug is: from types import * class C: __str__ = InstanceType.__str__ str(C()) Clearly, all special methods are affected: class C: __add__ = InstanceType.__add__ C()+1 It should be fixed together with [ 1202533 ], if the latter is ever fixed. -- Comment By: Terry J. Reedy (tjreedy) Date: 2005-09-01 20:37 Message: Logged In: YES user_id=593130 I believe this is essentially the same as open bug [ 1202533 ] a bunch of infinite C recursions Closing as duplicate and adding a cross-reference note to 1202533. Reopen if a fix to the above, if and when there is one, does not fix this. -- Comment By: Terry J. Reedy (tjreedy) Date: 2005-09-01 20:35 Message: Logged In: YES user_id=593130 I believe this is essentially the same as open bug [ 1202533 ] a bunch of infinite C recursions Closing as duplicate and adding note to 1202533. Reopen if a fix to the above, if and when there is one, does not fix this. -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1267884&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1277903 ] logging module broken for multiple threads?
Bugs item #1277903, was opened at 2005-09-01 04:49
Message generated for change (Settings changed) made by vsajip
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1277903&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: Python 2.4
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: Lenny G. Arbage (alengarbage)
Assigned to: Vinay Sajip (vsajip)
Summary: logging module broken for multiple threads?
Initial Comment:
After upgrading from python 2.2, I noticed that the
logging facility doesn't seem to work in my code anymore.
As far as I can tell, after spending a bit of time
isolating the problem, this is an issue with threading.
In the main thread, logging works without a hitch. In
the secondary thread (which is run via
twisted.reactor), any attempt to write to the log
results in:
Traceback (most recent call last):
File "/usr/lib/python2.4/logging/__init__.py", line
712, in emit
self.stream.write(fs % msg)
ValueError: I/O operation on closed file
The code that initializes the logger is as follows:
logger = logging.getLogger('mylogger')
screenhandler = logging.StreamHandler()
screenhandler.setLevel(logging.INFO)
logger.addHandler(self.screenhandler)
logfile = "/tmp/testlog"
if os.path.isfile(logfile):
os.remove(logfile)
handler = logging.FileHandler(logfile)
formatter = logging.Formatter('%(asctime)s
%(levelname)s: %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.setLevel(logging.INFO)
Alone, this works fine. It is only when a the second
thread does a 'logger = logging.getLogger('mylogger')
and subsequently calls 'logger.log()' that the above
error is produced.
--
>Comment By: Vinay Sajip (vsajip)
Date: 2005-09-02 10:05
Message:
Logged In: YES
user_id=308438
The problem is occurring because the main thread exits,
which causes shutdown of the logging system via an atexit
hook. If you add either of the following lines at the end of your
__name__ == "__main__" clause:
raw_input("Press a key:")
or
mythread.join()
Then the thread continues to run:
2005-09-02 10:23:37,023 2564 INFO: logging initialized
2005-09-02 10:23:37,023 2564 INFO: initializing MyThread
2005-09-02 10:23:37,023 2564 INFO: test (before starting
thread)
2005-09-02 10:23:37,032 2220 INFO: MyThread starting
2005-09-02 10:23:37,032 2564 INFO: test (after starting
thread)
2005-09-02 10:23:37,032 2220 INFO: MyThread ticking...
2005-09-02 10:23:39,036 2220 INFO: MyThread ticking...
2005-09-02 10:23:41,039 2220 INFO: MyThread ticking...
2005-09-02 10:23:43,042 2220 INFO: MyThread ticking...
2005-09-02 10:23:45,045 2220 INFO: MyThread ticking...
2005-09-02 10:23:47,048 2220 INFO: MyThread ticking...
(I modified the format string to show the thread ID in the
logged message).
Hence, this is not a bug and I am closing this entry
as "Invalid".
--
Comment By: Lenny G. Arbage (alengarbage)
Date: 2005-09-01 22:29
Message:
Logged In: YES
user_id=1338323
Here's an even more minimal snippet of code that produces
the error. Nothing but a logger and a thread. No need for
twisted anything. Ignore the previous example.
Does this code do something to abuse the logging facility?
--
Comment By: Lenny G. Arbage (alengarbage)
Date: 2005-09-01 16:04
Message:
Logged In: YES
user_id=1338323
file attached
--
Comment By: Lenny G. Arbage (alengarbage)
Date: 2005-09-01 16:04
Message:
Logged In: YES
user_id=1338323
file attached
--
Comment By: Alen Peacock (alenlpeacock)
Date: 2005-09-01 16:00
Message:
Logged In: YES
user_id=1239721
I'm attaching a minimal program that demonstrates the
behavior. You'll need twisted installed to run it. I've
tested on python 2.4.1 and 2.4.14, both produce the error.
--
Comment By: Raymond Hettinger (rhettinger)
Date: 2005-09-01 12:54
Message:
Logged In: YES
user_id=80475
It looks to me like you've created a race condition that
became evident only when switching Python versions.
Assigning to Vijay so he can give advice on the best way to
code this (most likely by moving resource competing calls to
the main thread).
--
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1277903&group_id=5470
___
Python-bugs
[ python-Bugs-761452 ] HTMLParser chokes on my.yahoo.com output
Bugs item #761452, was opened at 2003-06-26 23:11 Message generated for change (Comment added) made by birkenfeld You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=761452&group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: Python 2.2.3 Status: Closed >Resolution: Wont Fix Priority: 5 Submitted By: Robert Walsh (rjwalsh) Assigned to: Fred L. Drake, Jr. (fdrake) Summary: HTMLParser chokes on my.yahoo.com output Initial Comment: The HTML parser chokes on the output produced by http://my.yahoo.com/. The problem appears to be that the HTML Yahoo is producing contains stuff like this:
[ python-Bugs-1224621 ] tokenize module does not detect inconsistent dedents
Bugs item #1224621, was opened at 2005-06-21 06:10 Message generated for change (Settings changed) made by arigo You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1224621&group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: None >Status: Open >Resolution: None Priority: 5 Submitted By: Danny Yoo (dyoo) Assigned to: Raymond Hettinger (rhettinger) Summary: tokenize module does not detect inconsistent dedents Initial Comment: The attached code snippet 'testcase.py' should produce an IndentationError, but does not. The code in tokenize.py is too trusting, and needs to add a check against bad indentation as it yields DEDENT tokens. I'm including a diff to tokenize.py that should at least raise an exception on bad indentation like this. Just in case, I'm including testcase.py here too: -- import tokenize from StringIO import StringIO sampleBadText = """ def foo(): bar baz """ print list(tokenize.generate_tokens( StringIO(sampleBadText).readline)) -- >Comment By: Armin Rigo (arigo) Date: 2005-09-02 12:10 Message: Logged In: YES user_id=4771 Reopening this bug report: this might fix the problem at hand, but it breaks inspect.getsource() on cases where it used to work. See attached example. -- Comment By: Raymond Hettinger (rhettinger) Date: 2005-06-21 07:54 Message: Logged In: YES user_id=80475 Fixed. See Lib/tokenize.py 1.38 and 1.36.4.1 -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1224621&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1224621 ] tokenize module does not detect inconsistent dedents
Bugs item #1224621, was opened at 2005-06-21 06:10 Message generated for change (Comment added) made by arigo You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1224621&group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: None Status: Open Resolution: None Priority: 5 Submitted By: Danny Yoo (dyoo) Assigned to: Raymond Hettinger (rhettinger) Summary: tokenize module does not detect inconsistent dedents Initial Comment: The attached code snippet 'testcase.py' should produce an IndentationError, but does not. The code in tokenize.py is too trusting, and needs to add a check against bad indentation as it yields DEDENT tokens. I'm including a diff to tokenize.py that should at least raise an exception on bad indentation like this. Just in case, I'm including testcase.py here too: -- import tokenize from StringIO import StringIO sampleBadText = """ def foo(): bar baz """ print list(tokenize.generate_tokens( StringIO(sampleBadText).readline)) -- >Comment By: Armin Rigo (arigo) Date: 2005-09-02 12:40 Message: Logged In: YES user_id=4771 Here is a proposed patch. It relaxes the dedent policy a bit. It assumes that the first line may already have some initial indentation, as is the case when tokenizing from the middle of a file (as inspect.getsource() does). It should also be back-ported to 2.4, given that the previous patch was. For 2.4, only the non-test part of the patch applies cleanly; I suggest to ignore the test part and just apply it, given that there are much more tests in 2.5 for inspect.getsource() anyway. The whole issue of inspect.getsource() being muddy anyway, I will go ahead and check this patch in unless someone spots a problem. For now the previously-applied patch makes parts of PyPy break with an uncaught IndentationError. -- Comment By: Armin Rigo (arigo) Date: 2005-09-02 12:10 Message: Logged In: YES user_id=4771 Reopening this bug report: this might fix the problem at hand, but it breaks inspect.getsource() on cases where it used to work. See attached example. -- Comment By: Raymond Hettinger (rhettinger) Date: 2005-06-21 07:54 Message: Logged In: YES user_id=80475 Fixed. See Lib/tokenize.py 1.38 and 1.36.4.1 -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1224621&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1224621 ] tokenize module does not detect inconsistent dedents
Bugs item #1224621, was opened at 2005-06-21 01:10 Message generated for change (Settings changed) made by rhettinger You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1224621&group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: None Status: Open Resolution: None Priority: 5 Submitted By: Danny Yoo (dyoo) >Assigned to: Nobody/Anonymous (nobody) Summary: tokenize module does not detect inconsistent dedents Initial Comment: The attached code snippet 'testcase.py' should produce an IndentationError, but does not. The code in tokenize.py is too trusting, and needs to add a check against bad indentation as it yields DEDENT tokens. I'm including a diff to tokenize.py that should at least raise an exception on bad indentation like this. Just in case, I'm including testcase.py here too: -- import tokenize from StringIO import StringIO sampleBadText = """ def foo(): bar baz """ print list(tokenize.generate_tokens( StringIO(sampleBadText).readline)) -- Comment By: Armin Rigo (arigo) Date: 2005-09-02 07:40 Message: Logged In: YES user_id=4771 Here is a proposed patch. It relaxes the dedent policy a bit. It assumes that the first line may already have some initial indentation, as is the case when tokenizing from the middle of a file (as inspect.getsource() does). It should also be back-ported to 2.4, given that the previous patch was. For 2.4, only the non-test part of the patch applies cleanly; I suggest to ignore the test part and just apply it, given that there are much more tests in 2.5 for inspect.getsource() anyway. The whole issue of inspect.getsource() being muddy anyway, I will go ahead and check this patch in unless someone spots a problem. For now the previously-applied patch makes parts of PyPy break with an uncaught IndentationError. -- Comment By: Armin Rigo (arigo) Date: 2005-09-02 07:10 Message: Logged In: YES user_id=4771 Reopening this bug report: this might fix the problem at hand, but it breaks inspect.getsource() on cases where it used to work. See attached example. -- Comment By: Raymond Hettinger (rhettinger) Date: 2005-06-21 02:54 Message: Logged In: YES user_id=80475 Fixed. See Lib/tokenize.py 1.38 and 1.36.4.1 -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1224621&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1280061 ] time.strptime() fails with unicode date string, de_DE locale
Bugs item #1280061, was opened at 2005-09-01 13:06 Message generated for change (Comment added) made by meonkeys You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1280061&group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: Python 2.4 Status: Open Resolution: None Priority: 5 Submitted By: Adam Monsen (meonkeys) Assigned to: Nobody/Anonymous (nobody) Summary: time.strptime() fails with unicode date string, de_DE locale Initial Comment: Trying to parse a German date string fails in Python 2.4.1. Test case attached. Since there's no indenting, I suppose the test case can also be pasted here: import locale, time locale.setlocale(locale.LC_TIME, 'de_DE') date = u'10. September 2005 um 17:26' format = '%d. %B %Y um %H:%M' time.strptime(date, format) -- Adam Monsen http://adammonsen.com/ -- >Comment By: Adam Monsen (meonkeys) Date: 2005-09-02 09:43 Message: Logged In: YES user_id=259388 Here's a simpler, more precise test case (also attached): import locale, time locale.setlocale(locale.LC_TIME, 'de_DE') date = u'September'; format = '%B' time.strptime(date, format) Here's the error I see: Traceback (most recent call last): File "de_strptime_fail_simple.py", line 4, in ? time.strptime(date, format) File "/usr/lib/python2.4/_strptime.py", line 329, in strptime month = locale_time.f_month.index(found_dict['B'].lower()) UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 1: ordinal not in range(128) -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1280061&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1235646 ] codecs.StreamRecoder.next doesn't encode
Bugs item #1235646, was opened at 2005-07-10 18:55 Message generated for change (Comment added) made by doerwalter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1235646&group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Unicode Group: Python 2.4 >Status: Closed >Resolution: Fixed Priority: 5 Submitted By: Sebastian Wangnick (wangnick) Assigned to: Walter Dörwald (doerwalter) Summary: codecs.StreamRecoder.next doesn't encode Initial Comment: Codecs.StreamRecode.next does't encode the data it gets from self.reader.next. This breaks the "for line in codecs.EncodedFile(...)" idiom. -- >Comment By: Walter Dörwald (doerwalter) Date: 2005-09-02 20:33 Message: Logged In: YES user_id=89016 OK, now I'm beginning to understand the docstring. Nevertheless I think having a class that uses stateful codecs at both ends would be useful. If you want, I can give this a try (after I'm back from vactation in four weeks). Closing the report as fixed. -- Comment By: M.-A. Lemburg (lemburg) Date: 2005-09-01 20:28 Message: Logged In: YES user_id=38388 Thanks, Walter. StreamRecorder is not broken: it works as advertised (see the .__init__() doc-string and interface) and yes, this means that only stateless encodings can be used, such as e.g. UTF-16-LE, simply because the encode and decode functions are defined as being stateless. -- Comment By: Walter Dörwald (doerwalter) Date: 2005-09-01 14:22 Message: Logged In: YES user_id=89016 Checked in as: Lib/codecs.py 1.48/1.35.2.10 I'll try to add tests for StreamRecoder tomorrow. StreamRecoder is broken in its current form, as it uses the stateless codec for the frontend encoding. Recoding from e.g. latin-1 to utf-16 will return a BOM for every call to read() which is clearly wrong. What gets read from the backend stream should be pushed through a *stateful* encoder. BTW, a feed style API would help here ;) -- Comment By: M.-A. Lemburg (lemburg) Date: 2005-08-31 22:58 Message: Logged In: YES user_id=38388 Looks good, Walter. Please check it in. Thanks. -- Comment By: Walter Dörwald (doerwalter) Date: 2005-08-31 18:11 Message: Logged In: YES user_id=89016 Here's a simple patch -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1235646&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1280924 ] PyDateTime_Check references static object
Bugs item #1280924, was opened at 2005-09-02 14:14 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1280924&group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: None Status: Open Resolution: None Priority: 5 Submitted By: Skip Montanaro (montanaro) Assigned to: Nobody/Anonymous (nobody) Summary: PyDateTime_Check references static object Initial Comment: In trying to use the C API for datetime objects, we noticed that PyDateTime_Check references PyDateTime_DateTimeType, which is declared static in datetimemodule.c. This is true for 2.3, 2.4 and CVS. That suggests that either PyDateTime_Check is supposed to only be used in the datetime module (in which case it is incorrectly named or its definition is in the wrong file) or the static and statichere declarations need to be removed from it. On the assumption that PyDateTime_Check is supposed to be publically used, I'm going to opt for the latter fix. -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1280924&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1280924 ] PyDateTime_Check references static object
Bugs item #1280924, was opened at 2005-09-02 14:14 Message generated for change (Comment added) made by montanaro You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1280924&group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: None >Status: Closed >Resolution: Invalid Priority: 5 Submitted By: Skip Montanaro (montanaro) Assigned to: Nobody/Anonymous (nobody) Summary: PyDateTime_Check references static object Initial Comment: In trying to use the C API for datetime objects, we noticed that PyDateTime_Check references PyDateTime_DateTimeType, which is declared static in datetimemodule.c. This is true for 2.3, 2.4 and CVS. That suggests that either PyDateTime_Check is supposed to only be used in the datetime module (in which case it is incorrectly named or its definition is in the wrong file) or the static and statichere declarations need to be removed from it. On the assumption that PyDateTime_Check is supposed to be publically used, I'm going to opt for the latter fix. -- >Comment By: Skip Montanaro (montanaro) Date: 2005-09-02 14:49 Message: Logged In: YES user_id=44345 After looking things over a bit I realize that in 2.4 there are two versions of the check macros and that the check macros in 2.3 were probably intended to only be used from within the module itself since there was no fully defined C API. I'm going to close this, but others feel free to reopen in case my original thoughts were more correct than I now think. Skip -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1280924&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1280061 ] time.strptime() fails with unicode date string, de_DE locale
Bugs item #1280061, was opened at 2005-09-01 13:06 Message generated for change (Comment added) made by bcannon You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1280061&group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: Python 2.4 Status: Open Resolution: None Priority: 5 Submitted By: Adam Monsen (meonkeys) >Assigned to: Brett Cannon (bcannon) Summary: time.strptime() fails with unicode date string, de_DE locale Initial Comment: Trying to parse a German date string fails in Python 2.4.1. Test case attached. Since there's no indenting, I suppose the test case can also be pasted here: import locale, time locale.setlocale(locale.LC_TIME, 'de_DE') date = u'10. September 2005 um 17:26' format = '%d. %B %Y um %H:%M' time.strptime(date, format) -- Adam Monsen http://adammonsen.com/ -- >Comment By: Brett Cannon (bcannon) Date: 2005-09-02 13:37 Message: Logged In: YES user_id=357491 Can you let me know what time.strftime() outputs for your test case, specifically what type of basestring (str or unicode)? -- Comment By: Adam Monsen (meonkeys) Date: 2005-09-02 09:43 Message: Logged In: YES user_id=259388 Here's a simpler, more precise test case (also attached): import locale, time locale.setlocale(locale.LC_TIME, 'de_DE') date = u'September'; format = '%B' time.strptime(date, format) Here's the error I see: Traceback (most recent call last): File "de_strptime_fail_simple.py", line 4, in ? time.strptime(date, format) File "/usr/lib/python2.4/_strptime.py", line 329, in strptime month = locale_time.f_month.index(found_dict['B'].lower()) UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 1: ordinal not in range(128) -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1280061&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1280061 ] time.strptime() fails with unicode date string, de_DE locale
Bugs item #1280061, was opened at 2005-09-01 13:06
Message generated for change (Comment added) made by meonkeys
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1280061&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Adam Monsen (meonkeys)
Assigned to: Brett Cannon (bcannon)
Summary: time.strptime() fails with unicode date string, de_DE locale
Initial Comment:
Trying to parse a German date string fails in Python
2.4.1. Test case attached.
Since there's no indenting, I suppose the test case can
also be pasted here:
import locale, time
locale.setlocale(locale.LC_TIME, 'de_DE')
date = u'10. September 2005 um 17:26'
format = '%d. %B %Y um %H:%M'
time.strptime(date, format)
--
Adam Monsen
http://adammonsen.com/
--
>Comment By: Adam Monsen (meonkeys)
Date: 2005-09-02 13:57
Message:
Logged In: YES
user_id=259388
I get a str from time.strftime().
>>> import time
>>> time.strftime('%B')
'September'
>>> time.strftime('%B').__class__
--
Comment By: Brett Cannon (bcannon)
Date: 2005-09-02 13:37
Message:
Logged In: YES
user_id=357491
Can you let me know what time.strftime() outputs for your
test case, specifically what type of basestring (str or
unicode)?
--
Comment By: Adam Monsen (meonkeys)
Date: 2005-09-02 09:43
Message:
Logged In: YES
user_id=259388
Here's a simpler, more precise test case (also attached):
import locale, time
locale.setlocale(locale.LC_TIME, 'de_DE')
date = u'September'; format = '%B'
time.strptime(date, format)
Here's the error I see:
Traceback (most recent call last):
File "de_strptime_fail_simple.py", line 4, in ?
time.strptime(date, format)
File "/usr/lib/python2.4/_strptime.py", line 329, in strptime
month = locale_time.f_month.index(found_dict['B'].lower())
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in
position 1: ordinal not in range(128)
--
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1280061&group_id=5470
___
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1280061 ] time.strptime() fails with unicode date string, de_DE locale
Bugs item #1280061, was opened at 2005-09-01 13:06
Message generated for change (Settings changed) made by bcannon
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1280061&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
>Status: Closed
>Resolution: Wont Fix
Priority: 5
Submitted By: Adam Monsen (meonkeys)
Assigned to: Brett Cannon (bcannon)
Summary: time.strptime() fails with unicode date string, de_DE locale
Initial Comment:
Trying to parse a German date string fails in Python
2.4.1. Test case attached.
Since there's no indenting, I suppose the test case can
also be pasted here:
import locale, time
locale.setlocale(locale.LC_TIME, 'de_DE')
date = u'10. September 2005 um 17:26'
format = '%d. %B %Y um %H:%M'
time.strptime(date, format)
--
Adam Monsen
http://adammonsen.com/
--
>Comment By: Brett Cannon (bcannon)
Date: 2005-09-02 14:05
Message:
Logged In: YES
user_id=357491
OK, then that settles it. If time.strftime() ever returned
unicode, I would say this needs fixing. But since
time.strptime() is meant to be the mirror opposite of
time.strftime(), I am going to close this as "Won't Fix".
If time.strftime() ever gets changed to return unicode, then
I will fix it.
--
Comment By: Adam Monsen (meonkeys)
Date: 2005-09-02 13:57
Message:
Logged In: YES
user_id=259388
I get a str from time.strftime().
>>> import time
>>> time.strftime('%B')
'September'
>>> time.strftime('%B').__class__
--
Comment By: Brett Cannon (bcannon)
Date: 2005-09-02 13:37
Message:
Logged In: YES
user_id=357491
Can you let me know what time.strftime() outputs for your
test case, specifically what type of basestring (str or
unicode)?
--
Comment By: Adam Monsen (meonkeys)
Date: 2005-09-02 09:43
Message:
Logged In: YES
user_id=259388
Here's a simpler, more precise test case (also attached):
import locale, time
locale.setlocale(locale.LC_TIME, 'de_DE')
date = u'September'; format = '%B'
time.strptime(date, format)
Here's the error I see:
Traceback (most recent call last):
File "de_strptime_fail_simple.py", line 4, in ?
time.strptime(date, format)
File "/usr/lib/python2.4/_strptime.py", line 329, in strptime
month = locale_time.f_month.index(found_dict['B'].lower())
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in
position 1: ordinal not in range(128)
--
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1280061&group_id=5470
___
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1281032 ] xml.sax.expatreader doesn't pass encoding to ParserCreate
Bugs item #1281032, was opened at 2005-09-02 22:14 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1281032&group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: XML Group: None Status: Open Resolution: None Priority: 5 Submitted By: Samuel Bayer (sambayer) Assigned to: Nobody/Anonymous (nobody) Summary: xml.sax.expatreader doesn't pass encoding to ParserCreate Initial Comment: The ParserCreate function in the expat module accepts an encoding argument, presumably for use when the encoding is not provided in the XML document. This function is invoked by the reset() method of the ExpatParser class in xml.sax.expatreader. The encoding, if provided, is available from the InputSource object stored in the self._source variable, but the value is not passed along to ParserCreate. This bug is present in Python 2.4.1. I believe the correct fix is to change lines 246 and 247 in Lib/xml/ sax/expatreader.py from self._parser = expat.ParserCreate(None, " ", intern=self._interning) to self._parser = expat.ParserCreate(self._source.getEncoding (), " ", intern=self._interning) and line 252 from self._parser = expat.ParserCreate(intern = self._interning) to self._parser = expat.ParserCreate(self._source.getEncoding (), intern = self._interning) -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1281032&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Feature Requests-1281053 ] non-sequence map() arguments for optimization
Feature Requests item #1281053, was opened at 2005-09-02 16:30 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1281053&group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: None Status: Open Resolution: None Priority: 5 Submitted By: Ecnassianer of the Green Storm (ecnassianer) Assigned to: Nobody/Anonymous (nobody) Summary: non-sequence map() arguments for optimization Initial Comment: I'm trying to optimize some code thats similiar to this: anObject = someConstructor() # This isn't a sequence myList = myListMaker() # This IS a sequence for items in myList: function(items, anObject) I'd like to be able to do this: map(function, myList, anObject) But the map function takes two lists, so I have to do somethign like this: list2 = [] for x in range(len(myList)): list2.append(anObject) map(function, myList, list2) But intializing list2 kind of defeats the purpose of optimization. I was looking for some way to convince anObject that it was really a list containing a lots of entries of itself, but couldn't find anything in the API. What I'd love to have is a version of the map function which takes a function, a sequence, and an object as arguments and calls the function with the first argument as an element in the sequence, and the second element as the object for as many times as their are items in the sequence. (Note: Currently the API says if you pass sequences of unequal lenghths to map, it uses None to fill up the rest of the calls) -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1281053&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Feature Requests-1281053 ] non-sequence map() arguments for optimization
Feature Requests item #1281053, was opened at 2005-09-03 01:30 Message generated for change (Settings changed) made by birkenfeld You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1281053&group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: None >Status: Closed >Resolution: Invalid Priority: 5 Submitted By: Ecnassianer of the Green Storm (ecnassianer) Assigned to: Nobody/Anonymous (nobody) Summary: non-sequence map() arguments for optimization Initial Comment: I'm trying to optimize some code thats similiar to this: anObject = someConstructor() # This isn't a sequence myList = myListMaker() # This IS a sequence for items in myList: function(items, anObject) I'd like to be able to do this: map(function, myList, anObject) But the map function takes two lists, so I have to do somethign like this: list2 = [] for x in range(len(myList)): list2.append(anObject) map(function, myList, list2) But intializing list2 kind of defeats the purpose of optimization. I was looking for some way to convince anObject that it was really a list containing a lots of entries of itself, but couldn't find anything in the API. What I'd love to have is a version of the map function which takes a function, a sequence, and an object as arguments and calls the function with the first argument as an element in the sequence, and the second element as the object for as many times as their are items in the sequence. (Note: Currently the API says if you pass sequences of unequal lenghths to map, it uses None to fill up the rest of the calls) -- >Comment By: Reinhold Birkenfeld (birkenfeld) Date: 2005-09-03 08:43 Message: Logged In: YES user_id=1188172 Use a list comprehension: [function(item, anObject) for item in myList] or, if you must use map, map(lambda item: function(item, anObject), myList) And please direct such questions to comp.lang.python in the future. -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1281053&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
