You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3366 lines
86 KiB

32 years ago
31 years ago
31 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
Merged revisions 70578,70599,70641-70642,70650,70660-70661,70674,70691,70697-70698,70700,70704 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r70578 | benjamin.peterson | 2009-03-23 22:24:56 -0500 (Mon, 23 Mar 2009) | 1 line this is better written using assertRaises ........ r70599 | benjamin.peterson | 2009-03-25 16:42:51 -0500 (Wed, 25 Mar 2009) | 1 line this can be slightly less ugly ........ r70641 | guilherme.polo | 2009-03-27 16:43:08 -0500 (Fri, 27 Mar 2009) | 3 lines Adjusted _tkinter to compile without warnings when WITH_THREAD is not defined (part of issue #5035) ........ r70642 | georg.brandl | 2009-03-27 19:48:48 -0500 (Fri, 27 Mar 2009) | 1 line Fix typo. ........ r70650 | benjamin.peterson | 2009-03-28 14:16:10 -0500 (Sat, 28 Mar 2009) | 1 line give os.symlink and os.link() better parameter names #5564 ........ r70660 | georg.brandl | 2009-03-28 14:52:58 -0500 (Sat, 28 Mar 2009) | 1 line Switch to fixed Sphinx version. ........ r70661 | georg.brandl | 2009-03-28 14:57:36 -0500 (Sat, 28 Mar 2009) | 2 lines Add section numbering to some of the larger subdocuments. ........ r70674 | guilherme.polo | 2009-03-29 05:19:05 -0500 (Sun, 29 Mar 2009) | 1 line Typo fix. ........ r70691 | raymond.hettinger | 2009-03-29 13:51:11 -0500 (Sun, 29 Mar 2009) | 1 line Make life easier for non-CPython implementations. ........ r70697 | benjamin.peterson | 2009-03-29 16:22:35 -0500 (Sun, 29 Mar 2009) | 1 line this has been fixed since 2.6 (I love removing these) ........ r70698 | benjamin.peterson | 2009-03-29 16:31:05 -0500 (Sun, 29 Mar 2009) | 1 line thanks to guido's bytecode verifier, this is fixed ........ r70700 | benjamin.peterson | 2009-03-29 16:50:14 -0500 (Sun, 29 Mar 2009) | 1 line use the awesome new status iterator ........ r70704 | benjamin.peterson | 2009-03-29 21:49:32 -0500 (Sun, 29 Mar 2009) | 1 line there's actually three methods here #5600 ........
17 years ago
Merged revisions 70578,70599,70641-70642,70650,70660-70661,70674,70691,70697-70698,70700,70704 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r70578 | benjamin.peterson | 2009-03-23 22:24:56 -0500 (Mon, 23 Mar 2009) | 1 line this is better written using assertRaises ........ r70599 | benjamin.peterson | 2009-03-25 16:42:51 -0500 (Wed, 25 Mar 2009) | 1 line this can be slightly less ugly ........ r70641 | guilherme.polo | 2009-03-27 16:43:08 -0500 (Fri, 27 Mar 2009) | 3 lines Adjusted _tkinter to compile without warnings when WITH_THREAD is not defined (part of issue #5035) ........ r70642 | georg.brandl | 2009-03-27 19:48:48 -0500 (Fri, 27 Mar 2009) | 1 line Fix typo. ........ r70650 | benjamin.peterson | 2009-03-28 14:16:10 -0500 (Sat, 28 Mar 2009) | 1 line give os.symlink and os.link() better parameter names #5564 ........ r70660 | georg.brandl | 2009-03-28 14:52:58 -0500 (Sat, 28 Mar 2009) | 1 line Switch to fixed Sphinx version. ........ r70661 | georg.brandl | 2009-03-28 14:57:36 -0500 (Sat, 28 Mar 2009) | 2 lines Add section numbering to some of the larger subdocuments. ........ r70674 | guilherme.polo | 2009-03-29 05:19:05 -0500 (Sun, 29 Mar 2009) | 1 line Typo fix. ........ r70691 | raymond.hettinger | 2009-03-29 13:51:11 -0500 (Sun, 29 Mar 2009) | 1 line Make life easier for non-CPython implementations. ........ r70697 | benjamin.peterson | 2009-03-29 16:22:35 -0500 (Sun, 29 Mar 2009) | 1 line this has been fixed since 2.6 (I love removing these) ........ r70698 | benjamin.peterson | 2009-03-29 16:31:05 -0500 (Sun, 29 Mar 2009) | 1 line thanks to guido's bytecode verifier, this is fixed ........ r70700 | benjamin.peterson | 2009-03-29 16:50:14 -0500 (Sun, 29 Mar 2009) | 1 line use the awesome new status iterator ........ r70704 | benjamin.peterson | 2009-03-29 21:49:32 -0500 (Sun, 29 Mar 2009) | 1 line there's actually three methods here #5600 ........
17 years ago
32 years ago
Merged revisions 70578,70599,70641-70642,70650,70660-70661,70674,70691,70697-70698,70700,70704 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r70578 | benjamin.peterson | 2009-03-23 22:24:56 -0500 (Mon, 23 Mar 2009) | 1 line this is better written using assertRaises ........ r70599 | benjamin.peterson | 2009-03-25 16:42:51 -0500 (Wed, 25 Mar 2009) | 1 line this can be slightly less ugly ........ r70641 | guilherme.polo | 2009-03-27 16:43:08 -0500 (Fri, 27 Mar 2009) | 3 lines Adjusted _tkinter to compile without warnings when WITH_THREAD is not defined (part of issue #5035) ........ r70642 | georg.brandl | 2009-03-27 19:48:48 -0500 (Fri, 27 Mar 2009) | 1 line Fix typo. ........ r70650 | benjamin.peterson | 2009-03-28 14:16:10 -0500 (Sat, 28 Mar 2009) | 1 line give os.symlink and os.link() better parameter names #5564 ........ r70660 | georg.brandl | 2009-03-28 14:52:58 -0500 (Sat, 28 Mar 2009) | 1 line Switch to fixed Sphinx version. ........ r70661 | georg.brandl | 2009-03-28 14:57:36 -0500 (Sat, 28 Mar 2009) | 2 lines Add section numbering to some of the larger subdocuments. ........ r70674 | guilherme.polo | 2009-03-29 05:19:05 -0500 (Sun, 29 Mar 2009) | 1 line Typo fix. ........ r70691 | raymond.hettinger | 2009-03-29 13:51:11 -0500 (Sun, 29 Mar 2009) | 1 line Make life easier for non-CPython implementations. ........ r70697 | benjamin.peterson | 2009-03-29 16:22:35 -0500 (Sun, 29 Mar 2009) | 1 line this has been fixed since 2.6 (I love removing these) ........ r70698 | benjamin.peterson | 2009-03-29 16:31:05 -0500 (Sun, 29 Mar 2009) | 1 line thanks to guido's bytecode verifier, this is fixed ........ r70700 | benjamin.peterson | 2009-03-29 16:50:14 -0500 (Sun, 29 Mar 2009) | 1 line use the awesome new status iterator ........ r70704 | benjamin.peterson | 2009-03-29 21:49:32 -0500 (Sun, 29 Mar 2009) | 1 line there's actually three methods here #5600 ........
17 years ago
Merged revisions 70578,70599,70641-70642,70650,70660-70661,70674,70691,70697-70698,70700,70704 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r70578 | benjamin.peterson | 2009-03-23 22:24:56 -0500 (Mon, 23 Mar 2009) | 1 line this is better written using assertRaises ........ r70599 | benjamin.peterson | 2009-03-25 16:42:51 -0500 (Wed, 25 Mar 2009) | 1 line this can be slightly less ugly ........ r70641 | guilherme.polo | 2009-03-27 16:43:08 -0500 (Fri, 27 Mar 2009) | 3 lines Adjusted _tkinter to compile without warnings when WITH_THREAD is not defined (part of issue #5035) ........ r70642 | georg.brandl | 2009-03-27 19:48:48 -0500 (Fri, 27 Mar 2009) | 1 line Fix typo. ........ r70650 | benjamin.peterson | 2009-03-28 14:16:10 -0500 (Sat, 28 Mar 2009) | 1 line give os.symlink and os.link() better parameter names #5564 ........ r70660 | georg.brandl | 2009-03-28 14:52:58 -0500 (Sat, 28 Mar 2009) | 1 line Switch to fixed Sphinx version. ........ r70661 | georg.brandl | 2009-03-28 14:57:36 -0500 (Sat, 28 Mar 2009) | 2 lines Add section numbering to some of the larger subdocuments. ........ r70674 | guilherme.polo | 2009-03-29 05:19:05 -0500 (Sun, 29 Mar 2009) | 1 line Typo fix. ........ r70691 | raymond.hettinger | 2009-03-29 13:51:11 -0500 (Sun, 29 Mar 2009) | 1 line Make life easier for non-CPython implementations. ........ r70697 | benjamin.peterson | 2009-03-29 16:22:35 -0500 (Sun, 29 Mar 2009) | 1 line this has been fixed since 2.6 (I love removing these) ........ r70698 | benjamin.peterson | 2009-03-29 16:31:05 -0500 (Sun, 29 Mar 2009) | 1 line thanks to guido's bytecode verifier, this is fixed ........ r70700 | benjamin.peterson | 2009-03-29 16:50:14 -0500 (Sun, 29 Mar 2009) | 1 line use the awesome new status iterator ........ r70704 | benjamin.peterson | 2009-03-29 21:49:32 -0500 (Sun, 29 Mar 2009) | 1 line there's actually three methods here #5600 ........
17 years ago
32 years ago
32 years ago
Merged revisions 70578,70599,70641-70642,70650,70660-70661,70674,70691,70697-70698,70700,70704 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r70578 | benjamin.peterson | 2009-03-23 22:24:56 -0500 (Mon, 23 Mar 2009) | 1 line this is better written using assertRaises ........ r70599 | benjamin.peterson | 2009-03-25 16:42:51 -0500 (Wed, 25 Mar 2009) | 1 line this can be slightly less ugly ........ r70641 | guilherme.polo | 2009-03-27 16:43:08 -0500 (Fri, 27 Mar 2009) | 3 lines Adjusted _tkinter to compile without warnings when WITH_THREAD is not defined (part of issue #5035) ........ r70642 | georg.brandl | 2009-03-27 19:48:48 -0500 (Fri, 27 Mar 2009) | 1 line Fix typo. ........ r70650 | benjamin.peterson | 2009-03-28 14:16:10 -0500 (Sat, 28 Mar 2009) | 1 line give os.symlink and os.link() better parameter names #5564 ........ r70660 | georg.brandl | 2009-03-28 14:52:58 -0500 (Sat, 28 Mar 2009) | 1 line Switch to fixed Sphinx version. ........ r70661 | georg.brandl | 2009-03-28 14:57:36 -0500 (Sat, 28 Mar 2009) | 2 lines Add section numbering to some of the larger subdocuments. ........ r70674 | guilherme.polo | 2009-03-29 05:19:05 -0500 (Sun, 29 Mar 2009) | 1 line Typo fix. ........ r70691 | raymond.hettinger | 2009-03-29 13:51:11 -0500 (Sun, 29 Mar 2009) | 1 line Make life easier for non-CPython implementations. ........ r70697 | benjamin.peterson | 2009-03-29 16:22:35 -0500 (Sun, 29 Mar 2009) | 1 line this has been fixed since 2.6 (I love removing these) ........ r70698 | benjamin.peterson | 2009-03-29 16:31:05 -0500 (Sun, 29 Mar 2009) | 1 line thanks to guido's bytecode verifier, this is fixed ........ r70700 | benjamin.peterson | 2009-03-29 16:50:14 -0500 (Sun, 29 Mar 2009) | 1 line use the awesome new status iterator ........ r70704 | benjamin.peterson | 2009-03-29 21:49:32 -0500 (Sun, 29 Mar 2009) | 1 line there's actually three methods here #5600 ........
17 years ago
Merged revisions 70578,70599,70641-70642,70650,70660-70661,70674,70691,70697-70698,70700,70704 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r70578 | benjamin.peterson | 2009-03-23 22:24:56 -0500 (Mon, 23 Mar 2009) | 1 line this is better written using assertRaises ........ r70599 | benjamin.peterson | 2009-03-25 16:42:51 -0500 (Wed, 25 Mar 2009) | 1 line this can be slightly less ugly ........ r70641 | guilherme.polo | 2009-03-27 16:43:08 -0500 (Fri, 27 Mar 2009) | 3 lines Adjusted _tkinter to compile without warnings when WITH_THREAD is not defined (part of issue #5035) ........ r70642 | georg.brandl | 2009-03-27 19:48:48 -0500 (Fri, 27 Mar 2009) | 1 line Fix typo. ........ r70650 | benjamin.peterson | 2009-03-28 14:16:10 -0500 (Sat, 28 Mar 2009) | 1 line give os.symlink and os.link() better parameter names #5564 ........ r70660 | georg.brandl | 2009-03-28 14:52:58 -0500 (Sat, 28 Mar 2009) | 1 line Switch to fixed Sphinx version. ........ r70661 | georg.brandl | 2009-03-28 14:57:36 -0500 (Sat, 28 Mar 2009) | 2 lines Add section numbering to some of the larger subdocuments. ........ r70674 | guilherme.polo | 2009-03-29 05:19:05 -0500 (Sun, 29 Mar 2009) | 1 line Typo fix. ........ r70691 | raymond.hettinger | 2009-03-29 13:51:11 -0500 (Sun, 29 Mar 2009) | 1 line Make life easier for non-CPython implementations. ........ r70697 | benjamin.peterson | 2009-03-29 16:22:35 -0500 (Sun, 29 Mar 2009) | 1 line this has been fixed since 2.6 (I love removing these) ........ r70698 | benjamin.peterson | 2009-03-29 16:31:05 -0500 (Sun, 29 Mar 2009) | 1 line thanks to guido's bytecode verifier, this is fixed ........ r70700 | benjamin.peterson | 2009-03-29 16:50:14 -0500 (Sun, 29 Mar 2009) | 1 line use the awesome new status iterator ........ r70704 | benjamin.peterson | 2009-03-29 21:49:32 -0500 (Sun, 29 Mar 2009) | 1 line there's actually three methods here #5600 ........
17 years ago
Merge the rest of the trunk. Merged revisions 46490-46494,46496,46498,46500,46506,46521,46538,46558,46563-46567,46570-46571,46583,46593,46595-46598,46604,46606,46609-46753 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r46610 | martin.v.loewis | 2006-06-03 09:42:26 +0200 (Sat, 03 Jun 2006) | 2 lines Updated version (win32-icons2.zip) from #1490384. ........ r46612 | andrew.kuchling | 2006-06-03 20:09:41 +0200 (Sat, 03 Jun 2006) | 1 line [Bug #1472084] Fix description of do_tag ........ r46614 | andrew.kuchling | 2006-06-03 20:33:35 +0200 (Sat, 03 Jun 2006) | 1 line [Bug #1475554] Strengthen text to say 'must' instead of 'should' ........ r46616 | andrew.kuchling | 2006-06-03 20:41:28 +0200 (Sat, 03 Jun 2006) | 1 line [Bug #1441864] Clarify description of 'data' argument ........ r46617 | andrew.kuchling | 2006-06-03 20:43:24 +0200 (Sat, 03 Jun 2006) | 1 line Minor rewording ........ r46619 | andrew.kuchling | 2006-06-03 21:02:35 +0200 (Sat, 03 Jun 2006) | 9 lines [Bug #1497414] _self is a reserved word in the WATCOM 10.6 C compiler. Fix by renaming the variable. In a different module, Neal fixed it by renaming _self to self. There's already a variable named 'self' here, so I used selfptr. (I'm committing this on a Mac without Tk, but it's a simple search-and-replace. <crosses fingers>, so I'll watch the buildbots and see what happens.) ........ r46621 | fredrik.lundh | 2006-06-03 23:56:05 +0200 (Sat, 03 Jun 2006) | 5 lines "_self" is a said to be a reserved word in Watcom C 10.6. I'm not sure that's really standard compliant behaviour, but I guess we have to fix that anyway... ........ r46622 | andrew.kuchling | 2006-06-04 00:44:42 +0200 (Sun, 04 Jun 2006) | 1 line Update readme ........ r46623 | andrew.kuchling | 2006-06-04 00:59:23 +0200 (Sun, 04 Jun 2006) | 1 line Drop 0 parameter ........ r46624 | andrew.kuchling | 2006-06-04 00:59:59 +0200 (Sun, 04 Jun 2006) | 1 line Some code tidying; use curses.wrapper ........ r46625 | andrew.kuchling | 2006-06-04 01:02:15 +0200 (Sun, 04 Jun 2006) | 1 line Use True; value returned from main is unused ........ r46626 | andrew.kuchling | 2006-06-04 01:07:21 +0200 (Sun, 04 Jun 2006) | 1 line Use true division, and the True value ........ r46627 | andrew.kuchling | 2006-06-04 01:09:58 +0200 (Sun, 04 Jun 2006) | 1 line Docstring fix; use True ........ r46628 | andrew.kuchling | 2006-06-04 01:15:56 +0200 (Sun, 04 Jun 2006) | 1 line Put code in a main() function; loosen up the spacing to match current code style ........ r46629 | andrew.kuchling | 2006-06-04 01:39:07 +0200 (Sun, 04 Jun 2006) | 1 line Use functions; modernize code ........ r46630 | andrew.kuchling | 2006-06-04 01:43:22 +0200 (Sun, 04 Jun 2006) | 1 line This demo requires Medusa (not just asyncore); remove it ........ r46631 | andrew.kuchling | 2006-06-04 01:46:36 +0200 (Sun, 04 Jun 2006) | 2 lines Remove xmlrpc demo -- it duplicates the SimpleXMLRPCServer module. ........ r46632 | andrew.kuchling | 2006-06-04 01:47:22 +0200 (Sun, 04 Jun 2006) | 1 line Remove xmlrpc/ directory ........ r46633 | andrew.kuchling | 2006-06-04 01:51:21 +0200 (Sun, 04 Jun 2006) | 1 line Remove dangling reference ........ r46634 | andrew.kuchling | 2006-06-04 01:59:36 +0200 (Sun, 04 Jun 2006) | 1 line Add more whitespace; use a better socket name ........ r46635 | tim.peters | 2006-06-04 03:22:53 +0200 (Sun, 04 Jun 2006) | 2 lines Whitespace normalization. ........ r46637 | tim.peters | 2006-06-04 05:26:02 +0200 (Sun, 04 Jun 2006) | 16 lines In a PYMALLOC_DEBUG build obmalloc adds extra debugging info to each allocated block. This was using 4 bytes for each such piece of info regardless of platform. This didn't really matter before (proof: no bug reports, and the debug-build obmalloc would have assert-failed if it was ever asked for a chunk of memory >= 2**32 bytes), since container indices were plain ints. But after the Py_ssize_t changes, it's at least theoretically possible to allocate a list or string whose guts exceed 2**32 bytes, and the PYMALLOC_DEBUG routines would fail then (having only 4 bytes to record the originally requested size). Now we use sizeof(size_t) bytes for each of a PYMALLOC_DEBUG build's extra debugging fields. This won't make any difference on 32-bit boxes, but will add 16 bytes to each allocation in a debug build on a 64-bit box. ........ r46638 | tim.peters | 2006-06-04 05:38:04 +0200 (Sun, 04 Jun 2006) | 4 lines _PyObject_DebugMalloc(): The return value should add 2*sizeof(size_t) now, not 8. This probably accounts for current disasters on the 64-bit buildbot slaves. ........ r46639 | neal.norwitz | 2006-06-04 08:19:31 +0200 (Sun, 04 Jun 2006) | 1 line SF #1499797, Fix for memory leak in WindowsError_str ........ r46640 | andrew.macintyre | 2006-06-04 14:31:09 +0200 (Sun, 04 Jun 2006) | 2 lines Patch #1454481: Make thread stack size runtime tunable. ........ r46641 | andrew.macintyre | 2006-06-04 14:59:59 +0200 (Sun, 04 Jun 2006) | 2 lines clean up function declarations to conform to PEP-7 style. ........ r46642 | martin.blais | 2006-06-04 15:49:49 +0200 (Sun, 04 Jun 2006) | 15 lines Fixes in struct and socket from merge reviews. - Following Guido's comments, renamed * pack_to -> pack_into * recv_buf -> recv_into * recvfrom_buf -> recvfrom_into - Made fixes to _struct.c according to Neal Norwitz comments on the checkins list. - Converted some ints into the appropriate -- I hope -- ssize_t and size_t. ........ r46643 | ronald.oussoren | 2006-06-04 16:05:28 +0200 (Sun, 04 Jun 2006) | 3 lines "Import" LDFLAGS in Mac/OSX/Makefile.in to ensure pythonw gets build with the right compiler flags. ........ r46644 | ronald.oussoren | 2006-06-04 16:24:59 +0200 (Sun, 04 Jun 2006) | 2 lines Drop Mac wrappers for the WASTE library. ........ r46645 | tim.peters | 2006-06-04 17:49:07 +0200 (Sun, 04 Jun 2006) | 3 lines s_methods[]: Stop compiler warnings by casting s_unpack_from to PyCFunction. ........ r46646 | george.yoshida | 2006-06-04 19:04:12 +0200 (Sun, 04 Jun 2006) | 2 lines Remove a redundant word ........ r46647 | george.yoshida | 2006-06-04 19:17:25 +0200 (Sun, 04 Jun 2006) | 2 lines Markup fix ........ r46648 | martin.v.loewis | 2006-06-04 21:36:28 +0200 (Sun, 04 Jun 2006) | 2 lines Patch #1359618: Speed-up charmap encoder. ........ r46649 | georg.brandl | 2006-06-04 23:46:16 +0200 (Sun, 04 Jun 2006) | 3 lines Repair refleaks in unicodeobject. ........ r46650 | georg.brandl | 2006-06-04 23:56:52 +0200 (Sun, 04 Jun 2006) | 4 lines Patch #1346214: correctly optimize away "if 0"-style stmts (thanks to Neal for review) ........ r46651 | georg.brandl | 2006-06-05 00:15:37 +0200 (Mon, 05 Jun 2006) | 2 lines Bug #1500293: fix memory leaks in _subprocess module. ........ r46654 | tim.peters | 2006-06-05 01:43:53 +0200 (Mon, 05 Jun 2006) | 2 lines Whitespace normalization. ........ r46655 | tim.peters | 2006-06-05 01:52:47 +0200 (Mon, 05 Jun 2006) | 16 lines Revert revisions: 46640 Patch #1454481: Make thread stack size runtime tunable. 46647 Markup fix The first is causing many buildbots to fail test runs, and there are multiple causes with seemingly no immediate prospects for repairing them. See python-dev discussion. Note that a branch can (and should) be created for resolving these problems, like svn copy svn+ssh://svn.python.org/python/trunk -r46640 svn+ssh://svn.python.org/python/branches/NEW_BRANCH followed by merging rev 46647 to the new branch. ........ r46656 | andrew.kuchling | 2006-06-05 02:08:09 +0200 (Mon, 05 Jun 2006) | 1 line Mention second encoding speedup ........ r46657 | gregory.p.smith | 2006-06-05 02:31:01 +0200 (Mon, 05 Jun 2006) | 7 lines bugfix: when log_archive was called with the DB_ARCH_REMOVE flag present in BerkeleyDB >= 4.2 it tried to construct a list out of an uninitialized char **log_list. feature: export the DB_ARCH_REMOVE flag by name in the module on BerkeleyDB >= 4.2. ........ r46658 | gregory.p.smith | 2006-06-05 02:33:35 +0200 (Mon, 05 Jun 2006) | 5 lines fix a bug in the previous commit. don't leak empty list on error return and fix the additional rare (out of memory only) bug that it was supposed to fix of not freeing log_list when the python allocator failed. ........ r46660 | tim.peters | 2006-06-05 02:55:26 +0200 (Mon, 05 Jun 2006) | 9 lines "Flat is better than nested." Move the long-winded, multiply-nested -R support out of runtest() and into some module-level helper functions. This makes runtest() and the -R code easier to follow. That in turn allowed seeing some opportunities for code simplification, and made it obvious that reglog.txt never got closed. ........ r46661 | hyeshik.chang | 2006-06-05 02:59:54 +0200 (Mon, 05 Jun 2006) | 3 lines Fix a potentially invalid memory access of CJKCodecs' shift-jis decoder. (found by Neal Norwitz) ........ r46663 | gregory.p.smith | 2006-06-05 03:39:52 +0200 (Mon, 05 Jun 2006) | 3 lines * support DBEnv.log_stat() method on BerkeleyDB >= 4.0 [patch #1494885] ........ r46664 | tim.peters | 2006-06-05 03:43:03 +0200 (Mon, 05 Jun 2006) | 3 lines Remove doctest.testmod's deprecated (in 2.4) `isprivate` argument. A lot of hair went into supporting that! ........ r46665 | tim.peters | 2006-06-05 03:47:24 +0200 (Mon, 05 Jun 2006) | 2 lines Whitespace normalization. ........ r46666 | tim.peters | 2006-06-05 03:48:21 +0200 (Mon, 05 Jun 2006) | 2 lines Make doctest news more accurate. ........ r46667 | gregory.p.smith | 2006-06-05 03:56:15 +0200 (Mon, 05 Jun 2006) | 3 lines * support DBEnv.lsn_reset() method on BerkeleyDB >= 4.4 [patch #1494902] ........ r46668 | gregory.p.smith | 2006-06-05 04:02:25 +0200 (Mon, 05 Jun 2006) | 3 lines mention the just committed bsddb changes ........ r46671 | gregory.p.smith | 2006-06-05 19:38:04 +0200 (Mon, 05 Jun 2006) | 3 lines * add support for DBSequence objects [patch #1466734] ........ r46672 | gregory.p.smith | 2006-06-05 20:20:07 +0200 (Mon, 05 Jun 2006) | 3 lines forgot to add this file in previous commit ........ r46673 | tim.peters | 2006-06-05 20:36:12 +0200 (Mon, 05 Jun 2006) | 2 lines Whitespace normalization. ........ r46674 | tim.peters | 2006-06-05 20:36:54 +0200 (Mon, 05 Jun 2006) | 2 lines Add missing svn:eol-style property to text files. ........ r46675 | gregory.p.smith | 2006-06-05 20:48:21 +0200 (Mon, 05 Jun 2006) | 4 lines * fix DBCursor.pget() bug with keyword argument names when no data= is supplied [SF pybsddb bug #1477863] ........ r46676 | andrew.kuchling | 2006-06-05 21:05:32 +0200 (Mon, 05 Jun 2006) | 1 line Remove use of Trove name, which isn't very helpful to users ........ r46677 | andrew.kuchling | 2006-06-05 21:08:25 +0200 (Mon, 05 Jun 2006) | 1 line [Bug #1470026] Include link to list of classifiers ........ r46679 | tim.peters | 2006-06-05 22:48:49 +0200 (Mon, 05 Jun 2006) | 10 lines Access _struct attributes directly instead of mucking with getattr. string_reverse(): Simplify. assertRaises(): Raise TestFailed on failure. test_unpack_from(), test_pack_into(), test_pack_into_fn(): never use `assert` to test for an expected result (it doesn't test anything when Python is run with -O). ........ r46680 | tim.peters | 2006-06-05 22:49:27 +0200 (Mon, 05 Jun 2006) | 2 lines Add missing svn:eol-style property to text files. ........ r46681 | gregory.p.smith | 2006-06-06 01:38:06 +0200 (Tue, 06 Jun 2006) | 3 lines add depends = ['md5.h'] to the _md5 module extension for correctness sake. ........ r46682 | brett.cannon | 2006-06-06 01:51:55 +0200 (Tue, 06 Jun 2006) | 4 lines Add 3 more bytes to a buffer to cover constants in string and null byte on top of 10 possible digits for an int. Closes bug #1501223. ........ r46684 | gregory.p.smith | 2006-06-06 01:59:37 +0200 (Tue, 06 Jun 2006) | 5 lines - bsddb: the __len__ method of a DB object has been fixed to return correct results. It could previously incorrectly return 0 in some cases. Fixes SF bug 1493322 (pybsddb bug 1184012). ........ r46686 | tim.peters | 2006-06-06 02:25:07 +0200 (Tue, 06 Jun 2006) | 7 lines _PySys_Init(): It's rarely a good idea to size a buffer to the exact maximum size someone guesses is needed. In this case, if we're really worried about extreme integers, then "cp%d" can actually need 14 bytes (2 for "cp" + 1 for \0 at the end + 11 for -(2**31-1)). So reserve 128 bytes instead -- nothing is actually saved by making a stack-local buffer tiny. ........ r46687 | neal.norwitz | 2006-06-06 09:22:08 +0200 (Tue, 06 Jun 2006) | 1 line Remove unused variable (and stop compiler warning) ........ r46688 | neal.norwitz | 2006-06-06 09:23:01 +0200 (Tue, 06 Jun 2006) | 1 line Fix a bunch of parameter strings ........ r46689 | thomas.heller | 2006-06-06 13:34:33 +0200 (Tue, 06 Jun 2006) | 6 lines Convert CFieldObject tp_members to tp_getset, since there is no structmember typecode for Py_ssize_t fields. This should fix some of the errors on the PPC64 debian machine (64-bit, big endian). Assigning to readonly fields now raises AttributeError instead of TypeError, so the testcase has to be changed as well. ........ r46690 | thomas.heller | 2006-06-06 13:54:32 +0200 (Tue, 06 Jun 2006) | 1 line Damn - the sentinel was missing. And fix another silly mistake. ........ r46691 | martin.blais | 2006-06-06 14:46:55 +0200 (Tue, 06 Jun 2006) | 13 lines Normalized a few cases of whitespace in function declarations. Found them using:: find . -name '*.py' | while read i ; do grep 'def[^(]*( ' $i /dev/null ; done find . -name '*.py' | while read i ; do grep ' ):' $i /dev/null ; done (I was doing this all over my own code anyway, because I'd been using spaces in all defs, so I thought I'd make a run on the Python code as well. If you need to do such fixes in your own code, you can use xx-rename or parenregu.el within emacs.) ........ r46693 | thomas.heller | 2006-06-06 17:34:18 +0200 (Tue, 06 Jun 2006) | 1 line Specify argtypes for all test functions. Maybe that helps on strange ;-) architectures ........ r46694 | tim.peters | 2006-06-06 17:50:17 +0200 (Tue, 06 Jun 2006) | 5 lines BSequence_set_range(): Rev 46688 ("Fix a bunch of parameter strings") changed this function's signature seemingly by mistake, which is causing buildbots to fail test_bsddb3. Restored the pre-46688 signature. ........ r46695 | tim.peters | 2006-06-06 17:52:35 +0200 (Tue, 06 Jun 2006) | 4 lines On python-dev Thomas Heller said these were committed by mistake in rev 46693, so reverting this part of rev 46693. ........ r46696 | andrew.kuchling | 2006-06-06 19:10:41 +0200 (Tue, 06 Jun 2006) | 1 line Fix comment typo ........ r46697 | brett.cannon | 2006-06-06 20:08:16 +0200 (Tue, 06 Jun 2006) | 2 lines Fix coding style guide bug. ........ r46698 | thomas.heller | 2006-06-06 20:50:46 +0200 (Tue, 06 Jun 2006) | 2 lines Add a hack so that foreign functions returning float now do work on 64-bit big endian platforms. ........ r46699 | thomas.heller | 2006-06-06 21:25:13 +0200 (Tue, 06 Jun 2006) | 3 lines Use the same big-endian hack as in _ctypes/callproc.c for callback functions. This fixes the callback function tests that return float. ........ r46700 | ronald.oussoren | 2006-06-06 21:50:24 +0200 (Tue, 06 Jun 2006) | 5 lines * Ensure that "make altinstall" works when the tree was configured with --enable-framework * Also for --enable-framework: allow users to use --prefix to specify the location of the compatibility symlinks (such as /usr/local/bin/python) ........ r46701 | ronald.oussoren | 2006-06-06 21:56:00 +0200 (Tue, 06 Jun 2006) | 3 lines A quick hack to ensure the right key-bindings for IDLE on osx: install patched configuration files during a framework install. ........ r46702 | tim.peters | 2006-06-07 03:04:59 +0200 (Wed, 07 Jun 2006) | 4 lines dash_R_cleanup(): Clear filecmp._cache. This accounts for different results across -R runs (at least on Windows) of test_filecmp. ........ r46705 | tim.peters | 2006-06-07 08:57:51 +0200 (Wed, 07 Jun 2006) | 17 lines SF patch 1501987: Remove randomness from test_exceptions, from ?iga Seilnacht (sorry about the name, but Firefox on my box can't display the first character of the name -- the SF "Unix name" is zseil). This appears to cure the oddball intermittent leaks across runs when running test_exceptions under -R. I'm not sure why, but I'm too sleepy to care ;-) The thrust of the SF patch was to remove randomness in the pickle protocol used. I changed the patch to use range(pickle.HIGHEST_PROTOCOL + 1), to try both pickle and cPickle, and randomly mucked with other test lines to put statements on their own lines. Not a bugfix candidate (this is fiddling new-in-2.5 code). ........ r46706 | andrew.kuchling | 2006-06-07 15:55:33 +0200 (Wed, 07 Jun 2006) | 1 line Add an SQLite introduction, taken from the 'What's New' text ........ r46708 | andrew.kuchling | 2006-06-07 19:02:52 +0200 (Wed, 07 Jun 2006) | 1 line Mention other placeholders ........ r46709 | andrew.kuchling | 2006-06-07 19:03:46 +0200 (Wed, 07 Jun 2006) | 1 line Add an item; also, escape % ........ r46710 | andrew.kuchling | 2006-06-07 19:04:01 +0200 (Wed, 07 Jun 2006) | 1 line Mention other placeholders ........ r46716 | ronald.oussoren | 2006-06-07 20:57:44 +0200 (Wed, 07 Jun 2006) | 2 lines Move Mac/OSX/Tools one level up ........ r46717 | ronald.oussoren | 2006-06-07 20:58:01 +0200 (Wed, 07 Jun 2006) | 2 lines Move Mac/OSX/PythonLauncher one level up ........ r46718 | ronald.oussoren | 2006-06-07 20:58:42 +0200 (Wed, 07 Jun 2006) | 2 lines mv Mac/OSX/BuildScript one level up ........ r46719 | ronald.oussoren | 2006-06-07 21:02:03 +0200 (Wed, 07 Jun 2006) | 2 lines Move Mac/OSX/* one level up ........ r46720 | ronald.oussoren | 2006-06-07 21:06:01 +0200 (Wed, 07 Jun 2006) | 2 lines And the last bit: move IDLE one level up and adjust makefiles ........ r46723 | ronald.oussoren | 2006-06-07 21:38:53 +0200 (Wed, 07 Jun 2006) | 4 lines - Patch the correct version of python in the Info.plists at build time, instead of relying on a maintainer to update them before releases. - Remove the now empty Mac/OSX directory ........ r46727 | ronald.oussoren | 2006-06-07 22:18:44 +0200 (Wed, 07 Jun 2006) | 7 lines * If BuildApplet.py is used as an applet it starts with a version of sys.exutable that isn't usuable on an #!-line. That results in generated applets that don't actually work. Work around this problem by resetting sys.executable. * argvemulator.py didn't work on intel macs. This patch fixes this (bug #1491468) ........ r46728 | tim.peters | 2006-06-07 22:40:06 +0200 (Wed, 07 Jun 2006) | 2 lines Whitespace normalization. ........ r46729 | tim.peters | 2006-06-07 22:40:54 +0200 (Wed, 07 Jun 2006) | 2 lines Add missing svn:eol-style property to text files. ........ r46730 | thomas.heller | 2006-06-07 22:43:06 +0200 (Wed, 07 Jun 2006) | 7 lines Fix for foreign functions returning small structures on 64-bit big endian machines. Should fix the remaininf failure in the PPC64 Debian buildbot. Thanks to Matthias Klose for providing access to a machine to debug and test this. ........ r46731 | brett.cannon | 2006-06-07 23:48:17 +0200 (Wed, 07 Jun 2006) | 2 lines Clarify documentation for bf_getcharbuffer. ........ r46735 | neal.norwitz | 2006-06-08 07:12:45 +0200 (Thu, 08 Jun 2006) | 1 line Fix a refleak in recvfrom_into ........ r46736 | gregory.p.smith | 2006-06-08 07:17:08 +0200 (Thu, 08 Jun 2006) | 9 lines - bsddb: the bsddb.dbtables Modify method now raises the proper error and aborts the db transaction safely when a modifier callback fails. Fixes SF python patch/bug #1408584. Also cleans up the bsddb.dbtables docstrings since thats the only documentation that exists for that unadvertised module. (people really should really just use sqlite3) ........ r46737 | gregory.p.smith | 2006-06-08 07:38:11 +0200 (Thu, 08 Jun 2006) | 4 lines * Turn the deadlock situation described in SF bug #775414 into a DBDeadLockError exception. * add the test case for my previous dbtables commit. ........ r46738 | gregory.p.smith | 2006-06-08 07:39:54 +0200 (Thu, 08 Jun 2006) | 2 lines pasted set_lk_detect line in wrong spot in previous commit. fixed. passes tests this time. ........ r46739 | armin.rigo | 2006-06-08 12:56:24 +0200 (Thu, 08 Jun 2006) | 6 lines (arre, arigo) SF bug #1350060 Give a consistent behavior for comparison and hashing of method objects (both user- and built-in methods). Now compares the 'self' recursively. The hash was already asking for the hash of 'self'. ........ r46740 | andrew.kuchling | 2006-06-08 13:56:44 +0200 (Thu, 08 Jun 2006) | 1 line Typo fix ........ r46741 | georg.brandl | 2006-06-08 14:45:01 +0200 (Thu, 08 Jun 2006) | 2 lines Bug #1502750: Fix getargs "i" format to use LONG_MIN and LONG_MAX for bounds checking. ........ r46743 | georg.brandl | 2006-06-08 14:54:13 +0200 (Thu, 08 Jun 2006) | 2 lines Bug #1502728: Correctly link against librt library on HP-UX. ........ r46745 | georg.brandl | 2006-06-08 14:55:47 +0200 (Thu, 08 Jun 2006) | 3 lines Add news for recent bugfix. ........ r46746 | georg.brandl | 2006-06-08 15:31:07 +0200 (Thu, 08 Jun 2006) | 4 lines Argh. "integer" is a very confusing word ;) Actually, checking for INT_MAX and INT_MIN is correct since the format code explicitly handles a C "int". ........ r46748 | nick.coghlan | 2006-06-08 15:54:49 +0200 (Thu, 08 Jun 2006) | 1 line Add functools.update_wrapper() and functools.wraps() as described in PEP 356 ........ r46751 | georg.brandl | 2006-06-08 16:50:21 +0200 (Thu, 08 Jun 2006) | 4 lines Bug #1502805: don't alias file.__exit__ to file.close since the latter can return something that's true. ........ r46752 | georg.brandl | 2006-06-08 16:50:53 +0200 (Thu, 08 Jun 2006) | 3 lines Convert test_file to unittest. ........
20 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
Merged revisions 70578,70599,70641-70642,70650,70660-70661,70674,70691,70697-70698,70700,70704 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r70578 | benjamin.peterson | 2009-03-23 22:24:56 -0500 (Mon, 23 Mar 2009) | 1 line this is better written using assertRaises ........ r70599 | benjamin.peterson | 2009-03-25 16:42:51 -0500 (Wed, 25 Mar 2009) | 1 line this can be slightly less ugly ........ r70641 | guilherme.polo | 2009-03-27 16:43:08 -0500 (Fri, 27 Mar 2009) | 3 lines Adjusted _tkinter to compile without warnings when WITH_THREAD is not defined (part of issue #5035) ........ r70642 | georg.brandl | 2009-03-27 19:48:48 -0500 (Fri, 27 Mar 2009) | 1 line Fix typo. ........ r70650 | benjamin.peterson | 2009-03-28 14:16:10 -0500 (Sat, 28 Mar 2009) | 1 line give os.symlink and os.link() better parameter names #5564 ........ r70660 | georg.brandl | 2009-03-28 14:52:58 -0500 (Sat, 28 Mar 2009) | 1 line Switch to fixed Sphinx version. ........ r70661 | georg.brandl | 2009-03-28 14:57:36 -0500 (Sat, 28 Mar 2009) | 2 lines Add section numbering to some of the larger subdocuments. ........ r70674 | guilherme.polo | 2009-03-29 05:19:05 -0500 (Sun, 29 Mar 2009) | 1 line Typo fix. ........ r70691 | raymond.hettinger | 2009-03-29 13:51:11 -0500 (Sun, 29 Mar 2009) | 1 line Make life easier for non-CPython implementations. ........ r70697 | benjamin.peterson | 2009-03-29 16:22:35 -0500 (Sun, 29 Mar 2009) | 1 line this has been fixed since 2.6 (I love removing these) ........ r70698 | benjamin.peterson | 2009-03-29 16:31:05 -0500 (Sun, 29 Mar 2009) | 1 line thanks to guido's bytecode verifier, this is fixed ........ r70700 | benjamin.peterson | 2009-03-29 16:50:14 -0500 (Sun, 29 Mar 2009) | 1 line use the awesome new status iterator ........ r70704 | benjamin.peterson | 2009-03-29 21:49:32 -0500 (Sun, 29 Mar 2009) | 1 line there's actually three methods here #5600 ........
17 years ago
Merged revisions 70578,70599,70641-70642,70650,70660-70661,70674,70691,70697-70698,70700,70704 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r70578 | benjamin.peterson | 2009-03-23 22:24:56 -0500 (Mon, 23 Mar 2009) | 1 line this is better written using assertRaises ........ r70599 | benjamin.peterson | 2009-03-25 16:42:51 -0500 (Wed, 25 Mar 2009) | 1 line this can be slightly less ugly ........ r70641 | guilherme.polo | 2009-03-27 16:43:08 -0500 (Fri, 27 Mar 2009) | 3 lines Adjusted _tkinter to compile without warnings when WITH_THREAD is not defined (part of issue #5035) ........ r70642 | georg.brandl | 2009-03-27 19:48:48 -0500 (Fri, 27 Mar 2009) | 1 line Fix typo. ........ r70650 | benjamin.peterson | 2009-03-28 14:16:10 -0500 (Sat, 28 Mar 2009) | 1 line give os.symlink and os.link() better parameter names #5564 ........ r70660 | georg.brandl | 2009-03-28 14:52:58 -0500 (Sat, 28 Mar 2009) | 1 line Switch to fixed Sphinx version. ........ r70661 | georg.brandl | 2009-03-28 14:57:36 -0500 (Sat, 28 Mar 2009) | 2 lines Add section numbering to some of the larger subdocuments. ........ r70674 | guilherme.polo | 2009-03-29 05:19:05 -0500 (Sun, 29 Mar 2009) | 1 line Typo fix. ........ r70691 | raymond.hettinger | 2009-03-29 13:51:11 -0500 (Sun, 29 Mar 2009) | 1 line Make life easier for non-CPython implementations. ........ r70697 | benjamin.peterson | 2009-03-29 16:22:35 -0500 (Sun, 29 Mar 2009) | 1 line this has been fixed since 2.6 (I love removing these) ........ r70698 | benjamin.peterson | 2009-03-29 16:31:05 -0500 (Sun, 29 Mar 2009) | 1 line thanks to guido's bytecode verifier, this is fixed ........ r70700 | benjamin.peterson | 2009-03-29 16:50:14 -0500 (Sun, 29 Mar 2009) | 1 line use the awesome new status iterator ........ r70704 | benjamin.peterson | 2009-03-29 21:49:32 -0500 (Sun, 29 Mar 2009) | 1 line there's actually three methods here #5600 ........
17 years ago
Merged revisions 70578,70599,70641-70642,70650,70660-70661,70674,70691,70697-70698,70700,70704 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r70578 | benjamin.peterson | 2009-03-23 22:24:56 -0500 (Mon, 23 Mar 2009) | 1 line this is better written using assertRaises ........ r70599 | benjamin.peterson | 2009-03-25 16:42:51 -0500 (Wed, 25 Mar 2009) | 1 line this can be slightly less ugly ........ r70641 | guilherme.polo | 2009-03-27 16:43:08 -0500 (Fri, 27 Mar 2009) | 3 lines Adjusted _tkinter to compile without warnings when WITH_THREAD is not defined (part of issue #5035) ........ r70642 | georg.brandl | 2009-03-27 19:48:48 -0500 (Fri, 27 Mar 2009) | 1 line Fix typo. ........ r70650 | benjamin.peterson | 2009-03-28 14:16:10 -0500 (Sat, 28 Mar 2009) | 1 line give os.symlink and os.link() better parameter names #5564 ........ r70660 | georg.brandl | 2009-03-28 14:52:58 -0500 (Sat, 28 Mar 2009) | 1 line Switch to fixed Sphinx version. ........ r70661 | georg.brandl | 2009-03-28 14:57:36 -0500 (Sat, 28 Mar 2009) | 2 lines Add section numbering to some of the larger subdocuments. ........ r70674 | guilherme.polo | 2009-03-29 05:19:05 -0500 (Sun, 29 Mar 2009) | 1 line Typo fix. ........ r70691 | raymond.hettinger | 2009-03-29 13:51:11 -0500 (Sun, 29 Mar 2009) | 1 line Make life easier for non-CPython implementations. ........ r70697 | benjamin.peterson | 2009-03-29 16:22:35 -0500 (Sun, 29 Mar 2009) | 1 line this has been fixed since 2.6 (I love removing these) ........ r70698 | benjamin.peterson | 2009-03-29 16:31:05 -0500 (Sun, 29 Mar 2009) | 1 line thanks to guido's bytecode verifier, this is fixed ........ r70700 | benjamin.peterson | 2009-03-29 16:50:14 -0500 (Sun, 29 Mar 2009) | 1 line use the awesome new status iterator ........ r70704 | benjamin.peterson | 2009-03-29 21:49:32 -0500 (Sun, 29 Mar 2009) | 1 line there's actually three methods here #5600 ........
17 years ago
Merged revisions 70578,70599,70641-70642,70650,70660-70661,70674,70691,70697-70698,70700,70704 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r70578 | benjamin.peterson | 2009-03-23 22:24:56 -0500 (Mon, 23 Mar 2009) | 1 line this is better written using assertRaises ........ r70599 | benjamin.peterson | 2009-03-25 16:42:51 -0500 (Wed, 25 Mar 2009) | 1 line this can be slightly less ugly ........ r70641 | guilherme.polo | 2009-03-27 16:43:08 -0500 (Fri, 27 Mar 2009) | 3 lines Adjusted _tkinter to compile without warnings when WITH_THREAD is not defined (part of issue #5035) ........ r70642 | georg.brandl | 2009-03-27 19:48:48 -0500 (Fri, 27 Mar 2009) | 1 line Fix typo. ........ r70650 | benjamin.peterson | 2009-03-28 14:16:10 -0500 (Sat, 28 Mar 2009) | 1 line give os.symlink and os.link() better parameter names #5564 ........ r70660 | georg.brandl | 2009-03-28 14:52:58 -0500 (Sat, 28 Mar 2009) | 1 line Switch to fixed Sphinx version. ........ r70661 | georg.brandl | 2009-03-28 14:57:36 -0500 (Sat, 28 Mar 2009) | 2 lines Add section numbering to some of the larger subdocuments. ........ r70674 | guilherme.polo | 2009-03-29 05:19:05 -0500 (Sun, 29 Mar 2009) | 1 line Typo fix. ........ r70691 | raymond.hettinger | 2009-03-29 13:51:11 -0500 (Sun, 29 Mar 2009) | 1 line Make life easier for non-CPython implementations. ........ r70697 | benjamin.peterson | 2009-03-29 16:22:35 -0500 (Sun, 29 Mar 2009) | 1 line this has been fixed since 2.6 (I love removing these) ........ r70698 | benjamin.peterson | 2009-03-29 16:31:05 -0500 (Sun, 29 Mar 2009) | 1 line thanks to guido's bytecode verifier, this is fixed ........ r70700 | benjamin.peterson | 2009-03-29 16:50:14 -0500 (Sun, 29 Mar 2009) | 1 line use the awesome new status iterator ........ r70704 | benjamin.peterson | 2009-03-29 21:49:32 -0500 (Sun, 29 Mar 2009) | 1 line there's actually three methods here #5600 ........
17 years ago
Merge the rest of the trunk. Merged revisions 46490-46494,46496,46498,46500,46506,46521,46538,46558,46563-46567,46570-46571,46583,46593,46595-46598,46604,46606,46609-46753 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r46610 | martin.v.loewis | 2006-06-03 09:42:26 +0200 (Sat, 03 Jun 2006) | 2 lines Updated version (win32-icons2.zip) from #1490384. ........ r46612 | andrew.kuchling | 2006-06-03 20:09:41 +0200 (Sat, 03 Jun 2006) | 1 line [Bug #1472084] Fix description of do_tag ........ r46614 | andrew.kuchling | 2006-06-03 20:33:35 +0200 (Sat, 03 Jun 2006) | 1 line [Bug #1475554] Strengthen text to say 'must' instead of 'should' ........ r46616 | andrew.kuchling | 2006-06-03 20:41:28 +0200 (Sat, 03 Jun 2006) | 1 line [Bug #1441864] Clarify description of 'data' argument ........ r46617 | andrew.kuchling | 2006-06-03 20:43:24 +0200 (Sat, 03 Jun 2006) | 1 line Minor rewording ........ r46619 | andrew.kuchling | 2006-06-03 21:02:35 +0200 (Sat, 03 Jun 2006) | 9 lines [Bug #1497414] _self is a reserved word in the WATCOM 10.6 C compiler. Fix by renaming the variable. In a different module, Neal fixed it by renaming _self to self. There's already a variable named 'self' here, so I used selfptr. (I'm committing this on a Mac without Tk, but it's a simple search-and-replace. <crosses fingers>, so I'll watch the buildbots and see what happens.) ........ r46621 | fredrik.lundh | 2006-06-03 23:56:05 +0200 (Sat, 03 Jun 2006) | 5 lines "_self" is a said to be a reserved word in Watcom C 10.6. I'm not sure that's really standard compliant behaviour, but I guess we have to fix that anyway... ........ r46622 | andrew.kuchling | 2006-06-04 00:44:42 +0200 (Sun, 04 Jun 2006) | 1 line Update readme ........ r46623 | andrew.kuchling | 2006-06-04 00:59:23 +0200 (Sun, 04 Jun 2006) | 1 line Drop 0 parameter ........ r46624 | andrew.kuchling | 2006-06-04 00:59:59 +0200 (Sun, 04 Jun 2006) | 1 line Some code tidying; use curses.wrapper ........ r46625 | andrew.kuchling | 2006-06-04 01:02:15 +0200 (Sun, 04 Jun 2006) | 1 line Use True; value returned from main is unused ........ r46626 | andrew.kuchling | 2006-06-04 01:07:21 +0200 (Sun, 04 Jun 2006) | 1 line Use true division, and the True value ........ r46627 | andrew.kuchling | 2006-06-04 01:09:58 +0200 (Sun, 04 Jun 2006) | 1 line Docstring fix; use True ........ r46628 | andrew.kuchling | 2006-06-04 01:15:56 +0200 (Sun, 04 Jun 2006) | 1 line Put code in a main() function; loosen up the spacing to match current code style ........ r46629 | andrew.kuchling | 2006-06-04 01:39:07 +0200 (Sun, 04 Jun 2006) | 1 line Use functions; modernize code ........ r46630 | andrew.kuchling | 2006-06-04 01:43:22 +0200 (Sun, 04 Jun 2006) | 1 line This demo requires Medusa (not just asyncore); remove it ........ r46631 | andrew.kuchling | 2006-06-04 01:46:36 +0200 (Sun, 04 Jun 2006) | 2 lines Remove xmlrpc demo -- it duplicates the SimpleXMLRPCServer module. ........ r46632 | andrew.kuchling | 2006-06-04 01:47:22 +0200 (Sun, 04 Jun 2006) | 1 line Remove xmlrpc/ directory ........ r46633 | andrew.kuchling | 2006-06-04 01:51:21 +0200 (Sun, 04 Jun 2006) | 1 line Remove dangling reference ........ r46634 | andrew.kuchling | 2006-06-04 01:59:36 +0200 (Sun, 04 Jun 2006) | 1 line Add more whitespace; use a better socket name ........ r46635 | tim.peters | 2006-06-04 03:22:53 +0200 (Sun, 04 Jun 2006) | 2 lines Whitespace normalization. ........ r46637 | tim.peters | 2006-06-04 05:26:02 +0200 (Sun, 04 Jun 2006) | 16 lines In a PYMALLOC_DEBUG build obmalloc adds extra debugging info to each allocated block. This was using 4 bytes for each such piece of info regardless of platform. This didn't really matter before (proof: no bug reports, and the debug-build obmalloc would have assert-failed if it was ever asked for a chunk of memory >= 2**32 bytes), since container indices were plain ints. But after the Py_ssize_t changes, it's at least theoretically possible to allocate a list or string whose guts exceed 2**32 bytes, and the PYMALLOC_DEBUG routines would fail then (having only 4 bytes to record the originally requested size). Now we use sizeof(size_t) bytes for each of a PYMALLOC_DEBUG build's extra debugging fields. This won't make any difference on 32-bit boxes, but will add 16 bytes to each allocation in a debug build on a 64-bit box. ........ r46638 | tim.peters | 2006-06-04 05:38:04 +0200 (Sun, 04 Jun 2006) | 4 lines _PyObject_DebugMalloc(): The return value should add 2*sizeof(size_t) now, not 8. This probably accounts for current disasters on the 64-bit buildbot slaves. ........ r46639 | neal.norwitz | 2006-06-04 08:19:31 +0200 (Sun, 04 Jun 2006) | 1 line SF #1499797, Fix for memory leak in WindowsError_str ........ r46640 | andrew.macintyre | 2006-06-04 14:31:09 +0200 (Sun, 04 Jun 2006) | 2 lines Patch #1454481: Make thread stack size runtime tunable. ........ r46641 | andrew.macintyre | 2006-06-04 14:59:59 +0200 (Sun, 04 Jun 2006) | 2 lines clean up function declarations to conform to PEP-7 style. ........ r46642 | martin.blais | 2006-06-04 15:49:49 +0200 (Sun, 04 Jun 2006) | 15 lines Fixes in struct and socket from merge reviews. - Following Guido's comments, renamed * pack_to -> pack_into * recv_buf -> recv_into * recvfrom_buf -> recvfrom_into - Made fixes to _struct.c according to Neal Norwitz comments on the checkins list. - Converted some ints into the appropriate -- I hope -- ssize_t and size_t. ........ r46643 | ronald.oussoren | 2006-06-04 16:05:28 +0200 (Sun, 04 Jun 2006) | 3 lines "Import" LDFLAGS in Mac/OSX/Makefile.in to ensure pythonw gets build with the right compiler flags. ........ r46644 | ronald.oussoren | 2006-06-04 16:24:59 +0200 (Sun, 04 Jun 2006) | 2 lines Drop Mac wrappers for the WASTE library. ........ r46645 | tim.peters | 2006-06-04 17:49:07 +0200 (Sun, 04 Jun 2006) | 3 lines s_methods[]: Stop compiler warnings by casting s_unpack_from to PyCFunction. ........ r46646 | george.yoshida | 2006-06-04 19:04:12 +0200 (Sun, 04 Jun 2006) | 2 lines Remove a redundant word ........ r46647 | george.yoshida | 2006-06-04 19:17:25 +0200 (Sun, 04 Jun 2006) | 2 lines Markup fix ........ r46648 | martin.v.loewis | 2006-06-04 21:36:28 +0200 (Sun, 04 Jun 2006) | 2 lines Patch #1359618: Speed-up charmap encoder. ........ r46649 | georg.brandl | 2006-06-04 23:46:16 +0200 (Sun, 04 Jun 2006) | 3 lines Repair refleaks in unicodeobject. ........ r46650 | georg.brandl | 2006-06-04 23:56:52 +0200 (Sun, 04 Jun 2006) | 4 lines Patch #1346214: correctly optimize away "if 0"-style stmts (thanks to Neal for review) ........ r46651 | georg.brandl | 2006-06-05 00:15:37 +0200 (Mon, 05 Jun 2006) | 2 lines Bug #1500293: fix memory leaks in _subprocess module. ........ r46654 | tim.peters | 2006-06-05 01:43:53 +0200 (Mon, 05 Jun 2006) | 2 lines Whitespace normalization. ........ r46655 | tim.peters | 2006-06-05 01:52:47 +0200 (Mon, 05 Jun 2006) | 16 lines Revert revisions: 46640 Patch #1454481: Make thread stack size runtime tunable. 46647 Markup fix The first is causing many buildbots to fail test runs, and there are multiple causes with seemingly no immediate prospects for repairing them. See python-dev discussion. Note that a branch can (and should) be created for resolving these problems, like svn copy svn+ssh://svn.python.org/python/trunk -r46640 svn+ssh://svn.python.org/python/branches/NEW_BRANCH followed by merging rev 46647 to the new branch. ........ r46656 | andrew.kuchling | 2006-06-05 02:08:09 +0200 (Mon, 05 Jun 2006) | 1 line Mention second encoding speedup ........ r46657 | gregory.p.smith | 2006-06-05 02:31:01 +0200 (Mon, 05 Jun 2006) | 7 lines bugfix: when log_archive was called with the DB_ARCH_REMOVE flag present in BerkeleyDB >= 4.2 it tried to construct a list out of an uninitialized char **log_list. feature: export the DB_ARCH_REMOVE flag by name in the module on BerkeleyDB >= 4.2. ........ r46658 | gregory.p.smith | 2006-06-05 02:33:35 +0200 (Mon, 05 Jun 2006) | 5 lines fix a bug in the previous commit. don't leak empty list on error return and fix the additional rare (out of memory only) bug that it was supposed to fix of not freeing log_list when the python allocator failed. ........ r46660 | tim.peters | 2006-06-05 02:55:26 +0200 (Mon, 05 Jun 2006) | 9 lines "Flat is better than nested." Move the long-winded, multiply-nested -R support out of runtest() and into some module-level helper functions. This makes runtest() and the -R code easier to follow. That in turn allowed seeing some opportunities for code simplification, and made it obvious that reglog.txt never got closed. ........ r46661 | hyeshik.chang | 2006-06-05 02:59:54 +0200 (Mon, 05 Jun 2006) | 3 lines Fix a potentially invalid memory access of CJKCodecs' shift-jis decoder. (found by Neal Norwitz) ........ r46663 | gregory.p.smith | 2006-06-05 03:39:52 +0200 (Mon, 05 Jun 2006) | 3 lines * support DBEnv.log_stat() method on BerkeleyDB >= 4.0 [patch #1494885] ........ r46664 | tim.peters | 2006-06-05 03:43:03 +0200 (Mon, 05 Jun 2006) | 3 lines Remove doctest.testmod's deprecated (in 2.4) `isprivate` argument. A lot of hair went into supporting that! ........ r46665 | tim.peters | 2006-06-05 03:47:24 +0200 (Mon, 05 Jun 2006) | 2 lines Whitespace normalization. ........ r46666 | tim.peters | 2006-06-05 03:48:21 +0200 (Mon, 05 Jun 2006) | 2 lines Make doctest news more accurate. ........ r46667 | gregory.p.smith | 2006-06-05 03:56:15 +0200 (Mon, 05 Jun 2006) | 3 lines * support DBEnv.lsn_reset() method on BerkeleyDB >= 4.4 [patch #1494902] ........ r46668 | gregory.p.smith | 2006-06-05 04:02:25 +0200 (Mon, 05 Jun 2006) | 3 lines mention the just committed bsddb changes ........ r46671 | gregory.p.smith | 2006-06-05 19:38:04 +0200 (Mon, 05 Jun 2006) | 3 lines * add support for DBSequence objects [patch #1466734] ........ r46672 | gregory.p.smith | 2006-06-05 20:20:07 +0200 (Mon, 05 Jun 2006) | 3 lines forgot to add this file in previous commit ........ r46673 | tim.peters | 2006-06-05 20:36:12 +0200 (Mon, 05 Jun 2006) | 2 lines Whitespace normalization. ........ r46674 | tim.peters | 2006-06-05 20:36:54 +0200 (Mon, 05 Jun 2006) | 2 lines Add missing svn:eol-style property to text files. ........ r46675 | gregory.p.smith | 2006-06-05 20:48:21 +0200 (Mon, 05 Jun 2006) | 4 lines * fix DBCursor.pget() bug with keyword argument names when no data= is supplied [SF pybsddb bug #1477863] ........ r46676 | andrew.kuchling | 2006-06-05 21:05:32 +0200 (Mon, 05 Jun 2006) | 1 line Remove use of Trove name, which isn't very helpful to users ........ r46677 | andrew.kuchling | 2006-06-05 21:08:25 +0200 (Mon, 05 Jun 2006) | 1 line [Bug #1470026] Include link to list of classifiers ........ r46679 | tim.peters | 2006-06-05 22:48:49 +0200 (Mon, 05 Jun 2006) | 10 lines Access _struct attributes directly instead of mucking with getattr. string_reverse(): Simplify. assertRaises(): Raise TestFailed on failure. test_unpack_from(), test_pack_into(), test_pack_into_fn(): never use `assert` to test for an expected result (it doesn't test anything when Python is run with -O). ........ r46680 | tim.peters | 2006-06-05 22:49:27 +0200 (Mon, 05 Jun 2006) | 2 lines Add missing svn:eol-style property to text files. ........ r46681 | gregory.p.smith | 2006-06-06 01:38:06 +0200 (Tue, 06 Jun 2006) | 3 lines add depends = ['md5.h'] to the _md5 module extension for correctness sake. ........ r46682 | brett.cannon | 2006-06-06 01:51:55 +0200 (Tue, 06 Jun 2006) | 4 lines Add 3 more bytes to a buffer to cover constants in string and null byte on top of 10 possible digits for an int. Closes bug #1501223. ........ r46684 | gregory.p.smith | 2006-06-06 01:59:37 +0200 (Tue, 06 Jun 2006) | 5 lines - bsddb: the __len__ method of a DB object has been fixed to return correct results. It could previously incorrectly return 0 in some cases. Fixes SF bug 1493322 (pybsddb bug 1184012). ........ r46686 | tim.peters | 2006-06-06 02:25:07 +0200 (Tue, 06 Jun 2006) | 7 lines _PySys_Init(): It's rarely a good idea to size a buffer to the exact maximum size someone guesses is needed. In this case, if we're really worried about extreme integers, then "cp%d" can actually need 14 bytes (2 for "cp" + 1 for \0 at the end + 11 for -(2**31-1)). So reserve 128 bytes instead -- nothing is actually saved by making a stack-local buffer tiny. ........ r46687 | neal.norwitz | 2006-06-06 09:22:08 +0200 (Tue, 06 Jun 2006) | 1 line Remove unused variable (and stop compiler warning) ........ r46688 | neal.norwitz | 2006-06-06 09:23:01 +0200 (Tue, 06 Jun 2006) | 1 line Fix a bunch of parameter strings ........ r46689 | thomas.heller | 2006-06-06 13:34:33 +0200 (Tue, 06 Jun 2006) | 6 lines Convert CFieldObject tp_members to tp_getset, since there is no structmember typecode for Py_ssize_t fields. This should fix some of the errors on the PPC64 debian machine (64-bit, big endian). Assigning to readonly fields now raises AttributeError instead of TypeError, so the testcase has to be changed as well. ........ r46690 | thomas.heller | 2006-06-06 13:54:32 +0200 (Tue, 06 Jun 2006) | 1 line Damn - the sentinel was missing. And fix another silly mistake. ........ r46691 | martin.blais | 2006-06-06 14:46:55 +0200 (Tue, 06 Jun 2006) | 13 lines Normalized a few cases of whitespace in function declarations. Found them using:: find . -name '*.py' | while read i ; do grep 'def[^(]*( ' $i /dev/null ; done find . -name '*.py' | while read i ; do grep ' ):' $i /dev/null ; done (I was doing this all over my own code anyway, because I'd been using spaces in all defs, so I thought I'd make a run on the Python code as well. If you need to do such fixes in your own code, you can use xx-rename or parenregu.el within emacs.) ........ r46693 | thomas.heller | 2006-06-06 17:34:18 +0200 (Tue, 06 Jun 2006) | 1 line Specify argtypes for all test functions. Maybe that helps on strange ;-) architectures ........ r46694 | tim.peters | 2006-06-06 17:50:17 +0200 (Tue, 06 Jun 2006) | 5 lines BSequence_set_range(): Rev 46688 ("Fix a bunch of parameter strings") changed this function's signature seemingly by mistake, which is causing buildbots to fail test_bsddb3. Restored the pre-46688 signature. ........ r46695 | tim.peters | 2006-06-06 17:52:35 +0200 (Tue, 06 Jun 2006) | 4 lines On python-dev Thomas Heller said these were committed by mistake in rev 46693, so reverting this part of rev 46693. ........ r46696 | andrew.kuchling | 2006-06-06 19:10:41 +0200 (Tue, 06 Jun 2006) | 1 line Fix comment typo ........ r46697 | brett.cannon | 2006-06-06 20:08:16 +0200 (Tue, 06 Jun 2006) | 2 lines Fix coding style guide bug. ........ r46698 | thomas.heller | 2006-06-06 20:50:46 +0200 (Tue, 06 Jun 2006) | 2 lines Add a hack so that foreign functions returning float now do work on 64-bit big endian platforms. ........ r46699 | thomas.heller | 2006-06-06 21:25:13 +0200 (Tue, 06 Jun 2006) | 3 lines Use the same big-endian hack as in _ctypes/callproc.c for callback functions. This fixes the callback function tests that return float. ........ r46700 | ronald.oussoren | 2006-06-06 21:50:24 +0200 (Tue, 06 Jun 2006) | 5 lines * Ensure that "make altinstall" works when the tree was configured with --enable-framework * Also for --enable-framework: allow users to use --prefix to specify the location of the compatibility symlinks (such as /usr/local/bin/python) ........ r46701 | ronald.oussoren | 2006-06-06 21:56:00 +0200 (Tue, 06 Jun 2006) | 3 lines A quick hack to ensure the right key-bindings for IDLE on osx: install patched configuration files during a framework install. ........ r46702 | tim.peters | 2006-06-07 03:04:59 +0200 (Wed, 07 Jun 2006) | 4 lines dash_R_cleanup(): Clear filecmp._cache. This accounts for different results across -R runs (at least on Windows) of test_filecmp. ........ r46705 | tim.peters | 2006-06-07 08:57:51 +0200 (Wed, 07 Jun 2006) | 17 lines SF patch 1501987: Remove randomness from test_exceptions, from ?iga Seilnacht (sorry about the name, but Firefox on my box can't display the first character of the name -- the SF "Unix name" is zseil). This appears to cure the oddball intermittent leaks across runs when running test_exceptions under -R. I'm not sure why, but I'm too sleepy to care ;-) The thrust of the SF patch was to remove randomness in the pickle protocol used. I changed the patch to use range(pickle.HIGHEST_PROTOCOL + 1), to try both pickle and cPickle, and randomly mucked with other test lines to put statements on their own lines. Not a bugfix candidate (this is fiddling new-in-2.5 code). ........ r46706 | andrew.kuchling | 2006-06-07 15:55:33 +0200 (Wed, 07 Jun 2006) | 1 line Add an SQLite introduction, taken from the 'What's New' text ........ r46708 | andrew.kuchling | 2006-06-07 19:02:52 +0200 (Wed, 07 Jun 2006) | 1 line Mention other placeholders ........ r46709 | andrew.kuchling | 2006-06-07 19:03:46 +0200 (Wed, 07 Jun 2006) | 1 line Add an item; also, escape % ........ r46710 | andrew.kuchling | 2006-06-07 19:04:01 +0200 (Wed, 07 Jun 2006) | 1 line Mention other placeholders ........ r46716 | ronald.oussoren | 2006-06-07 20:57:44 +0200 (Wed, 07 Jun 2006) | 2 lines Move Mac/OSX/Tools one level up ........ r46717 | ronald.oussoren | 2006-06-07 20:58:01 +0200 (Wed, 07 Jun 2006) | 2 lines Move Mac/OSX/PythonLauncher one level up ........ r46718 | ronald.oussoren | 2006-06-07 20:58:42 +0200 (Wed, 07 Jun 2006) | 2 lines mv Mac/OSX/BuildScript one level up ........ r46719 | ronald.oussoren | 2006-06-07 21:02:03 +0200 (Wed, 07 Jun 2006) | 2 lines Move Mac/OSX/* one level up ........ r46720 | ronald.oussoren | 2006-06-07 21:06:01 +0200 (Wed, 07 Jun 2006) | 2 lines And the last bit: move IDLE one level up and adjust makefiles ........ r46723 | ronald.oussoren | 2006-06-07 21:38:53 +0200 (Wed, 07 Jun 2006) | 4 lines - Patch the correct version of python in the Info.plists at build time, instead of relying on a maintainer to update them before releases. - Remove the now empty Mac/OSX directory ........ r46727 | ronald.oussoren | 2006-06-07 22:18:44 +0200 (Wed, 07 Jun 2006) | 7 lines * If BuildApplet.py is used as an applet it starts with a version of sys.exutable that isn't usuable on an #!-line. That results in generated applets that don't actually work. Work around this problem by resetting sys.executable. * argvemulator.py didn't work on intel macs. This patch fixes this (bug #1491468) ........ r46728 | tim.peters | 2006-06-07 22:40:06 +0200 (Wed, 07 Jun 2006) | 2 lines Whitespace normalization. ........ r46729 | tim.peters | 2006-06-07 22:40:54 +0200 (Wed, 07 Jun 2006) | 2 lines Add missing svn:eol-style property to text files. ........ r46730 | thomas.heller | 2006-06-07 22:43:06 +0200 (Wed, 07 Jun 2006) | 7 lines Fix for foreign functions returning small structures on 64-bit big endian machines. Should fix the remaininf failure in the PPC64 Debian buildbot. Thanks to Matthias Klose for providing access to a machine to debug and test this. ........ r46731 | brett.cannon | 2006-06-07 23:48:17 +0200 (Wed, 07 Jun 2006) | 2 lines Clarify documentation for bf_getcharbuffer. ........ r46735 | neal.norwitz | 2006-06-08 07:12:45 +0200 (Thu, 08 Jun 2006) | 1 line Fix a refleak in recvfrom_into ........ r46736 | gregory.p.smith | 2006-06-08 07:17:08 +0200 (Thu, 08 Jun 2006) | 9 lines - bsddb: the bsddb.dbtables Modify method now raises the proper error and aborts the db transaction safely when a modifier callback fails. Fixes SF python patch/bug #1408584. Also cleans up the bsddb.dbtables docstrings since thats the only documentation that exists for that unadvertised module. (people really should really just use sqlite3) ........ r46737 | gregory.p.smith | 2006-06-08 07:38:11 +0200 (Thu, 08 Jun 2006) | 4 lines * Turn the deadlock situation described in SF bug #775414 into a DBDeadLockError exception. * add the test case for my previous dbtables commit. ........ r46738 | gregory.p.smith | 2006-06-08 07:39:54 +0200 (Thu, 08 Jun 2006) | 2 lines pasted set_lk_detect line in wrong spot in previous commit. fixed. passes tests this time. ........ r46739 | armin.rigo | 2006-06-08 12:56:24 +0200 (Thu, 08 Jun 2006) | 6 lines (arre, arigo) SF bug #1350060 Give a consistent behavior for comparison and hashing of method objects (both user- and built-in methods). Now compares the 'self' recursively. The hash was already asking for the hash of 'self'. ........ r46740 | andrew.kuchling | 2006-06-08 13:56:44 +0200 (Thu, 08 Jun 2006) | 1 line Typo fix ........ r46741 | georg.brandl | 2006-06-08 14:45:01 +0200 (Thu, 08 Jun 2006) | 2 lines Bug #1502750: Fix getargs "i" format to use LONG_MIN and LONG_MAX for bounds checking. ........ r46743 | georg.brandl | 2006-06-08 14:54:13 +0200 (Thu, 08 Jun 2006) | 2 lines Bug #1502728: Correctly link against librt library on HP-UX. ........ r46745 | georg.brandl | 2006-06-08 14:55:47 +0200 (Thu, 08 Jun 2006) | 3 lines Add news for recent bugfix. ........ r46746 | georg.brandl | 2006-06-08 15:31:07 +0200 (Thu, 08 Jun 2006) | 4 lines Argh. "integer" is a very confusing word ;) Actually, checking for INT_MAX and INT_MIN is correct since the format code explicitly handles a C "int". ........ r46748 | nick.coghlan | 2006-06-08 15:54:49 +0200 (Thu, 08 Jun 2006) | 1 line Add functools.update_wrapper() and functools.wraps() as described in PEP 356 ........ r46751 | georg.brandl | 2006-06-08 16:50:21 +0200 (Thu, 08 Jun 2006) | 4 lines Bug #1502805: don't alias file.__exit__ to file.close since the latter can return something that's true. ........ r46752 | georg.brandl | 2006-06-08 16:50:53 +0200 (Thu, 08 Jun 2006) | 3 lines Convert test_file to unittest. ........
20 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
Merged revisions 70578,70599,70641-70642,70650,70660-70661,70674,70691,70697-70698,70700,70704 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r70578 | benjamin.peterson | 2009-03-23 22:24:56 -0500 (Mon, 23 Mar 2009) | 1 line this is better written using assertRaises ........ r70599 | benjamin.peterson | 2009-03-25 16:42:51 -0500 (Wed, 25 Mar 2009) | 1 line this can be slightly less ugly ........ r70641 | guilherme.polo | 2009-03-27 16:43:08 -0500 (Fri, 27 Mar 2009) | 3 lines Adjusted _tkinter to compile without warnings when WITH_THREAD is not defined (part of issue #5035) ........ r70642 | georg.brandl | 2009-03-27 19:48:48 -0500 (Fri, 27 Mar 2009) | 1 line Fix typo. ........ r70650 | benjamin.peterson | 2009-03-28 14:16:10 -0500 (Sat, 28 Mar 2009) | 1 line give os.symlink and os.link() better parameter names #5564 ........ r70660 | georg.brandl | 2009-03-28 14:52:58 -0500 (Sat, 28 Mar 2009) | 1 line Switch to fixed Sphinx version. ........ r70661 | georg.brandl | 2009-03-28 14:57:36 -0500 (Sat, 28 Mar 2009) | 2 lines Add section numbering to some of the larger subdocuments. ........ r70674 | guilherme.polo | 2009-03-29 05:19:05 -0500 (Sun, 29 Mar 2009) | 1 line Typo fix. ........ r70691 | raymond.hettinger | 2009-03-29 13:51:11 -0500 (Sun, 29 Mar 2009) | 1 line Make life easier for non-CPython implementations. ........ r70697 | benjamin.peterson | 2009-03-29 16:22:35 -0500 (Sun, 29 Mar 2009) | 1 line this has been fixed since 2.6 (I love removing these) ........ r70698 | benjamin.peterson | 2009-03-29 16:31:05 -0500 (Sun, 29 Mar 2009) | 1 line thanks to guido's bytecode verifier, this is fixed ........ r70700 | benjamin.peterson | 2009-03-29 16:50:14 -0500 (Sun, 29 Mar 2009) | 1 line use the awesome new status iterator ........ r70704 | benjamin.peterson | 2009-03-29 21:49:32 -0500 (Sun, 29 Mar 2009) | 1 line there's actually three methods here #5600 ........
17 years ago
Merged revisions 70578,70599,70641-70642,70650,70660-70661,70674,70691,70697-70698,70700,70704 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r70578 | benjamin.peterson | 2009-03-23 22:24:56 -0500 (Mon, 23 Mar 2009) | 1 line this is better written using assertRaises ........ r70599 | benjamin.peterson | 2009-03-25 16:42:51 -0500 (Wed, 25 Mar 2009) | 1 line this can be slightly less ugly ........ r70641 | guilherme.polo | 2009-03-27 16:43:08 -0500 (Fri, 27 Mar 2009) | 3 lines Adjusted _tkinter to compile without warnings when WITH_THREAD is not defined (part of issue #5035) ........ r70642 | georg.brandl | 2009-03-27 19:48:48 -0500 (Fri, 27 Mar 2009) | 1 line Fix typo. ........ r70650 | benjamin.peterson | 2009-03-28 14:16:10 -0500 (Sat, 28 Mar 2009) | 1 line give os.symlink and os.link() better parameter names #5564 ........ r70660 | georg.brandl | 2009-03-28 14:52:58 -0500 (Sat, 28 Mar 2009) | 1 line Switch to fixed Sphinx version. ........ r70661 | georg.brandl | 2009-03-28 14:57:36 -0500 (Sat, 28 Mar 2009) | 2 lines Add section numbering to some of the larger subdocuments. ........ r70674 | guilherme.polo | 2009-03-29 05:19:05 -0500 (Sun, 29 Mar 2009) | 1 line Typo fix. ........ r70691 | raymond.hettinger | 2009-03-29 13:51:11 -0500 (Sun, 29 Mar 2009) | 1 line Make life easier for non-CPython implementations. ........ r70697 | benjamin.peterson | 2009-03-29 16:22:35 -0500 (Sun, 29 Mar 2009) | 1 line this has been fixed since 2.6 (I love removing these) ........ r70698 | benjamin.peterson | 2009-03-29 16:31:05 -0500 (Sun, 29 Mar 2009) | 1 line thanks to guido's bytecode verifier, this is fixed ........ r70700 | benjamin.peterson | 2009-03-29 16:50:14 -0500 (Sun, 29 Mar 2009) | 1 line use the awesome new status iterator ........ r70704 | benjamin.peterson | 2009-03-29 21:49:32 -0500 (Sun, 29 Mar 2009) | 1 line there's actually three methods here #5600 ........
17 years ago
32 years ago
Merge the rest of the trunk. Merged revisions 46490-46494,46496,46498,46500,46506,46521,46538,46558,46563-46567,46570-46571,46583,46593,46595-46598,46604,46606,46609-46753 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r46610 | martin.v.loewis | 2006-06-03 09:42:26 +0200 (Sat, 03 Jun 2006) | 2 lines Updated version (win32-icons2.zip) from #1490384. ........ r46612 | andrew.kuchling | 2006-06-03 20:09:41 +0200 (Sat, 03 Jun 2006) | 1 line [Bug #1472084] Fix description of do_tag ........ r46614 | andrew.kuchling | 2006-06-03 20:33:35 +0200 (Sat, 03 Jun 2006) | 1 line [Bug #1475554] Strengthen text to say 'must' instead of 'should' ........ r46616 | andrew.kuchling | 2006-06-03 20:41:28 +0200 (Sat, 03 Jun 2006) | 1 line [Bug #1441864] Clarify description of 'data' argument ........ r46617 | andrew.kuchling | 2006-06-03 20:43:24 +0200 (Sat, 03 Jun 2006) | 1 line Minor rewording ........ r46619 | andrew.kuchling | 2006-06-03 21:02:35 +0200 (Sat, 03 Jun 2006) | 9 lines [Bug #1497414] _self is a reserved word in the WATCOM 10.6 C compiler. Fix by renaming the variable. In a different module, Neal fixed it by renaming _self to self. There's already a variable named 'self' here, so I used selfptr. (I'm committing this on a Mac without Tk, but it's a simple search-and-replace. <crosses fingers>, so I'll watch the buildbots and see what happens.) ........ r46621 | fredrik.lundh | 2006-06-03 23:56:05 +0200 (Sat, 03 Jun 2006) | 5 lines "_self" is a said to be a reserved word in Watcom C 10.6. I'm not sure that's really standard compliant behaviour, but I guess we have to fix that anyway... ........ r46622 | andrew.kuchling | 2006-06-04 00:44:42 +0200 (Sun, 04 Jun 2006) | 1 line Update readme ........ r46623 | andrew.kuchling | 2006-06-04 00:59:23 +0200 (Sun, 04 Jun 2006) | 1 line Drop 0 parameter ........ r46624 | andrew.kuchling | 2006-06-04 00:59:59 +0200 (Sun, 04 Jun 2006) | 1 line Some code tidying; use curses.wrapper ........ r46625 | andrew.kuchling | 2006-06-04 01:02:15 +0200 (Sun, 04 Jun 2006) | 1 line Use True; value returned from main is unused ........ r46626 | andrew.kuchling | 2006-06-04 01:07:21 +0200 (Sun, 04 Jun 2006) | 1 line Use true division, and the True value ........ r46627 | andrew.kuchling | 2006-06-04 01:09:58 +0200 (Sun, 04 Jun 2006) | 1 line Docstring fix; use True ........ r46628 | andrew.kuchling | 2006-06-04 01:15:56 +0200 (Sun, 04 Jun 2006) | 1 line Put code in a main() function; loosen up the spacing to match current code style ........ r46629 | andrew.kuchling | 2006-06-04 01:39:07 +0200 (Sun, 04 Jun 2006) | 1 line Use functions; modernize code ........ r46630 | andrew.kuchling | 2006-06-04 01:43:22 +0200 (Sun, 04 Jun 2006) | 1 line This demo requires Medusa (not just asyncore); remove it ........ r46631 | andrew.kuchling | 2006-06-04 01:46:36 +0200 (Sun, 04 Jun 2006) | 2 lines Remove xmlrpc demo -- it duplicates the SimpleXMLRPCServer module. ........ r46632 | andrew.kuchling | 2006-06-04 01:47:22 +0200 (Sun, 04 Jun 2006) | 1 line Remove xmlrpc/ directory ........ r46633 | andrew.kuchling | 2006-06-04 01:51:21 +0200 (Sun, 04 Jun 2006) | 1 line Remove dangling reference ........ r46634 | andrew.kuchling | 2006-06-04 01:59:36 +0200 (Sun, 04 Jun 2006) | 1 line Add more whitespace; use a better socket name ........ r46635 | tim.peters | 2006-06-04 03:22:53 +0200 (Sun, 04 Jun 2006) | 2 lines Whitespace normalization. ........ r46637 | tim.peters | 2006-06-04 05:26:02 +0200 (Sun, 04 Jun 2006) | 16 lines In a PYMALLOC_DEBUG build obmalloc adds extra debugging info to each allocated block. This was using 4 bytes for each such piece of info regardless of platform. This didn't really matter before (proof: no bug reports, and the debug-build obmalloc would have assert-failed if it was ever asked for a chunk of memory >= 2**32 bytes), since container indices were plain ints. But after the Py_ssize_t changes, it's at least theoretically possible to allocate a list or string whose guts exceed 2**32 bytes, and the PYMALLOC_DEBUG routines would fail then (having only 4 bytes to record the originally requested size). Now we use sizeof(size_t) bytes for each of a PYMALLOC_DEBUG build's extra debugging fields. This won't make any difference on 32-bit boxes, but will add 16 bytes to each allocation in a debug build on a 64-bit box. ........ r46638 | tim.peters | 2006-06-04 05:38:04 +0200 (Sun, 04 Jun 2006) | 4 lines _PyObject_DebugMalloc(): The return value should add 2*sizeof(size_t) now, not 8. This probably accounts for current disasters on the 64-bit buildbot slaves. ........ r46639 | neal.norwitz | 2006-06-04 08:19:31 +0200 (Sun, 04 Jun 2006) | 1 line SF #1499797, Fix for memory leak in WindowsError_str ........ r46640 | andrew.macintyre | 2006-06-04 14:31:09 +0200 (Sun, 04 Jun 2006) | 2 lines Patch #1454481: Make thread stack size runtime tunable. ........ r46641 | andrew.macintyre | 2006-06-04 14:59:59 +0200 (Sun, 04 Jun 2006) | 2 lines clean up function declarations to conform to PEP-7 style. ........ r46642 | martin.blais | 2006-06-04 15:49:49 +0200 (Sun, 04 Jun 2006) | 15 lines Fixes in struct and socket from merge reviews. - Following Guido's comments, renamed * pack_to -> pack_into * recv_buf -> recv_into * recvfrom_buf -> recvfrom_into - Made fixes to _struct.c according to Neal Norwitz comments on the checkins list. - Converted some ints into the appropriate -- I hope -- ssize_t and size_t. ........ r46643 | ronald.oussoren | 2006-06-04 16:05:28 +0200 (Sun, 04 Jun 2006) | 3 lines "Import" LDFLAGS in Mac/OSX/Makefile.in to ensure pythonw gets build with the right compiler flags. ........ r46644 | ronald.oussoren | 2006-06-04 16:24:59 +0200 (Sun, 04 Jun 2006) | 2 lines Drop Mac wrappers for the WASTE library. ........ r46645 | tim.peters | 2006-06-04 17:49:07 +0200 (Sun, 04 Jun 2006) | 3 lines s_methods[]: Stop compiler warnings by casting s_unpack_from to PyCFunction. ........ r46646 | george.yoshida | 2006-06-04 19:04:12 +0200 (Sun, 04 Jun 2006) | 2 lines Remove a redundant word ........ r46647 | george.yoshida | 2006-06-04 19:17:25 +0200 (Sun, 04 Jun 2006) | 2 lines Markup fix ........ r46648 | martin.v.loewis | 2006-06-04 21:36:28 +0200 (Sun, 04 Jun 2006) | 2 lines Patch #1359618: Speed-up charmap encoder. ........ r46649 | georg.brandl | 2006-06-04 23:46:16 +0200 (Sun, 04 Jun 2006) | 3 lines Repair refleaks in unicodeobject. ........ r46650 | georg.brandl | 2006-06-04 23:56:52 +0200 (Sun, 04 Jun 2006) | 4 lines Patch #1346214: correctly optimize away "if 0"-style stmts (thanks to Neal for review) ........ r46651 | georg.brandl | 2006-06-05 00:15:37 +0200 (Mon, 05 Jun 2006) | 2 lines Bug #1500293: fix memory leaks in _subprocess module. ........ r46654 | tim.peters | 2006-06-05 01:43:53 +0200 (Mon, 05 Jun 2006) | 2 lines Whitespace normalization. ........ r46655 | tim.peters | 2006-06-05 01:52:47 +0200 (Mon, 05 Jun 2006) | 16 lines Revert revisions: 46640 Patch #1454481: Make thread stack size runtime tunable. 46647 Markup fix The first is causing many buildbots to fail test runs, and there are multiple causes with seemingly no immediate prospects for repairing them. See python-dev discussion. Note that a branch can (and should) be created for resolving these problems, like svn copy svn+ssh://svn.python.org/python/trunk -r46640 svn+ssh://svn.python.org/python/branches/NEW_BRANCH followed by merging rev 46647 to the new branch. ........ r46656 | andrew.kuchling | 2006-06-05 02:08:09 +0200 (Mon, 05 Jun 2006) | 1 line Mention second encoding speedup ........ r46657 | gregory.p.smith | 2006-06-05 02:31:01 +0200 (Mon, 05 Jun 2006) | 7 lines bugfix: when log_archive was called with the DB_ARCH_REMOVE flag present in BerkeleyDB >= 4.2 it tried to construct a list out of an uninitialized char **log_list. feature: export the DB_ARCH_REMOVE flag by name in the module on BerkeleyDB >= 4.2. ........ r46658 | gregory.p.smith | 2006-06-05 02:33:35 +0200 (Mon, 05 Jun 2006) | 5 lines fix a bug in the previous commit. don't leak empty list on error return and fix the additional rare (out of memory only) bug that it was supposed to fix of not freeing log_list when the python allocator failed. ........ r46660 | tim.peters | 2006-06-05 02:55:26 +0200 (Mon, 05 Jun 2006) | 9 lines "Flat is better than nested." Move the long-winded, multiply-nested -R support out of runtest() and into some module-level helper functions. This makes runtest() and the -R code easier to follow. That in turn allowed seeing some opportunities for code simplification, and made it obvious that reglog.txt never got closed. ........ r46661 | hyeshik.chang | 2006-06-05 02:59:54 +0200 (Mon, 05 Jun 2006) | 3 lines Fix a potentially invalid memory access of CJKCodecs' shift-jis decoder. (found by Neal Norwitz) ........ r46663 | gregory.p.smith | 2006-06-05 03:39:52 +0200 (Mon, 05 Jun 2006) | 3 lines * support DBEnv.log_stat() method on BerkeleyDB >= 4.0 [patch #1494885] ........ r46664 | tim.peters | 2006-06-05 03:43:03 +0200 (Mon, 05 Jun 2006) | 3 lines Remove doctest.testmod's deprecated (in 2.4) `isprivate` argument. A lot of hair went into supporting that! ........ r46665 | tim.peters | 2006-06-05 03:47:24 +0200 (Mon, 05 Jun 2006) | 2 lines Whitespace normalization. ........ r46666 | tim.peters | 2006-06-05 03:48:21 +0200 (Mon, 05 Jun 2006) | 2 lines Make doctest news more accurate. ........ r46667 | gregory.p.smith | 2006-06-05 03:56:15 +0200 (Mon, 05 Jun 2006) | 3 lines * support DBEnv.lsn_reset() method on BerkeleyDB >= 4.4 [patch #1494902] ........ r46668 | gregory.p.smith | 2006-06-05 04:02:25 +0200 (Mon, 05 Jun 2006) | 3 lines mention the just committed bsddb changes ........ r46671 | gregory.p.smith | 2006-06-05 19:38:04 +0200 (Mon, 05 Jun 2006) | 3 lines * add support for DBSequence objects [patch #1466734] ........ r46672 | gregory.p.smith | 2006-06-05 20:20:07 +0200 (Mon, 05 Jun 2006) | 3 lines forgot to add this file in previous commit ........ r46673 | tim.peters | 2006-06-05 20:36:12 +0200 (Mon, 05 Jun 2006) | 2 lines Whitespace normalization. ........ r46674 | tim.peters | 2006-06-05 20:36:54 +0200 (Mon, 05 Jun 2006) | 2 lines Add missing svn:eol-style property to text files. ........ r46675 | gregory.p.smith | 2006-06-05 20:48:21 +0200 (Mon, 05 Jun 2006) | 4 lines * fix DBCursor.pget() bug with keyword argument names when no data= is supplied [SF pybsddb bug #1477863] ........ r46676 | andrew.kuchling | 2006-06-05 21:05:32 +0200 (Mon, 05 Jun 2006) | 1 line Remove use of Trove name, which isn't very helpful to users ........ r46677 | andrew.kuchling | 2006-06-05 21:08:25 +0200 (Mon, 05 Jun 2006) | 1 line [Bug #1470026] Include link to list of classifiers ........ r46679 | tim.peters | 2006-06-05 22:48:49 +0200 (Mon, 05 Jun 2006) | 10 lines Access _struct attributes directly instead of mucking with getattr. string_reverse(): Simplify. assertRaises(): Raise TestFailed on failure. test_unpack_from(), test_pack_into(), test_pack_into_fn(): never use `assert` to test for an expected result (it doesn't test anything when Python is run with -O). ........ r46680 | tim.peters | 2006-06-05 22:49:27 +0200 (Mon, 05 Jun 2006) | 2 lines Add missing svn:eol-style property to text files. ........ r46681 | gregory.p.smith | 2006-06-06 01:38:06 +0200 (Tue, 06 Jun 2006) | 3 lines add depends = ['md5.h'] to the _md5 module extension for correctness sake. ........ r46682 | brett.cannon | 2006-06-06 01:51:55 +0200 (Tue, 06 Jun 2006) | 4 lines Add 3 more bytes to a buffer to cover constants in string and null byte on top of 10 possible digits for an int. Closes bug #1501223. ........ r46684 | gregory.p.smith | 2006-06-06 01:59:37 +0200 (Tue, 06 Jun 2006) | 5 lines - bsddb: the __len__ method of a DB object has been fixed to return correct results. It could previously incorrectly return 0 in some cases. Fixes SF bug 1493322 (pybsddb bug 1184012). ........ r46686 | tim.peters | 2006-06-06 02:25:07 +0200 (Tue, 06 Jun 2006) | 7 lines _PySys_Init(): It's rarely a good idea to size a buffer to the exact maximum size someone guesses is needed. In this case, if we're really worried about extreme integers, then "cp%d" can actually need 14 bytes (2 for "cp" + 1 for \0 at the end + 11 for -(2**31-1)). So reserve 128 bytes instead -- nothing is actually saved by making a stack-local buffer tiny. ........ r46687 | neal.norwitz | 2006-06-06 09:22:08 +0200 (Tue, 06 Jun 2006) | 1 line Remove unused variable (and stop compiler warning) ........ r46688 | neal.norwitz | 2006-06-06 09:23:01 +0200 (Tue, 06 Jun 2006) | 1 line Fix a bunch of parameter strings ........ r46689 | thomas.heller | 2006-06-06 13:34:33 +0200 (Tue, 06 Jun 2006) | 6 lines Convert CFieldObject tp_members to tp_getset, since there is no structmember typecode for Py_ssize_t fields. This should fix some of the errors on the PPC64 debian machine (64-bit, big endian). Assigning to readonly fields now raises AttributeError instead of TypeError, so the testcase has to be changed as well. ........ r46690 | thomas.heller | 2006-06-06 13:54:32 +0200 (Tue, 06 Jun 2006) | 1 line Damn - the sentinel was missing. And fix another silly mistake. ........ r46691 | martin.blais | 2006-06-06 14:46:55 +0200 (Tue, 06 Jun 2006) | 13 lines Normalized a few cases of whitespace in function declarations. Found them using:: find . -name '*.py' | while read i ; do grep 'def[^(]*( ' $i /dev/null ; done find . -name '*.py' | while read i ; do grep ' ):' $i /dev/null ; done (I was doing this all over my own code anyway, because I'd been using spaces in all defs, so I thought I'd make a run on the Python code as well. If you need to do such fixes in your own code, you can use xx-rename or parenregu.el within emacs.) ........ r46693 | thomas.heller | 2006-06-06 17:34:18 +0200 (Tue, 06 Jun 2006) | 1 line Specify argtypes for all test functions. Maybe that helps on strange ;-) architectures ........ r46694 | tim.peters | 2006-06-06 17:50:17 +0200 (Tue, 06 Jun 2006) | 5 lines BSequence_set_range(): Rev 46688 ("Fix a bunch of parameter strings") changed this function's signature seemingly by mistake, which is causing buildbots to fail test_bsddb3. Restored the pre-46688 signature. ........ r46695 | tim.peters | 2006-06-06 17:52:35 +0200 (Tue, 06 Jun 2006) | 4 lines On python-dev Thomas Heller said these were committed by mistake in rev 46693, so reverting this part of rev 46693. ........ r46696 | andrew.kuchling | 2006-06-06 19:10:41 +0200 (Tue, 06 Jun 2006) | 1 line Fix comment typo ........ r46697 | brett.cannon | 2006-06-06 20:08:16 +0200 (Tue, 06 Jun 2006) | 2 lines Fix coding style guide bug. ........ r46698 | thomas.heller | 2006-06-06 20:50:46 +0200 (Tue, 06 Jun 2006) | 2 lines Add a hack so that foreign functions returning float now do work on 64-bit big endian platforms. ........ r46699 | thomas.heller | 2006-06-06 21:25:13 +0200 (Tue, 06 Jun 2006) | 3 lines Use the same big-endian hack as in _ctypes/callproc.c for callback functions. This fixes the callback function tests that return float. ........ r46700 | ronald.oussoren | 2006-06-06 21:50:24 +0200 (Tue, 06 Jun 2006) | 5 lines * Ensure that "make altinstall" works when the tree was configured with --enable-framework * Also for --enable-framework: allow users to use --prefix to specify the location of the compatibility symlinks (such as /usr/local/bin/python) ........ r46701 | ronald.oussoren | 2006-06-06 21:56:00 +0200 (Tue, 06 Jun 2006) | 3 lines A quick hack to ensure the right key-bindings for IDLE on osx: install patched configuration files during a framework install. ........ r46702 | tim.peters | 2006-06-07 03:04:59 +0200 (Wed, 07 Jun 2006) | 4 lines dash_R_cleanup(): Clear filecmp._cache. This accounts for different results across -R runs (at least on Windows) of test_filecmp. ........ r46705 | tim.peters | 2006-06-07 08:57:51 +0200 (Wed, 07 Jun 2006) | 17 lines SF patch 1501987: Remove randomness from test_exceptions, from ?iga Seilnacht (sorry about the name, but Firefox on my box can't display the first character of the name -- the SF "Unix name" is zseil). This appears to cure the oddball intermittent leaks across runs when running test_exceptions under -R. I'm not sure why, but I'm too sleepy to care ;-) The thrust of the SF patch was to remove randomness in the pickle protocol used. I changed the patch to use range(pickle.HIGHEST_PROTOCOL + 1), to try both pickle and cPickle, and randomly mucked with other test lines to put statements on their own lines. Not a bugfix candidate (this is fiddling new-in-2.5 code). ........ r46706 | andrew.kuchling | 2006-06-07 15:55:33 +0200 (Wed, 07 Jun 2006) | 1 line Add an SQLite introduction, taken from the 'What's New' text ........ r46708 | andrew.kuchling | 2006-06-07 19:02:52 +0200 (Wed, 07 Jun 2006) | 1 line Mention other placeholders ........ r46709 | andrew.kuchling | 2006-06-07 19:03:46 +0200 (Wed, 07 Jun 2006) | 1 line Add an item; also, escape % ........ r46710 | andrew.kuchling | 2006-06-07 19:04:01 +0200 (Wed, 07 Jun 2006) | 1 line Mention other placeholders ........ r46716 | ronald.oussoren | 2006-06-07 20:57:44 +0200 (Wed, 07 Jun 2006) | 2 lines Move Mac/OSX/Tools one level up ........ r46717 | ronald.oussoren | 2006-06-07 20:58:01 +0200 (Wed, 07 Jun 2006) | 2 lines Move Mac/OSX/PythonLauncher one level up ........ r46718 | ronald.oussoren | 2006-06-07 20:58:42 +0200 (Wed, 07 Jun 2006) | 2 lines mv Mac/OSX/BuildScript one level up ........ r46719 | ronald.oussoren | 2006-06-07 21:02:03 +0200 (Wed, 07 Jun 2006) | 2 lines Move Mac/OSX/* one level up ........ r46720 | ronald.oussoren | 2006-06-07 21:06:01 +0200 (Wed, 07 Jun 2006) | 2 lines And the last bit: move IDLE one level up and adjust makefiles ........ r46723 | ronald.oussoren | 2006-06-07 21:38:53 +0200 (Wed, 07 Jun 2006) | 4 lines - Patch the correct version of python in the Info.plists at build time, instead of relying on a maintainer to update them before releases. - Remove the now empty Mac/OSX directory ........ r46727 | ronald.oussoren | 2006-06-07 22:18:44 +0200 (Wed, 07 Jun 2006) | 7 lines * If BuildApplet.py is used as an applet it starts with a version of sys.exutable that isn't usuable on an #!-line. That results in generated applets that don't actually work. Work around this problem by resetting sys.executable. * argvemulator.py didn't work on intel macs. This patch fixes this (bug #1491468) ........ r46728 | tim.peters | 2006-06-07 22:40:06 +0200 (Wed, 07 Jun 2006) | 2 lines Whitespace normalization. ........ r46729 | tim.peters | 2006-06-07 22:40:54 +0200 (Wed, 07 Jun 2006) | 2 lines Add missing svn:eol-style property to text files. ........ r46730 | thomas.heller | 2006-06-07 22:43:06 +0200 (Wed, 07 Jun 2006) | 7 lines Fix for foreign functions returning small structures on 64-bit big endian machines. Should fix the remaininf failure in the PPC64 Debian buildbot. Thanks to Matthias Klose for providing access to a machine to debug and test this. ........ r46731 | brett.cannon | 2006-06-07 23:48:17 +0200 (Wed, 07 Jun 2006) | 2 lines Clarify documentation for bf_getcharbuffer. ........ r46735 | neal.norwitz | 2006-06-08 07:12:45 +0200 (Thu, 08 Jun 2006) | 1 line Fix a refleak in recvfrom_into ........ r46736 | gregory.p.smith | 2006-06-08 07:17:08 +0200 (Thu, 08 Jun 2006) | 9 lines - bsddb: the bsddb.dbtables Modify method now raises the proper error and aborts the db transaction safely when a modifier callback fails. Fixes SF python patch/bug #1408584. Also cleans up the bsddb.dbtables docstrings since thats the only documentation that exists for that unadvertised module. (people really should really just use sqlite3) ........ r46737 | gregory.p.smith | 2006-06-08 07:38:11 +0200 (Thu, 08 Jun 2006) | 4 lines * Turn the deadlock situation described in SF bug #775414 into a DBDeadLockError exception. * add the test case for my previous dbtables commit. ........ r46738 | gregory.p.smith | 2006-06-08 07:39:54 +0200 (Thu, 08 Jun 2006) | 2 lines pasted set_lk_detect line in wrong spot in previous commit. fixed. passes tests this time. ........ r46739 | armin.rigo | 2006-06-08 12:56:24 +0200 (Thu, 08 Jun 2006) | 6 lines (arre, arigo) SF bug #1350060 Give a consistent behavior for comparison and hashing of method objects (both user- and built-in methods). Now compares the 'self' recursively. The hash was already asking for the hash of 'self'. ........ r46740 | andrew.kuchling | 2006-06-08 13:56:44 +0200 (Thu, 08 Jun 2006) | 1 line Typo fix ........ r46741 | georg.brandl | 2006-06-08 14:45:01 +0200 (Thu, 08 Jun 2006) | 2 lines Bug #1502750: Fix getargs "i" format to use LONG_MIN and LONG_MAX for bounds checking. ........ r46743 | georg.brandl | 2006-06-08 14:54:13 +0200 (Thu, 08 Jun 2006) | 2 lines Bug #1502728: Correctly link against librt library on HP-UX. ........ r46745 | georg.brandl | 2006-06-08 14:55:47 +0200 (Thu, 08 Jun 2006) | 3 lines Add news for recent bugfix. ........ r46746 | georg.brandl | 2006-06-08 15:31:07 +0200 (Thu, 08 Jun 2006) | 4 lines Argh. "integer" is a very confusing word ;) Actually, checking for INT_MAX and INT_MIN is correct since the format code explicitly handles a C "int". ........ r46748 | nick.coghlan | 2006-06-08 15:54:49 +0200 (Thu, 08 Jun 2006) | 1 line Add functools.update_wrapper() and functools.wraps() as described in PEP 356 ........ r46751 | georg.brandl | 2006-06-08 16:50:21 +0200 (Thu, 08 Jun 2006) | 4 lines Bug #1502805: don't alias file.__exit__ to file.close since the latter can return something that's true. ........ r46752 | georg.brandl | 2006-06-08 16:50:53 +0200 (Thu, 08 Jun 2006) | 3 lines Convert test_file to unittest. ........
20 years ago
32 years ago
32 years ago
Merged revisions 70578,70599,70641-70642,70650,70660-70661,70674,70691,70697-70698,70700,70704 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r70578 | benjamin.peterson | 2009-03-23 22:24:56 -0500 (Mon, 23 Mar 2009) | 1 line this is better written using assertRaises ........ r70599 | benjamin.peterson | 2009-03-25 16:42:51 -0500 (Wed, 25 Mar 2009) | 1 line this can be slightly less ugly ........ r70641 | guilherme.polo | 2009-03-27 16:43:08 -0500 (Fri, 27 Mar 2009) | 3 lines Adjusted _tkinter to compile without warnings when WITH_THREAD is not defined (part of issue #5035) ........ r70642 | georg.brandl | 2009-03-27 19:48:48 -0500 (Fri, 27 Mar 2009) | 1 line Fix typo. ........ r70650 | benjamin.peterson | 2009-03-28 14:16:10 -0500 (Sat, 28 Mar 2009) | 1 line give os.symlink and os.link() better parameter names #5564 ........ r70660 | georg.brandl | 2009-03-28 14:52:58 -0500 (Sat, 28 Mar 2009) | 1 line Switch to fixed Sphinx version. ........ r70661 | georg.brandl | 2009-03-28 14:57:36 -0500 (Sat, 28 Mar 2009) | 2 lines Add section numbering to some of the larger subdocuments. ........ r70674 | guilherme.polo | 2009-03-29 05:19:05 -0500 (Sun, 29 Mar 2009) | 1 line Typo fix. ........ r70691 | raymond.hettinger | 2009-03-29 13:51:11 -0500 (Sun, 29 Mar 2009) | 1 line Make life easier for non-CPython implementations. ........ r70697 | benjamin.peterson | 2009-03-29 16:22:35 -0500 (Sun, 29 Mar 2009) | 1 line this has been fixed since 2.6 (I love removing these) ........ r70698 | benjamin.peterson | 2009-03-29 16:31:05 -0500 (Sun, 29 Mar 2009) | 1 line thanks to guido's bytecode verifier, this is fixed ........ r70700 | benjamin.peterson | 2009-03-29 16:50:14 -0500 (Sun, 29 Mar 2009) | 1 line use the awesome new status iterator ........ r70704 | benjamin.peterson | 2009-03-29 21:49:32 -0500 (Sun, 29 Mar 2009) | 1 line there's actually three methods here #5600 ........
17 years ago
Merged revisions 70578,70599,70641-70642,70650,70660-70661,70674,70691,70697-70698,70700,70704 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r70578 | benjamin.peterson | 2009-03-23 22:24:56 -0500 (Mon, 23 Mar 2009) | 1 line this is better written using assertRaises ........ r70599 | benjamin.peterson | 2009-03-25 16:42:51 -0500 (Wed, 25 Mar 2009) | 1 line this can be slightly less ugly ........ r70641 | guilherme.polo | 2009-03-27 16:43:08 -0500 (Fri, 27 Mar 2009) | 3 lines Adjusted _tkinter to compile without warnings when WITH_THREAD is not defined (part of issue #5035) ........ r70642 | georg.brandl | 2009-03-27 19:48:48 -0500 (Fri, 27 Mar 2009) | 1 line Fix typo. ........ r70650 | benjamin.peterson | 2009-03-28 14:16:10 -0500 (Sat, 28 Mar 2009) | 1 line give os.symlink and os.link() better parameter names #5564 ........ r70660 | georg.brandl | 2009-03-28 14:52:58 -0500 (Sat, 28 Mar 2009) | 1 line Switch to fixed Sphinx version. ........ r70661 | georg.brandl | 2009-03-28 14:57:36 -0500 (Sat, 28 Mar 2009) | 2 lines Add section numbering to some of the larger subdocuments. ........ r70674 | guilherme.polo | 2009-03-29 05:19:05 -0500 (Sun, 29 Mar 2009) | 1 line Typo fix. ........ r70691 | raymond.hettinger | 2009-03-29 13:51:11 -0500 (Sun, 29 Mar 2009) | 1 line Make life easier for non-CPython implementations. ........ r70697 | benjamin.peterson | 2009-03-29 16:22:35 -0500 (Sun, 29 Mar 2009) | 1 line this has been fixed since 2.6 (I love removing these) ........ r70698 | benjamin.peterson | 2009-03-29 16:31:05 -0500 (Sun, 29 Mar 2009) | 1 line thanks to guido's bytecode verifier, this is fixed ........ r70700 | benjamin.peterson | 2009-03-29 16:50:14 -0500 (Sun, 29 Mar 2009) | 1 line use the awesome new status iterator ........ r70704 | benjamin.peterson | 2009-03-29 21:49:32 -0500 (Sun, 29 Mar 2009) | 1 line there's actually three methods here #5600 ........
17 years ago
32 years ago
32 years ago
32 years ago
Merge the rest of the trunk. Merged revisions 46490-46494,46496,46498,46500,46506,46521,46538,46558,46563-46567,46570-46571,46583,46593,46595-46598,46604,46606,46609-46753 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r46610 | martin.v.loewis | 2006-06-03 09:42:26 +0200 (Sat, 03 Jun 2006) | 2 lines Updated version (win32-icons2.zip) from #1490384. ........ r46612 | andrew.kuchling | 2006-06-03 20:09:41 +0200 (Sat, 03 Jun 2006) | 1 line [Bug #1472084] Fix description of do_tag ........ r46614 | andrew.kuchling | 2006-06-03 20:33:35 +0200 (Sat, 03 Jun 2006) | 1 line [Bug #1475554] Strengthen text to say 'must' instead of 'should' ........ r46616 | andrew.kuchling | 2006-06-03 20:41:28 +0200 (Sat, 03 Jun 2006) | 1 line [Bug #1441864] Clarify description of 'data' argument ........ r46617 | andrew.kuchling | 2006-06-03 20:43:24 +0200 (Sat, 03 Jun 2006) | 1 line Minor rewording ........ r46619 | andrew.kuchling | 2006-06-03 21:02:35 +0200 (Sat, 03 Jun 2006) | 9 lines [Bug #1497414] _self is a reserved word in the WATCOM 10.6 C compiler. Fix by renaming the variable. In a different module, Neal fixed it by renaming _self to self. There's already a variable named 'self' here, so I used selfptr. (I'm committing this on a Mac without Tk, but it's a simple search-and-replace. <crosses fingers>, so I'll watch the buildbots and see what happens.) ........ r46621 | fredrik.lundh | 2006-06-03 23:56:05 +0200 (Sat, 03 Jun 2006) | 5 lines "_self" is a said to be a reserved word in Watcom C 10.6. I'm not sure that's really standard compliant behaviour, but I guess we have to fix that anyway... ........ r46622 | andrew.kuchling | 2006-06-04 00:44:42 +0200 (Sun, 04 Jun 2006) | 1 line Update readme ........ r46623 | andrew.kuchling | 2006-06-04 00:59:23 +0200 (Sun, 04 Jun 2006) | 1 line Drop 0 parameter ........ r46624 | andrew.kuchling | 2006-06-04 00:59:59 +0200 (Sun, 04 Jun 2006) | 1 line Some code tidying; use curses.wrapper ........ r46625 | andrew.kuchling | 2006-06-04 01:02:15 +0200 (Sun, 04 Jun 2006) | 1 line Use True; value returned from main is unused ........ r46626 | andrew.kuchling | 2006-06-04 01:07:21 +0200 (Sun, 04 Jun 2006) | 1 line Use true division, and the True value ........ r46627 | andrew.kuchling | 2006-06-04 01:09:58 +0200 (Sun, 04 Jun 2006) | 1 line Docstring fix; use True ........ r46628 | andrew.kuchling | 2006-06-04 01:15:56 +0200 (Sun, 04 Jun 2006) | 1 line Put code in a main() function; loosen up the spacing to match current code style ........ r46629 | andrew.kuchling | 2006-06-04 01:39:07 +0200 (Sun, 04 Jun 2006) | 1 line Use functions; modernize code ........ r46630 | andrew.kuchling | 2006-06-04 01:43:22 +0200 (Sun, 04 Jun 2006) | 1 line This demo requires Medusa (not just asyncore); remove it ........ r46631 | andrew.kuchling | 2006-06-04 01:46:36 +0200 (Sun, 04 Jun 2006) | 2 lines Remove xmlrpc demo -- it duplicates the SimpleXMLRPCServer module. ........ r46632 | andrew.kuchling | 2006-06-04 01:47:22 +0200 (Sun, 04 Jun 2006) | 1 line Remove xmlrpc/ directory ........ r46633 | andrew.kuchling | 2006-06-04 01:51:21 +0200 (Sun, 04 Jun 2006) | 1 line Remove dangling reference ........ r46634 | andrew.kuchling | 2006-06-04 01:59:36 +0200 (Sun, 04 Jun 2006) | 1 line Add more whitespace; use a better socket name ........ r46635 | tim.peters | 2006-06-04 03:22:53 +0200 (Sun, 04 Jun 2006) | 2 lines Whitespace normalization. ........ r46637 | tim.peters | 2006-06-04 05:26:02 +0200 (Sun, 04 Jun 2006) | 16 lines In a PYMALLOC_DEBUG build obmalloc adds extra debugging info to each allocated block. This was using 4 bytes for each such piece of info regardless of platform. This didn't really matter before (proof: no bug reports, and the debug-build obmalloc would have assert-failed if it was ever asked for a chunk of memory >= 2**32 bytes), since container indices were plain ints. But after the Py_ssize_t changes, it's at least theoretically possible to allocate a list or string whose guts exceed 2**32 bytes, and the PYMALLOC_DEBUG routines would fail then (having only 4 bytes to record the originally requested size). Now we use sizeof(size_t) bytes for each of a PYMALLOC_DEBUG build's extra debugging fields. This won't make any difference on 32-bit boxes, but will add 16 bytes to each allocation in a debug build on a 64-bit box. ........ r46638 | tim.peters | 2006-06-04 05:38:04 +0200 (Sun, 04 Jun 2006) | 4 lines _PyObject_DebugMalloc(): The return value should add 2*sizeof(size_t) now, not 8. This probably accounts for current disasters on the 64-bit buildbot slaves. ........ r46639 | neal.norwitz | 2006-06-04 08:19:31 +0200 (Sun, 04 Jun 2006) | 1 line SF #1499797, Fix for memory leak in WindowsError_str ........ r46640 | andrew.macintyre | 2006-06-04 14:31:09 +0200 (Sun, 04 Jun 2006) | 2 lines Patch #1454481: Make thread stack size runtime tunable. ........ r46641 | andrew.macintyre | 2006-06-04 14:59:59 +0200 (Sun, 04 Jun 2006) | 2 lines clean up function declarations to conform to PEP-7 style. ........ r46642 | martin.blais | 2006-06-04 15:49:49 +0200 (Sun, 04 Jun 2006) | 15 lines Fixes in struct and socket from merge reviews. - Following Guido's comments, renamed * pack_to -> pack_into * recv_buf -> recv_into * recvfrom_buf -> recvfrom_into - Made fixes to _struct.c according to Neal Norwitz comments on the checkins list. - Converted some ints into the appropriate -- I hope -- ssize_t and size_t. ........ r46643 | ronald.oussoren | 2006-06-04 16:05:28 +0200 (Sun, 04 Jun 2006) | 3 lines "Import" LDFLAGS in Mac/OSX/Makefile.in to ensure pythonw gets build with the right compiler flags. ........ r46644 | ronald.oussoren | 2006-06-04 16:24:59 +0200 (Sun, 04 Jun 2006) | 2 lines Drop Mac wrappers for the WASTE library. ........ r46645 | tim.peters | 2006-06-04 17:49:07 +0200 (Sun, 04 Jun 2006) | 3 lines s_methods[]: Stop compiler warnings by casting s_unpack_from to PyCFunction. ........ r46646 | george.yoshida | 2006-06-04 19:04:12 +0200 (Sun, 04 Jun 2006) | 2 lines Remove a redundant word ........ r46647 | george.yoshida | 2006-06-04 19:17:25 +0200 (Sun, 04 Jun 2006) | 2 lines Markup fix ........ r46648 | martin.v.loewis | 2006-06-04 21:36:28 +0200 (Sun, 04 Jun 2006) | 2 lines Patch #1359618: Speed-up charmap encoder. ........ r46649 | georg.brandl | 2006-06-04 23:46:16 +0200 (Sun, 04 Jun 2006) | 3 lines Repair refleaks in unicodeobject. ........ r46650 | georg.brandl | 2006-06-04 23:56:52 +0200 (Sun, 04 Jun 2006) | 4 lines Patch #1346214: correctly optimize away "if 0"-style stmts (thanks to Neal for review) ........ r46651 | georg.brandl | 2006-06-05 00:15:37 +0200 (Mon, 05 Jun 2006) | 2 lines Bug #1500293: fix memory leaks in _subprocess module. ........ r46654 | tim.peters | 2006-06-05 01:43:53 +0200 (Mon, 05 Jun 2006) | 2 lines Whitespace normalization. ........ r46655 | tim.peters | 2006-06-05 01:52:47 +0200 (Mon, 05 Jun 2006) | 16 lines Revert revisions: 46640 Patch #1454481: Make thread stack size runtime tunable. 46647 Markup fix The first is causing many buildbots to fail test runs, and there are multiple causes with seemingly no immediate prospects for repairing them. See python-dev discussion. Note that a branch can (and should) be created for resolving these problems, like svn copy svn+ssh://svn.python.org/python/trunk -r46640 svn+ssh://svn.python.org/python/branches/NEW_BRANCH followed by merging rev 46647 to the new branch. ........ r46656 | andrew.kuchling | 2006-06-05 02:08:09 +0200 (Mon, 05 Jun 2006) | 1 line Mention second encoding speedup ........ r46657 | gregory.p.smith | 2006-06-05 02:31:01 +0200 (Mon, 05 Jun 2006) | 7 lines bugfix: when log_archive was called with the DB_ARCH_REMOVE flag present in BerkeleyDB >= 4.2 it tried to construct a list out of an uninitialized char **log_list. feature: export the DB_ARCH_REMOVE flag by name in the module on BerkeleyDB >= 4.2. ........ r46658 | gregory.p.smith | 2006-06-05 02:33:35 +0200 (Mon, 05 Jun 2006) | 5 lines fix a bug in the previous commit. don't leak empty list on error return and fix the additional rare (out of memory only) bug that it was supposed to fix of not freeing log_list when the python allocator failed. ........ r46660 | tim.peters | 2006-06-05 02:55:26 +0200 (Mon, 05 Jun 2006) | 9 lines "Flat is better than nested." Move the long-winded, multiply-nested -R support out of runtest() and into some module-level helper functions. This makes runtest() and the -R code easier to follow. That in turn allowed seeing some opportunities for code simplification, and made it obvious that reglog.txt never got closed. ........ r46661 | hyeshik.chang | 2006-06-05 02:59:54 +0200 (Mon, 05 Jun 2006) | 3 lines Fix a potentially invalid memory access of CJKCodecs' shift-jis decoder. (found by Neal Norwitz) ........ r46663 | gregory.p.smith | 2006-06-05 03:39:52 +0200 (Mon, 05 Jun 2006) | 3 lines * support DBEnv.log_stat() method on BerkeleyDB >= 4.0 [patch #1494885] ........ r46664 | tim.peters | 2006-06-05 03:43:03 +0200 (Mon, 05 Jun 2006) | 3 lines Remove doctest.testmod's deprecated (in 2.4) `isprivate` argument. A lot of hair went into supporting that! ........ r46665 | tim.peters | 2006-06-05 03:47:24 +0200 (Mon, 05 Jun 2006) | 2 lines Whitespace normalization. ........ r46666 | tim.peters | 2006-06-05 03:48:21 +0200 (Mon, 05 Jun 2006) | 2 lines Make doctest news more accurate. ........ r46667 | gregory.p.smith | 2006-06-05 03:56:15 +0200 (Mon, 05 Jun 2006) | 3 lines * support DBEnv.lsn_reset() method on BerkeleyDB >= 4.4 [patch #1494902] ........ r46668 | gregory.p.smith | 2006-06-05 04:02:25 +0200 (Mon, 05 Jun 2006) | 3 lines mention the just committed bsddb changes ........ r46671 | gregory.p.smith | 2006-06-05 19:38:04 +0200 (Mon, 05 Jun 2006) | 3 lines * add support for DBSequence objects [patch #1466734] ........ r46672 | gregory.p.smith | 2006-06-05 20:20:07 +0200 (Mon, 05 Jun 2006) | 3 lines forgot to add this file in previous commit ........ r46673 | tim.peters | 2006-06-05 20:36:12 +0200 (Mon, 05 Jun 2006) | 2 lines Whitespace normalization. ........ r46674 | tim.peters | 2006-06-05 20:36:54 +0200 (Mon, 05 Jun 2006) | 2 lines Add missing svn:eol-style property to text files. ........ r46675 | gregory.p.smith | 2006-06-05 20:48:21 +0200 (Mon, 05 Jun 2006) | 4 lines * fix DBCursor.pget() bug with keyword argument names when no data= is supplied [SF pybsddb bug #1477863] ........ r46676 | andrew.kuchling | 2006-06-05 21:05:32 +0200 (Mon, 05 Jun 2006) | 1 line Remove use of Trove name, which isn't very helpful to users ........ r46677 | andrew.kuchling | 2006-06-05 21:08:25 +0200 (Mon, 05 Jun 2006) | 1 line [Bug #1470026] Include link to list of classifiers ........ r46679 | tim.peters | 2006-06-05 22:48:49 +0200 (Mon, 05 Jun 2006) | 10 lines Access _struct attributes directly instead of mucking with getattr. string_reverse(): Simplify. assertRaises(): Raise TestFailed on failure. test_unpack_from(), test_pack_into(), test_pack_into_fn(): never use `assert` to test for an expected result (it doesn't test anything when Python is run with -O). ........ r46680 | tim.peters | 2006-06-05 22:49:27 +0200 (Mon, 05 Jun 2006) | 2 lines Add missing svn:eol-style property to text files. ........ r46681 | gregory.p.smith | 2006-06-06 01:38:06 +0200 (Tue, 06 Jun 2006) | 3 lines add depends = ['md5.h'] to the _md5 module extension for correctness sake. ........ r46682 | brett.cannon | 2006-06-06 01:51:55 +0200 (Tue, 06 Jun 2006) | 4 lines Add 3 more bytes to a buffer to cover constants in string and null byte on top of 10 possible digits for an int. Closes bug #1501223. ........ r46684 | gregory.p.smith | 2006-06-06 01:59:37 +0200 (Tue, 06 Jun 2006) | 5 lines - bsddb: the __len__ method of a DB object has been fixed to return correct results. It could previously incorrectly return 0 in some cases. Fixes SF bug 1493322 (pybsddb bug 1184012). ........ r46686 | tim.peters | 2006-06-06 02:25:07 +0200 (Tue, 06 Jun 2006) | 7 lines _PySys_Init(): It's rarely a good idea to size a buffer to the exact maximum size someone guesses is needed. In this case, if we're really worried about extreme integers, then "cp%d" can actually need 14 bytes (2 for "cp" + 1 for \0 at the end + 11 for -(2**31-1)). So reserve 128 bytes instead -- nothing is actually saved by making a stack-local buffer tiny. ........ r46687 | neal.norwitz | 2006-06-06 09:22:08 +0200 (Tue, 06 Jun 2006) | 1 line Remove unused variable (and stop compiler warning) ........ r46688 | neal.norwitz | 2006-06-06 09:23:01 +0200 (Tue, 06 Jun 2006) | 1 line Fix a bunch of parameter strings ........ r46689 | thomas.heller | 2006-06-06 13:34:33 +0200 (Tue, 06 Jun 2006) | 6 lines Convert CFieldObject tp_members to tp_getset, since there is no structmember typecode for Py_ssize_t fields. This should fix some of the errors on the PPC64 debian machine (64-bit, big endian). Assigning to readonly fields now raises AttributeError instead of TypeError, so the testcase has to be changed as well. ........ r46690 | thomas.heller | 2006-06-06 13:54:32 +0200 (Tue, 06 Jun 2006) | 1 line Damn - the sentinel was missing. And fix another silly mistake. ........ r46691 | martin.blais | 2006-06-06 14:46:55 +0200 (Tue, 06 Jun 2006) | 13 lines Normalized a few cases of whitespace in function declarations. Found them using:: find . -name '*.py' | while read i ; do grep 'def[^(]*( ' $i /dev/null ; done find . -name '*.py' | while read i ; do grep ' ):' $i /dev/null ; done (I was doing this all over my own code anyway, because I'd been using spaces in all defs, so I thought I'd make a run on the Python code as well. If you need to do such fixes in your own code, you can use xx-rename or parenregu.el within emacs.) ........ r46693 | thomas.heller | 2006-06-06 17:34:18 +0200 (Tue, 06 Jun 2006) | 1 line Specify argtypes for all test functions. Maybe that helps on strange ;-) architectures ........ r46694 | tim.peters | 2006-06-06 17:50:17 +0200 (Tue, 06 Jun 2006) | 5 lines BSequence_set_range(): Rev 46688 ("Fix a bunch of parameter strings") changed this function's signature seemingly by mistake, which is causing buildbots to fail test_bsddb3. Restored the pre-46688 signature. ........ r46695 | tim.peters | 2006-06-06 17:52:35 +0200 (Tue, 06 Jun 2006) | 4 lines On python-dev Thomas Heller said these were committed by mistake in rev 46693, so reverting this part of rev 46693. ........ r46696 | andrew.kuchling | 2006-06-06 19:10:41 +0200 (Tue, 06 Jun 2006) | 1 line Fix comment typo ........ r46697 | brett.cannon | 2006-06-06 20:08:16 +0200 (Tue, 06 Jun 2006) | 2 lines Fix coding style guide bug. ........ r46698 | thomas.heller | 2006-06-06 20:50:46 +0200 (Tue, 06 Jun 2006) | 2 lines Add a hack so that foreign functions returning float now do work on 64-bit big endian platforms. ........ r46699 | thomas.heller | 2006-06-06 21:25:13 +0200 (Tue, 06 Jun 2006) | 3 lines Use the same big-endian hack as in _ctypes/callproc.c for callback functions. This fixes the callback function tests that return float. ........ r46700 | ronald.oussoren | 2006-06-06 21:50:24 +0200 (Tue, 06 Jun 2006) | 5 lines * Ensure that "make altinstall" works when the tree was configured with --enable-framework * Also for --enable-framework: allow users to use --prefix to specify the location of the compatibility symlinks (such as /usr/local/bin/python) ........ r46701 | ronald.oussoren | 2006-06-06 21:56:00 +0200 (Tue, 06 Jun 2006) | 3 lines A quick hack to ensure the right key-bindings for IDLE on osx: install patched configuration files during a framework install. ........ r46702 | tim.peters | 2006-06-07 03:04:59 +0200 (Wed, 07 Jun 2006) | 4 lines dash_R_cleanup(): Clear filecmp._cache. This accounts for different results across -R runs (at least on Windows) of test_filecmp. ........ r46705 | tim.peters | 2006-06-07 08:57:51 +0200 (Wed, 07 Jun 2006) | 17 lines SF patch 1501987: Remove randomness from test_exceptions, from ?iga Seilnacht (sorry about the name, but Firefox on my box can't display the first character of the name -- the SF "Unix name" is zseil). This appears to cure the oddball intermittent leaks across runs when running test_exceptions under -R. I'm not sure why, but I'm too sleepy to care ;-) The thrust of the SF patch was to remove randomness in the pickle protocol used. I changed the patch to use range(pickle.HIGHEST_PROTOCOL + 1), to try both pickle and cPickle, and randomly mucked with other test lines to put statements on their own lines. Not a bugfix candidate (this is fiddling new-in-2.5 code). ........ r46706 | andrew.kuchling | 2006-06-07 15:55:33 +0200 (Wed, 07 Jun 2006) | 1 line Add an SQLite introduction, taken from the 'What's New' text ........ r46708 | andrew.kuchling | 2006-06-07 19:02:52 +0200 (Wed, 07 Jun 2006) | 1 line Mention other placeholders ........ r46709 | andrew.kuchling | 2006-06-07 19:03:46 +0200 (Wed, 07 Jun 2006) | 1 line Add an item; also, escape % ........ r46710 | andrew.kuchling | 2006-06-07 19:04:01 +0200 (Wed, 07 Jun 2006) | 1 line Mention other placeholders ........ r46716 | ronald.oussoren | 2006-06-07 20:57:44 +0200 (Wed, 07 Jun 2006) | 2 lines Move Mac/OSX/Tools one level up ........ r46717 | ronald.oussoren | 2006-06-07 20:58:01 +0200 (Wed, 07 Jun 2006) | 2 lines Move Mac/OSX/PythonLauncher one level up ........ r46718 | ronald.oussoren | 2006-06-07 20:58:42 +0200 (Wed, 07 Jun 2006) | 2 lines mv Mac/OSX/BuildScript one level up ........ r46719 | ronald.oussoren | 2006-06-07 21:02:03 +0200 (Wed, 07 Jun 2006) | 2 lines Move Mac/OSX/* one level up ........ r46720 | ronald.oussoren | 2006-06-07 21:06:01 +0200 (Wed, 07 Jun 2006) | 2 lines And the last bit: move IDLE one level up and adjust makefiles ........ r46723 | ronald.oussoren | 2006-06-07 21:38:53 +0200 (Wed, 07 Jun 2006) | 4 lines - Patch the correct version of python in the Info.plists at build time, instead of relying on a maintainer to update them before releases. - Remove the now empty Mac/OSX directory ........ r46727 | ronald.oussoren | 2006-06-07 22:18:44 +0200 (Wed, 07 Jun 2006) | 7 lines * If BuildApplet.py is used as an applet it starts with a version of sys.exutable that isn't usuable on an #!-line. That results in generated applets that don't actually work. Work around this problem by resetting sys.executable. * argvemulator.py didn't work on intel macs. This patch fixes this (bug #1491468) ........ r46728 | tim.peters | 2006-06-07 22:40:06 +0200 (Wed, 07 Jun 2006) | 2 lines Whitespace normalization. ........ r46729 | tim.peters | 2006-06-07 22:40:54 +0200 (Wed, 07 Jun 2006) | 2 lines Add missing svn:eol-style property to text files. ........ r46730 | thomas.heller | 2006-06-07 22:43:06 +0200 (Wed, 07 Jun 2006) | 7 lines Fix for foreign functions returning small structures on 64-bit big endian machines. Should fix the remaininf failure in the PPC64 Debian buildbot. Thanks to Matthias Klose for providing access to a machine to debug and test this. ........ r46731 | brett.cannon | 2006-06-07 23:48:17 +0200 (Wed, 07 Jun 2006) | 2 lines Clarify documentation for bf_getcharbuffer. ........ r46735 | neal.norwitz | 2006-06-08 07:12:45 +0200 (Thu, 08 Jun 2006) | 1 line Fix a refleak in recvfrom_into ........ r46736 | gregory.p.smith | 2006-06-08 07:17:08 +0200 (Thu, 08 Jun 2006) | 9 lines - bsddb: the bsddb.dbtables Modify method now raises the proper error and aborts the db transaction safely when a modifier callback fails. Fixes SF python patch/bug #1408584. Also cleans up the bsddb.dbtables docstrings since thats the only documentation that exists for that unadvertised module. (people really should really just use sqlite3) ........ r46737 | gregory.p.smith | 2006-06-08 07:38:11 +0200 (Thu, 08 Jun 2006) | 4 lines * Turn the deadlock situation described in SF bug #775414 into a DBDeadLockError exception. * add the test case for my previous dbtables commit. ........ r46738 | gregory.p.smith | 2006-06-08 07:39:54 +0200 (Thu, 08 Jun 2006) | 2 lines pasted set_lk_detect line in wrong spot in previous commit. fixed. passes tests this time. ........ r46739 | armin.rigo | 2006-06-08 12:56:24 +0200 (Thu, 08 Jun 2006) | 6 lines (arre, arigo) SF bug #1350060 Give a consistent behavior for comparison and hashing of method objects (both user- and built-in methods). Now compares the 'self' recursively. The hash was already asking for the hash of 'self'. ........ r46740 | andrew.kuchling | 2006-06-08 13:56:44 +0200 (Thu, 08 Jun 2006) | 1 line Typo fix ........ r46741 | georg.brandl | 2006-06-08 14:45:01 +0200 (Thu, 08 Jun 2006) | 2 lines Bug #1502750: Fix getargs "i" format to use LONG_MIN and LONG_MAX for bounds checking. ........ r46743 | georg.brandl | 2006-06-08 14:54:13 +0200 (Thu, 08 Jun 2006) | 2 lines Bug #1502728: Correctly link against librt library on HP-UX. ........ r46745 | georg.brandl | 2006-06-08 14:55:47 +0200 (Thu, 08 Jun 2006) | 3 lines Add news for recent bugfix. ........ r46746 | georg.brandl | 2006-06-08 15:31:07 +0200 (Thu, 08 Jun 2006) | 4 lines Argh. "integer" is a very confusing word ;) Actually, checking for INT_MAX and INT_MIN is correct since the format code explicitly handles a C "int". ........ r46748 | nick.coghlan | 2006-06-08 15:54:49 +0200 (Thu, 08 Jun 2006) | 1 line Add functools.update_wrapper() and functools.wraps() as described in PEP 356 ........ r46751 | georg.brandl | 2006-06-08 16:50:21 +0200 (Thu, 08 Jun 2006) | 4 lines Bug #1502805: don't alias file.__exit__ to file.close since the latter can return something that's true. ........ r46752 | georg.brandl | 2006-06-08 16:50:53 +0200 (Thu, 08 Jun 2006) | 3 lines Convert test_file to unittest. ........
20 years ago
Merged revisions 70578,70599,70641-70642,70650,70660-70661,70674,70691,70697-70698,70700,70704 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r70578 | benjamin.peterson | 2009-03-23 22:24:56 -0500 (Mon, 23 Mar 2009) | 1 line this is better written using assertRaises ........ r70599 | benjamin.peterson | 2009-03-25 16:42:51 -0500 (Wed, 25 Mar 2009) | 1 line this can be slightly less ugly ........ r70641 | guilherme.polo | 2009-03-27 16:43:08 -0500 (Fri, 27 Mar 2009) | 3 lines Adjusted _tkinter to compile without warnings when WITH_THREAD is not defined (part of issue #5035) ........ r70642 | georg.brandl | 2009-03-27 19:48:48 -0500 (Fri, 27 Mar 2009) | 1 line Fix typo. ........ r70650 | benjamin.peterson | 2009-03-28 14:16:10 -0500 (Sat, 28 Mar 2009) | 1 line give os.symlink and os.link() better parameter names #5564 ........ r70660 | georg.brandl | 2009-03-28 14:52:58 -0500 (Sat, 28 Mar 2009) | 1 line Switch to fixed Sphinx version. ........ r70661 | georg.brandl | 2009-03-28 14:57:36 -0500 (Sat, 28 Mar 2009) | 2 lines Add section numbering to some of the larger subdocuments. ........ r70674 | guilherme.polo | 2009-03-29 05:19:05 -0500 (Sun, 29 Mar 2009) | 1 line Typo fix. ........ r70691 | raymond.hettinger | 2009-03-29 13:51:11 -0500 (Sun, 29 Mar 2009) | 1 line Make life easier for non-CPython implementations. ........ r70697 | benjamin.peterson | 2009-03-29 16:22:35 -0500 (Sun, 29 Mar 2009) | 1 line this has been fixed since 2.6 (I love removing these) ........ r70698 | benjamin.peterson | 2009-03-29 16:31:05 -0500 (Sun, 29 Mar 2009) | 1 line thanks to guido's bytecode verifier, this is fixed ........ r70700 | benjamin.peterson | 2009-03-29 16:50:14 -0500 (Sun, 29 Mar 2009) | 1 line use the awesome new status iterator ........ r70704 | benjamin.peterson | 2009-03-29 21:49:32 -0500 (Sun, 29 Mar 2009) | 1 line there's actually three methods here #5600 ........
17 years ago
Merged revisions 70578,70599,70641-70642,70650,70660-70661,70674,70691,70697-70698,70700,70704 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r70578 | benjamin.peterson | 2009-03-23 22:24:56 -0500 (Mon, 23 Mar 2009) | 1 line this is better written using assertRaises ........ r70599 | benjamin.peterson | 2009-03-25 16:42:51 -0500 (Wed, 25 Mar 2009) | 1 line this can be slightly less ugly ........ r70641 | guilherme.polo | 2009-03-27 16:43:08 -0500 (Fri, 27 Mar 2009) | 3 lines Adjusted _tkinter to compile without warnings when WITH_THREAD is not defined (part of issue #5035) ........ r70642 | georg.brandl | 2009-03-27 19:48:48 -0500 (Fri, 27 Mar 2009) | 1 line Fix typo. ........ r70650 | benjamin.peterson | 2009-03-28 14:16:10 -0500 (Sat, 28 Mar 2009) | 1 line give os.symlink and os.link() better parameter names #5564 ........ r70660 | georg.brandl | 2009-03-28 14:52:58 -0500 (Sat, 28 Mar 2009) | 1 line Switch to fixed Sphinx version. ........ r70661 | georg.brandl | 2009-03-28 14:57:36 -0500 (Sat, 28 Mar 2009) | 2 lines Add section numbering to some of the larger subdocuments. ........ r70674 | guilherme.polo | 2009-03-29 05:19:05 -0500 (Sun, 29 Mar 2009) | 1 line Typo fix. ........ r70691 | raymond.hettinger | 2009-03-29 13:51:11 -0500 (Sun, 29 Mar 2009) | 1 line Make life easier for non-CPython implementations. ........ r70697 | benjamin.peterson | 2009-03-29 16:22:35 -0500 (Sun, 29 Mar 2009) | 1 line this has been fixed since 2.6 (I love removing these) ........ r70698 | benjamin.peterson | 2009-03-29 16:31:05 -0500 (Sun, 29 Mar 2009) | 1 line thanks to guido's bytecode verifier, this is fixed ........ r70700 | benjamin.peterson | 2009-03-29 16:50:14 -0500 (Sun, 29 Mar 2009) | 1 line use the awesome new status iterator ........ r70704 | benjamin.peterson | 2009-03-29 21:49:32 -0500 (Sun, 29 Mar 2009) | 1 line there's actually three methods here #5600 ........
17 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
Merge the rest of the trunk. Merged revisions 46490-46494,46496,46498,46500,46506,46521,46538,46558,46563-46567,46570-46571,46583,46593,46595-46598,46604,46606,46609-46753 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r46610 | martin.v.loewis | 2006-06-03 09:42:26 +0200 (Sat, 03 Jun 2006) | 2 lines Updated version (win32-icons2.zip) from #1490384. ........ r46612 | andrew.kuchling | 2006-06-03 20:09:41 +0200 (Sat, 03 Jun 2006) | 1 line [Bug #1472084] Fix description of do_tag ........ r46614 | andrew.kuchling | 2006-06-03 20:33:35 +0200 (Sat, 03 Jun 2006) | 1 line [Bug #1475554] Strengthen text to say 'must' instead of 'should' ........ r46616 | andrew.kuchling | 2006-06-03 20:41:28 +0200 (Sat, 03 Jun 2006) | 1 line [Bug #1441864] Clarify description of 'data' argument ........ r46617 | andrew.kuchling | 2006-06-03 20:43:24 +0200 (Sat, 03 Jun 2006) | 1 line Minor rewording ........ r46619 | andrew.kuchling | 2006-06-03 21:02:35 +0200 (Sat, 03 Jun 2006) | 9 lines [Bug #1497414] _self is a reserved word in the WATCOM 10.6 C compiler. Fix by renaming the variable. In a different module, Neal fixed it by renaming _self to self. There's already a variable named 'self' here, so I used selfptr. (I'm committing this on a Mac without Tk, but it's a simple search-and-replace. <crosses fingers>, so I'll watch the buildbots and see what happens.) ........ r46621 | fredrik.lundh | 2006-06-03 23:56:05 +0200 (Sat, 03 Jun 2006) | 5 lines "_self" is a said to be a reserved word in Watcom C 10.6. I'm not sure that's really standard compliant behaviour, but I guess we have to fix that anyway... ........ r46622 | andrew.kuchling | 2006-06-04 00:44:42 +0200 (Sun, 04 Jun 2006) | 1 line Update readme ........ r46623 | andrew.kuchling | 2006-06-04 00:59:23 +0200 (Sun, 04 Jun 2006) | 1 line Drop 0 parameter ........ r46624 | andrew.kuchling | 2006-06-04 00:59:59 +0200 (Sun, 04 Jun 2006) | 1 line Some code tidying; use curses.wrapper ........ r46625 | andrew.kuchling | 2006-06-04 01:02:15 +0200 (Sun, 04 Jun 2006) | 1 line Use True; value returned from main is unused ........ r46626 | andrew.kuchling | 2006-06-04 01:07:21 +0200 (Sun, 04 Jun 2006) | 1 line Use true division, and the True value ........ r46627 | andrew.kuchling | 2006-06-04 01:09:58 +0200 (Sun, 04 Jun 2006) | 1 line Docstring fix; use True ........ r46628 | andrew.kuchling | 2006-06-04 01:15:56 +0200 (Sun, 04 Jun 2006) | 1 line Put code in a main() function; loosen up the spacing to match current code style ........ r46629 | andrew.kuchling | 2006-06-04 01:39:07 +0200 (Sun, 04 Jun 2006) | 1 line Use functions; modernize code ........ r46630 | andrew.kuchling | 2006-06-04 01:43:22 +0200 (Sun, 04 Jun 2006) | 1 line This demo requires Medusa (not just asyncore); remove it ........ r46631 | andrew.kuchling | 2006-06-04 01:46:36 +0200 (Sun, 04 Jun 2006) | 2 lines Remove xmlrpc demo -- it duplicates the SimpleXMLRPCServer module. ........ r46632 | andrew.kuchling | 2006-06-04 01:47:22 +0200 (Sun, 04 Jun 2006) | 1 line Remove xmlrpc/ directory ........ r46633 | andrew.kuchling | 2006-06-04 01:51:21 +0200 (Sun, 04 Jun 2006) | 1 line Remove dangling reference ........ r46634 | andrew.kuchling | 2006-06-04 01:59:36 +0200 (Sun, 04 Jun 2006) | 1 line Add more whitespace; use a better socket name ........ r46635 | tim.peters | 2006-06-04 03:22:53 +0200 (Sun, 04 Jun 2006) | 2 lines Whitespace normalization. ........ r46637 | tim.peters | 2006-06-04 05:26:02 +0200 (Sun, 04 Jun 2006) | 16 lines In a PYMALLOC_DEBUG build obmalloc adds extra debugging info to each allocated block. This was using 4 bytes for each such piece of info regardless of platform. This didn't really matter before (proof: no bug reports, and the debug-build obmalloc would have assert-failed if it was ever asked for a chunk of memory >= 2**32 bytes), since container indices were plain ints. But after the Py_ssize_t changes, it's at least theoretically possible to allocate a list or string whose guts exceed 2**32 bytes, and the PYMALLOC_DEBUG routines would fail then (having only 4 bytes to record the originally requested size). Now we use sizeof(size_t) bytes for each of a PYMALLOC_DEBUG build's extra debugging fields. This won't make any difference on 32-bit boxes, but will add 16 bytes to each allocation in a debug build on a 64-bit box. ........ r46638 | tim.peters | 2006-06-04 05:38:04 +0200 (Sun, 04 Jun 2006) | 4 lines _PyObject_DebugMalloc(): The return value should add 2*sizeof(size_t) now, not 8. This probably accounts for current disasters on the 64-bit buildbot slaves. ........ r46639 | neal.norwitz | 2006-06-04 08:19:31 +0200 (Sun, 04 Jun 2006) | 1 line SF #1499797, Fix for memory leak in WindowsError_str ........ r46640 | andrew.macintyre | 2006-06-04 14:31:09 +0200 (Sun, 04 Jun 2006) | 2 lines Patch #1454481: Make thread stack size runtime tunable. ........ r46641 | andrew.macintyre | 2006-06-04 14:59:59 +0200 (Sun, 04 Jun 2006) | 2 lines clean up function declarations to conform to PEP-7 style. ........ r46642 | martin.blais | 2006-06-04 15:49:49 +0200 (Sun, 04 Jun 2006) | 15 lines Fixes in struct and socket from merge reviews. - Following Guido's comments, renamed * pack_to -> pack_into * recv_buf -> recv_into * recvfrom_buf -> recvfrom_into - Made fixes to _struct.c according to Neal Norwitz comments on the checkins list. - Converted some ints into the appropriate -- I hope -- ssize_t and size_t. ........ r46643 | ronald.oussoren | 2006-06-04 16:05:28 +0200 (Sun, 04 Jun 2006) | 3 lines "Import" LDFLAGS in Mac/OSX/Makefile.in to ensure pythonw gets build with the right compiler flags. ........ r46644 | ronald.oussoren | 2006-06-04 16:24:59 +0200 (Sun, 04 Jun 2006) | 2 lines Drop Mac wrappers for the WASTE library. ........ r46645 | tim.peters | 2006-06-04 17:49:07 +0200 (Sun, 04 Jun 2006) | 3 lines s_methods[]: Stop compiler warnings by casting s_unpack_from to PyCFunction. ........ r46646 | george.yoshida | 2006-06-04 19:04:12 +0200 (Sun, 04 Jun 2006) | 2 lines Remove a redundant word ........ r46647 | george.yoshida | 2006-06-04 19:17:25 +0200 (Sun, 04 Jun 2006) | 2 lines Markup fix ........ r46648 | martin.v.loewis | 2006-06-04 21:36:28 +0200 (Sun, 04 Jun 2006) | 2 lines Patch #1359618: Speed-up charmap encoder. ........ r46649 | georg.brandl | 2006-06-04 23:46:16 +0200 (Sun, 04 Jun 2006) | 3 lines Repair refleaks in unicodeobject. ........ r46650 | georg.brandl | 2006-06-04 23:56:52 +0200 (Sun, 04 Jun 2006) | 4 lines Patch #1346214: correctly optimize away "if 0"-style stmts (thanks to Neal for review) ........ r46651 | georg.brandl | 2006-06-05 00:15:37 +0200 (Mon, 05 Jun 2006) | 2 lines Bug #1500293: fix memory leaks in _subprocess module. ........ r46654 | tim.peters | 2006-06-05 01:43:53 +0200 (Mon, 05 Jun 2006) | 2 lines Whitespace normalization. ........ r46655 | tim.peters | 2006-06-05 01:52:47 +0200 (Mon, 05 Jun 2006) | 16 lines Revert revisions: 46640 Patch #1454481: Make thread stack size runtime tunable. 46647 Markup fix The first is causing many buildbots to fail test runs, and there are multiple causes with seemingly no immediate prospects for repairing them. See python-dev discussion. Note that a branch can (and should) be created for resolving these problems, like svn copy svn+ssh://svn.python.org/python/trunk -r46640 svn+ssh://svn.python.org/python/branches/NEW_BRANCH followed by merging rev 46647 to the new branch. ........ r46656 | andrew.kuchling | 2006-06-05 02:08:09 +0200 (Mon, 05 Jun 2006) | 1 line Mention second encoding speedup ........ r46657 | gregory.p.smith | 2006-06-05 02:31:01 +0200 (Mon, 05 Jun 2006) | 7 lines bugfix: when log_archive was called with the DB_ARCH_REMOVE flag present in BerkeleyDB >= 4.2 it tried to construct a list out of an uninitialized char **log_list. feature: export the DB_ARCH_REMOVE flag by name in the module on BerkeleyDB >= 4.2. ........ r46658 | gregory.p.smith | 2006-06-05 02:33:35 +0200 (Mon, 05 Jun 2006) | 5 lines fix a bug in the previous commit. don't leak empty list on error return and fix the additional rare (out of memory only) bug that it was supposed to fix of not freeing log_list when the python allocator failed. ........ r46660 | tim.peters | 2006-06-05 02:55:26 +0200 (Mon, 05 Jun 2006) | 9 lines "Flat is better than nested." Move the long-winded, multiply-nested -R support out of runtest() and into some module-level helper functions. This makes runtest() and the -R code easier to follow. That in turn allowed seeing some opportunities for code simplification, and made it obvious that reglog.txt never got closed. ........ r46661 | hyeshik.chang | 2006-06-05 02:59:54 +0200 (Mon, 05 Jun 2006) | 3 lines Fix a potentially invalid memory access of CJKCodecs' shift-jis decoder. (found by Neal Norwitz) ........ r46663 | gregory.p.smith | 2006-06-05 03:39:52 +0200 (Mon, 05 Jun 2006) | 3 lines * support DBEnv.log_stat() method on BerkeleyDB >= 4.0 [patch #1494885] ........ r46664 | tim.peters | 2006-06-05 03:43:03 +0200 (Mon, 05 Jun 2006) | 3 lines Remove doctest.testmod's deprecated (in 2.4) `isprivate` argument. A lot of hair went into supporting that! ........ r46665 | tim.peters | 2006-06-05 03:47:24 +0200 (Mon, 05 Jun 2006) | 2 lines Whitespace normalization. ........ r46666 | tim.peters | 2006-06-05 03:48:21 +0200 (Mon, 05 Jun 2006) | 2 lines Make doctest news more accurate. ........ r46667 | gregory.p.smith | 2006-06-05 03:56:15 +0200 (Mon, 05 Jun 2006) | 3 lines * support DBEnv.lsn_reset() method on BerkeleyDB >= 4.4 [patch #1494902] ........ r46668 | gregory.p.smith | 2006-06-05 04:02:25 +0200 (Mon, 05 Jun 2006) | 3 lines mention the just committed bsddb changes ........ r46671 | gregory.p.smith | 2006-06-05 19:38:04 +0200 (Mon, 05 Jun 2006) | 3 lines * add support for DBSequence objects [patch #1466734] ........ r46672 | gregory.p.smith | 2006-06-05 20:20:07 +0200 (Mon, 05 Jun 2006) | 3 lines forgot to add this file in previous commit ........ r46673 | tim.peters | 2006-06-05 20:36:12 +0200 (Mon, 05 Jun 2006) | 2 lines Whitespace normalization. ........ r46674 | tim.peters | 2006-06-05 20:36:54 +0200 (Mon, 05 Jun 2006) | 2 lines Add missing svn:eol-style property to text files. ........ r46675 | gregory.p.smith | 2006-06-05 20:48:21 +0200 (Mon, 05 Jun 2006) | 4 lines * fix DBCursor.pget() bug with keyword argument names when no data= is supplied [SF pybsddb bug #1477863] ........ r46676 | andrew.kuchling | 2006-06-05 21:05:32 +0200 (Mon, 05 Jun 2006) | 1 line Remove use of Trove name, which isn't very helpful to users ........ r46677 | andrew.kuchling | 2006-06-05 21:08:25 +0200 (Mon, 05 Jun 2006) | 1 line [Bug #1470026] Include link to list of classifiers ........ r46679 | tim.peters | 2006-06-05 22:48:49 +0200 (Mon, 05 Jun 2006) | 10 lines Access _struct attributes directly instead of mucking with getattr. string_reverse(): Simplify. assertRaises(): Raise TestFailed on failure. test_unpack_from(), test_pack_into(), test_pack_into_fn(): never use `assert` to test for an expected result (it doesn't test anything when Python is run with -O). ........ r46680 | tim.peters | 2006-06-05 22:49:27 +0200 (Mon, 05 Jun 2006) | 2 lines Add missing svn:eol-style property to text files. ........ r46681 | gregory.p.smith | 2006-06-06 01:38:06 +0200 (Tue, 06 Jun 2006) | 3 lines add depends = ['md5.h'] to the _md5 module extension for correctness sake. ........ r46682 | brett.cannon | 2006-06-06 01:51:55 +0200 (Tue, 06 Jun 2006) | 4 lines Add 3 more bytes to a buffer to cover constants in string and null byte on top of 10 possible digits for an int. Closes bug #1501223. ........ r46684 | gregory.p.smith | 2006-06-06 01:59:37 +0200 (Tue, 06 Jun 2006) | 5 lines - bsddb: the __len__ method of a DB object has been fixed to return correct results. It could previously incorrectly return 0 in some cases. Fixes SF bug 1493322 (pybsddb bug 1184012). ........ r46686 | tim.peters | 2006-06-06 02:25:07 +0200 (Tue, 06 Jun 2006) | 7 lines _PySys_Init(): It's rarely a good idea to size a buffer to the exact maximum size someone guesses is needed. In this case, if we're really worried about extreme integers, then "cp%d" can actually need 14 bytes (2 for "cp" + 1 for \0 at the end + 11 for -(2**31-1)). So reserve 128 bytes instead -- nothing is actually saved by making a stack-local buffer tiny. ........ r46687 | neal.norwitz | 2006-06-06 09:22:08 +0200 (Tue, 06 Jun 2006) | 1 line Remove unused variable (and stop compiler warning) ........ r46688 | neal.norwitz | 2006-06-06 09:23:01 +0200 (Tue, 06 Jun 2006) | 1 line Fix a bunch of parameter strings ........ r46689 | thomas.heller | 2006-06-06 13:34:33 +0200 (Tue, 06 Jun 2006) | 6 lines Convert CFieldObject tp_members to tp_getset, since there is no structmember typecode for Py_ssize_t fields. This should fix some of the errors on the PPC64 debian machine (64-bit, big endian). Assigning to readonly fields now raises AttributeError instead of TypeError, so the testcase has to be changed as well. ........ r46690 | thomas.heller | 2006-06-06 13:54:32 +0200 (Tue, 06 Jun 2006) | 1 line Damn - the sentinel was missing. And fix another silly mistake. ........ r46691 | martin.blais | 2006-06-06 14:46:55 +0200 (Tue, 06 Jun 2006) | 13 lines Normalized a few cases of whitespace in function declarations. Found them using:: find . -name '*.py' | while read i ; do grep 'def[^(]*( ' $i /dev/null ; done find . -name '*.py' | while read i ; do grep ' ):' $i /dev/null ; done (I was doing this all over my own code anyway, because I'd been using spaces in all defs, so I thought I'd make a run on the Python code as well. If you need to do such fixes in your own code, you can use xx-rename or parenregu.el within emacs.) ........ r46693 | thomas.heller | 2006-06-06 17:34:18 +0200 (Tue, 06 Jun 2006) | 1 line Specify argtypes for all test functions. Maybe that helps on strange ;-) architectures ........ r46694 | tim.peters | 2006-06-06 17:50:17 +0200 (Tue, 06 Jun 2006) | 5 lines BSequence_set_range(): Rev 46688 ("Fix a bunch of parameter strings") changed this function's signature seemingly by mistake, which is causing buildbots to fail test_bsddb3. Restored the pre-46688 signature. ........ r46695 | tim.peters | 2006-06-06 17:52:35 +0200 (Tue, 06 Jun 2006) | 4 lines On python-dev Thomas Heller said these were committed by mistake in rev 46693, so reverting this part of rev 46693. ........ r46696 | andrew.kuchling | 2006-06-06 19:10:41 +0200 (Tue, 06 Jun 2006) | 1 line Fix comment typo ........ r46697 | brett.cannon | 2006-06-06 20:08:16 +0200 (Tue, 06 Jun 2006) | 2 lines Fix coding style guide bug. ........ r46698 | thomas.heller | 2006-06-06 20:50:46 +0200 (Tue, 06 Jun 2006) | 2 lines Add a hack so that foreign functions returning float now do work on 64-bit big endian platforms. ........ r46699 | thomas.heller | 2006-06-06 21:25:13 +0200 (Tue, 06 Jun 2006) | 3 lines Use the same big-endian hack as in _ctypes/callproc.c for callback functions. This fixes the callback function tests that return float. ........ r46700 | ronald.oussoren | 2006-06-06 21:50:24 +0200 (Tue, 06 Jun 2006) | 5 lines * Ensure that "make altinstall" works when the tree was configured with --enable-framework * Also for --enable-framework: allow users to use --prefix to specify the location of the compatibility symlinks (such as /usr/local/bin/python) ........ r46701 | ronald.oussoren | 2006-06-06 21:56:00 +0200 (Tue, 06 Jun 2006) | 3 lines A quick hack to ensure the right key-bindings for IDLE on osx: install patched configuration files during a framework install. ........ r46702 | tim.peters | 2006-06-07 03:04:59 +0200 (Wed, 07 Jun 2006) | 4 lines dash_R_cleanup(): Clear filecmp._cache. This accounts for different results across -R runs (at least on Windows) of test_filecmp. ........ r46705 | tim.peters | 2006-06-07 08:57:51 +0200 (Wed, 07 Jun 2006) | 17 lines SF patch 1501987: Remove randomness from test_exceptions, from ?iga Seilnacht (sorry about the name, but Firefox on my box can't display the first character of the name -- the SF "Unix name" is zseil). This appears to cure the oddball intermittent leaks across runs when running test_exceptions under -R. I'm not sure why, but I'm too sleepy to care ;-) The thrust of the SF patch was to remove randomness in the pickle protocol used. I changed the patch to use range(pickle.HIGHEST_PROTOCOL + 1), to try both pickle and cPickle, and randomly mucked with other test lines to put statements on their own lines. Not a bugfix candidate (this is fiddling new-in-2.5 code). ........ r46706 | andrew.kuchling | 2006-06-07 15:55:33 +0200 (Wed, 07 Jun 2006) | 1 line Add an SQLite introduction, taken from the 'What's New' text ........ r46708 | andrew.kuchling | 2006-06-07 19:02:52 +0200 (Wed, 07 Jun 2006) | 1 line Mention other placeholders ........ r46709 | andrew.kuchling | 2006-06-07 19:03:46 +0200 (Wed, 07 Jun 2006) | 1 line Add an item; also, escape % ........ r46710 | andrew.kuchling | 2006-06-07 19:04:01 +0200 (Wed, 07 Jun 2006) | 1 line Mention other placeholders ........ r46716 | ronald.oussoren | 2006-06-07 20:57:44 +0200 (Wed, 07 Jun 2006) | 2 lines Move Mac/OSX/Tools one level up ........ r46717 | ronald.oussoren | 2006-06-07 20:58:01 +0200 (Wed, 07 Jun 2006) | 2 lines Move Mac/OSX/PythonLauncher one level up ........ r46718 | ronald.oussoren | 2006-06-07 20:58:42 +0200 (Wed, 07 Jun 2006) | 2 lines mv Mac/OSX/BuildScript one level up ........ r46719 | ronald.oussoren | 2006-06-07 21:02:03 +0200 (Wed, 07 Jun 2006) | 2 lines Move Mac/OSX/* one level up ........ r46720 | ronald.oussoren | 2006-06-07 21:06:01 +0200 (Wed, 07 Jun 2006) | 2 lines And the last bit: move IDLE one level up and adjust makefiles ........ r46723 | ronald.oussoren | 2006-06-07 21:38:53 +0200 (Wed, 07 Jun 2006) | 4 lines - Patch the correct version of python in the Info.plists at build time, instead of relying on a maintainer to update them before releases. - Remove the now empty Mac/OSX directory ........ r46727 | ronald.oussoren | 2006-06-07 22:18:44 +0200 (Wed, 07 Jun 2006) | 7 lines * If BuildApplet.py is used as an applet it starts with a version of sys.exutable that isn't usuable on an #!-line. That results in generated applets that don't actually work. Work around this problem by resetting sys.executable. * argvemulator.py didn't work on intel macs. This patch fixes this (bug #1491468) ........ r46728 | tim.peters | 2006-06-07 22:40:06 +0200 (Wed, 07 Jun 2006) | 2 lines Whitespace normalization. ........ r46729 | tim.peters | 2006-06-07 22:40:54 +0200 (Wed, 07 Jun 2006) | 2 lines Add missing svn:eol-style property to text files. ........ r46730 | thomas.heller | 2006-06-07 22:43:06 +0200 (Wed, 07 Jun 2006) | 7 lines Fix for foreign functions returning small structures on 64-bit big endian machines. Should fix the remaininf failure in the PPC64 Debian buildbot. Thanks to Matthias Klose for providing access to a machine to debug and test this. ........ r46731 | brett.cannon | 2006-06-07 23:48:17 +0200 (Wed, 07 Jun 2006) | 2 lines Clarify documentation for bf_getcharbuffer. ........ r46735 | neal.norwitz | 2006-06-08 07:12:45 +0200 (Thu, 08 Jun 2006) | 1 line Fix a refleak in recvfrom_into ........ r46736 | gregory.p.smith | 2006-06-08 07:17:08 +0200 (Thu, 08 Jun 2006) | 9 lines - bsddb: the bsddb.dbtables Modify method now raises the proper error and aborts the db transaction safely when a modifier callback fails. Fixes SF python patch/bug #1408584. Also cleans up the bsddb.dbtables docstrings since thats the only documentation that exists for that unadvertised module. (people really should really just use sqlite3) ........ r46737 | gregory.p.smith | 2006-06-08 07:38:11 +0200 (Thu, 08 Jun 2006) | 4 lines * Turn the deadlock situation described in SF bug #775414 into a DBDeadLockError exception. * add the test case for my previous dbtables commit. ........ r46738 | gregory.p.smith | 2006-06-08 07:39:54 +0200 (Thu, 08 Jun 2006) | 2 lines pasted set_lk_detect line in wrong spot in previous commit. fixed. passes tests this time. ........ r46739 | armin.rigo | 2006-06-08 12:56:24 +0200 (Thu, 08 Jun 2006) | 6 lines (arre, arigo) SF bug #1350060 Give a consistent behavior for comparison and hashing of method objects (both user- and built-in methods). Now compares the 'self' recursively. The hash was already asking for the hash of 'self'. ........ r46740 | andrew.kuchling | 2006-06-08 13:56:44 +0200 (Thu, 08 Jun 2006) | 1 line Typo fix ........ r46741 | georg.brandl | 2006-06-08 14:45:01 +0200 (Thu, 08 Jun 2006) | 2 lines Bug #1502750: Fix getargs "i" format to use LONG_MIN and LONG_MAX for bounds checking. ........ r46743 | georg.brandl | 2006-06-08 14:54:13 +0200 (Thu, 08 Jun 2006) | 2 lines Bug #1502728: Correctly link against librt library on HP-UX. ........ r46745 | georg.brandl | 2006-06-08 14:55:47 +0200 (Thu, 08 Jun 2006) | 3 lines Add news for recent bugfix. ........ r46746 | georg.brandl | 2006-06-08 15:31:07 +0200 (Thu, 08 Jun 2006) | 4 lines Argh. "integer" is a very confusing word ;) Actually, checking for INT_MAX and INT_MIN is correct since the format code explicitly handles a C "int". ........ r46748 | nick.coghlan | 2006-06-08 15:54:49 +0200 (Thu, 08 Jun 2006) | 1 line Add functools.update_wrapper() and functools.wraps() as described in PEP 356 ........ r46751 | georg.brandl | 2006-06-08 16:50:21 +0200 (Thu, 08 Jun 2006) | 4 lines Bug #1502805: don't alias file.__exit__ to file.close since the latter can return something that's true. ........ r46752 | georg.brandl | 2006-06-08 16:50:53 +0200 (Thu, 08 Jun 2006) | 3 lines Convert test_file to unittest. ........
20 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
32 years ago
  1. /***********************************************************
  2. Copyright (C) 1994 Steen Lumholt.
  3. All Rights Reserved
  4. ******************************************************************/
  5. /* _tkinter.c -- Interface to libtk.a and libtcl.a. */
  6. /* TCL/TK VERSION INFO:
  7. Only Tcl/Tk 8.3.1 and later are supported. Older versions are not
  8. supported. Use Python 2.6 or older if you cannot upgrade your
  9. Tcl/Tk libraries.
  10. */
  11. /* XXX Further speed-up ideas, involving Tcl 8.0 features:
  12. - Register a new Tcl type, "Python callable", which can be called more
  13. efficiently and passed to Tcl_EvalObj() directly (if this is possible).
  14. */
  15. #include "Python.h"
  16. #include <ctype.h>
  17. #ifdef WITH_THREAD
  18. #include "pythread.h"
  19. #endif
  20. #ifdef MS_WINDOWS
  21. #include <windows.h>
  22. #endif
  23. #define CHECK_SIZE(size, elemsize) \
  24. ((size_t)(size) <= Py_MIN((size_t)INT_MAX, UINT_MAX / (size_t)(elemsize)))
  25. /* Starting with Tcl 8.4, many APIs offer const-correctness. Unfortunately,
  26. making _tkinter correct for this API means to break earlier
  27. versions. USE_COMPAT_CONST allows to make _tkinter work with both 8.4 and
  28. earlier versions. Once Tcl releases before 8.4 don't need to be supported
  29. anymore, this should go. */
  30. #define USE_COMPAT_CONST
  31. /* If Tcl is compiled for threads, we must also define TCL_THREAD. We define
  32. it always; if Tcl is not threaded, the thread functions in
  33. Tcl are empty. */
  34. #define TCL_THREADS
  35. #ifdef TK_FRAMEWORK
  36. #include <Tcl/tcl.h>
  37. #include <Tk/tk.h>
  38. #else
  39. #include <tcl.h>
  40. #include <tk.h>
  41. #endif
  42. #include "tkinter.h"
  43. /* For Tcl 8.2 and 8.3, CONST* is not defined (except on Cygwin). */
  44. #ifndef CONST84_RETURN
  45. #define CONST84_RETURN
  46. #undef CONST
  47. #define CONST
  48. #endif
  49. #if TK_HEX_VERSION < 0x08030201
  50. #error "Tk older than 8.3.1 not supported"
  51. #endif
  52. #if TK_HEX_VERSION >= 0x08050208 && TK_HEX_VERSION < 0x08060000 || \
  53. TK_HEX_VERSION >= 0x08060200
  54. #define HAVE_LIBTOMMAMTH
  55. #include <tclTomMath.h>
  56. #endif
  57. #if !(defined(MS_WINDOWS) || defined(__CYGWIN__))
  58. #define HAVE_CREATEFILEHANDLER
  59. #endif
  60. #ifdef HAVE_CREATEFILEHANDLER
  61. /* This bit is to ensure that TCL_UNIX_FD is defined and doesn't interfere
  62. with the proper calculation of FHANDLETYPE == TCL_UNIX_FD below. */
  63. #ifndef TCL_UNIX_FD
  64. # ifdef TCL_WIN_SOCKET
  65. # define TCL_UNIX_FD (! TCL_WIN_SOCKET)
  66. # else
  67. # define TCL_UNIX_FD 1
  68. # endif
  69. #endif
  70. /* Tcl_CreateFileHandler() changed several times; these macros deal with the
  71. messiness. In Tcl 8.0 and later, it is not available on Windows (and on
  72. Unix, only because Jack added it back); when available on Windows, it only
  73. applies to sockets. */
  74. #ifdef MS_WINDOWS
  75. #define FHANDLETYPE TCL_WIN_SOCKET
  76. #else
  77. #define FHANDLETYPE TCL_UNIX_FD
  78. #endif
  79. /* If Tcl can wait for a Unix file descriptor, define the EventHook() routine
  80. which uses this to handle Tcl events while the user is typing commands. */
  81. #if FHANDLETYPE == TCL_UNIX_FD
  82. #define WAIT_FOR_STDIN
  83. #endif
  84. #endif /* HAVE_CREATEFILEHANDLER */
  85. #ifdef MS_WINDOWS
  86. #include <conio.h>
  87. #define WAIT_FOR_STDIN
  88. #endif
  89. #ifdef WITH_THREAD
  90. /* The threading situation is complicated. Tcl is not thread-safe, except
  91. when configured with --enable-threads.
  92. So we need to use a lock around all uses of Tcl. Previously, the
  93. Python interpreter lock was used for this. However, this causes
  94. problems when other Python threads need to run while Tcl is blocked
  95. waiting for events.
  96. To solve this problem, a separate lock for Tcl is introduced.
  97. Holding it is incompatible with holding Python's interpreter lock.
  98. The following four macros manipulate both locks together.
  99. ENTER_TCL and LEAVE_TCL are brackets, just like
  100. Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS. They should be
  101. used whenever a call into Tcl is made that could call an event
  102. handler, or otherwise affect the state of a Tcl interpreter. These
  103. assume that the surrounding code has the Python interpreter lock;
  104. inside the brackets, the Python interpreter lock has been released
  105. and the lock for Tcl has been acquired.
  106. Sometimes, it is necessary to have both the Python lock and the Tcl
  107. lock. (For example, when transferring data from the Tcl
  108. interpreter result to a Python string object.) This can be done by
  109. using different macros to close the ENTER_TCL block: ENTER_OVERLAP
  110. reacquires the Python lock (and restores the thread state) but
  111. doesn't release the Tcl lock; LEAVE_OVERLAP_TCL releases the Tcl
  112. lock.
  113. By contrast, ENTER_PYTHON and LEAVE_PYTHON are used in Tcl event
  114. handlers when the handler needs to use Python. Such event handlers
  115. are entered while the lock for Tcl is held; the event handler
  116. presumably needs to use Python. ENTER_PYTHON releases the lock for
  117. Tcl and acquires the Python interpreter lock, restoring the
  118. appropriate thread state, and LEAVE_PYTHON releases the Python
  119. interpreter lock and re-acquires the lock for Tcl. It is okay for
  120. ENTER_TCL/LEAVE_TCL pairs to be contained inside the code between
  121. ENTER_PYTHON and LEAVE_PYTHON.
  122. These locks expand to several statements and brackets; they should
  123. not be used in branches of if statements and the like.
  124. If Tcl is threaded, this approach won't work anymore. The Tcl
  125. interpreter is only valid in the thread that created it, and all Tk
  126. activity must happen in this thread, also. That means that the
  127. mainloop must be invoked in the thread that created the
  128. interpreter. Invoking commands from other threads is possible;
  129. _tkinter will queue an event for the interpreter thread, which will
  130. then execute the command and pass back the result. If the main
  131. thread is not in the mainloop, and invoking commands causes an
  132. exception; if the main loop is running but not processing events,
  133. the command invocation will block.
  134. In addition, for a threaded Tcl, a single global tcl_tstate won't
  135. be sufficient anymore, since multiple Tcl interpreters may
  136. simultaneously dispatch in different threads. So we use the Tcl TLS
  137. API.
  138. */
  139. static PyThread_type_lock tcl_lock = 0;
  140. #ifdef TCL_THREADS
  141. static Tcl_ThreadDataKey state_key;
  142. typedef PyThreadState *ThreadSpecificData;
  143. #define tcl_tstate \
  144. (*(PyThreadState**)Tcl_GetThreadData(&state_key, sizeof(PyThreadState*)))
  145. #else
  146. static PyThreadState *tcl_tstate = NULL;
  147. #endif
  148. #define ENTER_TCL \
  149. { PyThreadState *tstate = PyThreadState_Get(); Py_BEGIN_ALLOW_THREADS \
  150. if(tcl_lock)PyThread_acquire_lock(tcl_lock, 1); tcl_tstate = tstate;
  151. #define LEAVE_TCL \
  152. tcl_tstate = NULL; \
  153. if(tcl_lock)PyThread_release_lock(tcl_lock); Py_END_ALLOW_THREADS}
  154. #define ENTER_OVERLAP \
  155. Py_END_ALLOW_THREADS
  156. #define LEAVE_OVERLAP_TCL \
  157. tcl_tstate = NULL; if(tcl_lock)PyThread_release_lock(tcl_lock); }
  158. #define ENTER_PYTHON \
  159. { PyThreadState *tstate = tcl_tstate; tcl_tstate = NULL; \
  160. if(tcl_lock) \
  161. PyThread_release_lock(tcl_lock); PyEval_RestoreThread((tstate)); }
  162. #define LEAVE_PYTHON \
  163. { PyThreadState *tstate = PyEval_SaveThread(); \
  164. if(tcl_lock)PyThread_acquire_lock(tcl_lock, 1); tcl_tstate = tstate; }
  165. #define CHECK_TCL_APPARTMENT \
  166. if (((TkappObject *)self)->threaded && \
  167. ((TkappObject *)self)->thread_id != Tcl_GetCurrentThread()) { \
  168. PyErr_SetString(PyExc_RuntimeError, \
  169. "Calling Tcl from different appartment"); \
  170. return 0; \
  171. }
  172. #else
  173. #define ENTER_TCL
  174. #define LEAVE_TCL
  175. #define ENTER_OVERLAP
  176. #define LEAVE_OVERLAP_TCL
  177. #define ENTER_PYTHON
  178. #define LEAVE_PYTHON
  179. #define CHECK_TCL_APPARTMENT
  180. #endif
  181. #ifndef FREECAST
  182. #define FREECAST (char *)
  183. #endif
  184. /**** Tkapp Object Declaration ****/
  185. static PyObject *Tkapp_Type;
  186. typedef struct {
  187. PyObject_HEAD
  188. Tcl_Interp *interp;
  189. int wantobjects;
  190. int threaded; /* True if tcl_platform[threaded] */
  191. Tcl_ThreadId thread_id;
  192. int dispatching;
  193. /* We cannot include tclInt.h, as this is internal.
  194. So we cache interesting types here. */
  195. const Tcl_ObjType *OldBooleanType;
  196. const Tcl_ObjType *BooleanType;
  197. const Tcl_ObjType *ByteArrayType;
  198. const Tcl_ObjType *DoubleType;
  199. const Tcl_ObjType *IntType;
  200. const Tcl_ObjType *WideIntType;
  201. const Tcl_ObjType *BignumType;
  202. const Tcl_ObjType *ListType;
  203. const Tcl_ObjType *ProcBodyType;
  204. const Tcl_ObjType *StringType;
  205. } TkappObject;
  206. #define Tkapp_Interp(v) (((TkappObject *) (v))->interp)
  207. #define Tkapp_Result(v) Tcl_GetStringResult(Tkapp_Interp(v))
  208. #define DEBUG_REFCNT(v) (printf("DEBUG: id=%p, refcnt=%i\n", \
  209. (void *) v, Py_REFCNT(v)))
  210. /**** Error Handling ****/
  211. static PyObject *Tkinter_TclError;
  212. static int quitMainLoop = 0;
  213. static int errorInCmd = 0;
  214. static PyObject *excInCmd;
  215. static PyObject *valInCmd;
  216. static PyObject *trbInCmd;
  217. #ifdef TKINTER_PROTECT_LOADTK
  218. static int tk_load_failed = 0;
  219. #endif
  220. static PyObject *
  221. Tkinter_Error(PyObject *v)
  222. {
  223. PyErr_SetString(Tkinter_TclError, Tkapp_Result(v));
  224. return NULL;
  225. }
  226. /**** Utils ****/
  227. static int Tkinter_busywaitinterval = 20;
  228. #ifdef WITH_THREAD
  229. #ifndef MS_WINDOWS
  230. /* Millisecond sleep() for Unix platforms. */
  231. static void
  232. Sleep(int milli)
  233. {
  234. /* XXX Too bad if you don't have select(). */
  235. struct timeval t;
  236. t.tv_sec = milli/1000;
  237. t.tv_usec = (milli%1000) * 1000;
  238. select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &t);
  239. }
  240. #endif /* MS_WINDOWS */
  241. /* Wait up to 1s for the mainloop to come up. */
  242. static int
  243. WaitForMainloop(TkappObject* self)
  244. {
  245. int i;
  246. for (i = 0; i < 10; i++) {
  247. if (self->dispatching)
  248. return 1;
  249. Py_BEGIN_ALLOW_THREADS
  250. Sleep(100);
  251. Py_END_ALLOW_THREADS
  252. }
  253. if (self->dispatching)
  254. return 1;
  255. PyErr_SetString(PyExc_RuntimeError, "main thread is not in main loop");
  256. return 0;
  257. }
  258. #endif /* WITH_THREAD */
  259. #define ARGSZ 64
  260. static PyObject *
  261. unicodeFromTclStringAndSize(const char *s, Py_ssize_t size)
  262. {
  263. PyObject *r = PyUnicode_DecodeUTF8(s, size, NULL);
  264. if (!r && PyErr_ExceptionMatches(PyExc_UnicodeDecodeError)) {
  265. /* Tcl encodes null character as \xc0\x80 */
  266. if (memchr(s, '\xc0', size)) {
  267. char *buf, *q;
  268. const char *e = s + size;
  269. PyErr_Clear();
  270. q = buf = (char *)PyMem_Malloc(size);
  271. if (buf == NULL) {
  272. PyErr_NoMemory();
  273. return NULL;
  274. }
  275. while (s != e) {
  276. if (s + 1 != e && s[0] == '\xc0' && s[1] == '\x80') {
  277. *q++ = '\0';
  278. s += 2;
  279. }
  280. else
  281. *q++ = *s++;
  282. }
  283. s = buf;
  284. size = q - s;
  285. r = PyUnicode_DecodeUTF8(s, size, NULL);
  286. PyMem_Free(buf);
  287. }
  288. }
  289. return r;
  290. }
  291. static PyObject *
  292. unicodeFromTclString(const char *s)
  293. {
  294. return unicodeFromTclStringAndSize(s, strlen(s));
  295. }
  296. static PyObject *
  297. unicodeFromTclObj(Tcl_Obj *value)
  298. {
  299. int len;
  300. char *s = Tcl_GetStringFromObj(value, &len);
  301. return unicodeFromTclStringAndSize(s, len);
  302. }
  303. static PyObject *
  304. Split(char *list)
  305. {
  306. int argc;
  307. char **argv;
  308. PyObject *v;
  309. if (list == NULL) {
  310. Py_RETURN_NONE;
  311. }
  312. if (Tcl_SplitList((Tcl_Interp *)NULL, list, &argc, &argv) != TCL_OK) {
  313. /* Not a list.
  314. * Could be a quoted string containing funnies, e.g. {"}.
  315. * Return the string itself.
  316. */
  317. return unicodeFromTclString(list);
  318. }
  319. if (argc == 0)
  320. v = PyUnicode_FromString("");
  321. else if (argc == 1)
  322. v = unicodeFromTclString(argv[0]);
  323. else if ((v = PyTuple_New(argc)) != NULL) {
  324. int i;
  325. PyObject *w;
  326. for (i = 0; i < argc; i++) {
  327. if ((w = Split(argv[i])) == NULL) {
  328. Py_DECREF(v);
  329. v = NULL;
  330. break;
  331. }
  332. PyTuple_SetItem(v, i, w);
  333. }
  334. }
  335. Tcl_Free(FREECAST argv);
  336. return v;
  337. }
  338. /* In some cases, Tcl will still return strings that are supposed to
  339. be lists. SplitObj walks through a nested tuple, finding string
  340. objects that need to be split. */
  341. static PyObject *
  342. SplitObj(PyObject *arg)
  343. {
  344. if (PyTuple_Check(arg)) {
  345. int i, size;
  346. PyObject *elem, *newelem, *result;
  347. size = PyTuple_Size(arg);
  348. result = NULL;
  349. /* Recursively invoke SplitObj for all tuple items.
  350. If this does not return a new object, no action is
  351. needed. */
  352. for(i = 0; i < size; i++) {
  353. elem = PyTuple_GetItem(arg, i);
  354. newelem = SplitObj(elem);
  355. if (!newelem) {
  356. Py_XDECREF(result);
  357. return NULL;
  358. }
  359. if (!result) {
  360. int k;
  361. if (newelem == elem) {
  362. Py_DECREF(newelem);
  363. continue;
  364. }
  365. result = PyTuple_New(size);
  366. if (!result)
  367. return NULL;
  368. for(k = 0; k < i; k++) {
  369. elem = PyTuple_GetItem(arg, k);
  370. Py_INCREF(elem);
  371. PyTuple_SetItem(result, k, elem);
  372. }
  373. }
  374. PyTuple_SetItem(result, i, newelem);
  375. }
  376. if (result)
  377. return result;
  378. /* Fall through, returning arg. */
  379. }
  380. else if (PyUnicode_Check(arg)) {
  381. int argc;
  382. char **argv;
  383. char *list = PyUnicode_AsUTF8(arg);
  384. if (list == NULL ||
  385. Tcl_SplitList((Tcl_Interp *)NULL, list, &argc, &argv) != TCL_OK) {
  386. Py_INCREF(arg);
  387. return arg;
  388. }
  389. Tcl_Free(FREECAST argv);
  390. if (argc > 1)
  391. return Split(list);
  392. /* Fall through, returning arg. */
  393. }
  394. else if (PyBytes_Check(arg)) {
  395. int argc;
  396. char **argv;
  397. char *list = PyBytes_AsString(arg);
  398. if (Tcl_SplitList((Tcl_Interp *)NULL, list, &argc, &argv) != TCL_OK) {
  399. Py_INCREF(arg);
  400. return arg;
  401. }
  402. Tcl_Free(FREECAST argv);
  403. if (argc > 1)
  404. return Split(PyBytes_AsString(arg));
  405. /* Fall through, returning arg. */
  406. }
  407. Py_INCREF(arg);
  408. return arg;
  409. }
  410. /**** Tkapp Object ****/
  411. #ifndef WITH_APPINIT
  412. int
  413. Tcl_AppInit(Tcl_Interp *interp)
  414. {
  415. const char * _tkinter_skip_tk_init;
  416. if (Tcl_Init(interp) == TCL_ERROR) {
  417. PySys_WriteStderr("Tcl_Init error: %s\n", Tcl_GetStringResult(interp));
  418. return TCL_ERROR;
  419. }
  420. _tkinter_skip_tk_init = Tcl_GetVar(interp,
  421. "_tkinter_skip_tk_init", TCL_GLOBAL_ONLY);
  422. if (_tkinter_skip_tk_init != NULL &&
  423. strcmp(_tkinter_skip_tk_init, "1") == 0) {
  424. return TCL_OK;
  425. }
  426. #ifdef TKINTER_PROTECT_LOADTK
  427. if (tk_load_failed) {
  428. PySys_WriteStderr("Tk_Init error: %s\n", TKINTER_LOADTK_ERRMSG);
  429. return TCL_ERROR;
  430. }
  431. #endif
  432. if (Tk_Init(interp) == TCL_ERROR) {
  433. #ifdef TKINTER_PROTECT_LOADTK
  434. tk_load_failed = 1;
  435. #endif
  436. PySys_WriteStderr("Tk_Init error: %s\n", Tcl_GetStringResult(interp));
  437. return TCL_ERROR;
  438. }
  439. return TCL_OK;
  440. }
  441. #endif /* !WITH_APPINIT */
  442. /* Initialize the Tk application; see the `main' function in
  443. * `tkMain.c'.
  444. */
  445. static void EnableEventHook(void); /* Forward */
  446. static void DisableEventHook(void); /* Forward */
  447. static TkappObject *
  448. Tkapp_New(char *screenName, char *className,
  449. int interactive, int wantobjects, int wantTk, int sync, char *use)
  450. {
  451. TkappObject *v;
  452. char *argv0;
  453. v = PyObject_New(TkappObject, (PyTypeObject *) Tkapp_Type);
  454. if (v == NULL)
  455. return NULL;
  456. Py_INCREF(Tkapp_Type);
  457. v->interp = Tcl_CreateInterp();
  458. v->wantobjects = wantobjects;
  459. v->threaded = Tcl_GetVar2Ex(v->interp, "tcl_platform", "threaded",
  460. TCL_GLOBAL_ONLY) != NULL;
  461. v->thread_id = Tcl_GetCurrentThread();
  462. v->dispatching = 0;
  463. #ifndef TCL_THREADS
  464. if (v->threaded) {
  465. PyErr_SetString(PyExc_RuntimeError,
  466. "Tcl is threaded but _tkinter is not");
  467. Py_DECREF(v);
  468. return 0;
  469. }
  470. #endif
  471. #ifdef WITH_THREAD
  472. if (v->threaded && tcl_lock) {
  473. /* If Tcl is threaded, we don't need the lock. */
  474. PyThread_free_lock(tcl_lock);
  475. tcl_lock = NULL;
  476. }
  477. #endif
  478. v->OldBooleanType = Tcl_GetObjType("boolean");
  479. v->BooleanType = Tcl_GetObjType("booleanString");
  480. v->ByteArrayType = Tcl_GetObjType("bytearray");
  481. v->DoubleType = Tcl_GetObjType("double");
  482. v->IntType = Tcl_GetObjType("int");
  483. v->WideIntType = Tcl_GetObjType("wideInt");
  484. v->BignumType = Tcl_GetObjType("bignum");
  485. v->ListType = Tcl_GetObjType("list");
  486. v->ProcBodyType = Tcl_GetObjType("procbody");
  487. v->StringType = Tcl_GetObjType("string");
  488. /* Delete the 'exit' command, which can screw things up */
  489. Tcl_DeleteCommand(v->interp, "exit");
  490. if (screenName != NULL)
  491. Tcl_SetVar2(v->interp, "env", "DISPLAY",
  492. screenName, TCL_GLOBAL_ONLY);
  493. if (interactive)
  494. Tcl_SetVar(v->interp, "tcl_interactive", "1", TCL_GLOBAL_ONLY);
  495. else
  496. Tcl_SetVar(v->interp, "tcl_interactive", "0", TCL_GLOBAL_ONLY);
  497. /* This is used to get the application class for Tk 4.1 and up */
  498. argv0 = (char*)attemptckalloc(strlen(className) + 1);
  499. if (!argv0) {
  500. PyErr_NoMemory();
  501. Py_DECREF(v);
  502. return NULL;
  503. }
  504. strcpy(argv0, className);
  505. if (Py_ISUPPER(Py_CHARMASK(argv0[0])))
  506. argv0[0] = Py_TOLOWER(Py_CHARMASK(argv0[0]));
  507. Tcl_SetVar(v->interp, "argv0", argv0, TCL_GLOBAL_ONLY);
  508. ckfree(argv0);
  509. if (! wantTk) {
  510. Tcl_SetVar(v->interp,
  511. "_tkinter_skip_tk_init", "1", TCL_GLOBAL_ONLY);
  512. }
  513. #ifdef TKINTER_PROTECT_LOADTK
  514. else if (tk_load_failed) {
  515. Tcl_SetVar(v->interp,
  516. "_tkinter_tk_failed", "1", TCL_GLOBAL_ONLY);
  517. }
  518. #endif
  519. /* some initial arguments need to be in argv */
  520. if (sync || use) {
  521. char *args;
  522. int len = 0;
  523. if (sync)
  524. len += sizeof "-sync";
  525. if (use)
  526. len += strlen(use) + sizeof "-use ";
  527. args = (char*)attemptckalloc(len);
  528. if (!args) {
  529. PyErr_NoMemory();
  530. Py_DECREF(v);
  531. return NULL;
  532. }
  533. args[0] = '\0';
  534. if (sync)
  535. strcat(args, "-sync");
  536. if (use) {
  537. if (sync)
  538. strcat(args, " ");
  539. strcat(args, "-use ");
  540. strcat(args, use);
  541. }
  542. Tcl_SetVar(v->interp, "argv", args, TCL_GLOBAL_ONLY);
  543. ckfree(args);
  544. }
  545. if (Tcl_AppInit(v->interp) != TCL_OK) {
  546. PyObject *result = Tkinter_Error((PyObject *)v);
  547. #ifdef TKINTER_PROTECT_LOADTK
  548. if (wantTk) {
  549. const char *_tkinter_tk_failed;
  550. _tkinter_tk_failed = Tcl_GetVar(v->interp,
  551. "_tkinter_tk_failed", TCL_GLOBAL_ONLY);
  552. if ( _tkinter_tk_failed != NULL &&
  553. strcmp(_tkinter_tk_failed, "1") == 0) {
  554. tk_load_failed = 1;
  555. }
  556. }
  557. #endif
  558. Py_DECREF((PyObject *)v);
  559. return (TkappObject *)result;
  560. }
  561. EnableEventHook();
  562. return v;
  563. }
  564. #ifdef WITH_THREAD
  565. static void
  566. Tkapp_ThreadSend(TkappObject *self, Tcl_Event *ev,
  567. Tcl_Condition *cond, Tcl_Mutex *mutex)
  568. {
  569. Py_BEGIN_ALLOW_THREADS;
  570. Tcl_MutexLock(mutex);
  571. Tcl_ThreadQueueEvent(self->thread_id, ev, TCL_QUEUE_TAIL);
  572. Tcl_ThreadAlert(self->thread_id);
  573. Tcl_ConditionWait(cond, mutex, NULL);
  574. Tcl_MutexUnlock(mutex);
  575. Py_END_ALLOW_THREADS
  576. }
  577. #endif
  578. /** Tcl Eval **/
  579. typedef struct {
  580. PyObject_HEAD
  581. Tcl_Obj *value;
  582. PyObject *string; /* This cannot cause cycles. */
  583. } PyTclObject;
  584. static PyObject *PyTclObject_Type;
  585. #define PyTclObject_Check(v) ((v)->ob_type == (PyTypeObject *) PyTclObject_Type)
  586. static PyObject *
  587. newPyTclObject(Tcl_Obj *arg)
  588. {
  589. PyTclObject *self;
  590. self = PyObject_New(PyTclObject, (PyTypeObject *) PyTclObject_Type);
  591. if (self == NULL)
  592. return NULL;
  593. Py_INCREF(PyTclObject_Type);
  594. Tcl_IncrRefCount(arg);
  595. self->value = arg;
  596. self->string = NULL;
  597. return (PyObject*)self;
  598. }
  599. static void
  600. PyTclObject_dealloc(PyTclObject *self)
  601. {
  602. PyObject *tp = (PyObject *) Py_TYPE(self);
  603. Tcl_DecrRefCount(self->value);
  604. Py_XDECREF(self->string);
  605. PyObject_Del(self);
  606. Py_DECREF(tp);
  607. }
  608. static char*
  609. PyTclObject_TclString(PyObject *self)
  610. {
  611. return Tcl_GetString(((PyTclObject*)self)->value);
  612. }
  613. /* Like _str, but create Unicode if necessary. */
  614. PyDoc_STRVAR(PyTclObject_string__doc__,
  615. "the string representation of this object, either as str or bytes");
  616. static PyObject *
  617. PyTclObject_string(PyTclObject *self, void *ignored)
  618. {
  619. if (!self->string) {
  620. self->string = unicodeFromTclObj(self->value);
  621. if (!self->string)
  622. return NULL;
  623. }
  624. Py_INCREF(self->string);
  625. return self->string;
  626. }
  627. static PyObject *
  628. PyTclObject_str(PyTclObject *self, void *ignored)
  629. {
  630. if (self->string) {
  631. Py_INCREF(self->string);
  632. return self->string;
  633. }
  634. /* XXX Could chache result if it is non-ASCII. */
  635. return unicodeFromTclObj(self->value);
  636. }
  637. static PyObject *
  638. PyTclObject_repr(PyTclObject *self)
  639. {
  640. PyObject *repr, *str = PyTclObject_str(self, NULL);
  641. if (str == NULL)
  642. return NULL;
  643. repr = PyUnicode_FromFormat("<%s object: %R>",
  644. self->value->typePtr->name, str);
  645. Py_DECREF(str);
  646. return repr;
  647. }
  648. #define TEST_COND(cond) ((cond) ? Py_True : Py_False)
  649. static PyObject *
  650. PyTclObject_richcompare(PyObject *self, PyObject *other, int op)
  651. {
  652. int result;
  653. PyObject *v;
  654. /* neither argument should be NULL, unless something's gone wrong */
  655. if (self == NULL || other == NULL) {
  656. PyErr_BadInternalCall();
  657. return NULL;
  658. }
  659. /* both arguments should be instances of PyTclObject */
  660. if (!PyTclObject_Check(self) || !PyTclObject_Check(other)) {
  661. v = Py_NotImplemented;
  662. goto finished;
  663. }
  664. if (self == other)
  665. /* fast path when self and other are identical */
  666. result = 0;
  667. else
  668. result = strcmp(Tcl_GetString(((PyTclObject *)self)->value),
  669. Tcl_GetString(((PyTclObject *)other)->value));
  670. /* Convert return value to a Boolean */
  671. switch (op) {
  672. case Py_EQ:
  673. v = TEST_COND(result == 0);
  674. break;
  675. case Py_NE:
  676. v = TEST_COND(result != 0);
  677. break;
  678. case Py_LE:
  679. v = TEST_COND(result <= 0);
  680. break;
  681. case Py_GE:
  682. v = TEST_COND(result >= 0);
  683. break;
  684. case Py_LT:
  685. v = TEST_COND(result < 0);
  686. break;
  687. case Py_GT:
  688. v = TEST_COND(result > 0);
  689. break;
  690. default:
  691. PyErr_BadArgument();
  692. return NULL;
  693. }
  694. finished:
  695. Py_INCREF(v);
  696. return v;
  697. }
  698. PyDoc_STRVAR(get_typename__doc__, "name of the Tcl type");
  699. static PyObject*
  700. get_typename(PyTclObject* obj, void* ignored)
  701. {
  702. return unicodeFromTclString(obj->value->typePtr->name);
  703. }
  704. static PyGetSetDef PyTclObject_getsetlist[] = {
  705. {"typename", (getter)get_typename, NULL, get_typename__doc__},
  706. {"string", (getter)PyTclObject_string, NULL,
  707. PyTclObject_string__doc__},
  708. {0},
  709. };
  710. static PyType_Slot PyTclObject_Type_slots[] = {
  711. {Py_tp_dealloc, (destructor)PyTclObject_dealloc},
  712. {Py_tp_repr, (reprfunc)PyTclObject_repr},
  713. {Py_tp_str, (reprfunc)PyTclObject_str},
  714. {Py_tp_getattro, PyObject_GenericGetAttr},
  715. {Py_tp_richcompare, PyTclObject_richcompare},
  716. {Py_tp_getset, PyTclObject_getsetlist},
  717. {0, 0}
  718. };
  719. static PyType_Spec PyTclObject_Type_spec = {
  720. "_tkinter.Tcl_Obj",
  721. sizeof(PyTclObject),
  722. 0,
  723. Py_TPFLAGS_DEFAULT,
  724. PyTclObject_Type_slots,
  725. };
  726. #if PY_SIZE_MAX > INT_MAX
  727. #define CHECK_STRING_LENGTH(s) do { \
  728. if (s != NULL && strlen(s) >= INT_MAX) { \
  729. PyErr_SetString(PyExc_OverflowError, "string is too long"); \
  730. return NULL; \
  731. } } while(0)
  732. #else
  733. #define CHECK_STRING_LENGTH(s)
  734. #endif
  735. #ifdef HAVE_LIBTOMMAMTH
  736. static Tcl_Obj*
  737. asBignumObj(PyObject *value)
  738. {
  739. Tcl_Obj *result;
  740. int neg;
  741. PyObject *hexstr;
  742. char *hexchars;
  743. mp_int bigValue;
  744. neg = Py_SIZE(value) < 0;
  745. hexstr = _PyLong_Format(value, 16);
  746. if (hexstr == NULL)
  747. return NULL;
  748. hexchars = PyUnicode_AsUTF8(hexstr);
  749. if (hexchars == NULL) {
  750. Py_DECREF(hexstr);
  751. return NULL;
  752. }
  753. hexchars += neg + 2; /* skip sign and "0x" */
  754. mp_init(&bigValue);
  755. if (mp_read_radix(&bigValue, hexchars, 16) != MP_OKAY) {
  756. mp_clear(&bigValue);
  757. Py_DECREF(hexstr);
  758. PyErr_NoMemory();
  759. return NULL;
  760. }
  761. Py_DECREF(hexstr);
  762. bigValue.sign = neg ? MP_NEG : MP_ZPOS;
  763. result = Tcl_NewBignumObj(&bigValue);
  764. mp_clear(&bigValue);
  765. if (result == NULL) {
  766. PyErr_NoMemory();
  767. return NULL;
  768. }
  769. return result;
  770. }
  771. #endif
  772. static Tcl_Obj*
  773. AsObj(PyObject *value)
  774. {
  775. Tcl_Obj *result;
  776. if (PyBytes_Check(value))
  777. return Tcl_NewByteArrayObj((unsigned char *)PyBytes_AS_STRING(value),
  778. PyBytes_GET_SIZE(value));
  779. if (PyBool_Check(value))
  780. return Tcl_NewBooleanObj(PyObject_IsTrue(value));
  781. if (PyLong_CheckExact(value)) {
  782. int overflow;
  783. long longValue;
  784. #ifdef TCL_WIDE_INT_TYPE
  785. Tcl_WideInt wideValue;
  786. #endif
  787. longValue = PyLong_AsLongAndOverflow(value, &overflow);
  788. if (!overflow) {
  789. return Tcl_NewLongObj(longValue);
  790. }
  791. /* If there is an overflow in the long conversion,
  792. fall through to wideInt handling. */
  793. #ifdef TCL_WIDE_INT_TYPE
  794. if (_PyLong_AsByteArray((PyLongObject *)value,
  795. (unsigned char *)(void *)&wideValue,
  796. sizeof(wideValue),
  797. PY_LITTLE_ENDIAN,
  798. /* signed */ 1) == 0) {
  799. return Tcl_NewWideIntObj(wideValue);
  800. }
  801. PyErr_Clear();
  802. #endif
  803. /* If there is an overflow in the wideInt conversion,
  804. fall through to bignum handling. */
  805. #ifdef HAVE_LIBTOMMAMTH
  806. return asBignumObj(value);
  807. #endif
  808. /* If there is no wideInt or bignum support,
  809. fall through to default object handling. */
  810. }
  811. if (PyFloat_Check(value))
  812. return Tcl_NewDoubleObj(PyFloat_AS_DOUBLE(value));
  813. if (PyTuple_Check(value)) {
  814. Tcl_Obj **argv;
  815. Py_ssize_t size, i;
  816. size = PyTuple_Size(value);
  817. if (size == 0)
  818. return Tcl_NewListObj(0, NULL);
  819. if (!CHECK_SIZE(size, sizeof(Tcl_Obj *))) {
  820. PyErr_SetString(PyExc_OverflowError, "tuple is too long");
  821. return NULL;
  822. }
  823. argv = (Tcl_Obj **) attemptckalloc(((size_t)size) * sizeof(Tcl_Obj *));
  824. if(!argv)
  825. return 0;
  826. for (i = 0; i < size; i++)
  827. argv[i] = AsObj(PyTuple_GetItem(value,i));
  828. result = Tcl_NewListObj(PyTuple_Size(value), argv);
  829. ckfree(FREECAST argv);
  830. return result;
  831. }
  832. if (PyUnicode_Check(value)) {
  833. void *inbuf;
  834. Py_ssize_t size;
  835. int kind;
  836. Tcl_UniChar *outbuf = NULL;
  837. Py_ssize_t i;
  838. size_t allocsize;
  839. if (PyUnicode_READY(value) == -1)
  840. return NULL;
  841. inbuf = PyUnicode_DATA(value);
  842. size = PyUnicode_GET_LENGTH(value);
  843. if (size == 0)
  844. return Tcl_NewUnicodeObj((const void *)"", 0);
  845. if (!CHECK_SIZE(size, sizeof(Tcl_UniChar))) {
  846. PyErr_SetString(PyExc_OverflowError, "string is too long");
  847. return NULL;
  848. }
  849. kind = PyUnicode_KIND(value);
  850. if (kind == sizeof(Tcl_UniChar))
  851. return Tcl_NewUnicodeObj(inbuf, size);
  852. allocsize = ((size_t)size) * sizeof(Tcl_UniChar);
  853. outbuf = (Tcl_UniChar*)attemptckalloc(allocsize);
  854. /* Else overflow occurred, and we take the next exit */
  855. if (!outbuf) {
  856. PyErr_NoMemory();
  857. return NULL;
  858. }
  859. for (i = 0; i < size; i++) {
  860. Py_UCS4 ch = PyUnicode_READ(kind, inbuf, i);
  861. /* We cannot test for sizeof(Tcl_UniChar) directly,
  862. so we test for UTF-8 size instead. */
  863. #if TCL_UTF_MAX == 3
  864. if (ch >= 0x10000) {
  865. /* Tcl doesn't do UTF-16, yet. */
  866. PyErr_Format(Tkinter_TclError,
  867. "character U+%x is above the range "
  868. "(U+0000-U+FFFF) allowed by Tcl",
  869. ch);
  870. ckfree(FREECAST outbuf);
  871. return NULL;
  872. }
  873. #endif
  874. outbuf[i] = ch;
  875. }
  876. result = Tcl_NewUnicodeObj(outbuf, size);
  877. ckfree(FREECAST outbuf);
  878. return result;
  879. }
  880. if (PyTclObject_Check(value)) {
  881. Tcl_Obj *v = ((PyTclObject*)value)->value;
  882. Tcl_IncrRefCount(v);
  883. return v;
  884. }
  885. {
  886. PyObject *v = PyObject_Str(value);
  887. if (!v)
  888. return 0;
  889. result = AsObj(v);
  890. Py_DECREF(v);
  891. return result;
  892. }
  893. }
  894. static PyObject *
  895. fromBoolean(PyObject* tkapp, Tcl_Obj *value)
  896. {
  897. int boolValue;
  898. if (Tcl_GetBooleanFromObj(Tkapp_Interp(tkapp), value, &boolValue) == TCL_ERROR)
  899. return Tkinter_Error(tkapp);
  900. return PyBool_FromLong(boolValue);
  901. }
  902. #ifdef TCL_WIDE_INT_TYPE
  903. static PyObject*
  904. fromWideIntObj(PyObject* tkapp, Tcl_Obj *value)
  905. {
  906. Tcl_WideInt wideValue;
  907. if (Tcl_GetWideIntFromObj(Tkapp_Interp(tkapp), value, &wideValue) == TCL_OK) {
  908. #ifdef HAVE_LONG_LONG
  909. if (sizeof(wideValue) <= SIZEOF_LONG_LONG)
  910. return PyLong_FromLongLong(wideValue);
  911. #endif
  912. return _PyLong_FromByteArray((unsigned char *)(void *)&wideValue,
  913. sizeof(wideValue),
  914. PY_LITTLE_ENDIAN,
  915. /* signed */ 1);
  916. }
  917. return NULL;
  918. }
  919. #endif
  920. #ifdef HAVE_LIBTOMMAMTH
  921. static PyObject*
  922. fromBignumObj(PyObject* tkapp, Tcl_Obj *value)
  923. {
  924. mp_int bigValue;
  925. unsigned long numBytes;
  926. unsigned char *bytes;
  927. PyObject *res;
  928. if (Tcl_GetBignumFromObj(Tkapp_Interp(tkapp), value, &bigValue) != TCL_OK)
  929. return Tkinter_Error(tkapp);
  930. numBytes = mp_unsigned_bin_size(&bigValue);
  931. bytes = PyMem_Malloc(numBytes);
  932. if (bytes == NULL) {
  933. mp_clear(&bigValue);
  934. return PyErr_NoMemory();
  935. }
  936. if (mp_to_unsigned_bin_n(&bigValue, bytes,
  937. &numBytes) != MP_OKAY) {
  938. mp_clear(&bigValue);
  939. PyMem_Free(bytes);
  940. return PyErr_NoMemory();
  941. }
  942. res = _PyLong_FromByteArray(bytes, numBytes,
  943. /* big-endian */ 0,
  944. /* unsigned */ 0);
  945. PyMem_Free(bytes);
  946. if (res != NULL && bigValue.sign == MP_NEG) {
  947. PyObject *res2 = PyNumber_Negative(res);
  948. Py_DECREF(res);
  949. res = res2;
  950. }
  951. mp_clear(&bigValue);
  952. return res;
  953. }
  954. #endif
  955. static PyObject*
  956. FromObj(PyObject* tkapp, Tcl_Obj *value)
  957. {
  958. PyObject *result = NULL;
  959. TkappObject *app = (TkappObject*)tkapp;
  960. Tcl_Interp *interp = Tkapp_Interp(tkapp);
  961. if (value->typePtr == NULL) {
  962. return unicodeFromTclStringAndSize(value->bytes, value->length);
  963. }
  964. if (value->typePtr == app->BooleanType ||
  965. value->typePtr == app->OldBooleanType) {
  966. return fromBoolean(tkapp, value);
  967. }
  968. if (value->typePtr == app->ByteArrayType) {
  969. int size;
  970. char *data = (char*)Tcl_GetByteArrayFromObj(value, &size);
  971. return PyBytes_FromStringAndSize(data, size);
  972. }
  973. if (value->typePtr == app->DoubleType) {
  974. return PyFloat_FromDouble(value->internalRep.doubleValue);
  975. }
  976. if (value->typePtr == app->IntType) {
  977. long longValue;
  978. if (Tcl_GetLongFromObj(interp, value, &longValue) == TCL_OK)
  979. return PyLong_FromLong(longValue);
  980. /* If there is an error in the long conversion,
  981. fall through to wideInt handling. */
  982. }
  983. #ifdef TCL_WIDE_INT_TYPE
  984. if (value->typePtr == app->IntType ||
  985. value->typePtr == app->WideIntType) {
  986. result = fromWideIntObj(tkapp, value);
  987. if (result != NULL || PyErr_Occurred())
  988. return result;
  989. Tcl_ResetResult(interp);
  990. /* If there is an error in the wideInt conversion,
  991. fall through to bignum handling. */
  992. }
  993. #endif
  994. #ifdef HAVE_LIBTOMMAMTH
  995. if (value->typePtr == app->IntType ||
  996. value->typePtr == app->WideIntType ||
  997. value->typePtr == app->BignumType) {
  998. return fromBignumObj(tkapp, value);
  999. }
  1000. #endif
  1001. if (value->typePtr == app->ListType) {
  1002. int size;
  1003. int i, status;
  1004. PyObject *elem;
  1005. Tcl_Obj *tcl_elem;
  1006. status = Tcl_ListObjLength(interp, value, &size);
  1007. if (status == TCL_ERROR)
  1008. return Tkinter_Error(tkapp);
  1009. result = PyTuple_New(size);
  1010. if (!result)
  1011. return NULL;
  1012. for (i = 0; i < size; i++) {
  1013. status = Tcl_ListObjIndex(interp, value, i, &tcl_elem);
  1014. if (status == TCL_ERROR) {
  1015. Py_DECREF(result);
  1016. return Tkinter_Error(tkapp);
  1017. }
  1018. elem = FromObj(tkapp, tcl_elem);
  1019. if (!elem) {
  1020. Py_DECREF(result);
  1021. return NULL;
  1022. }
  1023. PyTuple_SetItem(result, i, elem);
  1024. }
  1025. return result;
  1026. }
  1027. if (value->typePtr == app->ProcBodyType) {
  1028. /* fall through: return tcl object. */
  1029. }
  1030. if (value->typePtr == app->StringType) {
  1031. return PyUnicode_FromKindAndData(
  1032. sizeof(Tcl_UniChar), Tcl_GetUnicode(value),
  1033. Tcl_GetCharLength(value));
  1034. }
  1035. #if TK_HEX_VERSION >= 0x08050000
  1036. if (app->BooleanType == NULL &&
  1037. strcmp(value->typePtr->name, "booleanString") == 0) {
  1038. /* booleanString type is not registered in Tcl */
  1039. app->BooleanType = value->typePtr;
  1040. return fromBoolean(tkapp, value);
  1041. }
  1042. #endif
  1043. #ifdef HAVE_LIBTOMMAMTH
  1044. if (app->BignumType == NULL &&
  1045. strcmp(value->typePtr->name, "bignum") == 0) {
  1046. /* bignum type is not registered in Tcl */
  1047. app->BignumType = value->typePtr;
  1048. return fromBignumObj(tkapp, value);
  1049. }
  1050. #endif
  1051. return newPyTclObject(value);
  1052. }
  1053. #ifdef WITH_THREAD
  1054. /* This mutex synchronizes inter-thread command calls. */
  1055. TCL_DECLARE_MUTEX(call_mutex)
  1056. typedef struct Tkapp_CallEvent {
  1057. Tcl_Event ev; /* Must be first */
  1058. TkappObject *self;
  1059. PyObject *args;
  1060. int flags;
  1061. PyObject **res;
  1062. PyObject **exc_type, **exc_value, **exc_tb;
  1063. Tcl_Condition *done;
  1064. } Tkapp_CallEvent;
  1065. #endif
  1066. void
  1067. Tkapp_CallDeallocArgs(Tcl_Obj** objv, Tcl_Obj** objStore, int objc)
  1068. {
  1069. int i;
  1070. for (i = 0; i < objc; i++)
  1071. Tcl_DecrRefCount(objv[i]);
  1072. if (objv != objStore)
  1073. ckfree(FREECAST objv);
  1074. }
  1075. /* Convert Python objects to Tcl objects. This must happen in the
  1076. interpreter thread, which may or may not be the calling thread. */
  1077. static Tcl_Obj**
  1078. Tkapp_CallArgs(PyObject *args, Tcl_Obj** objStore, int *pobjc)
  1079. {
  1080. Tcl_Obj **objv = objStore;
  1081. Py_ssize_t objc = 0, i;
  1082. if (args == NULL)
  1083. /* do nothing */;
  1084. else if (!PyTuple_Check(args)) {
  1085. objv[0] = AsObj(args);
  1086. if (objv[0] == 0)
  1087. goto finally;
  1088. objc = 1;
  1089. Tcl_IncrRefCount(objv[0]);
  1090. }
  1091. else {
  1092. objc = PyTuple_Size(args);
  1093. if (objc > ARGSZ) {
  1094. if (!CHECK_SIZE(objc, sizeof(Tcl_Obj *))) {
  1095. PyErr_SetString(PyExc_OverflowError, "tuple is too long");
  1096. return NULL;
  1097. }
  1098. objv = (Tcl_Obj **)attemptckalloc(((size_t)objc) * sizeof(Tcl_Obj *));
  1099. if (objv == NULL) {
  1100. PyErr_NoMemory();
  1101. objc = 0;
  1102. goto finally;
  1103. }
  1104. }
  1105. for (i = 0; i < objc; i++) {
  1106. PyObject *v = PyTuple_GetItem(args, i);
  1107. if (v == Py_None) {
  1108. objc = i;
  1109. break;
  1110. }
  1111. objv[i] = AsObj(v);
  1112. if (!objv[i]) {
  1113. /* Reset objc, so it attempts to clear
  1114. objects only up to i. */
  1115. objc = i;
  1116. goto finally;
  1117. }
  1118. Tcl_IncrRefCount(objv[i]);
  1119. }
  1120. }
  1121. *pobjc = objc;
  1122. return objv;
  1123. finally:
  1124. Tkapp_CallDeallocArgs(objv, objStore, objc);
  1125. return NULL;
  1126. }
  1127. /* Convert the results of a command call into a Python objects. */
  1128. static PyObject*
  1129. Tkapp_CallResult(TkappObject *self)
  1130. {
  1131. PyObject *res = NULL;
  1132. Tcl_Obj *value = Tcl_GetObjResult(self->interp);
  1133. if(self->wantobjects) {
  1134. /* Not sure whether the IncrRef is necessary, but something
  1135. may overwrite the interpreter result while we are
  1136. converting it. */
  1137. Tcl_IncrRefCount(value);
  1138. res = FromObj((PyObject*)self, value);
  1139. Tcl_DecrRefCount(value);
  1140. } else {
  1141. res = unicodeFromTclObj(value);
  1142. }
  1143. return res;
  1144. }
  1145. #ifdef WITH_THREAD
  1146. /* Tkapp_CallProc is the event procedure that is executed in the context of
  1147. the Tcl interpreter thread. Initially, it holds the Tcl lock, and doesn't
  1148. hold the Python lock. */
  1149. static int
  1150. Tkapp_CallProc(Tkapp_CallEvent *e, int flags)
  1151. {
  1152. Tcl_Obj *objStore[ARGSZ];
  1153. Tcl_Obj **objv;
  1154. int objc;
  1155. int i;
  1156. ENTER_PYTHON
  1157. objv = Tkapp_CallArgs(e->args, objStore, &objc);
  1158. if (!objv) {
  1159. PyErr_Fetch(e->exc_type, e->exc_value, e->exc_tb);
  1160. *(e->res) = NULL;
  1161. }
  1162. LEAVE_PYTHON
  1163. if (!objv)
  1164. goto done;
  1165. i = Tcl_EvalObjv(e->self->interp, objc, objv, e->flags);
  1166. ENTER_PYTHON
  1167. if (i == TCL_ERROR) {
  1168. *(e->res) = NULL;
  1169. *(e->exc_type) = NULL;
  1170. *(e->exc_tb) = NULL;
  1171. *(e->exc_value) = PyObject_CallFunction(
  1172. Tkinter_TclError, "s",
  1173. Tcl_GetStringResult(e->self->interp));
  1174. }
  1175. else {
  1176. *(e->res) = Tkapp_CallResult(e->self);
  1177. }
  1178. LEAVE_PYTHON
  1179. Tkapp_CallDeallocArgs(objv, objStore, objc);
  1180. done:
  1181. /* Wake up calling thread. */
  1182. Tcl_MutexLock(&call_mutex);
  1183. Tcl_ConditionNotify(e->done);
  1184. Tcl_MutexUnlock(&call_mutex);
  1185. return 1;
  1186. }
  1187. #endif
  1188. /* This is the main entry point for calling a Tcl command.
  1189. It supports three cases, with regard to threading:
  1190. 1. Tcl is not threaded: Must have the Tcl lock, then can invoke command in
  1191. the context of the calling thread.
  1192. 2. Tcl is threaded, caller of the command is in the interpreter thread:
  1193. Execute the command in the calling thread. Since the Tcl lock will
  1194. not be used, we can merge that with case 1.
  1195. 3. Tcl is threaded, caller is in a different thread: Must queue an event to
  1196. the interpreter thread. Allocation of Tcl objects needs to occur in the
  1197. interpreter thread, so we ship the PyObject* args to the target thread,
  1198. and perform processing there. */
  1199. static PyObject *
  1200. Tkapp_Call(PyObject *selfptr, PyObject *args)
  1201. {
  1202. Tcl_Obj *objStore[ARGSZ];
  1203. Tcl_Obj **objv = NULL;
  1204. int objc, i;
  1205. PyObject *res = NULL;
  1206. TkappObject *self = (TkappObject*)selfptr;
  1207. int flags = TCL_EVAL_DIRECT | TCL_EVAL_GLOBAL;
  1208. /* If args is a single tuple, replace with contents of tuple */
  1209. if (1 == PyTuple_Size(args)){
  1210. PyObject* item = PyTuple_GetItem(args, 0);
  1211. if (PyTuple_Check(item))
  1212. args = item;
  1213. }
  1214. #ifdef WITH_THREAD
  1215. if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) {
  1216. /* We cannot call the command directly. Instead, we must
  1217. marshal the parameters to the interpreter thread. */
  1218. Tkapp_CallEvent *ev;
  1219. Tcl_Condition cond = NULL;
  1220. PyObject *exc_type, *exc_value, *exc_tb;
  1221. if (!WaitForMainloop(self))
  1222. return NULL;
  1223. ev = (Tkapp_CallEvent*)attemptckalloc(sizeof(Tkapp_CallEvent));
  1224. if (ev == NULL) {
  1225. PyErr_NoMemory();
  1226. return NULL;
  1227. }
  1228. ev->ev.proc = (Tcl_EventProc*)Tkapp_CallProc;
  1229. ev->self = self;
  1230. ev->args = args;
  1231. ev->res = &res;
  1232. ev->exc_type = &exc_type;
  1233. ev->exc_value = &exc_value;
  1234. ev->exc_tb = &exc_tb;
  1235. ev->done = &cond;
  1236. Tkapp_ThreadSend(self, (Tcl_Event*)ev, &cond, &call_mutex);
  1237. if (res == NULL) {
  1238. if (exc_type)
  1239. PyErr_Restore(exc_type, exc_value, exc_tb);
  1240. else
  1241. PyErr_SetObject(Tkinter_TclError, exc_value);
  1242. }
  1243. Tcl_ConditionFinalize(&cond);
  1244. }
  1245. else
  1246. #endif
  1247. {
  1248. objv = Tkapp_CallArgs(args, objStore, &objc);
  1249. if (!objv)
  1250. return NULL;
  1251. ENTER_TCL
  1252. i = Tcl_EvalObjv(self->interp, objc, objv, flags);
  1253. ENTER_OVERLAP
  1254. if (i == TCL_ERROR)
  1255. Tkinter_Error(selfptr);
  1256. else
  1257. res = Tkapp_CallResult(self);
  1258. LEAVE_OVERLAP_TCL
  1259. Tkapp_CallDeallocArgs(objv, objStore, objc);
  1260. }
  1261. return res;
  1262. }
  1263. static PyObject *
  1264. Tkapp_Eval(PyObject *self, PyObject *args)
  1265. {
  1266. char *script;
  1267. PyObject *res = NULL;
  1268. int err;
  1269. if (!PyArg_ParseTuple(args, "s:eval", &script))
  1270. return NULL;
  1271. CHECK_STRING_LENGTH(script);
  1272. CHECK_TCL_APPARTMENT;
  1273. ENTER_TCL
  1274. err = Tcl_Eval(Tkapp_Interp(self), script);
  1275. ENTER_OVERLAP
  1276. if (err == TCL_ERROR)
  1277. res = Tkinter_Error(self);
  1278. else
  1279. res = unicodeFromTclString(Tkapp_Result(self));
  1280. LEAVE_OVERLAP_TCL
  1281. return res;
  1282. }
  1283. static PyObject *
  1284. Tkapp_EvalFile(PyObject *self, PyObject *args)
  1285. {
  1286. char *fileName;
  1287. PyObject *res = NULL;
  1288. int err;
  1289. if (!PyArg_ParseTuple(args, "s:evalfile", &fileName))
  1290. return NULL;
  1291. CHECK_STRING_LENGTH(fileName);
  1292. CHECK_TCL_APPARTMENT;
  1293. ENTER_TCL
  1294. err = Tcl_EvalFile(Tkapp_Interp(self), fileName);
  1295. ENTER_OVERLAP
  1296. if (err == TCL_ERROR)
  1297. res = Tkinter_Error(self);
  1298. else
  1299. res = unicodeFromTclString(Tkapp_Result(self));
  1300. LEAVE_OVERLAP_TCL
  1301. return res;
  1302. }
  1303. static PyObject *
  1304. Tkapp_Record(PyObject *self, PyObject *args)
  1305. {
  1306. char *script;
  1307. PyObject *res = NULL;
  1308. int err;
  1309. if (!PyArg_ParseTuple(args, "s:record", &script))
  1310. return NULL;
  1311. CHECK_STRING_LENGTH(script);
  1312. CHECK_TCL_APPARTMENT;
  1313. ENTER_TCL
  1314. err = Tcl_RecordAndEval(Tkapp_Interp(self), script, TCL_NO_EVAL);
  1315. ENTER_OVERLAP
  1316. if (err == TCL_ERROR)
  1317. res = Tkinter_Error(self);
  1318. else
  1319. res = unicodeFromTclString(Tkapp_Result(self));
  1320. LEAVE_OVERLAP_TCL
  1321. return res;
  1322. }
  1323. static PyObject *
  1324. Tkapp_AddErrorInfo(PyObject *self, PyObject *args)
  1325. {
  1326. char *msg;
  1327. if (!PyArg_ParseTuple(args, "s:adderrorinfo", &msg))
  1328. return NULL;
  1329. CHECK_STRING_LENGTH(msg);
  1330. CHECK_TCL_APPARTMENT;
  1331. ENTER_TCL
  1332. Tcl_AddErrorInfo(Tkapp_Interp(self), msg);
  1333. LEAVE_TCL
  1334. Py_RETURN_NONE;
  1335. }
  1336. /** Tcl Variable **/
  1337. typedef PyObject* (*EventFunc)(PyObject*, PyObject *args, int flags);
  1338. #ifdef WITH_THREAD
  1339. TCL_DECLARE_MUTEX(var_mutex)
  1340. typedef struct VarEvent {
  1341. Tcl_Event ev; /* must be first */
  1342. PyObject *self;
  1343. PyObject *args;
  1344. int flags;
  1345. EventFunc func;
  1346. PyObject **res;
  1347. PyObject **exc_type;
  1348. PyObject **exc_val;
  1349. Tcl_Condition *cond;
  1350. } VarEvent;
  1351. #endif
  1352. static int
  1353. varname_converter(PyObject *in, void *_out)
  1354. {
  1355. char *s;
  1356. char **out = (char**)_out;
  1357. if (PyBytes_Check(in)) {
  1358. if (PyBytes_Size(in) > INT_MAX) {
  1359. PyErr_SetString(PyExc_OverflowError, "bytes object is too long");
  1360. return 0;
  1361. }
  1362. s = PyBytes_AsString(in);
  1363. if (strlen(s) != PyBytes_Size(in)) {
  1364. PyErr_SetString(PyExc_ValueError, "null byte in bytes object");
  1365. return 0;
  1366. }
  1367. *out = s;
  1368. return 1;
  1369. }
  1370. if (PyUnicode_Check(in)) {
  1371. Py_ssize_t size;
  1372. s = PyUnicode_AsUTF8AndSize(in, &size);
  1373. if (s == NULL) {
  1374. return 0;
  1375. }
  1376. if (size > INT_MAX) {
  1377. PyErr_SetString(PyExc_OverflowError, "string is too long");
  1378. return 0;
  1379. }
  1380. if (strlen(s) != size) {
  1381. PyErr_SetString(PyExc_ValueError, "null character in string");
  1382. return 0;
  1383. }
  1384. *out = s;
  1385. return 1;
  1386. }
  1387. if (PyTclObject_Check(in)) {
  1388. *out = PyTclObject_TclString(in);
  1389. return 1;
  1390. }
  1391. PyErr_Format(PyExc_TypeError,
  1392. "must be str, bytes or Tcl_Obj, not %.50s",
  1393. in->ob_type->tp_name);
  1394. return 0;
  1395. }
  1396. #ifdef WITH_THREAD
  1397. static void
  1398. var_perform(VarEvent *ev)
  1399. {
  1400. *(ev->res) = ev->func(ev->self, ev->args, ev->flags);
  1401. if (!*(ev->res)) {
  1402. PyObject *exc, *val, *tb;
  1403. PyErr_Fetch(&exc, &val, &tb);
  1404. PyErr_NormalizeException(&exc, &val, &tb);
  1405. *(ev->exc_type) = exc;
  1406. *(ev->exc_val) = val;
  1407. Py_DECREF(tb);
  1408. }
  1409. }
  1410. static int
  1411. var_proc(VarEvent* ev, int flags)
  1412. {
  1413. ENTER_PYTHON
  1414. var_perform(ev);
  1415. Tcl_MutexLock(&var_mutex);
  1416. Tcl_ConditionNotify(ev->cond);
  1417. Tcl_MutexUnlock(&var_mutex);
  1418. LEAVE_PYTHON
  1419. return 1;
  1420. }
  1421. #endif
  1422. static PyObject*
  1423. var_invoke(EventFunc func, PyObject *selfptr, PyObject *args, int flags)
  1424. {
  1425. #ifdef WITH_THREAD
  1426. TkappObject *self = (TkappObject*)selfptr;
  1427. if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) {
  1428. TkappObject *self = (TkappObject*)selfptr;
  1429. VarEvent *ev;
  1430. PyObject *res, *exc_type, *exc_val;
  1431. Tcl_Condition cond = NULL;
  1432. /* The current thread is not the interpreter thread. Marshal
  1433. the call to the interpreter thread, then wait for
  1434. completion. */
  1435. if (!WaitForMainloop(self))
  1436. return NULL;
  1437. ev = (VarEvent*)attemptckalloc(sizeof(VarEvent));
  1438. if (ev == NULL) {
  1439. PyErr_NoMemory();
  1440. return NULL;
  1441. }
  1442. ev->self = selfptr;
  1443. ev->args = args;
  1444. ev->flags = flags;
  1445. ev->func = func;
  1446. ev->res = &res;
  1447. ev->exc_type = &exc_type;
  1448. ev->exc_val = &exc_val;
  1449. ev->cond = &cond;
  1450. ev->ev.proc = (Tcl_EventProc*)var_proc;
  1451. Tkapp_ThreadSend(self, (Tcl_Event*)ev, &cond, &var_mutex);
  1452. Tcl_ConditionFinalize(&cond);
  1453. if (!res) {
  1454. PyErr_SetObject(exc_type, exc_val);
  1455. Py_DECREF(exc_type);
  1456. Py_DECREF(exc_val);
  1457. return NULL;
  1458. }
  1459. return res;
  1460. }
  1461. #endif
  1462. /* Tcl is not threaded, or this is the interpreter thread. */
  1463. return func(selfptr, args, flags);
  1464. }
  1465. static PyObject *
  1466. SetVar(PyObject *self, PyObject *args, int flags)
  1467. {
  1468. char *name1, *name2;
  1469. PyObject *newValue;
  1470. PyObject *res = NULL;
  1471. Tcl_Obj *newval, *ok;
  1472. switch (PyTuple_GET_SIZE(args)) {
  1473. case 2:
  1474. if (!PyArg_ParseTuple(args, "O&O:setvar",
  1475. varname_converter, &name1, &newValue))
  1476. return NULL;
  1477. /* XXX Acquire tcl lock??? */
  1478. newval = AsObj(newValue);
  1479. if (newval == NULL)
  1480. return NULL;
  1481. ENTER_TCL
  1482. ok = Tcl_SetVar2Ex(Tkapp_Interp(self), name1, NULL,
  1483. newval, flags);
  1484. ENTER_OVERLAP
  1485. if (!ok)
  1486. Tkinter_Error(self);
  1487. else {
  1488. res = Py_None;
  1489. Py_INCREF(res);
  1490. }
  1491. LEAVE_OVERLAP_TCL
  1492. break;
  1493. case 3:
  1494. if (!PyArg_ParseTuple(args, "ssO:setvar",
  1495. &name1, &name2, &newValue))
  1496. return NULL;
  1497. CHECK_STRING_LENGTH(name1);
  1498. CHECK_STRING_LENGTH(name2);
  1499. /* XXX must hold tcl lock already??? */
  1500. newval = AsObj(newValue);
  1501. ENTER_TCL
  1502. ok = Tcl_SetVar2Ex(Tkapp_Interp(self), name1, name2, newval, flags);
  1503. ENTER_OVERLAP
  1504. if (!ok)
  1505. Tkinter_Error(self);
  1506. else {
  1507. res = Py_None;
  1508. Py_INCREF(res);
  1509. }
  1510. LEAVE_OVERLAP_TCL
  1511. break;
  1512. default:
  1513. PyErr_SetString(PyExc_TypeError, "setvar requires 2 to 3 arguments");
  1514. return NULL;
  1515. }
  1516. return res;
  1517. }
  1518. static PyObject *
  1519. Tkapp_SetVar(PyObject *self, PyObject *args)
  1520. {
  1521. return var_invoke(SetVar, self, args, TCL_LEAVE_ERR_MSG);
  1522. }
  1523. static PyObject *
  1524. Tkapp_GlobalSetVar(PyObject *self, PyObject *args)
  1525. {
  1526. return var_invoke(SetVar, self, args, TCL_LEAVE_ERR_MSG | TCL_GLOBAL_ONLY);
  1527. }
  1528. static PyObject *
  1529. GetVar(PyObject *self, PyObject *args, int flags)
  1530. {
  1531. char *name1, *name2=NULL;
  1532. PyObject *res = NULL;
  1533. Tcl_Obj *tres;
  1534. if (!PyArg_ParseTuple(args, "O&|s:getvar",
  1535. varname_converter, &name1, &name2))
  1536. return NULL;
  1537. CHECK_STRING_LENGTH(name2);
  1538. ENTER_TCL
  1539. tres = Tcl_GetVar2Ex(Tkapp_Interp(self), name1, name2, flags);
  1540. ENTER_OVERLAP
  1541. if (tres == NULL) {
  1542. PyErr_SetString(Tkinter_TclError,
  1543. Tcl_GetStringResult(Tkapp_Interp(self)));
  1544. } else {
  1545. if (((TkappObject*)self)->wantobjects) {
  1546. res = FromObj(self, tres);
  1547. }
  1548. else {
  1549. res = unicodeFromTclObj(tres);
  1550. }
  1551. }
  1552. LEAVE_OVERLAP_TCL
  1553. return res;
  1554. }
  1555. static PyObject *
  1556. Tkapp_GetVar(PyObject *self, PyObject *args)
  1557. {
  1558. return var_invoke(GetVar, self, args, TCL_LEAVE_ERR_MSG);
  1559. }
  1560. static PyObject *
  1561. Tkapp_GlobalGetVar(PyObject *self, PyObject *args)
  1562. {
  1563. return var_invoke(GetVar, self, args, TCL_LEAVE_ERR_MSG | TCL_GLOBAL_ONLY);
  1564. }
  1565. static PyObject *
  1566. UnsetVar(PyObject *self, PyObject *args, int flags)
  1567. {
  1568. char *name1, *name2=NULL;
  1569. int code;
  1570. PyObject *res = NULL;
  1571. if (!PyArg_ParseTuple(args, "s|s:unsetvar", &name1, &name2))
  1572. return NULL;
  1573. CHECK_STRING_LENGTH(name1);
  1574. CHECK_STRING_LENGTH(name2);
  1575. ENTER_TCL
  1576. code = Tcl_UnsetVar2(Tkapp_Interp(self), name1, name2, flags);
  1577. ENTER_OVERLAP
  1578. if (code == TCL_ERROR)
  1579. res = Tkinter_Error(self);
  1580. else {
  1581. Py_INCREF(Py_None);
  1582. res = Py_None;
  1583. }
  1584. LEAVE_OVERLAP_TCL
  1585. return res;
  1586. }
  1587. static PyObject *
  1588. Tkapp_UnsetVar(PyObject *self, PyObject *args)
  1589. {
  1590. return var_invoke(UnsetVar, self, args, TCL_LEAVE_ERR_MSG);
  1591. }
  1592. static PyObject *
  1593. Tkapp_GlobalUnsetVar(PyObject *self, PyObject *args)
  1594. {
  1595. return var_invoke(UnsetVar, self, args,
  1596. TCL_LEAVE_ERR_MSG | TCL_GLOBAL_ONLY);
  1597. }
  1598. /** Tcl to Python **/
  1599. static PyObject *
  1600. Tkapp_GetInt(PyObject *self, PyObject *args)
  1601. {
  1602. char *s;
  1603. #if defined(TCL_WIDE_INT_TYPE) || defined(HAVE_LIBTOMMAMTH)
  1604. Tcl_Obj *value;
  1605. PyObject *result;
  1606. #else
  1607. int intValue;
  1608. #endif
  1609. if (PyTuple_Size(args) == 1) {
  1610. PyObject* o = PyTuple_GetItem(args, 0);
  1611. if (PyLong_Check(o)) {
  1612. Py_INCREF(o);
  1613. return o;
  1614. }
  1615. }
  1616. if (!PyArg_ParseTuple(args, "s:getint", &s))
  1617. return NULL;
  1618. CHECK_STRING_LENGTH(s);
  1619. #if defined(TCL_WIDE_INT_TYPE) || defined(HAVE_LIBTOMMAMTH)
  1620. value = Tcl_NewStringObj(s, -1);
  1621. if (value == NULL)
  1622. return Tkinter_Error(self);
  1623. /* Don't use Tcl_GetInt() because it returns ambiguous result for value
  1624. in ranges -2**32..-2**31-1 and 2**31..2**32-1 (on 32-bit platform).
  1625. Prefer bignum because Tcl_GetWideIntFromObj returns ambiguous result for
  1626. value in ranges -2**64..-2**63-1 and 2**63..2**64-1 (on 32-bit platform).
  1627. */
  1628. #ifdef HAVE_LIBTOMMAMTH
  1629. result = fromBignumObj(self, value);
  1630. #else
  1631. result = fromWideIntObj(self, value);
  1632. #endif
  1633. Tcl_DecrRefCount(value);
  1634. if (result != NULL || PyErr_Occurred())
  1635. return result;
  1636. #else
  1637. if (Tcl_GetInt(Tkapp_Interp(self), s, &intValue) == TCL_OK)
  1638. return PyLong_FromLong(intValue);
  1639. #endif
  1640. return Tkinter_Error(self);
  1641. }
  1642. static PyObject *
  1643. Tkapp_GetDouble(PyObject *self, PyObject *args)
  1644. {
  1645. char *s;
  1646. double v;
  1647. if (PyTuple_Size(args) == 1) {
  1648. PyObject *o = PyTuple_GetItem(args, 0);
  1649. if (PyFloat_Check(o)) {
  1650. Py_INCREF(o);
  1651. return o;
  1652. }
  1653. }
  1654. if (!PyArg_ParseTuple(args, "s:getdouble", &s))
  1655. return NULL;
  1656. CHECK_STRING_LENGTH(s);
  1657. if (Tcl_GetDouble(Tkapp_Interp(self), s, &v) == TCL_ERROR)
  1658. return Tkinter_Error(self);
  1659. return Py_BuildValue("d", v);
  1660. }
  1661. static PyObject *
  1662. Tkapp_GetBoolean(PyObject *self, PyObject *arg)
  1663. {
  1664. char *s;
  1665. int v;
  1666. if (PyLong_Check(arg)) { /* int or bool */
  1667. return PyBool_FromLong(Py_SIZE(arg) != 0);
  1668. }
  1669. if (PyTclObject_Check(arg)) {
  1670. if (Tcl_GetBooleanFromObj(Tkapp_Interp(self),
  1671. ((PyTclObject*)arg)->value,
  1672. &v) == TCL_ERROR)
  1673. return Tkinter_Error(self);
  1674. return PyBool_FromLong(v);
  1675. }
  1676. if (!PyArg_Parse(arg, "s:getboolean", &s))
  1677. return NULL;
  1678. CHECK_STRING_LENGTH(s);
  1679. if (Tcl_GetBoolean(Tkapp_Interp(self), s, &v) == TCL_ERROR)
  1680. return Tkinter_Error(self);
  1681. return PyBool_FromLong(v);
  1682. }
  1683. static PyObject *
  1684. Tkapp_ExprString(PyObject *self, PyObject *args)
  1685. {
  1686. char *s;
  1687. PyObject *res = NULL;
  1688. int retval;
  1689. if (!PyArg_ParseTuple(args, "s:exprstring", &s))
  1690. return NULL;
  1691. CHECK_STRING_LENGTH(s);
  1692. CHECK_TCL_APPARTMENT;
  1693. ENTER_TCL
  1694. retval = Tcl_ExprString(Tkapp_Interp(self), s);
  1695. ENTER_OVERLAP
  1696. if (retval == TCL_ERROR)
  1697. res = Tkinter_Error(self);
  1698. else
  1699. res = unicodeFromTclString(Tkapp_Result(self));
  1700. LEAVE_OVERLAP_TCL
  1701. return res;
  1702. }
  1703. static PyObject *
  1704. Tkapp_ExprLong(PyObject *self, PyObject *args)
  1705. {
  1706. char *s;
  1707. PyObject *res = NULL;
  1708. int retval;
  1709. long v;
  1710. if (!PyArg_ParseTuple(args, "s:exprlong", &s))
  1711. return NULL;
  1712. CHECK_STRING_LENGTH(s);
  1713. CHECK_TCL_APPARTMENT;
  1714. ENTER_TCL
  1715. retval = Tcl_ExprLong(Tkapp_Interp(self), s, &v);
  1716. ENTER_OVERLAP
  1717. if (retval == TCL_ERROR)
  1718. res = Tkinter_Error(self);
  1719. else
  1720. res = Py_BuildValue("l", v);
  1721. LEAVE_OVERLAP_TCL
  1722. return res;
  1723. }
  1724. static PyObject *
  1725. Tkapp_ExprDouble(PyObject *self, PyObject *args)
  1726. {
  1727. char *s;
  1728. PyObject *res = NULL;
  1729. double v;
  1730. int retval;
  1731. if (!PyArg_ParseTuple(args, "s:exprdouble", &s))
  1732. return NULL;
  1733. CHECK_STRING_LENGTH(s);
  1734. CHECK_TCL_APPARTMENT;
  1735. PyFPE_START_PROTECT("Tkapp_ExprDouble", return 0)
  1736. ENTER_TCL
  1737. retval = Tcl_ExprDouble(Tkapp_Interp(self), s, &v);
  1738. ENTER_OVERLAP
  1739. PyFPE_END_PROTECT(retval)
  1740. if (retval == TCL_ERROR)
  1741. res = Tkinter_Error(self);
  1742. else
  1743. res = Py_BuildValue("d", v);
  1744. LEAVE_OVERLAP_TCL
  1745. return res;
  1746. }
  1747. static PyObject *
  1748. Tkapp_ExprBoolean(PyObject *self, PyObject *args)
  1749. {
  1750. char *s;
  1751. PyObject *res = NULL;
  1752. int retval;
  1753. int v;
  1754. if (!PyArg_ParseTuple(args, "s:exprboolean", &s))
  1755. return NULL;
  1756. CHECK_STRING_LENGTH(s);
  1757. CHECK_TCL_APPARTMENT;
  1758. ENTER_TCL
  1759. retval = Tcl_ExprBoolean(Tkapp_Interp(self), s, &v);
  1760. ENTER_OVERLAP
  1761. if (retval == TCL_ERROR)
  1762. res = Tkinter_Error(self);
  1763. else
  1764. res = Py_BuildValue("i", v);
  1765. LEAVE_OVERLAP_TCL
  1766. return res;
  1767. }
  1768. static PyObject *
  1769. Tkapp_SplitList(PyObject *self, PyObject *args)
  1770. {
  1771. char *list;
  1772. int argc;
  1773. char **argv;
  1774. PyObject *arg, *v;
  1775. int i;
  1776. if (!PyArg_ParseTuple(args, "O:splitlist", &arg))
  1777. return NULL;
  1778. if (PyTclObject_Check(arg)) {
  1779. int objc;
  1780. Tcl_Obj **objv;
  1781. if (Tcl_ListObjGetElements(Tkapp_Interp(self),
  1782. ((PyTclObject*)arg)->value,
  1783. &objc, &objv) == TCL_ERROR) {
  1784. return Tkinter_Error(self);
  1785. }
  1786. if (!(v = PyTuple_New(objc)))
  1787. return NULL;
  1788. for (i = 0; i < objc; i++) {
  1789. PyObject *s = FromObj(self, objv[i]);
  1790. if (!s || PyTuple_SetItem(v, i, s)) {
  1791. Py_DECREF(v);
  1792. return NULL;
  1793. }
  1794. }
  1795. return v;
  1796. }
  1797. if (PyTuple_Check(arg)) {
  1798. Py_INCREF(arg);
  1799. return arg;
  1800. }
  1801. if (!PyArg_ParseTuple(args, "et:splitlist", "utf-8", &list))
  1802. return NULL;
  1803. CHECK_STRING_LENGTH(list);
  1804. if (Tcl_SplitList(Tkapp_Interp(self), list,
  1805. &argc, &argv) == TCL_ERROR) {
  1806. PyMem_Free(list);
  1807. return Tkinter_Error(self);
  1808. }
  1809. if (!(v = PyTuple_New(argc)))
  1810. goto finally;
  1811. for (i = 0; i < argc; i++) {
  1812. PyObject *s = unicodeFromTclString(argv[i]);
  1813. if (!s || PyTuple_SetItem(v, i, s)) {
  1814. Py_DECREF(v);
  1815. v = NULL;
  1816. goto finally;
  1817. }
  1818. }
  1819. finally:
  1820. ckfree(FREECAST argv);
  1821. PyMem_Free(list);
  1822. return v;
  1823. }
  1824. static PyObject *
  1825. Tkapp_Split(PyObject *self, PyObject *args)
  1826. {
  1827. PyObject *arg, *v;
  1828. char *list;
  1829. if (!PyArg_ParseTuple(args, "O:split", &arg))
  1830. return NULL;
  1831. if (PyTclObject_Check(arg)) {
  1832. Tcl_Obj *value = ((PyTclObject*)arg)->value;
  1833. int objc;
  1834. Tcl_Obj **objv;
  1835. int i;
  1836. if (Tcl_ListObjGetElements(Tkapp_Interp(self), value,
  1837. &objc, &objv) == TCL_ERROR) {
  1838. return FromObj(self, value);
  1839. }
  1840. if (objc == 0)
  1841. return PyUnicode_FromString("");
  1842. if (objc == 1)
  1843. return FromObj(self, objv[0]);
  1844. if (!(v = PyTuple_New(objc)))
  1845. return NULL;
  1846. for (i = 0; i < objc; i++) {
  1847. PyObject *s = FromObj(self, objv[i]);
  1848. if (!s || PyTuple_SetItem(v, i, s)) {
  1849. Py_DECREF(v);
  1850. return NULL;
  1851. }
  1852. }
  1853. return v;
  1854. }
  1855. if (PyTuple_Check(arg))
  1856. return SplitObj(arg);
  1857. if (!PyArg_ParseTuple(args, "et:split", "utf-8", &list))
  1858. return NULL;
  1859. CHECK_STRING_LENGTH(list);
  1860. v = Split(list);
  1861. PyMem_Free(list);
  1862. return v;
  1863. }
  1864. /** Tcl Command **/
  1865. /* Client data struct */
  1866. typedef struct {
  1867. PyObject *self;
  1868. PyObject *func;
  1869. } PythonCmd_ClientData;
  1870. static int
  1871. PythonCmd_Error(Tcl_Interp *interp)
  1872. {
  1873. errorInCmd = 1;
  1874. PyErr_Fetch(&excInCmd, &valInCmd, &trbInCmd);
  1875. LEAVE_PYTHON
  1876. return TCL_ERROR;
  1877. }
  1878. /* This is the Tcl command that acts as a wrapper for Python
  1879. * function or method.
  1880. */
  1881. static int
  1882. PythonCmd(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[])
  1883. {
  1884. PythonCmd_ClientData *data = (PythonCmd_ClientData *)clientData;
  1885. PyObject *func, *arg, *res;
  1886. int i, rv;
  1887. Tcl_Obj *obj_res;
  1888. ENTER_PYTHON
  1889. /* TBD: no error checking here since we know, via the
  1890. * Tkapp_CreateCommand() that the client data is a two-tuple
  1891. */
  1892. func = data->func;
  1893. /* Create argument list (argv1, ..., argvN) */
  1894. if (!(arg = PyTuple_New(argc - 1)))
  1895. return PythonCmd_Error(interp);
  1896. for (i = 0; i < (argc - 1); i++) {
  1897. PyObject *s = unicodeFromTclString(argv[i + 1]);
  1898. if (!s || PyTuple_SetItem(arg, i, s)) {
  1899. Py_DECREF(arg);
  1900. return PythonCmd_Error(interp);
  1901. }
  1902. }
  1903. res = PyEval_CallObject(func, arg);
  1904. Py_DECREF(arg);
  1905. if (res == NULL)
  1906. return PythonCmd_Error(interp);
  1907. obj_res = AsObj(res);
  1908. if (obj_res == NULL) {
  1909. Py_DECREF(res);
  1910. return PythonCmd_Error(interp);
  1911. }
  1912. else {
  1913. Tcl_SetObjResult(interp, obj_res);
  1914. rv = TCL_OK;
  1915. }
  1916. Py_DECREF(res);
  1917. LEAVE_PYTHON
  1918. return rv;
  1919. }
  1920. static void
  1921. PythonCmdDelete(ClientData clientData)
  1922. {
  1923. PythonCmd_ClientData *data = (PythonCmd_ClientData *)clientData;
  1924. ENTER_PYTHON
  1925. Py_XDECREF(data->self);
  1926. Py_XDECREF(data->func);
  1927. PyMem_DEL(data);
  1928. LEAVE_PYTHON
  1929. }
  1930. #ifdef WITH_THREAD
  1931. TCL_DECLARE_MUTEX(command_mutex)
  1932. typedef struct CommandEvent{
  1933. Tcl_Event ev;
  1934. Tcl_Interp* interp;
  1935. char *name;
  1936. int create;
  1937. int *status;
  1938. ClientData *data;
  1939. Tcl_Condition *done;
  1940. } CommandEvent;
  1941. static int
  1942. Tkapp_CommandProc(CommandEvent *ev, int flags)
  1943. {
  1944. if (ev->create)
  1945. *ev->status = Tcl_CreateCommand(
  1946. ev->interp, ev->name, PythonCmd,
  1947. ev->data, PythonCmdDelete) == NULL;
  1948. else
  1949. *ev->status = Tcl_DeleteCommand(ev->interp, ev->name);
  1950. Tcl_MutexLock(&command_mutex);
  1951. Tcl_ConditionNotify(ev->done);
  1952. Tcl_MutexUnlock(&command_mutex);
  1953. return 1;
  1954. }
  1955. #endif
  1956. static PyObject *
  1957. Tkapp_CreateCommand(PyObject *selfptr, PyObject *args)
  1958. {
  1959. TkappObject *self = (TkappObject*)selfptr;
  1960. PythonCmd_ClientData *data;
  1961. char *cmdName;
  1962. PyObject *func;
  1963. int err;
  1964. if (!PyArg_ParseTuple(args, "sO:createcommand", &cmdName, &func))
  1965. return NULL;
  1966. CHECK_STRING_LENGTH(cmdName);
  1967. if (!PyCallable_Check(func)) {
  1968. PyErr_SetString(PyExc_TypeError, "command not callable");
  1969. return NULL;
  1970. }
  1971. #ifdef WITH_THREAD
  1972. if (self->threaded && self->thread_id != Tcl_GetCurrentThread() &&
  1973. !WaitForMainloop(self))
  1974. return NULL;
  1975. #endif
  1976. data = PyMem_NEW(PythonCmd_ClientData, 1);
  1977. if (!data)
  1978. return PyErr_NoMemory();
  1979. Py_INCREF(self);
  1980. Py_INCREF(func);
  1981. data->self = selfptr;
  1982. data->func = func;
  1983. #ifdef WITH_THREAD
  1984. if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) {
  1985. Tcl_Condition cond = NULL;
  1986. CommandEvent *ev = (CommandEvent*)attemptckalloc(sizeof(CommandEvent));
  1987. if (ev == NULL) {
  1988. PyErr_NoMemory();
  1989. PyMem_DEL(data);
  1990. return NULL;
  1991. }
  1992. ev->ev.proc = (Tcl_EventProc*)Tkapp_CommandProc;
  1993. ev->interp = self->interp;
  1994. ev->create = 1;
  1995. ev->name = cmdName;
  1996. ev->data = (ClientData)data;
  1997. ev->status = &err;
  1998. ev->done = &cond;
  1999. Tkapp_ThreadSend(self, (Tcl_Event*)ev, &cond, &command_mutex);
  2000. Tcl_ConditionFinalize(&cond);
  2001. }
  2002. else
  2003. #endif
  2004. {
  2005. ENTER_TCL
  2006. err = Tcl_CreateCommand(
  2007. Tkapp_Interp(self), cmdName, PythonCmd,
  2008. (ClientData)data, PythonCmdDelete) == NULL;
  2009. LEAVE_TCL
  2010. }
  2011. if (err) {
  2012. PyErr_SetString(Tkinter_TclError, "can't create Tcl command");
  2013. PyMem_DEL(data);
  2014. return NULL;
  2015. }
  2016. Py_RETURN_NONE;
  2017. }
  2018. static PyObject *
  2019. Tkapp_DeleteCommand(PyObject *selfptr, PyObject *args)
  2020. {
  2021. TkappObject *self = (TkappObject*)selfptr;
  2022. char *cmdName;
  2023. int err;
  2024. if (!PyArg_ParseTuple(args, "s:deletecommand", &cmdName))
  2025. return NULL;
  2026. CHECK_STRING_LENGTH(cmdName);
  2027. #ifdef WITH_THREAD
  2028. if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) {
  2029. Tcl_Condition cond = NULL;
  2030. CommandEvent *ev;
  2031. ev = (CommandEvent*)attemptckalloc(sizeof(CommandEvent));
  2032. if (ev == NULL) {
  2033. PyErr_NoMemory();
  2034. return NULL;
  2035. }
  2036. ev->ev.proc = (Tcl_EventProc*)Tkapp_CommandProc;
  2037. ev->interp = self->interp;
  2038. ev->create = 0;
  2039. ev->name = cmdName;
  2040. ev->status = &err;
  2041. ev->done = &cond;
  2042. Tkapp_ThreadSend(self, (Tcl_Event*)ev, &cond,
  2043. &command_mutex);
  2044. Tcl_ConditionFinalize(&cond);
  2045. }
  2046. else
  2047. #endif
  2048. {
  2049. ENTER_TCL
  2050. err = Tcl_DeleteCommand(self->interp, cmdName);
  2051. LEAVE_TCL
  2052. }
  2053. if (err == -1) {
  2054. PyErr_SetString(Tkinter_TclError, "can't delete Tcl command");
  2055. return NULL;
  2056. }
  2057. Py_RETURN_NONE;
  2058. }
  2059. #ifdef HAVE_CREATEFILEHANDLER
  2060. /** File Handler **/
  2061. typedef struct _fhcdata {
  2062. PyObject *func;
  2063. PyObject *file;
  2064. int id;
  2065. struct _fhcdata *next;
  2066. } FileHandler_ClientData;
  2067. static FileHandler_ClientData *HeadFHCD;
  2068. static FileHandler_ClientData *
  2069. NewFHCD(PyObject *func, PyObject *file, int id)
  2070. {
  2071. FileHandler_ClientData *p;
  2072. p = PyMem_NEW(FileHandler_ClientData, 1);
  2073. if (p != NULL) {
  2074. Py_XINCREF(func);
  2075. Py_XINCREF(file);
  2076. p->func = func;
  2077. p->file = file;
  2078. p->id = id;
  2079. p->next = HeadFHCD;
  2080. HeadFHCD = p;
  2081. }
  2082. return p;
  2083. }
  2084. static void
  2085. DeleteFHCD(int id)
  2086. {
  2087. FileHandler_ClientData *p, **pp;
  2088. pp = &HeadFHCD;
  2089. while ((p = *pp) != NULL) {
  2090. if (p->id == id) {
  2091. *pp = p->next;
  2092. Py_XDECREF(p->func);
  2093. Py_XDECREF(p->file);
  2094. PyMem_DEL(p);
  2095. }
  2096. else
  2097. pp = &p->next;
  2098. }
  2099. }
  2100. static void
  2101. FileHandler(ClientData clientData, int mask)
  2102. {
  2103. FileHandler_ClientData *data = (FileHandler_ClientData *)clientData;
  2104. PyObject *func, *file, *arg, *res;
  2105. ENTER_PYTHON
  2106. func = data->func;
  2107. file = data->file;
  2108. arg = Py_BuildValue("(Oi)", file, (long) mask);
  2109. res = PyEval_CallObject(func, arg);
  2110. Py_DECREF(arg);
  2111. if (res == NULL) {
  2112. errorInCmd = 1;
  2113. PyErr_Fetch(&excInCmd, &valInCmd, &trbInCmd);
  2114. }
  2115. Py_XDECREF(res);
  2116. LEAVE_PYTHON
  2117. }
  2118. static PyObject *
  2119. Tkapp_CreateFileHandler(PyObject *self, PyObject *args)
  2120. /* args is (file, mask, func) */
  2121. {
  2122. FileHandler_ClientData *data;
  2123. PyObject *file, *func;
  2124. int mask, tfile;
  2125. if (!PyArg_ParseTuple(args, "OiO:createfilehandler",
  2126. &file, &mask, &func))
  2127. return NULL;
  2128. CHECK_TCL_APPARTMENT;
  2129. tfile = PyObject_AsFileDescriptor(file);
  2130. if (tfile < 0)
  2131. return NULL;
  2132. if (!PyCallable_Check(func)) {
  2133. PyErr_SetString(PyExc_TypeError, "bad argument list");
  2134. return NULL;
  2135. }
  2136. data = NewFHCD(func, file, tfile);
  2137. if (data == NULL)
  2138. return NULL;
  2139. /* Ought to check for null Tcl_File object... */
  2140. ENTER_TCL
  2141. Tcl_CreateFileHandler(tfile, mask, FileHandler, (ClientData) data);
  2142. LEAVE_TCL
  2143. Py_RETURN_NONE;
  2144. }
  2145. static PyObject *
  2146. Tkapp_DeleteFileHandler(PyObject *self, PyObject *args)
  2147. {
  2148. PyObject *file;
  2149. int tfile;
  2150. if (!PyArg_ParseTuple(args, "O:deletefilehandler", &file))
  2151. return NULL;
  2152. CHECK_TCL_APPARTMENT;
  2153. tfile = PyObject_AsFileDescriptor(file);
  2154. if (tfile < 0)
  2155. return NULL;
  2156. DeleteFHCD(tfile);
  2157. /* Ought to check for null Tcl_File object... */
  2158. ENTER_TCL
  2159. Tcl_DeleteFileHandler(tfile);
  2160. LEAVE_TCL
  2161. Py_RETURN_NONE;
  2162. }
  2163. #endif /* HAVE_CREATEFILEHANDLER */
  2164. /**** Tktt Object (timer token) ****/
  2165. static PyObject *Tktt_Type;
  2166. typedef struct {
  2167. PyObject_HEAD
  2168. Tcl_TimerToken token;
  2169. PyObject *func;
  2170. } TkttObject;
  2171. static PyObject *
  2172. Tktt_DeleteTimerHandler(PyObject *self, PyObject *args)
  2173. {
  2174. TkttObject *v = (TkttObject *)self;
  2175. PyObject *func = v->func;
  2176. if (!PyArg_ParseTuple(args, ":deletetimerhandler"))
  2177. return NULL;
  2178. if (v->token != NULL) {
  2179. Tcl_DeleteTimerHandler(v->token);
  2180. v->token = NULL;
  2181. }
  2182. if (func != NULL) {
  2183. v->func = NULL;
  2184. Py_DECREF(func);
  2185. Py_DECREF(v); /* See Tktt_New() */
  2186. }
  2187. Py_RETURN_NONE;
  2188. }
  2189. static PyMethodDef Tktt_methods[] =
  2190. {
  2191. {"deletetimerhandler", Tktt_DeleteTimerHandler, METH_VARARGS},
  2192. {NULL, NULL}
  2193. };
  2194. static TkttObject *
  2195. Tktt_New(PyObject *func)
  2196. {
  2197. TkttObject *v;
  2198. v = PyObject_New(TkttObject, (PyTypeObject *) Tktt_Type);
  2199. if (v == NULL)
  2200. return NULL;
  2201. Py_INCREF(Tktt_Type);
  2202. Py_INCREF(func);
  2203. v->token = NULL;
  2204. v->func = func;
  2205. /* Extra reference, deleted when called or when handler is deleted */
  2206. Py_INCREF(v);
  2207. return v;
  2208. }
  2209. static void
  2210. Tktt_Dealloc(PyObject *self)
  2211. {
  2212. TkttObject *v = (TkttObject *)self;
  2213. PyObject *func = v->func;
  2214. PyObject *tp = (PyObject *) Py_TYPE(self);
  2215. Py_XDECREF(func);
  2216. PyObject_Del(self);
  2217. Py_DECREF(tp);
  2218. }
  2219. static PyObject *
  2220. Tktt_Repr(PyObject *self)
  2221. {
  2222. TkttObject *v = (TkttObject *)self;
  2223. return PyUnicode_FromFormat("<tktimertoken at %p%s>",
  2224. v,
  2225. v->func == NULL ? ", handler deleted" : "");
  2226. }
  2227. static PyType_Slot Tktt_Type_slots[] = {
  2228. {Py_tp_dealloc, Tktt_Dealloc},
  2229. {Py_tp_repr, Tktt_Repr},
  2230. {Py_tp_methods, Tktt_methods},
  2231. {0, 0}
  2232. };
  2233. static PyType_Spec Tktt_Type_spec = {
  2234. "_tkinter.tktimertoken",
  2235. sizeof(TkttObject),
  2236. 0,
  2237. Py_TPFLAGS_DEFAULT,
  2238. Tktt_Type_slots,
  2239. };
  2240. /** Timer Handler **/
  2241. static void
  2242. TimerHandler(ClientData clientData)
  2243. {
  2244. TkttObject *v = (TkttObject *)clientData;
  2245. PyObject *func = v->func;
  2246. PyObject *res;
  2247. if (func == NULL)
  2248. return;
  2249. v->func = NULL;
  2250. ENTER_PYTHON
  2251. res = PyEval_CallObject(func, NULL);
  2252. Py_DECREF(func);
  2253. Py_DECREF(v); /* See Tktt_New() */
  2254. if (res == NULL) {
  2255. errorInCmd = 1;
  2256. PyErr_Fetch(&excInCmd, &valInCmd, &trbInCmd);
  2257. }
  2258. else
  2259. Py_DECREF(res);
  2260. LEAVE_PYTHON
  2261. }
  2262. static PyObject *
  2263. Tkapp_CreateTimerHandler(PyObject *self, PyObject *args)
  2264. {
  2265. int milliseconds;
  2266. PyObject *func;
  2267. TkttObject *v;
  2268. if (!PyArg_ParseTuple(args, "iO:createtimerhandler",
  2269. &milliseconds, &func))
  2270. return NULL;
  2271. if (!PyCallable_Check(func)) {
  2272. PyErr_SetString(PyExc_TypeError, "bad argument list");
  2273. return NULL;
  2274. }
  2275. CHECK_TCL_APPARTMENT;
  2276. v = Tktt_New(func);
  2277. if (v) {
  2278. v->token = Tcl_CreateTimerHandler(milliseconds, TimerHandler,
  2279. (ClientData)v);
  2280. }
  2281. return (PyObject *) v;
  2282. }
  2283. /** Event Loop **/
  2284. static PyObject *
  2285. Tkapp_MainLoop(PyObject *selfptr, PyObject *args)
  2286. {
  2287. int threshold = 0;
  2288. TkappObject *self = (TkappObject*)selfptr;
  2289. #ifdef WITH_THREAD
  2290. PyThreadState *tstate = PyThreadState_Get();
  2291. #endif
  2292. if (!PyArg_ParseTuple(args, "|i:mainloop", &threshold))
  2293. return NULL;
  2294. CHECK_TCL_APPARTMENT;
  2295. self->dispatching = 1;
  2296. quitMainLoop = 0;
  2297. while (Tk_GetNumMainWindows() > threshold &&
  2298. !quitMainLoop &&
  2299. !errorInCmd)
  2300. {
  2301. int result;
  2302. #ifdef WITH_THREAD
  2303. if (self->threaded) {
  2304. /* Allow other Python threads to run. */
  2305. ENTER_TCL
  2306. result = Tcl_DoOneEvent(0);
  2307. LEAVE_TCL
  2308. }
  2309. else {
  2310. Py_BEGIN_ALLOW_THREADS
  2311. if(tcl_lock)PyThread_acquire_lock(tcl_lock, 1);
  2312. tcl_tstate = tstate;
  2313. result = Tcl_DoOneEvent(TCL_DONT_WAIT);
  2314. tcl_tstate = NULL;
  2315. if(tcl_lock)PyThread_release_lock(tcl_lock);
  2316. if (result == 0)
  2317. Sleep(Tkinter_busywaitinterval);
  2318. Py_END_ALLOW_THREADS
  2319. }
  2320. #else
  2321. result = Tcl_DoOneEvent(0);
  2322. #endif
  2323. if (PyErr_CheckSignals() != 0) {
  2324. self->dispatching = 0;
  2325. return NULL;
  2326. }
  2327. if (result < 0)
  2328. break;
  2329. }
  2330. self->dispatching = 0;
  2331. quitMainLoop = 0;
  2332. if (errorInCmd) {
  2333. errorInCmd = 0;
  2334. PyErr_Restore(excInCmd, valInCmd, trbInCmd);
  2335. excInCmd = valInCmd = trbInCmd = NULL;
  2336. return NULL;
  2337. }
  2338. Py_RETURN_NONE;
  2339. }
  2340. static PyObject *
  2341. Tkapp_DoOneEvent(PyObject *self, PyObject *args)
  2342. {
  2343. int flags = 0;
  2344. int rv;
  2345. if (!PyArg_ParseTuple(args, "|i:dooneevent", &flags))
  2346. return NULL;
  2347. ENTER_TCL
  2348. rv = Tcl_DoOneEvent(flags);
  2349. LEAVE_TCL
  2350. return Py_BuildValue("i", rv);
  2351. }
  2352. static PyObject *
  2353. Tkapp_Quit(PyObject *self, PyObject *args)
  2354. {
  2355. if (!PyArg_ParseTuple(args, ":quit"))
  2356. return NULL;
  2357. quitMainLoop = 1;
  2358. Py_RETURN_NONE;
  2359. }
  2360. static PyObject *
  2361. Tkapp_InterpAddr(PyObject *self, PyObject *args)
  2362. {
  2363. if (!PyArg_ParseTuple(args, ":interpaddr"))
  2364. return NULL;
  2365. return PyLong_FromVoidPtr(Tkapp_Interp(self));
  2366. }
  2367. static PyObject *
  2368. Tkapp_TkInit(PyObject *self, PyObject *args)
  2369. {
  2370. Tcl_Interp *interp = Tkapp_Interp(self);
  2371. const char * _tk_exists = NULL;
  2372. int err;
  2373. #ifdef TKINTER_PROTECT_LOADTK
  2374. /* Up to Tk 8.4.13, Tk_Init deadlocks on the second call when the
  2375. * first call failed.
  2376. * To avoid the deadlock, we just refuse the second call through
  2377. * a static variable.
  2378. */
  2379. if (tk_load_failed) {
  2380. PyErr_SetString(Tkinter_TclError, TKINTER_LOADTK_ERRMSG);
  2381. return NULL;
  2382. }
  2383. #endif
  2384. /* We want to guard against calling Tk_Init() multiple times */
  2385. CHECK_TCL_APPARTMENT;
  2386. ENTER_TCL
  2387. err = Tcl_Eval(Tkapp_Interp(self), "info exists tk_version");
  2388. ENTER_OVERLAP
  2389. if (err == TCL_ERROR) {
  2390. /* This sets an exception, but we cannot return right
  2391. away because we need to exit the overlap first. */
  2392. Tkinter_Error(self);
  2393. } else {
  2394. _tk_exists = Tkapp_Result(self);
  2395. }
  2396. LEAVE_OVERLAP_TCL
  2397. if (err == TCL_ERROR) {
  2398. return NULL;
  2399. }
  2400. if (_tk_exists == NULL || strcmp(_tk_exists, "1") != 0) {
  2401. if (Tk_Init(interp) == TCL_ERROR) {
  2402. PyErr_SetString(Tkinter_TclError,
  2403. Tcl_GetStringResult(Tkapp_Interp(self)));
  2404. #ifdef TKINTER_PROTECT_LOADTK
  2405. tk_load_failed = 1;
  2406. #endif
  2407. return NULL;
  2408. }
  2409. }
  2410. Py_RETURN_NONE;
  2411. }
  2412. static PyObject *
  2413. Tkapp_WantObjects(PyObject *self, PyObject *args)
  2414. {
  2415. int wantobjects = -1;
  2416. if (!PyArg_ParseTuple(args, "|i:wantobjects", &wantobjects))
  2417. return NULL;
  2418. if (wantobjects == -1)
  2419. return PyBool_FromLong(((TkappObject*)self)->wantobjects);
  2420. ((TkappObject*)self)->wantobjects = wantobjects;
  2421. Py_RETURN_NONE;
  2422. }
  2423. static PyObject *
  2424. Tkapp_WillDispatch(PyObject *self, PyObject *args)
  2425. {
  2426. ((TkappObject*)self)->dispatching = 1;
  2427. Py_RETURN_NONE;
  2428. }
  2429. /**** Tkapp Method List ****/
  2430. static PyMethodDef Tkapp_methods[] =
  2431. {
  2432. {"willdispatch", Tkapp_WillDispatch, METH_NOARGS},
  2433. {"wantobjects", Tkapp_WantObjects, METH_VARARGS},
  2434. {"call", Tkapp_Call, METH_VARARGS},
  2435. {"eval", Tkapp_Eval, METH_VARARGS},
  2436. {"evalfile", Tkapp_EvalFile, METH_VARARGS},
  2437. {"record", Tkapp_Record, METH_VARARGS},
  2438. {"adderrorinfo", Tkapp_AddErrorInfo, METH_VARARGS},
  2439. {"setvar", Tkapp_SetVar, METH_VARARGS},
  2440. {"globalsetvar", Tkapp_GlobalSetVar, METH_VARARGS},
  2441. {"getvar", Tkapp_GetVar, METH_VARARGS},
  2442. {"globalgetvar", Tkapp_GlobalGetVar, METH_VARARGS},
  2443. {"unsetvar", Tkapp_UnsetVar, METH_VARARGS},
  2444. {"globalunsetvar", Tkapp_GlobalUnsetVar, METH_VARARGS},
  2445. {"getint", Tkapp_GetInt, METH_VARARGS},
  2446. {"getdouble", Tkapp_GetDouble, METH_VARARGS},
  2447. {"getboolean", Tkapp_GetBoolean, METH_O},
  2448. {"exprstring", Tkapp_ExprString, METH_VARARGS},
  2449. {"exprlong", Tkapp_ExprLong, METH_VARARGS},
  2450. {"exprdouble", Tkapp_ExprDouble, METH_VARARGS},
  2451. {"exprboolean", Tkapp_ExprBoolean, METH_VARARGS},
  2452. {"splitlist", Tkapp_SplitList, METH_VARARGS},
  2453. {"split", Tkapp_Split, METH_VARARGS},
  2454. {"createcommand", Tkapp_CreateCommand, METH_VARARGS},
  2455. {"deletecommand", Tkapp_DeleteCommand, METH_VARARGS},
  2456. #ifdef HAVE_CREATEFILEHANDLER
  2457. {"createfilehandler", Tkapp_CreateFileHandler, METH_VARARGS},
  2458. {"deletefilehandler", Tkapp_DeleteFileHandler, METH_VARARGS},
  2459. #endif
  2460. {"createtimerhandler", Tkapp_CreateTimerHandler, METH_VARARGS},
  2461. {"mainloop", Tkapp_MainLoop, METH_VARARGS},
  2462. {"dooneevent", Tkapp_DoOneEvent, METH_VARARGS},
  2463. {"quit", Tkapp_Quit, METH_VARARGS},
  2464. {"interpaddr", Tkapp_InterpAddr, METH_VARARGS},
  2465. {"loadtk", Tkapp_TkInit, METH_NOARGS},
  2466. {NULL, NULL}
  2467. };
  2468. /**** Tkapp Type Methods ****/
  2469. static void
  2470. Tkapp_Dealloc(PyObject *self)
  2471. {
  2472. PyObject *tp = (PyObject *) Py_TYPE(self);
  2473. /*CHECK_TCL_APPARTMENT;*/
  2474. ENTER_TCL
  2475. Tcl_DeleteInterp(Tkapp_Interp(self));
  2476. LEAVE_TCL
  2477. PyObject_Del(self);
  2478. Py_DECREF(tp);
  2479. DisableEventHook();
  2480. }
  2481. static PyType_Slot Tkapp_Type_slots[] = {
  2482. {Py_tp_dealloc, Tkapp_Dealloc},
  2483. {Py_tp_methods, Tkapp_methods},
  2484. {0, 0}
  2485. };
  2486. static PyType_Spec Tkapp_Type_spec = {
  2487. "_tkinter.tkapp",
  2488. sizeof(TkappObject),
  2489. 0,
  2490. Py_TPFLAGS_DEFAULT,
  2491. Tkapp_Type_slots,
  2492. };
  2493. /**** Tkinter Module ****/
  2494. typedef struct {
  2495. PyObject* tuple;
  2496. int size; /* current size */
  2497. int maxsize; /* allocated size */
  2498. } FlattenContext;
  2499. static int
  2500. _bump(FlattenContext* context, int size)
  2501. {
  2502. /* expand tuple to hold (at least) size new items.
  2503. return true if successful, false if an exception was raised */
  2504. int maxsize = context->maxsize * 2;
  2505. if (maxsize < context->size + size)
  2506. maxsize = context->size + size;
  2507. context->maxsize = maxsize;
  2508. return _PyTuple_Resize(&context->tuple, maxsize) >= 0;
  2509. }
  2510. static int
  2511. _flatten1(FlattenContext* context, PyObject* item, int depth)
  2512. {
  2513. /* add tuple or list to argument tuple (recursively) */
  2514. int i, size;
  2515. if (depth > 1000) {
  2516. PyErr_SetString(PyExc_ValueError,
  2517. "nesting too deep in _flatten");
  2518. return 0;
  2519. } else if (PyList_Check(item)) {
  2520. size = PyList_GET_SIZE(item);
  2521. /* preallocate (assume no nesting) */
  2522. if (context->size + size > context->maxsize &&
  2523. !_bump(context, size))
  2524. return 0;
  2525. /* copy items to output tuple */
  2526. for (i = 0; i < size; i++) {
  2527. PyObject *o = PyList_GET_ITEM(item, i);
  2528. if (PyList_Check(o) || PyTuple_Check(o)) {
  2529. if (!_flatten1(context, o, depth + 1))
  2530. return 0;
  2531. } else if (o != Py_None) {
  2532. if (context->size + 1 > context->maxsize &&
  2533. !_bump(context, 1))
  2534. return 0;
  2535. Py_INCREF(o);
  2536. PyTuple_SET_ITEM(context->tuple,
  2537. context->size++, o);
  2538. }
  2539. }
  2540. } else if (PyTuple_Check(item)) {
  2541. /* same, for tuples */
  2542. size = PyTuple_GET_SIZE(item);
  2543. if (context->size + size > context->maxsize &&
  2544. !_bump(context, size))
  2545. return 0;
  2546. for (i = 0; i < size; i++) {
  2547. PyObject *o = PyTuple_GET_ITEM(item, i);
  2548. if (PyList_Check(o) || PyTuple_Check(o)) {
  2549. if (!_flatten1(context, o, depth + 1))
  2550. return 0;
  2551. } else if (o != Py_None) {
  2552. if (context->size + 1 > context->maxsize &&
  2553. !_bump(context, 1))
  2554. return 0;
  2555. Py_INCREF(o);
  2556. PyTuple_SET_ITEM(context->tuple,
  2557. context->size++, o);
  2558. }
  2559. }
  2560. } else {
  2561. PyErr_SetString(PyExc_TypeError, "argument must be sequence");
  2562. return 0;
  2563. }
  2564. return 1;
  2565. }
  2566. static PyObject *
  2567. Tkinter_Flatten(PyObject* self, PyObject* args)
  2568. {
  2569. FlattenContext context;
  2570. PyObject* item;
  2571. if (!PyArg_ParseTuple(args, "O:_flatten", &item))
  2572. return NULL;
  2573. context.maxsize = PySequence_Size(item);
  2574. if (context.maxsize < 0)
  2575. return NULL;
  2576. if (context.maxsize == 0)
  2577. return PyTuple_New(0);
  2578. context.tuple = PyTuple_New(context.maxsize);
  2579. if (!context.tuple)
  2580. return NULL;
  2581. context.size = 0;
  2582. if (!_flatten1(&context, item,0))
  2583. return NULL;
  2584. if (_PyTuple_Resize(&context.tuple, context.size))
  2585. return NULL;
  2586. return context.tuple;
  2587. }
  2588. static PyObject *
  2589. Tkinter_Create(PyObject *self, PyObject *args)
  2590. {
  2591. char *screenName = NULL;
  2592. char *baseName = NULL; /* XXX this is not used anymore;
  2593. try getting rid of it. */
  2594. char *className = NULL;
  2595. int interactive = 0;
  2596. int wantobjects = 0;
  2597. int wantTk = 1; /* If false, then Tk_Init() doesn't get called */
  2598. int sync = 0; /* pass -sync to wish */
  2599. char *use = NULL; /* pass -use to wish */
  2600. className = "Tk";
  2601. if (!PyArg_ParseTuple(args, "|zssiiiiz:create",
  2602. &screenName, &baseName, &className,
  2603. &interactive, &wantobjects, &wantTk,
  2604. &sync, &use))
  2605. return NULL;
  2606. CHECK_STRING_LENGTH(screenName);
  2607. CHECK_STRING_LENGTH(baseName);
  2608. CHECK_STRING_LENGTH(className);
  2609. CHECK_STRING_LENGTH(use);
  2610. return (PyObject *) Tkapp_New(screenName, className,
  2611. interactive, wantobjects, wantTk,
  2612. sync, use);
  2613. }
  2614. static PyObject *
  2615. Tkinter_setbusywaitinterval(PyObject *self, PyObject *args)
  2616. {
  2617. int new_val;
  2618. if (!PyArg_ParseTuple(args, "i:setbusywaitinterval", &new_val))
  2619. return NULL;
  2620. if (new_val < 0) {
  2621. PyErr_SetString(PyExc_ValueError,
  2622. "busywaitinterval must be >= 0");
  2623. return NULL;
  2624. }
  2625. Tkinter_busywaitinterval = new_val;
  2626. Py_RETURN_NONE;
  2627. }
  2628. static char setbusywaitinterval_doc[] =
  2629. "setbusywaitinterval(n) -> None\n\
  2630. \n\
  2631. Set the busy-wait interval in milliseconds between successive\n\
  2632. calls to Tcl_DoOneEvent in a threaded Python interpreter.\n\
  2633. It should be set to a divisor of the maximum time between\n\
  2634. frames in an animation.";
  2635. static PyObject *
  2636. Tkinter_getbusywaitinterval(PyObject *self, PyObject *args)
  2637. {
  2638. return PyLong_FromLong(Tkinter_busywaitinterval);
  2639. }
  2640. static char getbusywaitinterval_doc[] =
  2641. "getbusywaitinterval() -> int\n\
  2642. \n\
  2643. Return the current busy-wait interval between successive\n\
  2644. calls to Tcl_DoOneEvent in a threaded Python interpreter.";
  2645. static PyMethodDef moduleMethods[] =
  2646. {
  2647. {"_flatten", Tkinter_Flatten, METH_VARARGS},
  2648. {"create", Tkinter_Create, METH_VARARGS},
  2649. {"setbusywaitinterval",Tkinter_setbusywaitinterval, METH_VARARGS,
  2650. setbusywaitinterval_doc},
  2651. {"getbusywaitinterval",(PyCFunction)Tkinter_getbusywaitinterval,
  2652. METH_NOARGS, getbusywaitinterval_doc},
  2653. {NULL, NULL}
  2654. };
  2655. #ifdef WAIT_FOR_STDIN
  2656. static int stdin_ready = 0;
  2657. #ifndef MS_WINDOWS
  2658. static void
  2659. MyFileProc(void *clientData, int mask)
  2660. {
  2661. stdin_ready = 1;
  2662. }
  2663. #endif
  2664. #ifdef WITH_THREAD
  2665. static PyThreadState *event_tstate = NULL;
  2666. #endif
  2667. static int
  2668. EventHook(void)
  2669. {
  2670. #ifndef MS_WINDOWS
  2671. int tfile;
  2672. #endif
  2673. #ifdef WITH_THREAD
  2674. PyEval_RestoreThread(event_tstate);
  2675. #endif
  2676. stdin_ready = 0;
  2677. errorInCmd = 0;
  2678. #ifndef MS_WINDOWS
  2679. tfile = fileno(stdin);
  2680. Tcl_CreateFileHandler(tfile, TCL_READABLE, MyFileProc, NULL);
  2681. #endif
  2682. while (!errorInCmd && !stdin_ready) {
  2683. int result;
  2684. #ifdef MS_WINDOWS
  2685. if (_kbhit()) {
  2686. stdin_ready = 1;
  2687. break;
  2688. }
  2689. #endif
  2690. #if defined(WITH_THREAD) || defined(MS_WINDOWS)
  2691. Py_BEGIN_ALLOW_THREADS
  2692. if(tcl_lock)PyThread_acquire_lock(tcl_lock, 1);
  2693. tcl_tstate = event_tstate;
  2694. result = Tcl_DoOneEvent(TCL_DONT_WAIT);
  2695. tcl_tstate = NULL;
  2696. if(tcl_lock)PyThread_release_lock(tcl_lock);
  2697. if (result == 0)
  2698. Sleep(Tkinter_busywaitinterval);
  2699. Py_END_ALLOW_THREADS
  2700. #else
  2701. result = Tcl_DoOneEvent(0);
  2702. #endif
  2703. if (result < 0)
  2704. break;
  2705. }
  2706. #ifndef MS_WINDOWS
  2707. Tcl_DeleteFileHandler(tfile);
  2708. #endif
  2709. if (errorInCmd) {
  2710. errorInCmd = 0;
  2711. PyErr_Restore(excInCmd, valInCmd, trbInCmd);
  2712. excInCmd = valInCmd = trbInCmd = NULL;
  2713. PyErr_Print();
  2714. }
  2715. #ifdef WITH_THREAD
  2716. PyEval_SaveThread();
  2717. #endif
  2718. return 0;
  2719. }
  2720. #endif
  2721. static void
  2722. EnableEventHook(void)
  2723. {
  2724. #ifdef WAIT_FOR_STDIN
  2725. if (PyOS_InputHook == NULL) {
  2726. #ifdef WITH_THREAD
  2727. event_tstate = PyThreadState_Get();
  2728. #endif
  2729. PyOS_InputHook = EventHook;
  2730. }
  2731. #endif
  2732. }
  2733. static void
  2734. DisableEventHook(void)
  2735. {
  2736. #ifdef WAIT_FOR_STDIN
  2737. if (Tk_GetNumMainWindows() == 0 && PyOS_InputHook == EventHook) {
  2738. PyOS_InputHook = NULL;
  2739. }
  2740. #endif
  2741. }
  2742. static struct PyModuleDef _tkintermodule = {
  2743. PyModuleDef_HEAD_INIT,
  2744. "_tkinter",
  2745. NULL,
  2746. -1,
  2747. moduleMethods,
  2748. NULL,
  2749. NULL,
  2750. NULL,
  2751. NULL
  2752. };
  2753. PyMODINIT_FUNC
  2754. PyInit__tkinter(void)
  2755. {
  2756. PyObject *m, *uexe, *cexe, *o;
  2757. #ifdef WITH_THREAD
  2758. tcl_lock = PyThread_allocate_lock();
  2759. if (tcl_lock == NULL)
  2760. return NULL;
  2761. #endif
  2762. m = PyModule_Create(&_tkintermodule);
  2763. if (m == NULL)
  2764. return NULL;
  2765. o = PyErr_NewException("_tkinter.TclError", NULL, NULL);
  2766. if (o == NULL) {
  2767. Py_DECREF(m);
  2768. return NULL;
  2769. }
  2770. Py_INCREF(o);
  2771. if (PyModule_AddObject(m, "TclError", o)) {
  2772. Py_DECREF(o);
  2773. Py_DECREF(m);
  2774. return NULL;
  2775. }
  2776. Tkinter_TclError = o;
  2777. if (PyModule_AddIntConstant(m, "READABLE", TCL_READABLE)) {
  2778. Py_DECREF(m);
  2779. return NULL;
  2780. }
  2781. if (PyModule_AddIntConstant(m, "WRITABLE", TCL_WRITABLE)) {
  2782. Py_DECREF(m);
  2783. return NULL;
  2784. }
  2785. if (PyModule_AddIntConstant(m, "EXCEPTION", TCL_EXCEPTION)) {
  2786. Py_DECREF(m);
  2787. return NULL;
  2788. }
  2789. if (PyModule_AddIntConstant(m, "WINDOW_EVENTS", TCL_WINDOW_EVENTS)) {
  2790. Py_DECREF(m);
  2791. return NULL;
  2792. }
  2793. if (PyModule_AddIntConstant(m, "FILE_EVENTS", TCL_FILE_EVENTS)) {
  2794. Py_DECREF(m);
  2795. return NULL;
  2796. }
  2797. if (PyModule_AddIntConstant(m, "TIMER_EVENTS", TCL_TIMER_EVENTS)) {
  2798. Py_DECREF(m);
  2799. return NULL;
  2800. }
  2801. if (PyModule_AddIntConstant(m, "IDLE_EVENTS", TCL_IDLE_EVENTS)) {
  2802. Py_DECREF(m);
  2803. return NULL;
  2804. }
  2805. if (PyModule_AddIntConstant(m, "ALL_EVENTS", TCL_ALL_EVENTS)) {
  2806. Py_DECREF(m);
  2807. return NULL;
  2808. }
  2809. if (PyModule_AddIntConstant(m, "DONT_WAIT", TCL_DONT_WAIT)) {
  2810. Py_DECREF(m);
  2811. return NULL;
  2812. }
  2813. if (PyModule_AddStringConstant(m, "TK_VERSION", TK_VERSION)) {
  2814. Py_DECREF(m);
  2815. return NULL;
  2816. }
  2817. if (PyModule_AddStringConstant(m, "TCL_VERSION", TCL_VERSION)) {
  2818. Py_DECREF(m);
  2819. return NULL;
  2820. }
  2821. o = PyType_FromSpec(&Tkapp_Type_spec);
  2822. if (o == NULL) {
  2823. Py_DECREF(m);
  2824. return NULL;
  2825. }
  2826. if (PyModule_AddObject(m, "TkappType", o)) {
  2827. Py_DECREF(o);
  2828. Py_DECREF(m);
  2829. return NULL;
  2830. }
  2831. Tkapp_Type = o;
  2832. o = PyType_FromSpec(&Tktt_Type_spec);
  2833. if (o == NULL) {
  2834. Py_DECREF(m);
  2835. return NULL;
  2836. }
  2837. if (PyModule_AddObject(m, "TkttType", o)) {
  2838. Py_DECREF(o);
  2839. Py_DECREF(m);
  2840. return NULL;
  2841. }
  2842. Tktt_Type = o;
  2843. o = PyType_FromSpec(&PyTclObject_Type_spec);
  2844. if (o == NULL) {
  2845. Py_DECREF(m);
  2846. return NULL;
  2847. }
  2848. if (PyModule_AddObject(m, "Tcl_Obj", o)) {
  2849. Py_DECREF(o);
  2850. Py_DECREF(m);
  2851. return NULL;
  2852. }
  2853. PyTclObject_Type = o;
  2854. #ifdef TK_AQUA
  2855. /* Tk_MacOSXSetupTkNotifier must be called before Tcl's subsystems
  2856. * start waking up. Note that Tcl_FindExecutable will do this, this
  2857. * code must be above it! The original warning from
  2858. * tkMacOSXAppInit.c is copied below.
  2859. *
  2860. * NB - You have to swap in the Tk Notifier BEFORE you start up the
  2861. * Tcl interpreter for now. It probably should work to do this
  2862. * in the other order, but for now it doesn't seem to.
  2863. *
  2864. */
  2865. Tk_MacOSXSetupTkNotifier();
  2866. #endif
  2867. /* This helps the dynamic loader; in Unicode aware Tcl versions
  2868. it also helps Tcl find its encodings. */
  2869. uexe = PyUnicode_FromWideChar(Py_GetProgramName(), -1);
  2870. if (uexe) {
  2871. cexe = PyUnicode_EncodeFSDefault(uexe);
  2872. if (cexe)
  2873. Tcl_FindExecutable(PyBytes_AsString(cexe));
  2874. Py_XDECREF(cexe);
  2875. Py_DECREF(uexe);
  2876. }
  2877. if (PyErr_Occurred()) {
  2878. Py_DECREF(m);
  2879. return NULL;
  2880. }
  2881. #if 0
  2882. /* This was not a good idea; through <Destroy> bindings,
  2883. Tcl_Finalize() may invoke Python code but at that point the
  2884. interpreter and thread state have already been destroyed! */
  2885. Py_AtExit(Tcl_Finalize);
  2886. #endif
  2887. return m;
  2888. }