[issue5139] Add combinatoric counting functions to the math module.
Mark Dickinson dicki...@gmail.com added the comment: This all sounds good to me. -- nosy: +marketdickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5139 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5134] Compiler warnings in sqlite module
Gerhard Häring g...@ghaering.de added the comment: This is a known issue with SQLite. It's not as bad as it looks at first sight, though. http://www.sqlite.org/faq.html#q17 (17) I get hundreds of compiler warnings when I compile SQLite. Isn't this a problem? Doesn't it indicate poor code quality? Quality assurance in SQLite is done using full-coverage testing, not by compiler warnings or other static code analysis tools. [...] ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5134 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue831643] Set option for subprocess in setup.py
Pim Buurman pimb...@users.sourceforge.net added the comment: I am not developing Python extensions anymore, so I am not interested in this issue. I am not sure whether this issue is still applicable to e.g. Python 3.0 You can close it if you wisj ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue831643 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5134] Compiler warnings in sqlite module
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: Martin, if you can find a way to silence the compiler for the upstream code that would be great. If not, go ahead and close as won't fix. -- assignee: ghaering - loewis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5134 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2459] speedup for / while / if with better bytecode
Changes by Armin Rigo ar...@users.sourceforge.net: -- nosy: -arigo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2459 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5134] Compiler warnings in sqlite module
Gerhard Häring g...@ghaering.de added the comment: I propose to either close this as wontfix. I don't know the switches for the Microsoft compiler to disable the warnings myself. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5134 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4879] Allow buffering for HTTPResponse
Kristján Valur Jónsson krist...@ccpgames.com added the comment: The socket.socket.makefile() now returns a quite different kind of object, namely a SocketIO thing. This comes as a result of the IO refactoring in 3.0. The good side to this is that old and naughty apps have been forbidden to access the _sock member directly. This was the reason that we had to disable read buffering in 2.x: Some clients would read directly from the socket, even though it was hidden. As for the test failure, I admit that I didn't enable the network resource for the testsuite. Will fix. Btw, test_xmlrpc_net.py fails, because time.xmlrpc.com doesn't resolve. Are there any other good and stable rpc servers out there? ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4879 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4879] Allow buffering for HTTPResponse
Kristján Valur Jónsson krist...@ccpgames.com added the comment: I'm afraid I misunderstood the problem. Yes, since u.fp is now a io.BufferedReader() rather than a socket.Socket (), the _sock member has moved. But looking at the other assertions in test_urllib2net.py, you can see the different ways the code uses to get at the socket: There is u.fp.raw._sock and there is u.fp.fp.raw._sock. IMHO I think we have to assume the _sock member to be an implementation detail that is not part of the interface. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4879 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5134] Compiler warnings in sqlite module
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: The attached patch sets the /W1 flag for the sqlite3 project. -- keywords: +patch nosy: +amaury.forgeotdarc Added file: http://bugs.python.org/file12928/sqlite3_warnings.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5134 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue831643] Set option for subprocess in setup.py
Changes by Tarek Ziadé ziade.ta...@gmail.com: -- resolution: - wont fix status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue831643 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5139] Add combinatoric counting functions to the math module.
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: I had a thought to name them perms(n,r), combs(n,r) and combs_with_replacement(n,r). The abbreviated names read nicely and avoid a namespace collision with the itertools module (making the world safe for from math import *). ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5139 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5094] datetime lacks concrete tzinfo impl. for UTC
STINNER Victor victor.stin...@haypocalc.com added the comment: The UTC class have to be converted to C. Can someone write a patch for datetimemodule.c (and the doc plus an unit test ;-))? -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5094 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5134] Compiler warnings in sqlite module
Ulrich Eckhardt eckha...@satorlaser.com added the comment: The syntax would be this: #if defined(_MSC_VER) # pragma warning(push) /* Disable warnings for this file, see http://www.sqlite.org/faq.html#q17 why we don't care for them. */ # pragma warning(disable: 4244) # pragma warning(disable: 4018) #endif ...// code that produces warnings #if defined(_MSC_VER) # pragma warning(pop) #endif For SQLite, I think the push/pop can be removed, as it is only a single file and not just a section of code. Otherwise, they are good style, in particular in header files, because they then don't affect other code. -- nosy: +eckhardt ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5134 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5139] Add combinatoric counting functions to the math module.
Mark Dickinson dicki...@gmail.com added the comment: I agree that the names shouldn't clash with those in math, especially since it seems quite plausible that a user might want to use both itertools.combinations and math.combs (for example) in the same script. No strong feelings about the actual names, but it would be nice if they somehow conveyed the idea of counting rather than enumerating. That is, if it weren't for the clearly ridiculous length, it would be nice to have: itertools.combinations itertools.permutations and math.number_of_combinations math.number_of_permutations etc. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5139 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5139] Add combinatoric counting functions to the math module.
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: Will put together a patch. -- assignee: - rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5139 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5127] UnicodeEncodeError - I can't even see license
Ezio Melotti ezio.melo...@gmail.com added the comment: FWIW, on Python3 it seems to work: import unicodedata unicodedata.category(\U0001) 'Lo' unicodedata.category(\U00011000) 'Cn' unicodedata.category(chr(0x1)) 'Lo' unicodedata.category(chr(0x11000)) 'Cn' ord(chr(0x1)), 0x1 (65536, 65536) ord(chr(0x11000)), 0x11000 (69632, 69632) I'm using a narrow build too: import sys sys.maxunicode 65535 len('\U0001') 2 ord('\U0001') 65536 On Python2 unichr() is supposed to raise a ValueError on a narrow build if the value is greater than 0x [1], but if the characters above 0x can be represented with u\U there should be a way to fix unichr so it can return them. Python3 already does it with chr(). Maybe we should open a new issue for this if it's not present already. [1]: http://docs.python.org/library/functions.html#unichr ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5127 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5127] UnicodeEncodeError - I can't even see license
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: Since r56395, ord() and chr() accept and return surrogate pairs even in narrow builds. The goal is to remove most differences between narrow and wide unicode builds (except for string lengths, indices or slices) To address this problem, I suggest to change all functions in unicodectype.c so that they accept Py_UCS4 characters (instead of Py_UNICODE). This would be a binary-incompatible change; and --with-wctype-functions would have an effect only if sizeof(wchar_t)==4 (instead of the current condition sizeof(wchar_t)==sizeof(PY_UNICODE_TYPE)) ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5127 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5127] UnicodeEncodeError - I can't even see license
STINNER Victor victor.stin...@haypocalc.com added the comment: amaury Since r56395, ord() and chr() accept and return surrogate pairs amaury even in narrow builds. Note: My examples are made with Python 2.x. The goal is to remove most differences between narrow and wide unicode builds (except for string lengths, indices or slices) It would be nice to get the same behaviour in Python 2.x and 3.x to help migration from Python2 to Python3 ;-) unichr() (in Python 2.x) documentation is correct. But I would approciate to support surrogates using unichr() which means also changing ord() behaviour. To address this problem, I suggest to change all functions in unicodectype.c so that they accept Py_UCS4 characters (instead of Py_UNICODE). Why? Using surrogates, you can use 16-bits Py_UNICODE to store non-BMP characters (code 0x). -- I can open a new issue if you agree that we can change unichr() / ord() behaviour on narrow build. We may ask on the mailing list? ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5127 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4804] Python on Windows disables all C runtime library assertions
Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment: Only file descriptors seem to have no way to verify them. How about _get_osfhandle()? (Strictly, there is race condition between _get_osfhandle and fdopen etc though) ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4804 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4804] Python on Windows disables all C runtime library assertions
Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment: Hmm, maybe _lock_fhandle can be used to solve such race condition. I'm not sure. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4804 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5110] Printing Unicode chars from the interpreter in a non-UTF8 terminal (Py3)
STINNER Victor victor.stin...@haypocalc.com added the comment: Victor, I'm not sure whether you are proposing that display_hook_ascii.patch is included into Python. IIUC, this patch breaks PEP3138, so it clearly must be rejected. Overall, I fail to see the bug in this report. Python 3.0 works as designed as shown here. The idea is to avoid unicode error (by replacing not printable characters by their code in hexadecimal) when the display hook tries to display a message which is not printable in the terminal charset. It's just to make Python3 interpreter a little bit more user friendly on Windows. Problem: use different (encoding) rule for the display hook and for print() may disturb new users (Why does chr(...) work whereas print(chr(...)) fails?). ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5110 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5127] UnicodeEncodeError - I can't even see license
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: That would cause major breakage in the C API Not if you recompile. I don't see how this breaks the API at the C level. and is not inline with the intention of having a Py_UNICODE type in the first place. Py_UNICODE is still used as the allocation unit for unicode strings. To get correct results, we need a way to access the whole unicode database even on ucs2 builds; it's possible with the unicodedata module, why not from C? My motivation for the change is this post: http://mail.python.org/pipermail/python-dev/2008-July/080900.html ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5127 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5142] pdb feature request: Ability to skip standard lib modules and other selected packages/modules
New submission from Senthil orsent...@gmail.com: When using the python debugger, most often I step ('s') through the code base and I often Call the standard library modules, whichever are imported in the scripts. This is often not desirable as I know that errors are within my modules and not in standard library. Two things which a developer can do while using pdb is: 1) Be careful as not to 's' into stdlib but use next 'n'. 2) If accidentally stepped into, then use return 'r'. Instead of doing this repeatedly, how about having method in the debugger to skip certain modules ( like standard library modules, certain package's modules etc) This would save a lot of distraction in call and returns, and developers can just go ahead with 's' and Enters. -- messages: 81058 nosy: orsenthil severity: normal status: open title: pdb feature request: Ability to skip standard lib modules and other selected packages/modules type: feature request versions: Python 2.6, Python 2.7, Python 3.0, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5142 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5142] pdb feature request: Ability to skip standard lib modules and other selected packages/modules
Changes by Senthil orsent...@gmail.com: -- components: +Library (Lib) ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5142 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5127] UnicodeEncodeError - I can't even see license
Marc-Andre Lemburg m...@egenix.com added the comment: On 2009-02-03 13:39, Amaury Forgeot d'Arc wrote: Amaury Forgeot d'Arc amaur...@gmail.com added the comment: Since r56395, ord() and chr() accept and return surrogate pairs even in narrow builds. The goal is to remove most differences between narrow and wide unicode builds (except for string lengths, indices or slices) To address this problem, I suggest to change all functions in unicodectype.c so that they accept Py_UCS4 characters (instead of Py_UNICODE). -1. That would cause major breakage in the C API and is not inline with the intention of having a Py_UNICODE type in the first place. Users who are interested in UCS4 builds should simply use UCS4 builds. This would be a binary-incompatible change; and --with-wctype-functions would have an effect only if sizeof(wchar_t)==4 (instead of the current condition sizeof(wchar_t)==sizeof(PY_UNICODE_TYPE)) --with-wctype-functions was scheduled for removal many releases ago, but I never got around to it. The only reason it's still there is that some Linux distribution use this config option (AFAIR, RedHat). I'd be +1 on removing the option in 3.0.1 or deprecating it in 3.0.1 and removing it in 3.1. It's not useful in any way, and causes compatibility problems with regular builds. -- nosy: +lemburg ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5127 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1028] Tkinter binding involving Control-spacebar raises unicode error
Guilherme Polo ggp...@gmail.com added the comment: Can you tell what: print(tkinter.Tcl().tk.call('info', 'patchlevel')) prints ? Specifically to know which tk 8.5.x has the problem. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1028 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5110] Printing Unicode chars from the interpreter in a non-UTF8 terminal raises an error (Py3)
Ezio Melotti ezio.melo...@gmail.com added the comment: Problem: use different (encoding) rule for the display hook and for print() may disturb new users (Why does chr(...) work whereas print(chr(...)) fails?). This is the same behavior that Python2.x has (with the only difference that Py2 always show the char as u'\u' if 0x7F whereas Py3 /tries/ to display it): unichr(0x0100) u'\u0100' print unichr(0x0100) UnicodeEncodeError: 'charmap' codec can't encode character u'\u0100' in position 0: character maps to undefined -- title: Printing Unicode chars from the interpreter in a non-UTF8 terminal (Py3) - Printing Unicode chars from the interpreter in a non-UTF8 terminal raises an error (Py3) ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5110 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5139] Add combinatoric counting functions to the math module.
Ezio Melotti ezio.melo...@gmail.com added the comment: Should we add permutations with repetitions? Example (from Schaum's outline of theory and problems of probability and statistics): The number of different permutations of the 11 letters of the word MISSISSIPPI, which consists of 1 M, 4 I's, 4 S's and 2 P's, is 11! / (1!*4!*4!*2!) = 34650 math.perms_with_repetitions(11, [1,4,4,2]) and maybe parallel function in itertools: itertools.permutations_with_repetitions(iterable[, r]) This should be equal to itertools.permutations(set(iterable)[, r]). ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5139 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1731706] tkinter memory leak problem
Robert Hancock hanc...@sedsystems.ca added the comment: That's not really a meaningful difference, though.. if the application uses this code continuously then the conditions will pile up in memory until it fills up. -- nosy: +robhancock1 -robhancock ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1731706 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1519638] Unmatched Group issue - workaround
Gerard g...@gp-net.nl added the comment: Bobby, Can you post the actual text you need this for? The back ref indeed returns a None. I'm wondering if the regex can be be simplefied and if a positive lookbehind could solve this. Symantically speaking ... If there's a b then return the ar, because then an empty alternate might again be of help. Kind regards, Gerard. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1519638 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1731706] tkinter memory leak problem
Guilherme Polo ggp...@gmail.com added the comment: That's not really a meaningful difference, though.. if the application uses this code continuously then the conditions will pile up in memory until it fills up. I'm not trying to discourage you to do the complete fix (for these two problems), but this API was made public only in tcl 8.3.1 as can be seen at http://tcl.cvs.sourceforge.net/viewvc/tcl/tcl/ChangeLog?revision=1.226view=markuppathrev=core-8-3-1 Still, the call fix should be backported to python 2.6 as it doesn't depend on changing supported tcl versions and is also more severe. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1731706 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5127] UnicodeEncodeError - I can't even see license
STINNER Victor victor.stin...@haypocalc.com added the comment: I don't understand the behaviour of unichr(): Python 2.7a0 (trunk:68963M, Jan 30 2009, 00:49:28) import unicodedata unicodedata.category(u\U0001) 'Lo' unicodedata.category(u\U00011000) 'Cn' unicodedata.category(unichr(0x1)) Traceback (most recent call last): File stdin, line 1, in module ValueError: unichr() arg not in range(0x1) (narrow Python build) Why unichr() fails whereas \U works? len(u\U0001) 2 ord(u\U0001) Traceback (most recent call last): File stdin, line 1, in module TypeError: ord() expected a character, but string of length 2 found -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5127 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3959] Add Google's ipaddr.py to the stdlib
David Moss drk...@gmail.com added the comment: For reference, here are the (cross-posted) links to the discussion on the (now failed) netaddr/ipaddr merge talks :- http://groups.google.com/group/netaddr/browse_thread/thread/f80b7c69e459 02b7 http://groups.google.com/group/ipaddr-py- dev/browse_thread/thread/2bc329151fef01eb Out of interest, here is some data from each project's download counters (taken 2nd Feb 2009) :- project: netaddr total downloads: 3298 first official release: July 7th, 2008 project: ipaddr total downloads: 998 first official release: September 24th, 2008 This only includes those accessing official releases (not direct subversion repository access). As these projects are both still less the 6 months old its probably difficult to gauge any kind of long term trend from this. However, what it does show is the high level of user interest in both projects. I have no desire to continue being a blocker on the decision to include ipaddr in the stdlib. At this point, I'm sure we are all keen to move on. As previously stated, netaddr will continue to be a viable alternative to those users that prefer its interface, documentation, additional features (layer-2 options, etc) and direction. Choice is a good thing and that choice will remain open to Python users as long as their interest persists. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3959 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4804] Python on Windows disables all C runtime library assertions
Changes by Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp: ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4804 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5143] OS X: Py_SetProgramName argument has type char*; should be wchar_t*
New submission from Mark Dickinson dicki...@gmail.com: When building the py3k branch on OS X, I get the following warning: gcc -c -fno-strict-aliasing -g -Wall -Wstrict-prototypes -I. -IInclude - I./Include -DPy_BUILD_CORE -o Modules/main.o Modules/main.c Modules/main.c: In function ‘Py_Main’: Modules/main.c:491: warning: passing argument 1 of ‘Py_SetProgramName’ from incompatible pointer type This *looks* like it might be a genuine problem. Lines 490-493 of main.c (which occur inside an #ifdef __APPLE__) look like this: if ((p = Py_GETENV(PYTHONEXECUTABLE)) *p != '\0') Py_SetProgramName(p); else Py_SetProgramName(argv[0]); The return from Py_GETENV (which calls the system getenv) has type char*, but Py_SetProgramName expects something of type wchar_t*. However, I don't know enough about this part of Python to tell for sure whether there's really something wrong here. Ronald, any ideas? -- components: Macintosh messages: 81066 nosy: marketdickinson, ronaldoussoren severity: normal status: open title: OS X: Py_SetProgramName argument has type char*; should be wchar_t* versions: Python 3.0, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5143 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5144] PySys_SetArgv has wrong documentation
New submission from jan matejek jmate...@suse.cz: documentation for PySys_SetArgv states that the function sets sys.argv, but fails to mention that it also resolves script's path and prepends it to sys.path. Or, in case no script was specified, it prepends empty string (which in versions 2.6 allowed relative imports from cwd) -- assignee: georg.brandl components: Documentation messages: 81067 nosy: georg.brandl, matejcik severity: normal status: open title: PySys_SetArgv has wrong documentation ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5144 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3871] cross and native build of python for mingw32 with distutils
Changes by Giampaolo Rodola' billiej...@users.sourceforge.net: -- nosy: +giampaolo.rodola ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3871 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5127] UnicodeEncodeError - I can't even see license
Marc-Andre Lemburg m...@egenix.com added the comment: On 2009-02-03 14:14, STINNER Victor wrote: STINNER Victor victor.stin...@haypocalc.com added the comment: amaury Since r56395, ord() and chr() accept and return surrogate pairs amaury even in narrow builds. Note: My examples are made with Python 2.x. The goal is to remove most differences between narrow and wide unicode builds (except for string lengths, indices or slices) It would be nice to get the same behaviour in Python 2.x and 3.x to help migration from Python2 to Python3 ;-) unichr() (in Python 2.x) documentation is correct. But I would approciate to support surrogates using unichr() which means also changing ord() behaviour. This is not possible for unichr() in Python 2.x, since applications always expect len(unichr(x)) == 1. Changing ord() would be possible in Python 2.x is easier, since this would only extend the range of returned values for UCS2 builds. To address this problem, I suggest to change all functions in unicodectype.c so that they accept Py_UCS4 characters (instead of Py_UNICODE). Why? Using surrogates, you can use 16-bits Py_UNICODE to store non-BMP characters (code 0x). -- I can open a new issue if you agree that we can change unichr() / ord() behaviour on narrow build. We may ask on the mailing list? ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5127 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1079] decode_header does not follow RFC 2047
Tom Lynn tl...@users.sourceforge.net added the comment: The only difference between the two regexps is that the email/header.py version looks for:: (?=[ \t]|$) # whitespace or the end of the string at the end (with re.MULTILINE, so $ also matches '\n'). To expand on There is nothing about that thing in RFC 2047, it says:: IMPORTANT: 'encoded-word's are designed to be recognized as 'atom's by an RFC 822 parser. RFC 822 says:: atom= 1*any CHAR except specials, SPACE and CTLs ... specials= ( / ) / / / @ ; Must be in quoted- / , / ; / : / \ / ; string, to use / . / [ / ] ; within a word. So an example of mis-parsing is:: import email.header h = '=?utf-8?q?=E2=98=BA?=(unicode white smiling face)' email.header.decode_header(h) [('=?utf-8?q?=E2=98=BA?=(unicode white smiling face)', None)] The correct result would be:: email.header.decode_header(h) [('\xe2\x98\xba', 'utf-8'), ('(unicode white smiling face)', None)] which is what you get if you insert a space before the '(' in h. -- nosy: +tlynn ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1079 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4958] email/header.py ecre regular expression issue
Tom Lynn tl...@users.sourceforge.net added the comment: Duplicates issue1047. -- nosy: +tlynn ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4958 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4804] Python on Windows disables all C runtime library assertions
Changes by Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp: ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4804 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4958] email/header.py ecre regular expression issue
Tom Lynn tl...@users.sourceforge.net added the comment: Oops, duplicates issue 1079 even. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4958 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4491] email.Header.decode_header() doesn't work if encoded-word was separeted by CRLF
Tom Lynn tl...@users.sourceforge.net added the comment: Duplicates issue1079. -- nosy: +tlynn ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4491 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4804] Python on Windows disables all C runtime library assertions
Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment: Only file descriptors seem to have no way to verify them. How about _get_osfhandle()? I cannot see _ASSERTE in that function on VC6, but maybe there on VC9. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4804 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue976869] Stripping script extensions with distutils
Akira Kitada akit...@gmail.com added the comment: I doubt strip-extensions has to be in distutils. Isn't a simple script like below enough for this? $ for i in *.py; do mv $i ${i%.py}; done -- nosy: +akitada, tarek ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue976869 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4804] Python on Windows disables all C runtime library assertions
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: On VS8.0, _get_osfhandle() begins with three assert statements. This function is not safer than the others... ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4804 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5141] C API for appending to arrays
New submission from Hrvoje Nikšić hnik...@gmail.com: The array.array type is an excellent type for storing a large amount of native elements, such as integers, chars, doubles, etc., without involving the heavy machinery of numpy. It's both blazingly fast and reasonably efficient with memory. The one thing missing from the array module is the ability to directly access array values from C. This might seem superfluous, as it's perfectly possible to manipulate array contents from Python/C using PyObject_CallMethod and friends. The problem is that it requires the native values to be marshalled to Python objects, only to be immediately converted back to native values by the array code. This can be a problem when, for example, a numeric array needs to be filled with contents, such as in this hypothetical example: /* error checking and refcounting subtleties omitted for brevity */ PyObject *load_data(Source *src) { PyObject *array_type = get_array_type(); PyObject *array = PyObject_CallFunction(array_type, c, 'd'); PyObject *append = PyObect_GetAttrString(array, append); while (!source_done(src)) { double num = source_next(src); PyObject *f = PyFloat_FromDouble(num); PyObject *ret = PyObject_CallFunctionObjArgs(append, f, NULL); if (!ret) return NULL; Py_DECREF(ret); Py_DECREF(f); } Py_DECREF(array_type); return array; } The inner loop must convert each C double to a Python Float, only for the array to immediately extract the double back from the Float and store it into the underlying array of C doubles. This may seem like a nitpick, but it turns out that more than half of the time of this function is spent creating and deleting those short-lived floating-point objects. Float creation is already well-optimized, so opportunities for speedup lie elsewhere. The array object exposes a writable buffer, which can be used to store values directly. For test purposes I created a faster append specialized for doubles, defined like this: int array_append(PyObject *array, PyObject *appendfun, double val) { PyObject *ret; double *buf; Py_ssize_t bufsize; static PyObject *zero; if (!zero) zero = PyFloat_FromDouble(0); // append dummy zero value, created only once ret = PyObject_CallFunctionObjArgs(appendfun, zero, NULL); if (!ret) return -1; Py_DECREF(ret); // append the element directly at the end of the C buffer PyObject_AsWriteBuffer(array, (void **) buf, bufsize)); buf[bufsize / sizeof(double) - 1] = val; return 0; } This hack actually speeds up array creation by a significant percentage (30-40% in my case, and that's for code that was producing the values by parsing a large text file). It turns out that an even faster method of creating an array is by using the fromstring() method. fromstring() requires an actual string, not a buffer, so in C++ I created an std::vectordouble with a contiguous array of doubles, passed that array to PyString_FromStringAndSize, and called array.fromstring with the resulting string. Despite all the unnecessary copying, the result was much faster than either of the previous versions. Would it be possible for the array module to define a C interface for the most frequent operations on array objects, such as appending an item, and getting/setting an item? Failing that, could we at least make fromstring() accept an arbitrary read buffer, not just an actual string? -- messages: 81039 nosy: hniksic severity: normal status: open title: C API for appending to arrays type: feature request ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5141 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5143] OS X: Py_SetProgramName argument has type char*; should be wchar_t*
Ned Deily n...@acm.org added the comment: I think it is a problem and it explains one of the problems with IDLE.app in 3.x. The value of PYTHONEXECUTABLE should end up in sys.executable: $ export PYTHONEXECUTABLE='/test' @fimt:~$ python2.6 Python 2.6.1 (r261:67515, Dec 17 2008, 23:27:50) [GCC 4.0.1 (Apple Inc. build 5490)] on darwin import sys; sys.executable '/test' $ python3.1 Python 3.1a0 (py3k, Feb 2 2009, 02:33:48) [GCC 4.0.1 (Apple Computer, Inc. build 5370)] on darwin import sys; sys.executable '/Users/nad/' -- nosy: +nad ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5143 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5127] UnicodeEncodeError - I can't even see license
STINNER Victor victor.stin...@haypocalc.com added the comment: lemburg This is not possible for unichr() in Python 2.x, since applications lemburg always expect len(unichr(x)) == 1 Oh, ok. lemburg Changing ord() would be possible in Python 2.x is easier, since lemburg this would only extend the range of returned values for UCS2 lemburg builds. ord() of Python3 (narrow build) rejects surrogate characters: '\U0001' len(chr(0x1)) 2 ord(0x1) Traceback (most recent call last): File stdin, line 1, in module TypeError: ord() expected string of length 1, but int found --- It looks that narrow builds with surrogates have some more problems... Test with U+1: LINEAR B SYLLABLE B008 A, category: Letter, Other. Correct result (Python 2.5, wide build): $ python Python 2.5.1 (r251:54863, Jul 31 2008, 23:17:40) unichr(0x1) u'\U0001' unichr(0x1).isalpha() True Error in Python3 (narrow build): marge$ ./python Python 3.1a0 (py3k:69105M, Feb 3 2009, 15:04:35) chr(0x1).isalpha() False list(chr(0x1)) ['\ud800', '\udc00'] chr(0xd800).isalpha() False chr(0xdc00).isalpha() False Unicode ranges, all in the category Other, Surrogate: - U+D800..U+DB7F: Non Private Use High Surrogate - U+DB80..U+DBFF: Private Use High Surrogate - U+DC00..U+DFFF: Low Surrogate range ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5127 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5139] Add combinatoric counting functions to the math module.
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +ezio.melotti ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5139 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5115] Extend subprocess.kill to be able to kill process groups
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: I suspect that on Windows, TerminateJobObject won't work with a handle returned by CreateProcess. A solution could look like http://www.mobzystems.com/code/killprocesstree.aspx -- nosy: +amaury.forgeotdarc ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5115 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5143] OS X: Py_SetProgramName argument has type char*; should be wchar_t*
Ronald Oussoren ronaldousso...@mac.com added the comment: This is a bug, I'm working on a fix. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5143 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue976869] Stripping script extensions with distutils
Tarek Ziadé ziade.ta...@gmail.com added the comment: It makes sense to me but we need to look at setuptools console feature nowadays. I think it might be the right piece to add in distutils for console scripts. -- assignee: - tarek ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue976869 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3871] cross and native build of python for mingw32 with distutils
Luke Kenneth Casson Leighton l...@lkcl.net added the comment: On Mon, Feb 2, 2009 at 9:10 PM, Roumen Petrov rep...@bugs.python.org wrote: Roumen Petrov bugtr...@roumenpetrov.info added the comment: The proposed patch for this issue include parts of other pending issues - so its all is single file. If python team don't like idea for canonical host names (part of issue 3754) this patch can be modified do not use host-triplet. Also some discussions in py-dev list show that small patches are preferred. I'm ready to split into small patches to be reviewed. excellent. that _would_ be good. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3871 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4804] Python on Windows disables all C runtime library assertions
Kristján Valur Jónsson krist...@ccpgames.com added the comment: Ok. I have submitted methods to verify the input to strftime() and fopen(). Only file descriptors seem to have no way to verify them. Mark Hammond seems to think this is ok (if tests can be selectively turned off), and if that is so, I have no objections. My chief concern is to get the global CRT setting out of the way. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4804 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5119] wide character parameter handling in ctypes
Changes by Amaury Forgeot d'Arc amaur...@gmail.com: -- status: pending - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5119 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5119] wide character parameter handling in ctypes
Jason R. Coombs jar...@jaraco.com added the comment: Thanks for the excellent suggestion. Please close this issue. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5119 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4804] Python on Windows disables all C runtime library assertions
Martin v. Löwis mar...@v.loewis.de added the comment: fopen.patch is fine, please apply. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4804 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2124] xml.sax and xml.dom fetch DTDs by default
Damien Neil ne...@misago.org added the comment: I just ran into this problem. I was very surprised to realize that every time the code I was working on parsed a docbook file, it generated several HTTP requests to oasis-open.org to fetch the docbook DTDs. I attempted to fix the issue by adding an EntityResolver that would cache fetched DTDs. (The documentation on how to do this is not, by the way, very clear.) Unfortunately, this proves to not be possible. The main docbook DTD includes subsidiary DTDs using relative system identifiers. For example, the main DTD at: publicId: -//OASIS//DTD DocBook V4.1//EN systemId: http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd ...includes this second DTD: publicId: -//OASIS//ENTITIES DocBook Notations V4.4//EN systemId: dbnotnx.mod The EntityResolver's resolveEntity() method is not, however, passed the base path to resolve the relative systemId from. This makes it impossible to properly implement a parser which caches fetched DTDs. -- nosy: +damien ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2124 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5143] OS X: Py_SetProgramName argument has type char*; should be wchar_t*
Ronald Oussoren ronaldousso...@mac.com added the comment: The quick fix is to convert p to a wchar_t (using mbstowcs), see patch-mbstowcs.txt. However, I don't think this is the right fix. AFAIK this environment variable is only used by .app bundles created by bundlebuilder.py which is no longer part of the standard library. IDLE.app uses the same mechanism, but that's not needed there and can be removed without problems. The file patch-remove-PYTHONEXECUTABLE.txt removed the environment variable, and results in a working IDLE.app on my machine (IDLE launches with a working shell window and I can open python files). I'd prefer to apply patch-remove-PYTHONEXECUTABLE.txt on the trunk, the more limited fix can be applied on the 3.0.x branch (although I have no idea if that branch even works correctly on OSX) Added file: http://bugs.python.org/file12929/patch-mbstowcs.txt ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5143 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5127] UnicodeEncodeError - I can't even see license
Marc-Andre Lemburg m...@egenix.com added the comment: On 2009-02-03 14:50, Amaury Forgeot d'Arc wrote: Amaury Forgeot d'Arc amaur...@gmail.com added the comment: That would cause major breakage in the C API Not if you recompile. I don't see how this breaks the API at the C level. Well, then try to look at such a change from a C extension writer's perspective. They'd have to change all their function calls and routines to work with Py_UCS4. Supporting both the old API and the new one would be nearly impossible and require either an adapter API or a lot of #ifdef'ery. Please remember that the public Python C API is not only meant for Python developers. It's main purpose is for it to be used by other developers extending or embedding Python and those developers use different release cycles and want to support more than just the bleeding edge Python version. Python has a long history of providing very stable APIs, both in C and in Python. FWIW: The last major change in the C API (the change to Py_ssize_t from Python 2.4 to 2.5) has not even propogated to all major C extensions yet. It's only now that people start to realize problems with this, since their extensions start failing with segfaults on 64-bit machines. That said, we can of course provide additional UCS4 APIs for certain things and also provide conversion helpers between Py_UNICODE and Py_UCS4 where needed. and is not inline with the intention of having a Py_UNICODE type in the first place. Py_UNICODE is still used as the allocation unit for unicode strings. To get correct results, we need a way to access the whole unicode database even on ucs2 builds; it's possible with the unicodedata module, why not from C? I must be missing some detail, but what does the Unicode database have to do with the unicodeobject.c C API ? My motivation for the change is this post: http://mail.python.org/pipermail/python-dev/2008-July/080900.html There are certainly other ways to make Python deal with surrogates in more cases than the ones we already support. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5127 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5143] OS X: Py_SetProgramName argument has type char*; should be wchar_t*
Changes by Ronald Oussoren ronaldousso...@mac.com: Added file: http://bugs.python.org/file12930/patch-remove-PYTHONEXECUTABLE.txt ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5143 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5143] OS X: Py_SetProgramName argument has type char*; should be wchar_t*
Ronald Oussoren ronaldousso...@mac.com added the comment: Please let me know if second patch (patch-remove-PYTHONEXECUTABLE.txt) fixes the issue for you as well, if it does I'll commit it to the 3.x branch (and add an item to the NEWS file). -- resolution: - accepted ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5143 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5094] datetime lacks concrete tzinfo impl. for UTC
Brett Cannon br...@python.org added the comment: On Tue, Feb 3, 2009 at 03:28, STINNER Victor rep...@bugs.python.org wrote: STINNER Victor victor.stin...@haypocalc.com added the comment: The UTC class have to be converted to C. Yes, the example code is just an example. =) Can someone write a patch for datetimemodule.c (and the doc plus an unit test ;-))? I might have some people lined up to take this on. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5094 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5094] datetime lacks concrete tzinfo impl. for UTC
Changes by Brett Cannon br...@python.org: -- assignee: - brett.cannon stage: needs patch - test needed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5094 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1731706] tkinter memory leak problem
Martin v. Löwis mar...@v.loewis.de added the comment: Still, the call fix should be backported to python 2.6 as it doesn't depend on changing supported tcl versions and is also more severe. That sounds like a good approach. If you can split the patch into two, backporting only one of them - go ahead! ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1731706 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5145] struct.calcsize('cd') returns 16 instead of 9
Changes by Antoine Pitrou pit...@free.fr: -- assignee: - georg.brandl components: +Documentation -Extension Modules nosy: +georg.brandl ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5145 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2124] xml.sax and xml.dom fetch DTDs by default
Changes by Jean-Paul Calderone exar...@divmod.com: -- nosy: +exarkun ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2124 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5139] Add combinatoric counting functions to the math module.
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: -1 on perms_with_repetitions. That's headed in the direction of bloat -- taking every formula in a textbook and putting it in the module. Also, it is somewhat use case challenged. I've *never* needed this in my 30 years of programming. I like Mark's idea for names that indicate that they return a number or count instead an iterator. Perhaps something like: ncombinations() npermutations() ncombinations_with_replacement() ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5139 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1294959] Problems with /usr/lib64 builds.
Akira Kitada akit...@gmail.com added the comment: Similar problem report: http://bugs.python.org/issue1019715 -- nosy: +akitada ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1294959 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2124] xml.sax and xml.dom fetch DTDs by default
Jean-Paul Calderone exar...@divmod.com added the comment: Though it's inconvenient to do so, you can arrange to have the locator available from the entity resolver. The content handler's setDocumentLocator method will be called early on with the locator object. So you can give your entity resolver a reference to your content handler and save a reference to the document locator in the content handler. Then in the entity resolver's resolveEntity method you can reach over into the content handler and grab the document locator to call its getSystemId method. Note that you have to be careful with the InputStreams you return from resolveEntity. I wasn't aware of this before (and perhaps I've misinterpreted some observer), but I just noticed that if you return an InputSource based on a file object, the file object's name will be used as the document id! This is quite not what you want. InputStream has a setSystemId method, but even if you call it before you call setByteStream, the system id will be the name of the file object passed to setByteStream. Perhaps calling these two methods in the opposite order will fix this, I'm not sure, I haven't tried. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2124 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2124] xml.sax and xml.dom fetch DTDs by default
Martin v. Löwis mar...@v.loewis.de added the comment: EntityResolver.resolveEntity() is called with the publicId and systemId as arguments. It does not receive a locator. Sure. But ContentHandler.setDocumentLocator receives it, and you are supposed to store it for the entire parse, to always know what entity is being processed if you want to. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2124 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5015] The Py_SetPythonHome C API function is undocumented
Changes by Tim Lesher tles...@gmail.com: -- nosy: +tlesher ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5015 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5139] Add combinatoric counting functions to the math module.
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: Besides paralleling itertools names, the names should also parallel each other -- when I find permutations, I also expect to find combinations. No matter what names are selected, we'll include alternate index targets for the various names binonimial coefficient, choose function, multichoose, combinations with repetition. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5139 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2124] xml.sax and xml.dom fetch DTDs by default
Damien Neil ne...@misago.org added the comment: On Feb 3, 2009, at 1:42 PM, Martin v. Löwis wrote: Sure. But ContentHandler.setDocumentLocator receives it, and you are supposed to store it for the entire parse, to always know what entity is being processed if you want to. Where in the following sequence am I supposed to receive the document locator? parser = xml.sax.make_parser() parser.setEntityResolver(CachingEntityResolver()) doc = xml.dom.minidom.parse('file.xml', parser) The content handler is being created deep inside xml.dom. It does, in fact, store the document locator, but not in any place that I can easily access without breaking several layers of abstraction. Or, as a more general question: How can I get a DOM tree that includes external entities? If there's an easy way to do it, the documentation does not make it clear at all. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2124 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3783] dbm.sqlite proof of concept
Antoine Pitrou pit...@free.fr added the comment: I think issuing 'SELECT MAX(ROWID)' to compute the length of the table is not correct if some rows get deleted in the table. I've found a thread about it here: http://osdir.com/ml/db.sqlite.general/2004-03/msg00329.html In that thread someone suggested caching the length in another table and updating it through a trigger each time the main table is modified. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3783 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2124] xml.sax and xml.dom fetch DTDs by default
Damien Neil ne...@misago.org added the comment: I just discovered another really fun wrinkle in this. Let's say I want to have my entity resolver return a reference to my local copy of a DTD. I write: source = xml.sax.InputSource() source.setPublicId(publicId) source.setSystemId(systemId) source.setCharacterStream(file(path_to_local_copy)) return source This will appear to work. However, the parser will still silently fetch the DTD over the network! I needed to call source.setByteStream()--character streams are silently ignored. I'd never have noticed this if I hadn't used strace on my process and noticed a slew of recvfrom() calls that shouldn't have been there. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2124 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2636] Regexp 2.7 (modifications to current re 2.2.2)
Matthew Barnett pyt...@mrabarnett.plus.com added the comment: issue2636-features.diff is based on Python 2.6. It includes: Named Unicode characters eg \N{LATIN CAPITAL LETTER A} Unicode character properties eg \p{Lu} (uppercase letter) and \P{Lu} (not uppercase letter) Other character properties not restricted to Unicode eg \p{Alnum} and \P{Alnum} Issue #3511 : Incorrect charset range handling with ignore case flag? Issue #3665 : Support \u and \U escapes in regexes Issue #1519638 Unmatched Group issue - workaround Issue #1693050 \w not helpful for non-Roman scripts The next 2 seemed a good idea at the time. :-) Octal escape \onnn Extended hex escape \x{n} Added file: http://bugs.python.org/file12932/issue2636-features.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2636 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1076233] distutils.core.setup() with unicode arguments broken
Akira Kitada akit...@gmail.com added the comment: It seems this problem was fixed already. Can we close this? -- nosy: +akitada, tarek ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1076233 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue977470] Deleted files are reinstalled
Akira Kitada akit...@gmail.com added the comment: Tarek, I think this is not a bug and would be safe to close. What do you think? -- nosy: +akitada, tarek ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue977470 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3783] dbm.sqlite proof of concept
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: That's a bummer. Changing this method to __bool__ and then setting __len__ back to count(*). Added file: http://bugs.python.org/file12933/dbsqlite.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3783 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3783] dbm.sqlite proof of concept
Changes by Raymond Hettinger rhettin...@users.sourceforge.net: Removed file: http://bugs.python.org/file12931/dbsqlite.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3783 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2124] xml.sax and xml.dom fetch DTDs by default
Jean-Paul Calderone exar...@divmod.com added the comment: It's indeed possible to provide that as a third-party module; one would have to implement an EntityResolver, and applications would have to use it. If there was a need for such a thing, somebody would have done it years ago. I don't think this is true, for several reasons. First, most people never notice that they are writing or using an application which has this behavior. This is because the behavior is transparent in almost all cases, manifesting only as a slowdown. Often, no one is paying close attention to whether a function takes 0.1s or 0.5s. So code gets written which fetches resources from the network by accident. Similarly, users generally don't have any idea that this kind of defect is possible, or they don't think it's unusual behavior. In general, they're not equipped to understand why this is a bad thing. At best, they may decide a program is slow and be upset, but out of the myriad reasons a program might be slow, they have no particular reason to settle on this one as the real cause. Second, it is *difficult* to implement the non-network behavior. Seriously, seriously difficult. The documentation for these APIs is obscure and incomplete in places. It takes a long time to puzzle out what it means and how to achieve the desired behavior. I wouldn't be surprised if many people simply gave up and either switched to another parser or decided they could live with the slowdown (perhaps not realizing that it could be arbitrarily long and might add a network dependency to a program which doesn't already have one). Third, there are several pitfalls on the way to a correct implementation of the non-network behavior which may lead a developer to decide they have succeeded when they have actually failed. The most obvious is that simply turning off the external-general-entities feature appears to solve the problem but actually changes the parser's behavior so that it will silently drop named character entities. This is quite surprising behavior to anyone who hasn't spent a lot of time with the XML specification. So I think it would be a significant improvement if there were a simple, documented way to switch from network retrieval to local retrieval from a cache. I also think that the current default behavior is wrong. The default should not be to go out to the network, even if there is a well-behaved HTTP caching client involved. So the current behavior should be deprecated. After a sufficient period of time, the local-only behavior should be made the default. I don't see any problem with making it easy to re-enable the old behavior, though. -1 on issuing a warning. I really cannot see much of a problem in this entire issue. XML was designed to be straightforwardly usable over the Internet (XML rec., section 1.1), and this issue is a direct consequence of that design decision. You might just as well warn people against using XML in the first place. Quoting part of the XML design goals isn't a strong argument for the current behavior. Transparently requesting network resources in order to process local data isn't a necessary consequence of the straightforwardly usable over the internet goal. Allowing this behavior to be explicitly enabled, but not enabled by default, easily meets this goal. Straightforwardly supporting a local cache of DTDs is even better, since it improves application performance and removes a large number of of security concerns. With the general disfavor of DTDs (in favor of other validation techniques, such as relax-ng) and the general disfavor of named character entities (basically only XHTML uses them), I find it extremely difficult to justify Python's current default behavior. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2124 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5145] struct.calcsize('cd') returns 16 instead of 9
bob gailer bgai...@gmail.com added the comment: Someone pointed out that one must consider alignment. I had overlooked that. It makes sense that a d is double-word aligned. Perhaps the documentation should mention alignment. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5145 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3783] dbm.sqlite proof of concept
Changes by Raymond Hettinger rhettin...@users.sourceforge.net: Removed file: http://bugs.python.org/file12896/dbsqlite.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3783 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4124] Patch for adding default to itemgetter and attrgetter
Miki Tebeka miki.teb...@gmail.com added the comment: Can't we find a faster dog for lambda :) Anyway, I agree that we need to see more demand for that before going on. Let's keep this ticket open and see if someone else comes along. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4124 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1706256] Give Partial the ability to skip positionals
John Ehresman j...@wingware.com added the comment: Commenting because this was brought up on python-dev -- I'd like this, primarily for the string method itertools optimization. It's ugly, but it would be better than writing C code. The alternative might be to somehow optimize trivial functions to execute without bytecode, but that would be considerably harder. -- nosy: +jpe ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1706256 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3783] dbm.sqlite proof of concept
Changes by Raymond Hettinger rhettin...@users.sourceforge.net: Removed file: http://bugs.python.org/file12891/tmp_dev_shelver.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3783 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5127] UnicodeEncodeError - I can't even see license
Ezio Melotti ezio.melo...@gmail.com added the comment: haypo ord() of Python3 (narrow build) rejects surrogate characters: haypo '\U0001' haypo len(chr(0x1)) haypo 2 haypo ord(0x1) haypo TypeError: ord() expected string of length 1, but int found ord() works fine on Py3, you probably meant to do ord('\U0001') 65536 or ord(chr(0x1)) 65536 In Py3 is also stated that it accepts surrogate pairs (help(ord)). Py2 instead doesn't support them: ord(u'\U0001') TypeError: ord() expected a character, but string of length 2 found ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5127 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3783] dbm.sqlite proof of concept
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: Here's an updated patch (it's also in the sandbox): * Added a sync() method to support shelves. * Removed commits on granular sets and gets. * Optimized __len__ and __contains__. Added file: http://bugs.python.org/file12931/dbsqlite.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3783 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1019715] distutils ignores configure's --includedir
Akira Kitada akit...@gmail.com added the comment: I'm having the same problem. This is a real headache, especially on systems that run both 32-bit and 64-bit apps, where I often see lib64, include64 and bin64. In my opinion, lib, include and bin shouldn't be hard-coded in anywhere. Note that these hard-coded paths are found in other places, too. See http://bugs.python.org/issue1294959 for further detials. -- nosy: +akitada, tarek ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1019715 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5147] MozillaCookieJar should not store leading whitespace in Magic header
New submission from Ajith Antony ajith.ant...@gmail.com: It seems that in the MozillaCookieJar library, the author accidently indented the long string that represents the magic header of the Netscape compatible cookie file. This is not a problem for MozillaCookieJar as the regex to test the magic header is not bound to the beginning of the line. Other libraries, however, may bind the pattern match to the beginning of the line, such as perl's HTTP::Cookies::Netscape. For better compatibility of Netscape cookies files, the magic header must not be indented. Index: svn-python-lib/_MozillaCookieJar.py === --- svn-python-lib/_MozillaCookieJar.py (revision 69261) +++ svn-python-lib/_MozillaCookieJar.py (working copy) @@ -38,9 +38,9 @@ magic_re = #( Netscape)? HTTP Cookie File header = \ -# Netscape HTTP Cookie File -# http://www.netscape.com/newsref/std/cookie_spec.html -# This is a generated file! Do not edit. +# Netscape HTTP Cookie File +# http://www.netscape.com/newsref/std/cookie_spec.html +# This is a generated file! Do not edit. -- components: Library (Lib) messages: 81100 nosy: aantony severity: normal status: open title: MozillaCookieJar should not store leading whitespace in Magic header type: behavior versions: Python 2.4, Python 2.5, Python 2.6, Python 2.7, Python 3.0, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5147 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5146] threading via uid method doesn't work in imaplib
New submission from abhishek abhis...@synovel.com: Hi, IMAP commands in general can be either called directly or via the UID command which basically returns the UIDs instead of message IDs. Consider this example: 02:23.02 GDJB3 UID THREAD references UTF-8 (SEEN) 02:23.02 * THREAD (3)(2)(4)(1) 02:23.02 matched r'\* (?Ptype[A-Z-]+)( (?Pdata.*))?' = ('THREAD', ' (3)(2)(4)(1)', '(3)(2)(4)(1)') 02:23.03 untagged_responses[THREAD] 0 += [(3)(2)(4)(1)] 02:23.03 GDJB3 OK Thread completed. 02:23.03 matched r'(?PtagGDJB\d+) (?Ptype[A-Z]+) (?Pdata.*)' = ('GDJB3', 'OK', 'Thread completed.') [None] ... 02:59.22 CNCF3 THREAD references UTF-8 (SEEN) 02:59.23 * THREAD (3)(2)(4)(1) 02:59.23 matched r'\* (?Ptype[A-Z-]+)( (?Pdata.*))?' = ('THREAD', ' (3)(2)(4)(1)', '(3)(2)(4)(1)') 02:59.23 untagged_responses[THREAD] 0 += [(3)(2)(4)(1)] 02:59.23 CNCF3 OK Thread completed. 02:59.23 matched r'(?PtagCNCF\d+) (?Ptype[A-Z]+) (?Pdata.*)' = ('CNCF3', 'OK', 'Thread completed.') 02:59.23 untagged_responses[THREAD] = ['(3)(2)(4)(1)'] ['(3)(2)(4)(1)'] The reason I figured out why UID failed whereas the direct method call worked lies in this particular line of the method 'uid' in imaplib.py: if command in ('SEARCH', 'SORT'): name = command else: name = 'FETCH' which should be : if command in ('SEARCH', 'SORT', 'THREAD'): name = command else: name = 'FETCH' I was able to confirm this in both 2.4 and 2.5. Hope this would be looked upon and fixed. Regards, Abhishek -- components: Library (Lib) messages: 81094 nosy: abhishek, piers, pierslauder severity: normal status: open title: threading via uid method doesn't work in imaplib type: behavior versions: Python 2.4, Python 2.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5146 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1519638] Unmatched Group issue - workaround
Bobby Xiao nneon...@gmail.com added the comment: It was so long ago, I've since redone half my codebase (the hack is still there, but I can't remember what it was meant to replace now :( ). Sorry about that. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1519638 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5146] threading via uid method doesn't work in imaplib
Piers Lauder pi...@it.usyd.edu.au added the comment: I agree with this change. It should be propagated to all versions. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5146 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2124] xml.sax and xml.dom fetch DTDs by default
Martin v. Löwis mar...@v.loewis.de added the comment: Where in the following sequence am I supposed to receive the document locator? parser = xml.sax.make_parser() parser.setEntityResolver(CachingEntityResolver()) doc = xml.dom.minidom.parse('file.xml', parser) This is DOM parsing, not SAX parsing. The content handler is being created deep inside xml.dom. It does, in fact, store the document locator, but not in any place that I can easily access without breaking several layers of abstraction. So break layers of abstraction, then. Or else, use dom.expatbuilder, and ignore SAX/pulldom for DOM parsing. Or, as a more general question: How can I get a DOM tree that includes external entities? If there's an easy way to do it, the documentation does not make it clear at all. This tracker is really not the place to ask questions; use python-list for that. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2124 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5139] Add combinatoric counting functions to the math module.
Fredrik Johansson fredrik.johans...@gmail.com added the comment: I understand the connection with itertools, but why not just call a binomial coefficient a binomial coefficient? Probably 90% of all math libraries call this function 'binomial' or 'bincoef' and I suspect that's the name most people would search for. -- nosy: +fredrikj ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5139 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5134] Compiler warnings in sqlite module
Martin v. Löwis mar...@v.loewis.de added the comment: The syntax would be this: #if defined(_MSC_VER) # pragma warning(push) /* Disable warnings for this file, see http://www.sqlite.org/faq.html#q17 why we don't care for them. */ # pragma warning(disable: 4244) # pragma warning(disable: 4018) #endif I'd rather disable them in the project, instead of putting it into the source code. I'd also just disable *all* warnings, since we wouldn't fix any of them. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5134 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4285] Use a named tuple for sys.version_info
Changes by Eric Smith e...@trueblade.com: -- nosy: +eric.smith ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4285 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4124] Patch for adding default to itemgetter and attrgetter
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: That makes sense. You've found two object models that have optional attributes and have had some need to extract them with a default. My remaining concern is about adding complexity for functionality that is not often needed. It wouldn't be an issue if itemgetter() and attrgetter() already had a simple signature, but they already allow multiple arguments and IMO that doesn't mesh well with providing defaults. FWIW, looking back at your use cases, it feels like the functional tools have come together awkwardly. It may be slower, but the following seems easier to read, easier to write, and clearer about its intention: sum('tr' == getattr(node, 'name', '') for node in soup) max(getattr(art, 'time', 0) for art in articles) In general, listcomps and genexps read better than equivalents using lambda or a stack of builtin operators. And, lambda is dog slow. So, the following may be slower than the above code: len(filter(lambda n: n == tr, map(attrgetter(name, ), soup))) ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4124 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com