summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorThomas Wouters <thomas@python.org>2006-06-08 15:35:45 (GMT)
committerThomas Wouters <thomas@python.org>2006-06-08 15:35:45 (GMT)
commit73e5a5b65d66f4fba9c4f626bcd6400f4a7215e6 (patch)
tree206b2ca44cf23af41ac27cb7b3744f2e60a3341d /Modules
parent1ba5b3b425e970ec3e4a19165475aa68fa5ac893 (diff)
downloadcpython-73e5a5b65d66f4fba9c4f626bcd6400f4a7215e6.zip
cpython-73e5a5b65d66f4fba9c4f626bcd6400f4a7215e6.tar.gz
cpython-73e5a5b65d66f4fba9c4f626bcd6400f4a7215e6.tar.bz2
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. ........
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_bsddb.c594
-rw-r--r--Modules/_codecsmodule.c10
-rw-r--r--Modules/_ctypes/callbacks.c43
-rw-r--r--Modules/_ctypes/callproc.c9
-rw-r--r--Modules/_ctypes/cfield.c37
-rw-r--r--Modules/_elementtree.c4
-rw-r--r--Modules/_struct.c29
-rw-r--r--Modules/_tkinter.c30
-rw-r--r--Modules/cjkcodecs/_codecs_jp.c3
-rw-r--r--Modules/socketmodule.c74
10 files changed, 699 insertions, 134 deletions
diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c
index e18e072..a640d52 100644
--- a/Modules/_bsddb.c
+++ b/Modules/_bsddb.c
@@ -61,13 +61,14 @@
*
* http://www.python.org/peps/pep-0291.html
*
- * This module contains 5 types:
+ * This module contains 6 types:
*
* DB (Database)
* DBCursor (Database Cursor)
* DBEnv (database environment)
* DBTxn (An explicit database transaction)
* DBLock (A lock handle)
+ * DBSequence (Sequence)
*
*/
@@ -97,7 +98,7 @@
#error "eek! DBVER can't handle minor versions > 9"
#endif
-#define PY_BSDDB_VERSION "4.4.2"
+#define PY_BSDDB_VERSION "4.4.4"
static char *rcs_id = "$Id$";
@@ -285,7 +286,17 @@ typedef struct {
#endif
} DBLockObject;
-
+#if (DBVER >= 43)
+typedef struct {
+ PyObject_HEAD
+ DB_SEQUENCE* sequence;
+ DBObject* mydb;
+#ifdef HAVE_WEAKREF
+ PyObject *in_weakreflist; /* List of weak references */
+#endif
+} DBSequenceObject;
+static PyTypeObject DBSequence_Type;
+#endif
static PyTypeObject DB_Type, DBCursor_Type, DBEnv_Type, DBTxn_Type, DBLock_Type;
@@ -294,6 +305,9 @@ static PyTypeObject DB_Type, DBCursor_Type, DBEnv_Type, DBTxn_Type, DBLock_Type;
#define DBEnvObject_Check(v) ((v)->ob_type == &DBEnv_Type)
#define DBTxnObject_Check(v) ((v)->ob_type == &DBTxn_Type)
#define DBLockObject_Check(v) ((v)->ob_type == &DBLock_Type)
+#if (DBVER >= 43)
+#define DBSequenceObject_Check(v) ((v)->ob_type == &DBSequence_Type)
+#endif
/* --------------------------------------------------------------------- */
@@ -324,6 +338,10 @@ static PyTypeObject DB_Type, DBCursor_Type, DBEnv_Type, DBTxn_Type, DBLock_Type;
#define CHECK_CURSOR_NOT_CLOSED(curs) \
_CHECK_OBJECT_NOT_CLOSED(curs->dbc, DBCursorClosedError, DBCursor)
+#if (DBVER >= 43)
+#define CHECK_SEQUENCE_NOT_CLOSED(curs) \
+ _CHECK_OBJECT_NOT_CLOSED(curs->sequence, DBError, DBSequence)
+#endif
#define CHECK_DBFLAG(mydb, flag) (((mydb)->flags & (flag)) || \
(((mydb)->myenvobj != NULL) && ((mydb)->myenvobj->flags & (flag))))
@@ -724,7 +742,17 @@ static void _addIntToDict(PyObject* dict, char *name, int value)
Py_XDECREF(v);
}
+#if (DBVER >= 43)
+/* add an db_seq_t to a dictionary using the given name as a key */
+static void _addDb_seq_tToDict(PyObject* dict, char *name, db_seq_t value)
+{
+ PyObject* v = PyLong_FromLongLong(value);
+ if (!v || PyDict_SetItemString(dict, name, v))
+ PyErr_Clear();
+ Py_XDECREF(v);
+}
+#endif
@@ -777,7 +805,7 @@ newDBObject(DBEnvObject* arg, int flags)
MYDB_END_ALLOW_THREADS;
/* TODO add a weakref(self) to the self->myenvobj->open_child_weakrefs
* list so that a DBEnv can refuse to close without aborting any open
- * open DBTxns and closing any open DBs first. */
+ * DBTxns and closing any open DBs first. */
if (makeDBError(err)) {
if (self->myenvobj) {
Py_DECREF(self->myenvobj);
@@ -1029,6 +1057,48 @@ DBLock_dealloc(DBLockObject* self)
}
+#if (DBVER >= 43)
+static DBSequenceObject*
+newDBSequenceObject(DBObject* mydb, int flags)
+{
+ int err;
+ DBSequenceObject* self = PyObject_New(DBSequenceObject, &DBSequence_Type);
+ if (self == NULL)
+ return NULL;
+ Py_INCREF(mydb);
+ self->mydb = mydb;
+#ifdef HAVE_WEAKREF
+ self->in_weakreflist = NULL;
+#endif
+
+
+ MYDB_BEGIN_ALLOW_THREADS;
+ err = db_sequence_create(&self->sequence, self->mydb->db, flags);
+ MYDB_END_ALLOW_THREADS;
+ if (makeDBError(err)) {
+ Py_DECREF(self->mydb);
+ PyObject_Del(self);
+ self = NULL;
+ }
+
+ return self;
+}
+
+
+static void
+DBSequence_dealloc(DBSequenceObject* self)
+{
+#ifdef HAVE_WEAKREF
+ if (self->in_weakreflist != NULL) {
+ PyObject_ClearWeakRefs((PyObject *) self);
+ }
+#endif
+
+ Py_DECREF(self->mydb);
+ PyObject_Del(self);
+}
+#endif
+
/* --------------------------------------------------------------------- */
/* DB methods */
@@ -2614,7 +2684,7 @@ DB_set_encrypt(DBObject* self, PyObject* args, PyObject* kwargs)
Py_ssize_t DB_length(DBObject* self)
{
int err;
- long size = 0;
+ Py_ssize_t size = 0;
int flags = 0;
void* sp;
@@ -2627,10 +2697,11 @@ Py_ssize_t DB_length(DBObject* self)
if (self->haveStat) { /* Has the stat function been called recently? If
so, we can use the cached value. */
- flags = DB_CACHED_COUNTS;
+ flags = DB_FAST_STAT;
}
MYDB_BEGIN_ALLOW_THREADS;
+redo_stat_for_length:
#if (DBVER >= 43)
err = self->db->stat(self->db, /*txnid*/ NULL, &sp, flags);
#elif (DBVER >= 33)
@@ -2638,6 +2709,20 @@ Py_ssize_t DB_length(DBObject* self)
#else
err = self->db->stat(self->db, &sp, NULL, flags);
#endif
+
+ /* All the stat structures have matching fields upto the ndata field,
+ so we can use any of them for the type cast */
+ size = ((DB_BTREE_STAT*)sp)->bt_ndata;
+
+ /* A size of 0 could mean that BerkeleyDB no longer had the stat values cached.
+ * redo a full stat to make sure.
+ * Fixes SF python bug 1493322, pybsddb bug 1184012
+ */
+ if (size == 0 && (flags & DB_FAST_STAT)) {
+ flags = 0;
+ goto redo_stat_for_length;
+ }
+
MYDB_END_ALLOW_THREADS;
if (err)
@@ -2645,9 +2730,6 @@ Py_ssize_t DB_length(DBObject* self)
self->haveStat = 1;
- /* All the stat structures have matching fields upto the ndata field,
- so we can use any of them for the type cast */
- size = ((DB_BTREE_STAT*)sp)->bt_ndata;
free(sp);
return size;
}
@@ -3124,8 +3206,8 @@ DBC_pget(DBCursorObject* self, PyObject* args, PyObject *kwargs)
int dlen = -1;
int doff = -1;
DBT key, pkey, data;
- static char* kwnames[] = { "key","data", "flags", "dlen", "doff",
- NULL };
+ static char* kwnames_keyOnly[] = { "key", "flags", "dlen", "doff", NULL };
+ static char* kwnames[] = { "key", "data", "flags", "dlen", "doff", NULL };
CLEAR_DBT(key);
CLEAR_DBT(data);
@@ -3134,7 +3216,7 @@ DBC_pget(DBCursorObject* self, PyObject* args, PyObject *kwargs)
{
PyErr_Clear();
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Oi|ii:pget",
- &kwnames[1],
+ kwnames_keyOnly,
&keyobj, &flags, &dlen, &doff))
{
PyErr_Clear();
@@ -4294,6 +4376,93 @@ DBEnv_lock_put(DBEnvObject* self, PyObject* args)
RETURN_NONE();
}
+#if (DBVER >= 44)
+static PyObject*
+DBEnv_lsn_reset(DBEnvObject* self, PyObject* args, PyObject* kwargs)
+{
+ int err;
+ char *file;
+ u_int32_t flags = 0;
+ static char* kwnames[] = { "file", "flags", NULL};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "z|i:lsn_reset", kwnames,
+ &file, &flags))
+ return NULL;
+ CHECK_ENV_NOT_CLOSED(self);
+
+ MYDB_BEGIN_ALLOW_THREADS;
+ err = self->db_env->lsn_reset(self->db_env, file, flags);
+ MYDB_END_ALLOW_THREADS;
+ RETURN_IF_ERR();
+ RETURN_NONE();
+}
+#endif /* DBVER >= 4.4 */
+
+#if (DBVER >= 40)
+static PyObject*
+DBEnv_log_stat(DBEnvObject* self, PyObject* args)
+{
+ int err;
+ DB_LOG_STAT* statp = NULL;
+ PyObject* d = NULL;
+ u_int32_t flags = 0;
+
+ if (!PyArg_ParseTuple(args, "|i:log_stat", &flags))
+ return NULL;
+ CHECK_ENV_NOT_CLOSED(self);
+
+ MYDB_BEGIN_ALLOW_THREADS;
+ err = self->db_env->log_stat(self->db_env, &statp, flags);
+ MYDB_END_ALLOW_THREADS;
+ RETURN_IF_ERR();
+
+ /* Turn the stat structure into a dictionary */
+ d = PyDict_New();
+ if (d == NULL) {
+ if (statp)
+ free(statp);
+ return NULL;
+ }
+
+#define MAKE_ENTRY(name) _addIntToDict(d, #name, statp->st_##name)
+
+ MAKE_ENTRY(magic);
+ MAKE_ENTRY(version);
+ MAKE_ENTRY(mode);
+ MAKE_ENTRY(lg_bsize);
+#if (DBVER >= 44)
+ MAKE_ENTRY(lg_size);
+ MAKE_ENTRY(record);
+#endif
+#if (DBVER <= 40)
+ MAKE_ENTRY(lg_max);
+#endif
+ MAKE_ENTRY(w_mbytes);
+ MAKE_ENTRY(w_bytes);
+ MAKE_ENTRY(wc_mbytes);
+ MAKE_ENTRY(wc_bytes);
+ MAKE_ENTRY(wcount);
+ MAKE_ENTRY(wcount_fill);
+#if (DBVER >= 44)
+ MAKE_ENTRY(rcount);
+#endif
+ MAKE_ENTRY(scount);
+ MAKE_ENTRY(cur_file);
+ MAKE_ENTRY(cur_offset);
+ MAKE_ENTRY(disk_file);
+ MAKE_ENTRY(disk_offset);
+ MAKE_ENTRY(maxcommitperflush);
+ MAKE_ENTRY(mincommitperflush);
+ MAKE_ENTRY(regsize);
+ MAKE_ENTRY(region_wait);
+ MAKE_ENTRY(region_nowait);
+
+#undef MAKE_ENTRY
+ free(statp);
+ return d;
+} /* DBEnv_log_stat */
+#endif /* DBVER >= 4.0 for log_stat method */
+
static PyObject*
DBEnv_lock_stat(DBEnvObject* self, PyObject* args)
@@ -4371,7 +4540,7 @@ DBEnv_log_archive(DBEnvObject* self, PyObject* args)
{
int flags=0;
int err;
- char **log_list_start, **log_list;
+ char **log_list = NULL;
PyObject* list;
PyObject* item = NULL;
@@ -4391,10 +4560,14 @@ DBEnv_log_archive(DBEnvObject* self, PyObject* args)
RETURN_IF_ERR();
list = PyList_New(0);
- if (list == NULL)
+ if (list == NULL) {
+ if (log_list)
+ free(log_list);
return NULL;
+ }
if (log_list) {
+ char **log_list_start;
for (log_list_start = log_list; *log_list != NULL; ++log_list) {
item = PyString_FromString (*log_list);
if (item == NULL) {
@@ -4624,6 +4797,294 @@ DBTxn_id(DBTxnObject* self, PyObject* args)
return PyInt_FromLong(id);
}
+#if (DBVER >= 43)
+/* --------------------------------------------------------------------- */
+/* DBSequence methods */
+
+
+static PyObject*
+DBSequence_close(DBSequenceObject* self, PyObject* args)
+{
+ int err, flags=0;
+ if (!PyArg_ParseTuple(args,"|i:close", &flags))
+ return NULL;
+ CHECK_SEQUENCE_NOT_CLOSED(self)
+
+ MYDB_BEGIN_ALLOW_THREADS
+ err = self->sequence->close(self->sequence, flags);
+ self->sequence = NULL;
+ MYDB_END_ALLOW_THREADS
+
+ RETURN_IF_ERR();
+
+ RETURN_NONE();
+}
+
+static PyObject*
+DBSequence_get(DBSequenceObject* self, PyObject* args, PyObject* kwargs)
+{
+ int err, flags = 0;
+ int delta = 1;
+ db_seq_t value;
+ PyObject *txnobj = NULL;
+ DB_TXN *txn = NULL;
+ static char* kwnames[] = {"delta", "txn", "flags", NULL };
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|iOi:get", kwnames, &delta, &txnobj, &flags))
+ return NULL;
+ CHECK_SEQUENCE_NOT_CLOSED(self)
+
+ if (!checkTxnObj(txnobj, &txn))
+ return NULL;
+
+ MYDB_BEGIN_ALLOW_THREADS
+ err = self->sequence->get(self->sequence, txn, delta, &value, flags);
+ MYDB_END_ALLOW_THREADS
+
+ RETURN_IF_ERR();
+ return PyLong_FromLongLong(value);
+
+}
+
+static PyObject*
+DBSequence_get_dbp(DBSequenceObject* self, PyObject* args)
+{
+ if (!PyArg_ParseTuple(args,":get_dbp"))
+ return NULL;
+ CHECK_SEQUENCE_NOT_CLOSED(self)
+ Py_INCREF(self->mydb);
+ return (PyObject* )self->mydb;
+}
+
+static PyObject*
+DBSequence_get_key(DBSequenceObject* self, PyObject* args)
+{
+ int err;
+ DBT key;
+ CHECK_SEQUENCE_NOT_CLOSED(self)
+ MYDB_BEGIN_ALLOW_THREADS
+ err = self->sequence->get_key(self->sequence, &key);
+ MYDB_END_ALLOW_THREADS
+
+ RETURN_IF_ERR();
+
+ return PyString_FromStringAndSize(key.data, key.size);
+}
+
+static PyObject*
+DBSequence_init_value(DBSequenceObject* self, PyObject* args)
+{
+ int err;
+ db_seq_t value;
+ if (!PyArg_ParseTuple(args,"L:init_value", &value))
+ return NULL;
+ CHECK_SEQUENCE_NOT_CLOSED(self)
+
+ MYDB_BEGIN_ALLOW_THREADS
+ err = self->sequence->initial_value(self->sequence, value);
+ MYDB_END_ALLOW_THREADS
+
+ RETURN_IF_ERR();
+
+ RETURN_NONE();
+}
+
+static PyObject*
+DBSequence_open(DBSequenceObject* self, PyObject* args, PyObject* kwargs)
+{
+ int err, flags = 0;
+ PyObject* keyobj;
+ PyObject *txnobj = NULL;
+ DB_TXN *txn = NULL;
+ DBT key;
+
+ static char* kwnames[] = {"key", "txn", "flags", NULL };
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|Oi:open", kwnames, &keyobj, &txnobj, &flags))
+ return NULL;
+
+ if (!checkTxnObj(txnobj, &txn))
+ return NULL;
+
+ if (!make_key_dbt(self->mydb, keyobj, &key, NULL))
+ return NULL;
+
+ MYDB_BEGIN_ALLOW_THREADS
+ err = self->sequence->open(self->sequence, txn, &key, flags);
+ MYDB_END_ALLOW_THREADS
+
+ CLEAR_DBT(key);
+ RETURN_IF_ERR();
+
+ RETURN_NONE();
+}
+
+static PyObject*
+DBSequence_remove(DBSequenceObject* self, PyObject* args, PyObject* kwargs)
+{
+ int err, flags = 0;
+ PyObject *txnobj = NULL;
+ DB_TXN *txn = NULL;
+
+ static char* kwnames[] = {"txn", "flags", NULL };
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Oi:remove", kwnames, &txnobj, &flags))
+ return NULL;
+
+ if (!checkTxnObj(txnobj, &txn))
+ return NULL;
+
+ CHECK_SEQUENCE_NOT_CLOSED(self)
+
+ MYDB_BEGIN_ALLOW_THREADS
+ err = self->sequence->remove(self->sequence, txn, flags);
+ MYDB_END_ALLOW_THREADS
+
+ RETURN_IF_ERR();
+ RETURN_NONE();
+}
+
+static PyObject*
+DBSequence_set_cachesize(DBSequenceObject* self, PyObject* args)
+{
+ int err, size;
+ if (!PyArg_ParseTuple(args,"i:set_cachesize", &size))
+ return NULL;
+ CHECK_SEQUENCE_NOT_CLOSED(self)
+
+ MYDB_BEGIN_ALLOW_THREADS
+ err = self->sequence->set_cachesize(self->sequence, size);
+ MYDB_END_ALLOW_THREADS
+
+ RETURN_IF_ERR();
+ RETURN_NONE();
+}
+
+static PyObject*
+DBSequence_get_cachesize(DBSequenceObject* self, PyObject* args)
+{
+ int err, size;
+ if (!PyArg_ParseTuple(args,":get_cachesize"))
+ return NULL;
+ CHECK_SEQUENCE_NOT_CLOSED(self)
+
+ MYDB_BEGIN_ALLOW_THREADS
+ err = self->sequence->get_cachesize(self->sequence, &size);
+ MYDB_END_ALLOW_THREADS
+
+ RETURN_IF_ERR();
+ return PyInt_FromLong(size);
+}
+
+static PyObject*
+DBSequence_set_flags(DBSequenceObject* self, PyObject* args)
+{
+ int err, flags = 0;
+ if (!PyArg_ParseTuple(args,"i:set_flags", &flags))
+ return NULL;
+ CHECK_SEQUENCE_NOT_CLOSED(self)
+
+ MYDB_BEGIN_ALLOW_THREADS
+ err = self->sequence->set_flags(self->sequence, flags);
+ MYDB_END_ALLOW_THREADS
+
+ RETURN_IF_ERR();
+ RETURN_NONE();
+
+}
+
+static PyObject*
+DBSequence_get_flags(DBSequenceObject* self, PyObject* args)
+{
+ unsigned int flags;
+ int err;
+ if (!PyArg_ParseTuple(args,":get_flags"))
+ return NULL;
+ CHECK_SEQUENCE_NOT_CLOSED(self)
+
+ MYDB_BEGIN_ALLOW_THREADS
+ err = self->sequence->get_flags(self->sequence, &flags);
+ MYDB_END_ALLOW_THREADS
+
+ RETURN_IF_ERR();
+ return PyInt_FromLong((int)flags);
+}
+
+static PyObject*
+DBSequence_set_range(DBSequenceObject* self, PyObject* args)
+{
+ int err;
+ db_seq_t min, max;
+ if (!PyArg_ParseTuple(args,"(LL):set_range", &min, &max))
+ return NULL;
+ CHECK_SEQUENCE_NOT_CLOSED(self)
+
+ MYDB_BEGIN_ALLOW_THREADS
+ err = self->sequence->set_range(self->sequence, min, max);
+ MYDB_END_ALLOW_THREADS
+
+ RETURN_IF_ERR();
+ RETURN_NONE();
+}
+
+static PyObject*
+DBSequence_get_range(DBSequenceObject* self, PyObject* args)
+{
+ int err;
+ db_seq_t min, max;
+ if (!PyArg_ParseTuple(args,":get_range"))
+ return NULL;
+ CHECK_SEQUENCE_NOT_CLOSED(self)
+
+ MYDB_BEGIN_ALLOW_THREADS
+ err = self->sequence->get_range(self->sequence, &min, &max);
+ MYDB_END_ALLOW_THREADS
+
+ RETURN_IF_ERR();
+ return Py_BuildValue("(LL)", min, max);
+}
+
+static PyObject*
+DBSequence_stat(DBSequenceObject* self, PyObject* args, PyObject* kwargs)
+{
+ int err, flags = 0;
+ DB_SEQUENCE_STAT* sp = NULL;
+ PyObject* dict_stat;
+ static char* kwnames[] = {"flags", NULL };
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:stat", kwnames, &flags))
+ return NULL;
+ CHECK_SEQUENCE_NOT_CLOSED(self);
+
+ MYDB_BEGIN_ALLOW_THREADS;
+ err = self->sequence->stat(self->sequence, &sp, flags);
+ MYDB_END_ALLOW_THREADS;
+ RETURN_IF_ERR();
+
+ if ((dict_stat = PyDict_New()) == NULL) {
+ free(sp);
+ return NULL;
+ }
+
+
+#define MAKE_INT_ENTRY(name) _addIntToDict(dict_stat, #name, sp->st_##name)
+#define MAKE_LONG_LONG_ENTRY(name) _addDb_seq_tToDict(dict_stat, #name, sp->st_##name)
+
+ MAKE_INT_ENTRY(wait);
+ MAKE_INT_ENTRY(nowait);
+ MAKE_LONG_LONG_ENTRY(current);
+ MAKE_LONG_LONG_ENTRY(value);
+ MAKE_LONG_LONG_ENTRY(last_value);
+ MAKE_LONG_LONG_ENTRY(min);
+ MAKE_LONG_LONG_ENTRY(max);
+ MAKE_INT_ENTRY(cache_size);
+ MAKE_INT_ENTRY(flags);
+
+#undef MAKE_INT_ENTRY
+#undef MAKE_LONG_LONG_ENTRY
+
+ free(sp);
+ return dict_stat;
+}
+#endif
+
+
/* --------------------------------------------------------------------- */
/* Method definition tables and type objects */
@@ -4777,6 +5238,12 @@ static PyMethodDef DBEnv_methods[] = {
{"lock_put", (PyCFunction)DBEnv_lock_put, METH_VARARGS},
{"lock_stat", (PyCFunction)DBEnv_lock_stat, METH_VARARGS},
{"log_archive", (PyCFunction)DBEnv_log_archive, METH_VARARGS},
+#if (DBVER >= 40)
+ {"log_stat", (PyCFunction)DBEnv_log_stat, METH_VARARGS},
+#endif
+#if (DBVER >= 44)
+ {"lsn_reset", (PyCFunction)DBEnv_lsn_reset, METH_VARARGS|METH_KEYWORDS},
+#endif
{"set_get_returns_none",(PyCFunction)DBEnv_set_get_returns_none, METH_VARARGS},
{NULL, NULL} /* sentinel */
};
@@ -4791,6 +5258,27 @@ static PyMethodDef DBTxn_methods[] = {
};
+#if (DBVER >= 43)
+static PyMethodDef DBSequence_methods[] = {
+ {"close", (PyCFunction)DBSequence_close, METH_VARARGS},
+ {"get", (PyCFunction)DBSequence_get, METH_VARARGS|METH_KEYWORDS},
+ {"get_dbp", (PyCFunction)DBSequence_get_dbp, METH_VARARGS},
+ {"get_key", (PyCFunction)DBSequence_get_key, METH_VARARGS},
+ {"init_value", (PyCFunction)DBSequence_init_value, METH_VARARGS},
+ {"open", (PyCFunction)DBSequence_open, METH_VARARGS|METH_KEYWORDS},
+ {"remove", (PyCFunction)DBSequence_remove, METH_VARARGS|METH_KEYWORDS},
+ {"set_cachesize", (PyCFunction)DBSequence_set_cachesize, METH_VARARGS},
+ {"get_cachesize", (PyCFunction)DBSequence_get_cachesize, METH_VARARGS},
+ {"set_flags", (PyCFunction)DBSequence_set_flags, METH_VARARGS},
+ {"get_flags", (PyCFunction)DBSequence_get_flags, METH_VARARGS},
+ {"set_range", (PyCFunction)DBSequence_set_range, METH_VARARGS},
+ {"get_range", (PyCFunction)DBSequence_get_range, METH_VARARGS},
+ {"stat", (PyCFunction)DBSequence_stat, METH_VARARGS|METH_KEYWORDS},
+ {NULL, NULL} /* sentinel */
+};
+#endif
+
+
static PyObject*
DB_getattr(DBObject* self, char *name)
{
@@ -4831,6 +5319,14 @@ DBLock_getattr(DBLockObject* self, char *name)
return NULL;
}
+#if (DBVER >= 43)
+static PyObject*
+DBSequence_getattr(DBSequenceObject* self, char *name)
+{
+ return Py_FindMethod(DBSequence_methods, (PyObject* )self, name);
+}
+#endif
+
static PyTypeObject DB_Type = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
@@ -4994,6 +5490,39 @@ static PyTypeObject DBLock_Type = {
#endif
};
+#if (DBVER >= 43)
+static PyTypeObject DBSequence_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "DBSequence", /*tp_name*/
+ sizeof(DBSequenceObject), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ /* methods */
+ (destructor)DBSequence_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ (getattrfunc)DBSequence_getattr,/*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash*/
+#ifdef HAVE_WEAKREF
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_WEAKREFS, /* tp_flags */
+ 0, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ offsetof(DBSequenceObject, in_weakreflist), /* tp_weaklistoffset */
+#endif
+};
+#endif
/* --------------------------------------------------------------------- */
/* Module-level functions */
@@ -5027,6 +5556,25 @@ DBEnv_construct(PyObject* self, PyObject* args)
return (PyObject* )newDBEnvObject(flags);
}
+#if (DBVER >= 43)
+static PyObject*
+DBSequence_construct(PyObject* self, PyObject* args, PyObject* kwargs)
+{
+ PyObject* dbobj = NULL;
+ int flags = 0;
+ static char* kwnames[] = { "db", "flags", NULL};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|i:DBSequence", kwnames, &dbobj, &flags))
+ return NULL;
+ if (dbobj == Py_None)
+ dbobj = NULL;
+ else if (dbobj && !DBObject_Check(dbobj)) {
+ makeTypeError("DB", dbobj);
+ return NULL;
+ }
+ return (PyObject* )newDBSequenceObject((DBObject*)dbobj, flags);
+}
+#endif
static char bsddb_version_doc[] =
"Returns a tuple of major, minor, and patch release numbers of the\n\
@@ -5047,9 +5595,12 @@ bsddb_version(PyObject* self, PyObject* args)
/* List of functions defined in the module */
static PyMethodDef bsddb_methods[] = {
- {"DB", (PyCFunction)DB_construct, METH_VARARGS | METH_KEYWORDS },
- {"DBEnv", (PyCFunction)DBEnv_construct, METH_VARARGS},
- {"version", (PyCFunction)bsddb_version, METH_VARARGS, bsddb_version_doc},
+ {"DB", (PyCFunction)DB_construct, METH_VARARGS | METH_KEYWORDS },
+ {"DBEnv", (PyCFunction)DBEnv_construct, METH_VARARGS},
+#if (DBVER >= 43)
+ {"DBSequence", (PyCFunction)DBSequence_construct, METH_VARARGS | METH_KEYWORDS },
+#endif
+ {"version", (PyCFunction)bsddb_version, METH_VARARGS, bsddb_version_doc},
{NULL, NULL} /* sentinel */
};
@@ -5081,6 +5632,9 @@ DL_EXPORT(void) init_bsddb(void)
DBEnv_Type.ob_type = &PyType_Type;
DBTxn_Type.ob_type = &PyType_Type;
DBLock_Type.ob_type = &PyType_Type;
+#if (DBVER >= 43)
+ DBSequence_Type.ob_type = &PyType_Type;
+#endif
#if defined(WITH_THREAD) && !defined(MYDB_USE_GILSTATE)
@@ -5247,6 +5801,9 @@ DL_EXPORT(void) init_bsddb(void)
ADD_INT(d, DB_ARCH_ABS);
ADD_INT(d, DB_ARCH_DATA);
ADD_INT(d, DB_ARCH_LOG);
+#if (DBVER >= 42)
+ ADD_INT(d, DB_ARCH_REMOVE);
+#endif
ADD_INT(d, DB_BTREE);
ADD_INT(d, DB_HASH);
@@ -5368,6 +5925,9 @@ DL_EXPORT(void) init_bsddb(void)
#if (DBVER >= 43)
ADD_INT(d, DB_LOG_INMEMORY);
ADD_INT(d, DB_BUFFER_SMALL);
+ ADD_INT(d, DB_SEQ_DEC);
+ ADD_INT(d, DB_SEQ_INC);
+ ADD_INT(d, DB_SEQ_WRAP);
#endif
#if (DBVER >= 41)
diff --git a/Modules/_codecsmodule.c b/Modules/_codecsmodule.c
index 080fa74..32fa82f 100644
--- a/Modules/_codecsmodule.c
+++ b/Modules/_codecsmodule.c
@@ -792,6 +792,15 @@ charmap_encode(PyObject *self,
return v;
}
+static PyObject*
+charmap_build(PyObject *self, PyObject *args)
+{
+ PyObject *map;
+ if (!PyArg_ParseTuple(args, "U:charmap_build", &map))
+ return NULL;
+ return PyUnicode_BuildEncodingMap(map);
+}
+
#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
static PyObject *
@@ -897,6 +906,7 @@ static PyMethodDef _codecs_functions[] = {
{"ascii_decode", ascii_decode, METH_VARARGS},
{"charmap_encode", charmap_encode, METH_VARARGS},
{"charmap_decode", charmap_decode, METH_VARARGS},
+ {"charmap_build", charmap_build, METH_VARARGS},
{"readbuffer_encode", readbuffer_encode, METH_VARARGS},
{"charbuffer_encode", charbuffer_encode, METH_VARARGS},
#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c
index 8c29c55..4baf3aa 100644
--- a/Modules/_ctypes/callbacks.c
+++ b/Modules/_ctypes/callbacks.c
@@ -199,45 +199,16 @@ if (x == NULL) _AddTraceback(what, __FILE__, __LINE__ - 1), PyErr_Print()
result = PyObject_CallObject(callable, arglist);
CHECK("'calling callback function'", result);
- if ((restype != &ffi_type_void)
- && result && result != Py_None) { /* XXX What is returned for Py_None ? */
- /* another big endian hack */
- union {
- char c;
- short s;
- int i;
- long l;
- } r;
+ if ((restype != &ffi_type_void) && result && result != Py_None) {
PyObject *keep;
assert(setfunc);
- switch (restype->size) {
- case 1:
- keep = setfunc(&r, result, 0);
- CHECK("'converting callback result'", keep);
- *(ffi_arg *)mem = r.c;
- break;
- case SIZEOF_SHORT:
- keep = setfunc(&r, result, 0);
- CHECK("'converting callback result'", keep);
- *(ffi_arg *)mem = r.s;
- break;
- case SIZEOF_INT:
- keep = setfunc(&r, result, 0);
- CHECK("'converting callback result'", keep);
- *(ffi_arg *)mem = r.i;
- break;
-#if (SIZEOF_LONG != SIZEOF_INT)
- case SIZEOF_LONG:
- keep = setfunc(&r, result, 0);
- CHECK("'converting callback result'", keep);
- *(ffi_arg *)mem = r.l;
- break;
+#ifdef WORDS_BIGENDIAN
+ /* See the corresponding code in callproc.c, around line 961 */
+ if (restype->type != FFI_TYPE_FLOAT && restype->size < sizeof(ffi_arg))
+ mem = (char *)mem + sizeof(ffi_arg) - restype->size;
#endif
- default:
- keep = setfunc(mem, result, 0);
- CHECK("'converting callback result'", keep);
- break;
- }
+ keep = setfunc(mem, result, 0);
+ CHECK("'converting callback result'", keep);
/* keep is an object we have to keep alive so that the result
stays valid. If there is no such object, the setfunc will
have returned Py_None.
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c
index 8163f49..8108498 100644
--- a/Modules/_ctypes/callproc.c
+++ b/Modules/_ctypes/callproc.c
@@ -964,7 +964,14 @@ PyObject *_CallProc(PPROC pProc,
address cannot simply be used as result pointer, instead we must
adjust the pointer value:
*/
- if (rtype->size < sizeof(ffi_arg))
+ /*
+ XXX I should find out and clarify why this is needed at all,
+ especially why adjusting for ffi_type_float must be avoided on
+ 64-bit platforms.
+ */
+ if (rtype->type != FFI_TYPE_FLOAT
+ && rtype->type != FFI_TYPE_STRUCT
+ && rtype->size < sizeof(ffi_arg))
resbuf = (char *)resbuf + sizeof(ffi_arg) - rtype->size;
#endif
diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c
index 7bef412..ae0290f 100644
--- a/Modules/_ctypes/cfield.c
+++ b/Modules/_ctypes/cfield.c
@@ -1,5 +1,4 @@
#include "Python.h"
-#include "structmember.h"
#include <ffi.h>
#ifdef MS_WIN32
@@ -208,14 +207,30 @@ CField_get(CFieldObject *self, PyObject *inst, PyTypeObject *type)
self->index, self->size, src->b_ptr + self->offset);
}
-static PyMemberDef CField_members[] = {
- { "offset", T_UINT,
- offsetof(CFieldObject, offset), READONLY,
- "offset in bytes of this field"},
- { "size", T_UINT,
- offsetof(CFieldObject, size), READONLY,
- "size in bytes of this field"},
- { NULL },
+static PyObject *
+CField_get_offset(PyObject *self, void *data)
+{
+#if (PY_VERSION_HEX < 0x02050000)
+ return PyInt_FromLong(((CFieldObject *)self)->offset);
+#else
+ return PyInt_FromSsize_t(((CFieldObject *)self)->offset);
+#endif
+}
+
+static PyObject *
+CField_get_size(PyObject *self, void *data)
+{
+#if (PY_VERSION_HEX < 0x02050000)
+ return PyInt_FromLong(((CFieldObject *)self)->size);
+#else
+ return PyInt_FromSsize_t(((CFieldObject *)self)->size);
+#endif
+}
+
+static PyGetSetDef CField_getset[] = {
+ { "offset", CField_get_offset, NULL, "offset in bytes of this field" },
+ { "size", CField_get_size, NULL, "size in bytes of this field" },
+ { NULL, NULL, NULL, NULL },
};
static int
@@ -298,8 +313,8 @@ PyTypeObject CField_Type = {
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
- CField_members, /* tp_members */
- 0, /* tp_getset */
+ 0, /* tp_members */
+ CField_getset, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
(descrgetfunc)CField_get, /* tp_descr_get */
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index 871aa18..dda5042 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -1476,7 +1476,7 @@ treebuilder_new(void)
}
static PyObject*
-treebuilder(PyObject* _self, PyObject* args)
+treebuilder(PyObject* self_, PyObject* args)
{
if (!PyArg_ParseTuple(args, ":TreeBuilder"))
return NULL;
@@ -2201,7 +2201,7 @@ expat_unknown_encoding_handler(XMLParserObject *self, const XML_Char *name,
/* constructor and destructor */
static PyObject*
-xmlparser(PyObject* _self, PyObject* args, PyObject* kw)
+xmlparser(PyObject* self_, PyObject* args, PyObject* kw)
{
XMLParserObject* self;
/* FIXME: does this need to be static? */
diff --git a/Modules/_struct.c b/Modules/_struct.c
index fd550c9..3a44bde 100644
--- a/Modules/_struct.c
+++ b/Modules/_struct.c
@@ -1572,8 +1572,7 @@ s_pack(PyObject *self, PyObject *args)
soself = (PyStructObject *)self;
assert(PyStruct_Check(self));
assert(soself->s_codes != NULL);
- if (args == NULL || !PyTuple_Check(args) ||
- PyTuple_GET_SIZE(args) != soself->s_len)
+ if (PyTuple_GET_SIZE(args) != soself->s_len)
{
PyErr_Format(StructError,
"pack requires exactly %zd arguments", soself->s_len);
@@ -1594,16 +1593,16 @@ s_pack(PyObject *self, PyObject *args)
return result;
}
-PyDoc_STRVAR(s_pack_to__doc__,
-"S.pack_to(buffer, offset, v1, v2, ...)\n\
+PyDoc_STRVAR(s_pack_into__doc__,
+"S.pack_into(buffer, offset, v1, v2, ...)\n\
\n\
-Pack the values v2, v2, ... according to this Struct's format, write \n\
+Pack the values v1, v2, ... according to this Struct's format, write \n\
the packed bytes into the writable buffer buf starting at offset. Note\n\
that the offset is not an optional argument. See struct.__doc__ for \n\
more on format strings.");
static PyObject *
-s_pack_to(PyObject *self, PyObject *args)
+s_pack_into(PyObject *self, PyObject *args)
{
PyStructObject *soself;
char *buffer;
@@ -1613,11 +1612,10 @@ s_pack_to(PyObject *self, PyObject *args)
soself = (PyStructObject *)self;
assert(PyStruct_Check(self));
assert(soself->s_codes != NULL);
- if (args == NULL || !PyTuple_Check(args) ||
- PyTuple_GET_SIZE(args) != (soself->s_len + 2))
+ if (PyTuple_GET_SIZE(args) != (soself->s_len + 2))
{
PyErr_Format(StructError,
- "pack_to requires exactly %zd arguments",
+ "pack_into requires exactly %zd arguments",
(soself->s_len + 2));
return NULL;
}
@@ -1630,7 +1628,7 @@ s_pack_to(PyObject *self, PyObject *args)
assert( buffer_len >= 0 );
/* Extract the offset from the first argument */
- offset = PyInt_AsLong(PyTuple_GET_ITEM(args, 1));
+ offset = PyInt_AsSsize_t(PyTuple_GET_ITEM(args, 1));
/* Support negative offsets. */
if (offset < 0)
@@ -1639,7 +1637,7 @@ s_pack_to(PyObject *self, PyObject *args)
/* Check boundaries */
if (offset < 0 || (buffer_len - offset) < soself->s_size) {
PyErr_Format(StructError,
- "pack_to requires a buffer of at least %zd bytes",
+ "pack_into requires a buffer of at least %zd bytes",
soself->s_size);
return NULL;
}
@@ -1668,10 +1666,11 @@ s_get_size(PyStructObject *self, void *unused)
/* List of functions */
static struct PyMethodDef s_methods[] = {
- {"pack", (PyCFunction)s_pack, METH_VARARGS, s_pack__doc__},
- {"pack_to", (PyCFunction)s_pack_to, METH_VARARGS, s_pack_to__doc__},
- {"unpack", (PyCFunction)s_unpack, METH_O, s_unpack__doc__},
- {"unpack_from", (PyCFunction)s_unpack_from, METH_KEYWORDS, s_unpack_from__doc__},
+ {"pack", s_pack, METH_VARARGS, s_pack__doc__},
+ {"pack_into", s_pack_into, METH_VARARGS, s_pack_into__doc__},
+ {"unpack", s_unpack, METH_O, s_unpack__doc__},
+ {"unpack_from", (PyCFunction)s_unpack_from, METH_KEYWORDS,
+ s_unpack_from__doc__},
{NULL, NULL} /* sentinel */
};
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
index 77583b7..cec83f5 100644
--- a/Modules/_tkinter.c
+++ b/Modules/_tkinter.c
@@ -1274,13 +1274,13 @@ Tkapp_CallProc(Tkapp_CallEvent *e, int flags)
and perform processing there. */
static PyObject *
-Tkapp_Call(PyObject *_self, PyObject *args)
+Tkapp_Call(PyObject *selfptr, PyObject *args)
{
Tcl_Obj *objStore[ARGSZ];
Tcl_Obj **objv = NULL;
int objc, i;
PyObject *res = NULL;
- TkappObject *self = (TkappObject*)_self;
+ TkappObject *self = (TkappObject*)selfptr;
/* Could add TCL_EVAL_GLOBAL if wrapped by GlobalCall... */
int flags = TCL_EVAL_DIRECT;
@@ -1326,7 +1326,7 @@ Tkapp_Call(PyObject *_self, PyObject *args)
ENTER_OVERLAP
if (i == TCL_ERROR)
- Tkinter_Error(_self);
+ Tkinter_Error(selfptr);
else
res = Tkapp_CallResult(self);
@@ -1542,12 +1542,12 @@ var_proc(VarEvent* ev, int flags)
}
static PyObject*
-var_invoke(EventFunc func, PyObject *_self, PyObject *args, int flags)
+var_invoke(EventFunc func, PyObject *selfptr, PyObject *args, int flags)
{
- TkappObject *self = (TkappObject*)_self;
+ TkappObject *self = (TkappObject*)selfptr;
#ifdef WITH_THREAD
if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) {
- TkappObject *self = (TkappObject*)_self;
+ TkappObject *self = (TkappObject*)selfptr;
VarEvent *ev;
PyObject *res, *exc_type, *exc_val;
@@ -1559,7 +1559,7 @@ var_invoke(EventFunc func, PyObject *_self, PyObject *args, int flags)
ev = (VarEvent*)ckalloc(sizeof(VarEvent));
- ev->self = _self;
+ ev->self = selfptr;
ev->args = args;
ev->flags = flags;
ev->func = func;
@@ -1579,7 +1579,7 @@ var_invoke(EventFunc func, PyObject *_self, PyObject *args, int flags)
}
#endif
/* Tcl is not threaded, or this is the interpreter thread. */
- return func(_self, args, flags);
+ return func(selfptr, args, flags);
}
static PyObject *
@@ -2079,9 +2079,9 @@ Tkapp_CommandProc(CommandEvent *ev, int flags)
}
static PyObject *
-Tkapp_CreateCommand(PyObject *_self, PyObject *args)
+Tkapp_CreateCommand(PyObject *selfptr, PyObject *args)
{
- TkappObject *self = (TkappObject*)_self;
+ TkappObject *self = (TkappObject*)selfptr;
PythonCmd_ClientData *data;
char *cmdName;
PyObject *func;
@@ -2105,7 +2105,7 @@ Tkapp_CreateCommand(PyObject *_self, PyObject *args)
return PyErr_NoMemory();
Py_XINCREF(self);
Py_XINCREF(func);
- data->self = _self;
+ data->self = selfptr;
data->func = func;
if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) {
@@ -2139,9 +2139,9 @@ Tkapp_CreateCommand(PyObject *_self, PyObject *args)
static PyObject *
-Tkapp_DeleteCommand(PyObject *_self, PyObject *args)
+Tkapp_DeleteCommand(PyObject *selfptr, PyObject *args)
{
- TkappObject *self = (TkappObject*)_self;
+ TkappObject *self = (TkappObject*)selfptr;
char *cmdName;
int err;
@@ -2502,10 +2502,10 @@ Tkapp_CreateTimerHandler(PyObject *self, PyObject *args)
/** Event Loop **/
static PyObject *
-Tkapp_MainLoop(PyObject *_self, PyObject *args)
+Tkapp_MainLoop(PyObject *selfptr, PyObject *args)
{
int threshold = 0;
- TkappObject *self = (TkappObject*)_self;
+ TkappObject *self = (TkappObject*)selfptr;
#ifdef WITH_THREAD
PyThreadState *tstate = PyThreadState_Get();
#endif
diff --git a/Modules/cjkcodecs/_codecs_jp.c b/Modules/cjkcodecs/_codecs_jp.c
index 9b8d324..f49a10b 100644
--- a/Modules/cjkcodecs/_codecs_jp.c
+++ b/Modules/cjkcodecs/_codecs_jp.c
@@ -639,10 +639,11 @@ DECODER(shift_jis_2004)
REQUIRE_OUTBUF(1)
JISX0201_DECODE(c, **outbuf)
else if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xfc)){
- unsigned char c1, c2 = IN2;
+ unsigned char c1, c2;
ucs4_t code;
REQUIRE_INBUF(2)
+ c2 = IN2;
if (c2 < 0x40 || (c2 > 0x7e && c2 < 0x80) || c2 > 0xfc)
return 2;
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 847a194..262abe8 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -104,9 +104,9 @@ gettimeout() -- return timeout or None\n\
listen(n) -- start listening for incoming connections\n\
makefile([mode, [bufsize]]) -- return a file object for the socket [*]\n\
recv(buflen[, flags]) -- receive data\n\
-recv_buf(buffer[, nbytes[, flags]]) -- receive data (into a buffer)\n\
+recv_into(buffer[, nbytes[, flags]]) -- receive data (into a buffer)\n\
recvfrom(buflen[, flags]) -- receive data and sender\'s address\n\
-recvfrom_buf(buffer[, nbytes, [, flags])\n\
+recvfrom_into(buffer[, nbytes, [, flags])\n\
-- receive data and sender\'s address (into a buffer)\n\
sendall(data[, flags]) -- send all data\n\
send(data[, flags]) -- send data, may not send all of it\n\
@@ -2139,17 +2139,18 @@ The mode and buffersize arguments are as for the built-in open() function.");
#endif /* NO_DUP */
/*
- * This is the guts of the recv() and recv_buf() methods, which reads into a
+ * This is the guts of the recv() and recv_into() methods, which reads into a
* char buffer. If you have any inc/def ref to do to the objects that contain
* the buffer, do it in the caller. This function returns the number of bytes
* succesfully read. If there was an error, it returns -1. Note that it is
* also possible that we return a number of bytes smaller than the request
* bytes.
*/
-static int
+static ssize_t
sock_recv_guts(PySocketSockObject *s, char* cbuf, int len, int flags)
{
- int timeout, outlen = 0;
+ ssize_t outlen = 0;
+ int timeout;
#ifdef __VMS
int remaining, nread;
char *read_buf;
@@ -2225,7 +2226,8 @@ sock_recv_guts(PySocketSockObject *s, char* cbuf, int len, int flags)
static PyObject *
sock_recv(PySocketSockObject *s, PyObject *args)
{
- int recvlen, flags = 0, outlen;
+ int recvlen, flags = 0;
+ ssize_t outlen;
PyObject *buf;
if (!PyArg_ParseTuple(args, "i|i:recv", &recvlen, &flags))
@@ -2243,7 +2245,7 @@ sock_recv(PySocketSockObject *s, PyObject *args)
return NULL;
/* Call the guts */
- outlen = sock_recv_guts(s, PyString_AsString(buf), recvlen, flags);
+ outlen = sock_recv_guts(s, PyString_AS_STRING(buf), recvlen, flags);
if (outlen < 0) {
/* An error occured, release the string and return an
error. */
@@ -2270,19 +2272,20 @@ at least one byte is available or until the remote end is closed. When\n\
the remote end is closed and all data is read, return the empty string.");
-/* s.recv_buf(buffer, [nbytes [,flags]]) method */
+/* s.recv_into(buffer, [nbytes [,flags]]) method */
static PyObject*
-sock_recv_buf(PySocketSockObject *s, PyObject *args, PyObject *kwds)
+sock_recv_into(PySocketSockObject *s, PyObject *args, PyObject *kwds)
{
static char *kwlist[] = {"buffer", "nbytes", "flags", 0};
- int recvlen = 0, flags = 0, readlen;
+ int recvlen = 0, flags = 0;
+ ssize_t readlen;
char *buf;
int buflen;
/* Get the buffer's memory */
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "s#|ii:recv", kwlist,
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "w#|ii:recv", kwlist,
&buf, &buflen, &recvlen, &flags))
return NULL;
assert(buf != 0 && buflen > 0);
@@ -2313,11 +2316,11 @@ sock_recv_buf(PySocketSockObject *s, PyObject *args, PyObject *kwds)
/* Return the number of bytes read. Note that we do not do anything
special here in the case that readlen < recvlen. */
- return PyInt_FromLong(readlen);
+ return PyInt_FromSsize_t(readlen);
}
-PyDoc_STRVAR(recv_buf_doc,
-"recv_buf(buffer, [nbytes[, flags]]) -> nbytes_read\n\
+PyDoc_STRVAR(recv_into_doc,
+"recv_into(buffer, [nbytes[, flags]]) -> nbytes_read\n\
\n\
A version of recv() that stores its data into a buffer rather than creating \n\
a new string. Receive up to buffersize bytes from the socket. If buffersize \n\
@@ -2327,7 +2330,7 @@ See recv() for documentation about the flags.");
/*
- * This is the guts of the recv() and recv_buf() methods, which reads into a
+ * This is the guts of the recv() and recv_into() methods, which reads into a
* char buffer. If you have any inc/def ref to do to the objects that contain
* the buffer, do it in the caller. This function returns the number of bytes
* succesfully read. If there was an error, it returns -1. Note that it is
@@ -2337,12 +2340,13 @@ See recv() for documentation about the flags.");
* 'addr' is a return value for the address object. Note that you must decref
* it yourself.
*/
-static int
+static ssize_t
sock_recvfrom_guts(PySocketSockObject *s, char* cbuf, int len, int flags,
PyObject** addr)
{
sock_addr_t addrbuf;
- int n = 0, timeout;
+ int timeout;
+ ssize_t n = 0;
socklen_t addrlen;
*addr = NULL;
@@ -2398,7 +2402,8 @@ sock_recvfrom(PySocketSockObject *s, PyObject *args)
PyObject *buf = NULL;
PyObject *addr = NULL;
PyObject *ret = NULL;
- int recvlen, outlen, flags = 0;
+ int recvlen, flags = 0;
+ ssize_t outlen;
if (!PyArg_ParseTuple(args, "i|i:recvfrom", &recvlen, &flags))
return NULL;
@@ -2435,21 +2440,21 @@ PyDoc_STRVAR(recvfrom_doc,
Like recv(buffersize, flags) but also return the sender's address info.");
-/* s.recvfrom_buf(buffer[, nbytes [,flags]]) method */
+/* s.recvfrom_into(buffer[, nbytes [,flags]]) method */
static PyObject *
-sock_recvfrom_buf(PySocketSockObject *s, PyObject *args, PyObject* kwds)
+sock_recvfrom_into(PySocketSockObject *s, PyObject *args, PyObject* kwds)
{
static char *kwlist[] = {"buffer", "nbytes", "flags", 0};
- int recvlen = 0, flags = 0, readlen;
+ int recvlen = 0, flags = 0;
+ ssize_t readlen;
char *buf;
int buflen;
PyObject *addr = NULL;
- PyObject *ret = NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "s#|ii:recvfrom", kwlist,
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "w#|ii:recvfrom", kwlist,
&buf, &buflen, &recvlen, &flags))
return NULL;
assert(buf != 0 && buflen > 0);
@@ -2467,22 +2472,19 @@ sock_recvfrom_buf(PySocketSockObject *s, PyObject *args, PyObject* kwds)
readlen = sock_recvfrom_guts(s, buf, recvlen, flags, &addr);
if (readlen < 0) {
/* Return an error */
- goto finally;
+ Py_XDECREF(addr);
+ return NULL;
}
/* Return the number of bytes read and the address. Note that we do
not do anything special here in the case that readlen < recvlen. */
- ret = Py_BuildValue("lO", readlen, addr);
-
-finally:
- Py_XDECREF(addr);
- return ret;
+ return Py_BuildValue("lN", readlen, addr);
}
-PyDoc_STRVAR(recvfrom_buf_doc,
-"recvfrom_buf(buffer[, nbytes[, flags]]) -> (nbytes, address info)\n\
+PyDoc_STRVAR(recvfrom_into_doc,
+"recvfrom_into(buffer[, nbytes[, flags]]) -> (nbytes, address info)\n\
\n\
-Like recv_buf(buffer[, nbytes[, flags]]) but also return the sender's address info.");
+Like recv_into(buffer[, nbytes[, flags]]) but also return the sender's address info.");
/* s.send(data [,flags]) method */
@@ -2711,12 +2713,12 @@ static PyMethodDef sock_methods[] = {
#endif
{"recv", (PyCFunction)sock_recv, METH_VARARGS,
recv_doc},
- {"recv_buf", (PyCFunction)sock_recv_buf, METH_VARARGS | METH_KEYWORDS,
- recv_buf_doc},
+ {"recv_into", (PyCFunction)sock_recv_into, METH_VARARGS | METH_KEYWORDS,
+ recv_into_doc},
{"recvfrom", (PyCFunction)sock_recvfrom, METH_VARARGS,
recvfrom_doc},
- {"recvfrom_buf", (PyCFunction)sock_recvfrom_buf, METH_VARARGS | METH_KEYWORDS,
- recvfrom_buf_doc},
+ {"recvfrom_into", (PyCFunction)sock_recvfrom_into, METH_VARARGS | METH_KEYWORDS,
+ recvfrom_into_doc},
{"send", (PyCFunction)sock_send, METH_VARARGS,
send_doc},
{"sendall", (PyCFunction)sock_sendall, METH_VARARGS,