Re: [Python-Dev] [Python-3000] Need help fixing failing Py3k Unittests in py3k-struni
Please use self.assertEqual() instead of self.failUnlessEqual() -- the assertEqual() form is much more common. Otherwise, good idea! On 7/11/07, Christian Heimes [EMAIL PROTECTED] wrote: Steven Bethard wrote: I'd probably go with something a little more restrictive, maybe: r'self.assert_\(\S+ == \S+\)' Something like that ought to have fewer false positives. Woops! You are right. Even your pattern has caused some false positives but I've reread the patch and removed the offending lines. I'm going to upload another patch as soon as I have verified mine again. Christian ___ Python-3000 mailing list [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/guido%40python.org -- --Guido van Rossum (home page: http://www.python.org/~guido/) ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] itertools addition: getitem()
Giovanni Bajo wrote: On 09/07/2007 21.23, Walter Dörwald wrote: from ll.xist import parsers, xfind from ll.xist.ns import html e = parsers.parseURL(http://www.python.org;, tidy=True) print e.walknode(html.h2 xfind.hasclass(news))[-1] Google Adds Python Support to Google Calendar Developer's Guide Get the first comment line from a python file: getitem((line for line in open(Lib/codecs.py) if line.startswith(#)), 0) '### Registry and builtin stateless codec functions\n' Create a new unused identifier: def candidates(base): ... yield base ... for suffix in count(2): ... yield %s%d % (base, suffix) ... usedids = set((foo, bar)) getitem((i for i in candidates(foo) if i not in usedids), 0) 'foo2' You keep posting examples where you call your getitem() function with 0 as index, or -1. getitem(it, 0) already exists and it's spelled it.next(). getitem(it, -1) might be useful in fact, and it might be spelled last(it) (or it.last()). Then one may want to add first() for simmetry, but that's it: first(i for i in candidates(foo) if i not in usedids) last(line for line in open(Lib/codecs.py) if line[0] == '#') Are there real-world use cases for getitem(it, n) with n not in (0, -1)? I share Raymond's feelings on this. And by the way, if you wonder, I have these exact feelings as well for islice... :) It useful for screen scraping HTML. Suppose you have the following HTML table: table trtd01.01.2007/tdtd12.34/tdtdFoo/td/tr trtd13.01.2007/tdtd23.45/tdtdBar/td/tr trtd04.02.2007/tdtd45.56/tdtdBaz/td/tr trtd27.02.2007/tdtd56.78/tdtdSpam/td/tr trtd17.03.2007/tdtd67.89/tdtdEggs/td/tr trtd /tdtd164.51/tdtdTotal/td/tr trtd /tdtd(incl. VAT)/tdtd/td/tr /table To extract the total sum, you want the second column from the second to last row, i.e. something like: row = getitem((r for r in table if r.name == tr), -2) col = getitem((c for c in row if c.name == td), 1) Servus, Walter ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Need help fixing failing Py3k Unittests in py3k-struni
Christian Heimes schrieb: By the way the ctypes unit tests are causing a segfault on my machine: test_ctypes Warning: could not import ctypes.test.test_numbers: unpack requires a string argument of length 1 Segmentation fault Ubunutu 7.04 on i386 machine with an Intel P3. I can reproduce this. ctypes.test.test_numbers is easy to fix, but there are other severe problems with ctypes. I would love to look into these, but I prefer debugging on Windows. However, the windows build does not work because the _fileio builtin module is missing from config.c. Again, this is not so easy to fix, because the ftruncate function does not exist on Windows. Thomas ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Need help fixing failing Py3k Unittests in py3k-struni
On 7/11/07, Thomas Heller [EMAIL PROTECTED] wrote: Christian Heimes schrieb: By the way the ctypes unit tests are causing a segfault on my machine: test_ctypes Warning: could not import ctypes.test.test_numbers: unpack requires a string argument of length 1 Segmentation fault Ubunutu 7.04 on i386 machine with an Intel P3. I can reproduce this. ctypes.test.test_numbers is easy to fix, but there are other severe problems with ctypes. I would love to look into these, but I prefer debugging on Windows. However, the windows build does not work because the _fileio builtin module is missing from config.c. Again, this is not so easy to fix, because the ftruncate function does not exist on Windows. I don't have a Windows box; contributions to fix this situation are welcome. -- --Guido van Rossum (home page: http://www.python.org/~guido/) ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
[Python-Dev] SVN precommit hook
I just got this traceback trying to do a rather large checkin: Transmitting file data svn: Commit failed (details follow): svn: 'pre-commit' hook failed with error output: file /python/branches/p3yk-noslice/Lib/test/string_tests.py is not whitespace-normalized file /python/branches/p3yk-noslice/Doc/tools/buildindex.py is not whitespace-normalized file /python/branches/p3yk-noslice/Lib/test/test_array.py is not whitespace-normalized Traceback (most recent call last): File /data/repos/projects/hooks/checkwhitespace.py, line 50, in ? File /var/lib/python-support/python2.4/svn/core.py, line 217, in run_app File /data/repos/projects/hooks/checkwhitespace.py, line 32, in main File /var/lib/python-support/python2.4/libsvn/fs.py, line 381, in svn_fs_node_prop libsvn._core.SubversionException: (Can't open file '/data/repos/projects/db/transactions/56255-1.txn/props': Too many open files, 24) I'm not complaining about the whitespace-normalization issues, but rather the open files issue ;-P It sounds like a buglet somewhere, although it may be in libsvn. -- Thomas Wouters [EMAIL PROTECTED] Hi! I'm a .signature virus! copy me into your .signature file to help me spread! ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] SVN precommit hook
On 7/11/07, Thomas Wouters [EMAIL PROTECTED] wrote: I just got this traceback trying to do a rather large checkin: Transmitting file data svn: Commit failed (details follow): svn: 'pre-commit' hook failed with error output: file /python/branches/p3yk-noslice/Lib/test/string_tests.py is not whitespace-normalized file /python/branches/p3yk-noslice/Doc/tools/buildindex.py is not whitespace-normalized file /python/branches/p3yk-noslice/Lib/test/test_array.py is not whitespace-normalized Traceback (most recent call last): File /data/repos/projects/hooks/checkwhitespace.py, line 50, in ? File /var/lib/python-support/python2.4/svn/core.py, line 217, in run_app File /data/repos/projects/hooks/checkwhitespace.py, line 32, in main File /var/lib/python-support/python2.4/libsvn/fs.py, line 381, in svn_fs_node_prop libsvn._core.SubversionException: (Can't open file '/data/repos/projects/db/transactions/56255- 1.txn/props': Too many open files, 24) I'm not complaining about the whitespace-normalization issues, but rather the open files issue ;-P It sounds like a buglet somewhere, although it may be in libsvn. Oh, and for the record, it also fails when there are no whitespace issues to fix. I can't check in my (admittedly somewhat big) svnmerge now. It touches about 1130 files. -- Thomas Wouters [EMAIL PROTECTED] Hi! I'm a .signature virus! copy me into your .signature file to help me spread! ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] SVN precommit hook
On 7/11/07, Thomas Wouters [EMAIL PROTECTED] wrote: libsvn._core.SubversionException: (Can't open file '/data/repos/projects/db/transactions/56255- 1.txn/props': Too many open files, 24) Fixed. The problem was that checkwhitespace.py wasn't closing the SVN streams it was reading. Added the 'svn_stream_close' call and my checkin got through. Should be safe to do massive checkins from now on ;-) -- Thomas Wouters [EMAIL PROTECTED] Hi! I'm a .signature virus! copy me into your .signature file to help me spread! ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Need help fixing failing Py3k Unittests in py3k-struni
Guido van Rossum wrote: On 7/11/07, Thomas Heller [EMAIL PROTECTED] wrote: Christian Heimes schrieb: By the way the ctypes unit tests are causing a segfault on my machine: test_ctypes Warning: could not import ctypes.test.test_numbers: unpack requires a string argument of length 1 Segmentation fault Ubunutu 7.04 on i386 machine with an Intel P3. I can reproduce this. ctypes.test.test_numbers is easy to fix, but there are other severe problems with ctypes. I would love to look into these, but I prefer debugging on Windows. However, the windows build does not work because the _fileio builtin module is missing from config.c. Again, this is not so easy to fix, because the ftruncate function does not exist on Windows. I don't have a Windows box; contributions to fix this situation are welcome. You would accept a donated Windows box ? (1/2 ;-) Michael Foord ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
[Python-Dev] [PATCH] fixing 2.5.1 build with unicode and dynamic loading disabled
Hi, this is my first email to this list, I'm currently porting python to some platforms with limited capabilities and so I thought it would be a good idea to subscribe here. While doing the porting, I found two small problems in Python 2.5.1: If Py_USING_UNICODE is disabled, in Python/ast.c decode_unicode() still calls unicode-related functions, which leads to undefined references when linking. If HAVE_DYNAMIC_LOADING is disabled, in Python/import.c _PyImport_DynLoadFiletab is still initialized, which also leads to undefined references when linking, since then no source file which defines this variable is used. A patch against 2.5.1 is attached. Best regards Alex diff -rbup Python-2.5.1-orig/Python/ast.c Python-2.5.1/Python/ast.c --- Python-2.5.1-orig/Python/ast.c 2007-03-16 00:12:48.0 -0400 +++ Python-2.5.1/Python/ast.c 2007-07-10 17:06:00.0 -0400 @@ -3113,6 +3113,10 @@ decode_utf8(const char **sPtr, const cha static PyObject * decode_unicode(const char *s, size_t len, int rawmode, const char *encoding) { +#ifndef Py_USING_UNICODE +Py_FatalError(decode_unicode should not be called in this build.); +return NULL; +#else PyObject *v, *u; char *buf; char *p; @@ -3170,6 +3174,7 @@ decode_unicode(const char *s, size_t len v = PyUnicode_DecodeUnicodeEscape(s, len, NULL); Py_XDECREF(u); return v; +#endif } /* s is a Python string literal, including the bracketing quote characters, diff -rbup Python-2.5.1-orig/Python/import.c Python-2.5.1/Python/import.c --- Python-2.5.1-orig/Python/import.c 2007-03-13 19:04:29.0 -0400 +++ Python-2.5.1/Python/import.c 2007-07-10 17:02:25.0 -0400 @@ -117,15 +117,20 @@ _PyImport_Init(void) /* prepare _PyImport_Filetab: copy entries from _PyImport_DynLoadFiletab and _PyImport_StandardFiletab. */ +#ifdef HAVE_DYNAMIC_LOADING for (scan = _PyImport_DynLoadFiletab; scan-suffix != NULL; ++scan) ++countD; +#endif + for (scan = _PyImport_StandardFiletab; scan-suffix != NULL; ++scan) ++countS; filetab = PyMem_NEW(struct filedescr, countD + countS + 1); if (filetab == NULL) Py_FatalError(Can't initialize import file table.); +#ifdef HAVE_DYNAMIC_LOADING memcpy(filetab, _PyImport_DynLoadFiletab, countD * sizeof(struct filedescr)); +#endif memcpy(filetab + countD, _PyImport_StandardFiletab, countS * sizeof(struct filedescr)); filetab[countD + countS].suffix = NULL; ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Need help fixing failing Py3k Unittests in py3k-struni
I have a very remedial question about how to fix test failures due to the side effects of string-unicode integration. The xmlrpc library uses explicit encoding to encode XML tag payloads to (almost always) utf8. Tag literals are not encoded. What would be the best way to mimic this behavior under the new regime? Just use unicode everywhere and encode the entire XML body to utf-8 at the end? Or deal explicitly in bytes everywhere? Or..? Remedially, - C On Jul 10, 2007, at 5:14 PM, Guido van Rossum wrote: One of the most daunting tasks remaining for Python 3.0a1 (to be released by the end of August) is fixing the remaining failing unit tests in the py3k-struni branch (http://svn.python.org/view/python/branches/py3k-struni/). This is the branch where I have started the work on the string/unification branch. I want to promote this branch to become the main Py3k branch ASAP (by renaming it to py3k), but I don't want to do that until all unit tests pass. I've been working diligently on this task, and I've got it down to about 50 tests that are failing on at least one of OSX and Ubuntu (the platforms to which I have easy access). Now I need help. To facilitate distributing the task of getting the remaining tests to pass, I've created a wiki page: http://wiki.python.org/moin/Py3kStrUniTests . Please help! It's easy to help: (1) check out the py3k-struni branch; (2) build it; (3) pick a test and figure out why it's failing; (4) produce a fix; (5) submit the fix to SF (or check it in, if you have submit privileges and are confident enough). In order to avoid duplicate work, I've come up with a simple protocol: you mark a test in the wiki as MINE (with your name) when you start looking at it. You mark it as FIXED [IN SF] once you fix it, adding the patch# if the fix is in SF. If you give up, remove your lock, adding instead a note with what you've found (even just the names of the failing subtests is helpful). Please help! There are other tasks, see PEP 3100. Mail me if you're interested in anything specifically. (Please don't ask me do you think I could do this -- you know better than I whether you're capable of coding at a specific level. If you don't understand the task, you're probably not qualified.) -- --Guido van Rossum (home page: http://www.python.org/~guido/) ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/lists %40plope.com ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] proposed attribute lookup optimization
[I don't know why I didn't receive this mail, presumably spam filter at gmx.net sucks as always] Phillip J. Eby wrote: At 08:23 PM 7/8/2007 +0300, Paul Pogonyshev wrote: I would like to propose an optimization (I think so, anyway) for the way attributes are looked up. [...] [...] Again, though, this has already been proposed, and I believe there's a patch awaiting review for inclusion in 2.6 (and presumably 3.0). OK, good to know. Of course it is better if done by someone familiar with Python internals :) After proposing this I decided it wasn't worthwile, since it would require cache revalidation after any assignment to a new class attribute. But supposedly I just have incorrect picture of what is often in Python :) Paul ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] [PATCH] fixing 2.5.1 build with unicode and dynamic loading disabled
On Wednesday 11 July 2007 15:01, Aahz wrote: On Wed, Jul 11, 2007, Alexander Neundorf wrote: A patch against 2.5.1 is attached. Patches to the list tend to get lost. Please post to SourceForge and then send the ID to python-dev. Done, it's #1752175 Alex ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] SVN precommit hook
Fixed. The problem was that checkwhitespace.py wasn't closing the SVN streams it was reading. Added the 'svn_stream_close' call and my checkin got through. Should be safe to do massive checkins from now on ;-) Thanks for fixing it. Those of you having access to dinsdale, feel free to temporarily disable this particular hook in the future if you find it is in your way; don't forgot to report the problem at least, and try enabling it after the questionable checkin has completed. Regards, Martin ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Need help fixing failing Py3k Unittests in py3k-struni
On 7/11/07, Chris McDonough [EMAIL PROTECTED] wrote: I have a very remedial question about how to fix test failures due to the side effects of string-unicode integration. The xmlrpc library uses explicit encoding to encode XML tag payloads to (almost always) utf8. Tag literals are not encoded. What would be the best way to mimic this behavior under the new regime? Just use unicode everywhere and encode the entire XML body to utf-8 at the end? Or deal explicitly in bytes everywhere? Or..? The correct approach would be to use Unicode (i.e., str) everywhere and encode to UTF-8 at the end. If that's too hard something's wrong with the philosophy of using Unicode everywhere... -- --Guido van Rossum (home page: http://www.python.org/~guido/) ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
[Python-Dev] Subprocesses and SIGPIPE
The documentation for the subprocess module says that it can be used as a replacement for shell pipelines, and gives an example. On *nix systems, cpython is set to ignore SIGPIPE, and this setting is inherited by child processes created by the subprocess module. This is nearly always not what you want when you're constructing a pipeline. In practice, I think most programs are not particularly designed (or tested) to run with SIGPIPE ignored, and I've had trouble caused by this a couple of times now. If you know about this, it's easy enough to avoid trouble using something like this as a preexec_fn for subprocess.Popen: def permit_sigpipe(): signal.signal(signal.SIGPIPE, signal.SIG_DFL) My question is: should subprocess.Popen do this by default? In any case, it would be good to see this issue mentioned near the pipeline example. -M- ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Need help fixing failing Py3k Unittests in py3k-struni
Michael Foord wrote: Guido van Rossum wrote: On 7/11/07, Thomas Heller [EMAIL PROTECTED] wrote: Christian Heimes schrieb: By the way the ctypes unit tests are causing a segfault on my machine: test_ctypes Warning: could not import ctypes.test.test_numbers: unpack requires a string argument of length 1 Segmentation fault Ubunutu 7.04 on i386 machine with an Intel P3. I can reproduce this. ctypes.test.test_numbers is easy to fix, but there are other severe problems with ctypes. I would love to look into these, but I prefer debugging on Windows. However, the windows build does not work because the _fileio builtin module is missing from config.c. Again, this is not so easy to fix, because the ftruncate function does not exist on Windows. I don't have a Windows box; contributions to fix this situation are welcome. You would accept a donated Windows box ? (1/2 ;-) Please don't force Guido to spend valuable development time climbing *that* learning curve! regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --- Asciimercial -- Get on the web: Blog, lens and tag the Internet Many services currently offer free registration --- Thank You for Reading - ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
[Python-Dev] Add a -z interpreter flag to execute a zip file
(resending this now that I'm subscribed, not sure it made it through the moderation the first time) I'd like to request comments on this patch I submitted: https://sourceforge.net/tracker/index.php?func=detailaid=1739468group_id=5470atid=305470 There are many details given in the comments on that page. This can be used to deploy Python programs in a very lightweight and cross-platform way. You could imagine a cgi script or a light web app server being deployed like this. I have personally deployed Python programs using zip files and this would get rid of the need for boilerplate needed for each platform. The good thing about this is that it's extremely simple -- basically 20 lines of C code to add a -z flag that calls a 3-line Python function in the runpy module. I don't believe it overlaps with anything that already exists. py2exe and py2app are platform specific and bundle the Python interpreter. This will be a cross platform binary that doesn't bundle the Python interpreter. It doesn't require eggs but I think it would work fine with eggs, and could help fix a little bug as I mentioned on the patch page. Nick Coghlan has reviewed the patch and seems to think it's a good idea. Thomas Wouters also said he likes it, and I ran it by Guido earlier and he seemed to think the idea is good, although I don't think he has seen the implementation. thanks, Andy ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Add a -z interpreter flag to execute a zip file
Nick Coghlan has reviewed the patch and seems to think it's a good idea. Thomas Wouters also said he likes it, and I ran it by Guido earlier and he seemed to think the idea is good, although I don't think he has seen the implementation. See my comment: I must be missing the point of the patch, since I can do the same thing (make a single executable zip file on Linux) through a /bin/sh header just fine. Regards, Martin ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com