summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorThomas Wouters <thomas@python.org>2006-12-13 04:49:30 (GMT)
committerThomas Wouters <thomas@python.org>2006-12-13 04:49:30 (GMT)
commit89f507fe8c497b3f70fdcecce8bc240f9af2bbe2 (patch)
tree8acfdf7de23d9802924a2cef9f8ed32222eaa8f4 /Python
parent16f3e03283cdbea6101d21960743d3901ddf8d57 (diff)
downloadcpython-89f507fe8c497b3f70fdcecce8bc240f9af2bbe2.zip
cpython-89f507fe8c497b3f70fdcecce8bc240f9af2bbe2.tar.gz
cpython-89f507fe8c497b3f70fdcecce8bc240f9af2bbe2.tar.bz2
Four months of trunk changes (including a few releases...)
Merged revisions 51434-53004 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r51434 | neal.norwitz | 2006-08-21 20:20:10 +0200 (Mon, 21 Aug 2006) | 1 line Fix a couple of ssize-t issues reported by Alexander Belopolsky on python-dev ........ r51439 | neal.norwitz | 2006-08-21 21:47:08 +0200 (Mon, 21 Aug 2006) | 6 lines Patch #1542451: disallow continue anywhere under a finally I'm undecided if this should be backported to 2.5 or 2.5.1. Armin suggested to wait (I'm of the same opinion). Thomas W thinks it's fine to go in 2.5. ........ r51443 | neal.norwitz | 2006-08-21 22:16:24 +0200 (Mon, 21 Aug 2006) | 4 lines Handle a few more error conditions. Klocwork 301 and 302. Will backport. ........ r51450 | neal.norwitz | 2006-08-22 00:21:19 +0200 (Tue, 22 Aug 2006) | 5 lines Patch #1541585: fix buffer overrun when performing repr() on a unicode string in a build with wide unicode (UCS-4) support. This code could be improved, so add an XXX comment. ........ r51456 | neal.norwitz | 2006-08-22 01:44:48 +0200 (Tue, 22 Aug 2006) | 1 line Try to get the windows bots working again with the new peephole.c ........ r51461 | anthony.baxter | 2006-08-22 09:36:59 +0200 (Tue, 22 Aug 2006) | 1 line patch for documentation for recent uuid changes (from ping) ........ r51473 | neal.norwitz | 2006-08-22 15:56:56 +0200 (Tue, 22 Aug 2006) | 1 line Alexander Belopolsky pointed out that pos is a size_t ........ r51489 | jeremy.hylton | 2006-08-22 22:46:00 +0200 (Tue, 22 Aug 2006) | 2 lines Expose column offset information in parse trees. ........ r51497 | andrew.kuchling | 2006-08-23 01:13:43 +0200 (Wed, 23 Aug 2006) | 1 line Move functional howto into trunk ........ r51515 | jeremy.hylton | 2006-08-23 20:37:43 +0200 (Wed, 23 Aug 2006) | 2 lines Baby steps towards better tests for tokenize ........ r51525 | alex.martelli | 2006-08-23 22:42:02 +0200 (Wed, 23 Aug 2006) | 6 lines x**2 should about equal x*x (including for a float x such that the result is inf) but didn't; added a test to test_float to verify that, and ignored the ERANGE value for errno in the pow operation to make the new test pass (with help from Marilyn Davis at the Google Python Sprint -- thanks!). ........ r51526 | jeremy.hylton | 2006-08-23 23:14:03 +0200 (Wed, 23 Aug 2006) | 20 lines Bug fixes large and small for tokenize. Small: Always generate a NL or NEWLINE token following a COMMENT token. The old code did not generate an NL token if the comment was on a line by itself. Large: The output of untokenize() will now match the input exactly if it is passed the full token sequence. The old, crufty output is still generated if a limited input sequence is provided, where limited means that it does not include position information for tokens. Remaining bug: There is no CONTINUATION token (\) so there is no way for untokenize() to handle such code. Also, expanded the number of doctests in hopes of eventually removing the old-style tests that compare against a golden file. Bug fix candidate for Python 2.5.1. (Sigh.) ........ r51527 | jeremy.hylton | 2006-08-23 23:26:46 +0200 (Wed, 23 Aug 2006) | 5 lines Replace dead code with an assert. Now that COMMENT tokens are reliably followed by NL or NEWLINE, there is never a need to add extra newlines in untokenize. ........ r51530 | alex.martelli | 2006-08-24 00:17:59 +0200 (Thu, 24 Aug 2006) | 7 lines Reverting the patch that tried to fix the issue whereby x**2 raises OverflowError while x*x succeeds and produces infinity; apparently these inconsistencies cannot be fixed across ``all'' platforms and there's a widespread feeling that therefore ``every'' platform should keep suffering forevermore. Ah well. ........ r51565 | thomas.wouters | 2006-08-24 20:40:20 +0200 (Thu, 24 Aug 2006) | 6 lines Fix SF bug #1545837: array.array borks on deepcopy. array.__deepcopy__() needs to take an argument, even if it doesn't actually use it. Will backport to 2.5 and 2.4 (if applicable.) ........ r51580 | martin.v.loewis | 2006-08-25 02:03:34 +0200 (Fri, 25 Aug 2006) | 3 lines Patch #1545507: Exclude ctypes package in Win64 MSI file. Will backport to 2.5. ........ r51589 | neal.norwitz | 2006-08-25 03:52:49 +0200 (Fri, 25 Aug 2006) | 1 line importing types is not necessary if we use isinstance ........ r51604 | thomas.heller | 2006-08-25 09:27:33 +0200 (Fri, 25 Aug 2006) | 3 lines Port _ctypes.pyd to win64 on AMD64. ........ r51605 | thomas.heller | 2006-08-25 09:34:51 +0200 (Fri, 25 Aug 2006) | 3 lines Add missing file for _ctypes.pyd port to win64 on AMD64. ........ r51606 | thomas.heller | 2006-08-25 11:26:33 +0200 (Fri, 25 Aug 2006) | 6 lines Build _ctypes.pyd for win AMD64 into the MSVC project file. Since MSVC doesn't know about .asm files, a helper batch file is needed to find ml64.exe in predefined locations. The helper script hardcodes the path to the MS Platform SDK. ........ r51608 | armin.rigo | 2006-08-25 14:44:28 +0200 (Fri, 25 Aug 2006) | 4 lines The regular expression engine in '_sre' can segfault when interpreting bogus bytecode. It is unclear whether this is a real bug or a "won't fix" case like bogus_code_obj.py. ........ r51617 | tim.peters | 2006-08-26 00:05:39 +0200 (Sat, 26 Aug 2006) | 2 lines Whitespace normalization. ........ r51618 | tim.peters | 2006-08-26 00:06:44 +0200 (Sat, 26 Aug 2006) | 2 lines Add missing svn:eol-style property to text files. ........ r51619 | tim.peters | 2006-08-26 00:26:21 +0200 (Sat, 26 Aug 2006) | 3 lines A new test here relied on preserving invisible trailing whitespace in expected output. Stop that. ........ r51624 | jack.diederich | 2006-08-26 20:42:06 +0200 (Sat, 26 Aug 2006) | 4 lines - Move functions common to all path modules into genericpath.py and have the OS speicifc path modules import them. - Have os2emxpath import common functions fron ntpath instead of using copies ........ r51642 | neal.norwitz | 2006-08-29 07:40:58 +0200 (Tue, 29 Aug 2006) | 1 line Fix a couple of typos. ........ r51647 | marc-andre.lemburg | 2006-08-29 12:34:12 +0200 (Tue, 29 Aug 2006) | 5 lines Fix a buglet in the error reporting (SF bug report #1546372). This should probably go into Python 2.5 or 2.5.1 as well. ........ r51663 | armin.rigo | 2006-08-31 10:51:06 +0200 (Thu, 31 Aug 2006) | 3 lines Doc fix: hashlib objects don't always return a digest of 16 bytes. Backport candidate for 2.5. ........ r51664 | nick.coghlan | 2006-08-31 14:00:43 +0200 (Thu, 31 Aug 2006) | 1 line Fix the wrongheaded implementation of context management in the decimal module and add unit tests. (python-dev discussion is ongoing regarding what we do about Python 2.5) ........ r51665 | nick.coghlan | 2006-08-31 14:51:25 +0200 (Thu, 31 Aug 2006) | 1 line Remove the old decimal context management tests from test_contextlib (guess who didn't run the test suite before committing...) ........ r51669 | brett.cannon | 2006-08-31 20:54:26 +0200 (Thu, 31 Aug 2006) | 4 lines Make sure memory is properly cleaned up in file_init. Backport candidate. ........ r51671 | brett.cannon | 2006-08-31 23:47:52 +0200 (Thu, 31 Aug 2006) | 2 lines Fix comment about indentation level in C files. ........ r51674 | brett.cannon | 2006-09-01 00:42:37 +0200 (Fri, 01 Sep 2006) | 3 lines Have pre-existing C files use 8 spaces indents (to match old PEP 7 style), but have all new files use 4 spaces (to match current PEP 7 style). ........ r51676 | fred.drake | 2006-09-01 05:57:19 +0200 (Fri, 01 Sep 2006) | 3 lines - SF patch #1550263: Enhance and correct unittest docs - various minor cleanups for improved consistency ........ r51677 | georg.brandl | 2006-09-02 00:30:52 +0200 (Sat, 02 Sep 2006) | 2 lines evalfile() should be execfile(). ........ r51681 | neal.norwitz | 2006-09-02 04:43:17 +0200 (Sat, 02 Sep 2006) | 1 line SF #1547931, fix typo (missing and). Will backport to 2.5 ........ r51683 | neal.norwitz | 2006-09-02 04:50:35 +0200 (Sat, 02 Sep 2006) | 1 line Bug #1548092: fix curses.tparm seg fault on invalid input. Needs backport to 2.5.1 and earlier. ........ r51684 | neal.norwitz | 2006-09-02 04:58:13 +0200 (Sat, 02 Sep 2006) | 4 lines Bug #1550714: fix SystemError from itertools.tee on negative value for n. Needs backport to 2.5.1 and earlier. ........ r51685 | nick.coghlan | 2006-09-02 05:54:17 +0200 (Sat, 02 Sep 2006) | 1 line Make decimal.ContextManager a private implementation detail of decimal.localcontext() ........ r51686 | nick.coghlan | 2006-09-02 06:04:18 +0200 (Sat, 02 Sep 2006) | 1 line Further corrections to the decimal module context management documentation ........ r51688 | raymond.hettinger | 2006-09-02 19:07:23 +0200 (Sat, 02 Sep 2006) | 1 line Fix documentation nits for decimal context managers. ........ r51690 | neal.norwitz | 2006-09-02 20:51:34 +0200 (Sat, 02 Sep 2006) | 1 line Add missing word in comment ........ r51691 | neal.norwitz | 2006-09-02 21:40:19 +0200 (Sat, 02 Sep 2006) | 7 lines Hmm, this test has failed at least twice recently on the OpenBSD and Debian sparc buildbots. Since this goes through a lot of tests and hits the disk a lot it could be slow (especially if NFS is involved). I'm not sure if that's the problem, but printing periodic msgs shouldn't hurt. The code was stolen from test_compiler. ........ r51693 | nick.coghlan | 2006-09-03 03:02:00 +0200 (Sun, 03 Sep 2006) | 1 line Fix final documentation nits before backporting decimal module fixes to 2.5 ........ r51694 | nick.coghlan | 2006-09-03 03:06:07 +0200 (Sun, 03 Sep 2006) | 1 line Typo fix for decimal docs ........ r51697 | nick.coghlan | 2006-09-03 03:20:46 +0200 (Sun, 03 Sep 2006) | 1 line NEWS entry on trunk for decimal module changes ........ r51704 | raymond.hettinger | 2006-09-04 17:32:48 +0200 (Mon, 04 Sep 2006) | 1 line Fix endcase for str.rpartition() ........ r51716 | tim.peters | 2006-09-05 04:18:09 +0200 (Tue, 05 Sep 2006) | 12 lines "Conceptual" merge of rev 51711 from the 2.5 branch. i_divmod(): As discussed on Python-Dev, changed the overflow checking to live happily with recent gcc optimizations that assume signed integer arithmetic never overflows. This differs from the corresponding change on the 2.5 and 2.4 branches, using a less obscure approach, but one that /may/ tickle platform idiocies in their definitions of LONG_MIN. The 2.4 + 2.5 change avoided introducing a dependence on LONG_MIN, at the cost of substantially goofier code. ........ r51717 | tim.peters | 2006-09-05 04:21:19 +0200 (Tue, 05 Sep 2006) | 2 lines Whitespace normalization. ........ r51719 | tim.peters | 2006-09-05 04:22:17 +0200 (Tue, 05 Sep 2006) | 2 lines Add missing svn:eol-style property to text files. ........ r51720 | neal.norwitz | 2006-09-05 04:24:03 +0200 (Tue, 05 Sep 2006) | 2 lines Fix SF bug #1546288, crash in dict_equal. ........ r51721 | neal.norwitz | 2006-09-05 04:25:41 +0200 (Tue, 05 Sep 2006) | 1 line Fix SF #1552093, eval docstring typo (3 ps in mapping) ........ r51724 | neal.norwitz | 2006-09-05 04:35:08 +0200 (Tue, 05 Sep 2006) | 1 line This was found by Guido AFAIK on p3yk (sic) branch. ........ r51725 | neal.norwitz | 2006-09-05 04:36:20 +0200 (Tue, 05 Sep 2006) | 1 line Add a NEWS entry for str.rpartition() change ........ r51728 | neal.norwitz | 2006-09-05 04:57:01 +0200 (Tue, 05 Sep 2006) | 1 line Patch #1540470, for OpenBSD 4.0. Backport candidate for 2.[34]. ........ r51729 | neal.norwitz | 2006-09-05 05:53:08 +0200 (Tue, 05 Sep 2006) | 12 lines Bug #1520864 (again): unpacking singleton tuples in list comprehensions and generator expressions (x for x, in ... ) works again. Sigh, I only fixed for loops the first time, not list comps and genexprs too. I couldn't find any more unpacking cases where there is a similar bug lurking. This code should be refactored to eliminate the duplication. I'm sure the listcomp/genexpr code can be refactored. I'm not sure if the for loop can re-use any of the same code though. Will backport to 2.5 (the only place it matters). ........ r51731 | neal.norwitz | 2006-09-05 05:58:26 +0200 (Tue, 05 Sep 2006) | 1 line Add a comment about some refactoring. (There's probably more that should be done.) I will reformat this file in the next checkin due to the inconsistent tabs/spaces. ........ r51732 | neal.norwitz | 2006-09-05 06:00:12 +0200 (Tue, 05 Sep 2006) | 1 line M-x untabify ........ r51737 | hyeshik.chang | 2006-09-05 14:07:09 +0200 (Tue, 05 Sep 2006) | 7 lines Fix a few bugs on cjkcodecs found by Oren Tirosh: - gbk and gb18030 codec now handle U+30FB KATAKANA MIDDLE DOT correctly. - iso2022_jp_2 codec now encodes into G0 for KS X 1001, GB2312 codepoints to conform the standard. - iso2022_jp_3 and iso2022_jp_2004 codec can encode JIS X 2013:2 codepoints now. ........ r51738 | hyeshik.chang | 2006-09-05 14:14:57 +0200 (Tue, 05 Sep 2006) | 2 lines Fix a typo: 2013 -> 0213 ........ r51740 | georg.brandl | 2006-09-05 14:44:58 +0200 (Tue, 05 Sep 2006) | 3 lines Bug #1552618: change docs of dict.has_key() to reflect recommendation to use "in". ........ r51742 | andrew.kuchling | 2006-09-05 15:02:40 +0200 (Tue, 05 Sep 2006) | 1 line Rearrange example a bit, and show rpartition() when separator is not found ........ r51744 | andrew.kuchling | 2006-09-05 15:15:41 +0200 (Tue, 05 Sep 2006) | 1 line [Bug #1525469] SimpleXMLRPCServer still uses the sys.exc_{value,type} module-level globals instead of calling sys.exc_info(). Reported by Russell Warren ........ r51745 | andrew.kuchling | 2006-09-05 15:19:18 +0200 (Tue, 05 Sep 2006) | 3 lines [Bug #1526834] Fix crash in pdb when you do 'b f('; the function name was placed into a regex pattern and the unbalanced paren caused re.compile() to report an error ........ r51751 | kristjan.jonsson | 2006-09-05 19:58:12 +0200 (Tue, 05 Sep 2006) | 6 lines Update the PCBuild8 solution. Facilitate cross-compilation by having binaries in separate Win32 and x64 directories. Rationalized configs by making proper use of platforms/configurations. Remove pythoncore_pgo project. Add new PGIRelease and PGORelease configurations to perform Profile Guided Optimisation. Removed I64 support, but this can be easily added by copying the x64 platform settings. ........ r51758 | gustavo.niemeyer | 2006-09-06 03:58:52 +0200 (Wed, 06 Sep 2006) | 3 lines Fixing #1531862: Do not close standard file descriptors in the subprocess module. ........ r51760 | neal.norwitz | 2006-09-06 05:58:34 +0200 (Wed, 06 Sep 2006) | 1 line Revert 51758 because it broke all the buildbots ........ r51762 | georg.brandl | 2006-09-06 08:03:59 +0200 (Wed, 06 Sep 2006) | 3 lines Bug #1551427: fix a wrong NULL pointer check in the win32 version of os.urandom(). ........ r51765 | georg.brandl | 2006-09-06 08:09:31 +0200 (Wed, 06 Sep 2006) | 3 lines Bug #1550983: emit better error messages for erroneous relative imports (if not in package and if beyond toplevel package). ........ r51767 | neal.norwitz | 2006-09-06 08:28:06 +0200 (Wed, 06 Sep 2006) | 1 line with and as are now keywords. There are some generated files I can't recreate. ........ r51770 | georg.brandl | 2006-09-06 08:50:05 +0200 (Wed, 06 Sep 2006) | 5 lines Bug #1542051: Exceptions now correctly call PyObject_GC_UnTrack. Also make sure that every exception class has __module__ set to 'exceptions'. ........ r51785 | georg.brandl | 2006-09-06 22:05:58 +0200 (Wed, 06 Sep 2006) | 2 lines Fix missing import of the types module in logging.config. ........ r51789 | marc-andre.lemburg | 2006-09-06 22:40:22 +0200 (Wed, 06 Sep 2006) | 3 lines Add news item for bug fix of SF bug report #1546372. ........ r51797 | gustavo.niemeyer | 2006-09-07 02:48:33 +0200 (Thu, 07 Sep 2006) | 3 lines Fixed subprocess bug #1531862 again, after removing tests offending buildbot ........ r51798 | raymond.hettinger | 2006-09-07 04:42:48 +0200 (Thu, 07 Sep 2006) | 1 line Fix refcounts and add error checks. ........ r51803 | nick.coghlan | 2006-09-07 12:50:34 +0200 (Thu, 07 Sep 2006) | 1 line Fix the speed regression in inspect.py by adding another cache to speed up getmodule(). Patch #1553314 ........ r51805 | ronald.oussoren | 2006-09-07 14:03:10 +0200 (Thu, 07 Sep 2006) | 2 lines Fix a glaring error and update some version numbers. ........ r51814 | andrew.kuchling | 2006-09-07 15:56:23 +0200 (Thu, 07 Sep 2006) | 1 line Typo fix ........ r51815 | andrew.kuchling | 2006-09-07 15:59:38 +0200 (Thu, 07 Sep 2006) | 8 lines [Bug #1552726] Avoid repeatedly polling in interactive mode -- only put a timeout on the select() if an input hook has been defined. Patch by Richard Boulton. This select() code is only executed with readline 2.1, or if READLINE_CALLBACKS is defined. Backport candidate for 2.5, 2.4, probably earlier versions too. ........ r51816 | armin.rigo | 2006-09-07 17:06:00 +0200 (Thu, 07 Sep 2006) | 2 lines Add a warning notice on top of the generated grammar.txt. ........ r51819 | thomas.heller | 2006-09-07 20:56:28 +0200 (Thu, 07 Sep 2006) | 5 lines Anonymous structure fields that have a bit-width specified did not work, and they gave a strange error message from PyArg_ParseTuple: function takes exactly 2 arguments (3 given). With tests. ........ r51820 | thomas.heller | 2006-09-07 21:09:54 +0200 (Thu, 07 Sep 2006) | 4 lines The cast function did not accept c_char_p or c_wchar_p instances as first argument, and failed with a 'bad argument to internal function' error message. ........ r51827 | nick.coghlan | 2006-09-08 12:04:38 +0200 (Fri, 08 Sep 2006) | 1 line Add missing NEWS entry for rev 51803 ........ r51828 | andrew.kuchling | 2006-09-08 15:25:23 +0200 (Fri, 08 Sep 2006) | 1 line Add missing word ........ r51829 | andrew.kuchling | 2006-09-08 15:35:49 +0200 (Fri, 08 Sep 2006) | 1 line Explain SQLite a bit more clearly ........ r51830 | andrew.kuchling | 2006-09-08 15:36:36 +0200 (Fri, 08 Sep 2006) | 1 line Explain SQLite a bit more clearly ........ r51832 | andrew.kuchling | 2006-09-08 16:02:45 +0200 (Fri, 08 Sep 2006) | 1 line Use native SQLite types ........ r51833 | andrew.kuchling | 2006-09-08 16:03:01 +0200 (Fri, 08 Sep 2006) | 1 line Use native SQLite types ........ r51835 | andrew.kuchling | 2006-09-08 16:05:10 +0200 (Fri, 08 Sep 2006) | 1 line Fix typo in example ........ r51837 | brett.cannon | 2006-09-09 09:11:46 +0200 (Sat, 09 Sep 2006) | 6 lines Remove the __unicode__ method from exceptions. Allows unicode() to be called on exception classes. Would require introducing a tp_unicode slot to make it work otherwise. Fixes bug #1551432 and will be backported. ........ r51854 | neal.norwitz | 2006-09-11 06:24:09 +0200 (Mon, 11 Sep 2006) | 8 lines Forward port of 51850 from release25-maint branch. As mentioned on python-dev, reverting patch #1504333 because it introduced an infinite loop in rev 47154. This patch also adds a test to prevent the regression. ........ r51855 | neal.norwitz | 2006-09-11 06:28:16 +0200 (Mon, 11 Sep 2006) | 5 lines Properly handle a NULL returned from PyArena_New(). (Also fix some whitespace) Klocwork #364. ........ r51856 | neal.norwitz | 2006-09-11 06:32:57 +0200 (Mon, 11 Sep 2006) | 1 line Add a "crasher" taken from the sgml bug report referenced in the comment ........ r51858 | georg.brandl | 2006-09-11 11:38:35 +0200 (Mon, 11 Sep 2006) | 12 lines Forward-port of rev. 51857: Building with HP's cc on HP-UX turned up a couple of problems. _PyGILState_NoteThreadState was declared as static inconsistently. Make it static as it's not necessary outside of this module. Some tests failed because errno was reset to 0. (I think the tests that failed were at least: test_fcntl and test_mailbox). Ensure that errno doesn't change after a call to Py_END_ALLOW_THREADS. This only affected debug builds. ........ r51865 | martin.v.loewis | 2006-09-12 21:49:20 +0200 (Tue, 12 Sep 2006) | 2 lines Forward-port 51862: Add sgml_input.html. ........ r51866 | andrew.kuchling | 2006-09-12 22:50:23 +0200 (Tue, 12 Sep 2006) | 1 line Markup typo fix ........ r51867 | andrew.kuchling | 2006-09-12 23:09:02 +0200 (Tue, 12 Sep 2006) | 1 line Some editing, markup fixes ........ r51868 | andrew.kuchling | 2006-09-12 23:21:51 +0200 (Tue, 12 Sep 2006) | 1 line More wordsmithing ........ r51877 | andrew.kuchling | 2006-09-14 13:22:18 +0200 (Thu, 14 Sep 2006) | 1 line Make --help mention that -v can be supplied multiple times ........ r51878 | andrew.kuchling | 2006-09-14 13:28:50 +0200 (Thu, 14 Sep 2006) | 1 line Rewrite help message to remove some of the parentheticals. (There were a lot of them.) ........ r51883 | ka-ping.yee | 2006-09-15 02:34:19 +0200 (Fri, 15 Sep 2006) | 2 lines Fix grammar errors and improve clarity. ........ r51885 | georg.brandl | 2006-09-15 07:22:24 +0200 (Fri, 15 Sep 2006) | 3 lines Correct elementtree module index entry. ........ r51889 | fred.drake | 2006-09-15 17:18:04 +0200 (Fri, 15 Sep 2006) | 4 lines - fix module name in links in formatted documentation - minor markup cleanup (forward-ported from release25-maint revision 51888) ........ r51891 | fred.drake | 2006-09-15 18:11:27 +0200 (Fri, 15 Sep 2006) | 3 lines revise explanation of returns_unicode to reflect bool values and to include the default value (merged from release25-maint revision 51890) ........ r51897 | martin.v.loewis | 2006-09-16 19:36:37 +0200 (Sat, 16 Sep 2006) | 2 lines Patch #1557515: Add RLIMIT_SBSIZE. ........ r51903 | ronald.oussoren | 2006-09-17 20:42:53 +0200 (Sun, 17 Sep 2006) | 2 lines Port of revision 51902 in release25-maint to the trunk ........ r51904 | ronald.oussoren | 2006-09-17 21:23:27 +0200 (Sun, 17 Sep 2006) | 3 lines Tweak Mac/Makefile in to ensure that pythonw gets rebuild when the major version of python changes (2.5 -> 2.6). Bug #1552935. ........ r51913 | guido.van.rossum | 2006-09-18 23:36:16 +0200 (Mon, 18 Sep 2006) | 2 lines Make this thing executable. ........ r51920 | gregory.p.smith | 2006-09-19 19:35:04 +0200 (Tue, 19 Sep 2006) | 5 lines Fixes a bug with bsddb.DB.stat where the flags and txn keyword arguments are transposed. (reported by Louis Zechtzer) ..already committed to release24-maint ..needs committing to release25-maint ........ r51926 | brett.cannon | 2006-09-20 20:34:28 +0200 (Wed, 20 Sep 2006) | 3 lines Accidentally didn't commit Misc/NEWS entry on when __unicode__() was removed from exceptions. ........ r51927 | brett.cannon | 2006-09-20 20:43:13 +0200 (Wed, 20 Sep 2006) | 6 lines Allow exceptions to be directly sliced again (e.g., ``BaseException(1,2,3)[0:2]``). Discovered in Python 2.5.0 by Thomas Heller and reported to python-dev. This should be backported to 2.5 . ........ r51928 | brett.cannon | 2006-09-20 21:28:35 +0200 (Wed, 20 Sep 2006) | 2 lines Make python.vim output more deterministic. ........ r51949 | walter.doerwald | 2006-09-21 17:09:55 +0200 (Thu, 21 Sep 2006) | 2 lines Fix typo. ........ r51950 | jack.diederich | 2006-09-21 19:50:26 +0200 (Thu, 21 Sep 2006) | 5 lines * regression bug, count_next was coercing a Py_ssize_t to an unsigned Py_size_t which breaks negative counts * added test for negative numbers will backport to 2.5.1 ........ r51953 | jack.diederich | 2006-09-21 22:34:49 +0200 (Thu, 21 Sep 2006) | 1 line added itertools.count(-n) fix ........ r51971 | neal.norwitz | 2006-09-22 10:16:26 +0200 (Fri, 22 Sep 2006) | 10 lines Fix %zd string formatting on Mac OS X so it prints negative numbers. In addition to testing positive numbers, verify negative numbers work in configure. In order to avoid compiler warnings on OS X 10.4, also change the order of the check for the format character to use (PY_FORMAT_SIZE_T) in the sprintf format for Py_ssize_t. This patch changes PY_FORMAT_SIZE_T from "" to "l" if it wasn't defined at configure time. Need to verify the buildbot results. Backport candidate (if everyone thinks this patch can't be improved). ........ r51972 | neal.norwitz | 2006-09-22 10:18:10 +0200 (Fri, 22 Sep 2006) | 7 lines Bug #1557232: fix seg fault with def f((((x)))) and def f(((x),)). These tests should be improved. Hopefully this fixes variations when flipping back and forth between fpdef and fplist. Backport candidate. ........ r51975 | neal.norwitz | 2006-09-22 10:47:23 +0200 (Fri, 22 Sep 2006) | 4 lines Mostly revert this file to the same version as before. Only force setting of PY_FORMAT_SIZE_T to "l" for Mac OSX. I don't know a better define to use. This should get rid of the warnings on other platforms and Mac too. ........ r51986 | fred.drake | 2006-09-23 02:26:31 +0200 (Sat, 23 Sep 2006) | 1 line add boilerplate "What's New" document so the docs will build ........ r51987 | neal.norwitz | 2006-09-23 06:11:38 +0200 (Sat, 23 Sep 2006) | 1 line Remove extra semi-colons reported by Johnny Lee on python-dev. Backport if anyone cares. ........ r51989 | neal.norwitz | 2006-09-23 20:11:58 +0200 (Sat, 23 Sep 2006) | 1 line SF Bug #1563963, add missing word and cleanup first sentance ........ r51990 | brett.cannon | 2006-09-23 21:53:20 +0200 (Sat, 23 Sep 2006) | 3 lines Make output on test_strptime() be more verbose in face of failure. This is in hopes that more information will help debug the failing test on HPPA Ubuntu. ........ r51991 | georg.brandl | 2006-09-24 12:36:01 +0200 (Sun, 24 Sep 2006) | 2 lines Fix webbrowser.BackgroundBrowser on Windows. ........ r51993 | georg.brandl | 2006-09-24 14:35:36 +0200 (Sun, 24 Sep 2006) | 4 lines Fix a bug in the parser's future statement handling that led to "with" not being recognized as a keyword after, e.g., this statement: from __future__ import division, with_statement ........ r51995 | georg.brandl | 2006-09-24 14:50:24 +0200 (Sun, 24 Sep 2006) | 4 lines Fix a bug in traceback.format_exception_only() that led to an error being raised when print_exc() was called without an exception set. In version 2.4, this printed "None", restored that behavior. ........ r52000 | armin.rigo | 2006-09-25 17:16:26 +0200 (Mon, 25 Sep 2006) | 2 lines Another crasher. ........ r52011 | brett.cannon | 2006-09-27 01:38:24 +0200 (Wed, 27 Sep 2006) | 2 lines Make the error message for when the time data and format do not match clearer. ........ r52014 | andrew.kuchling | 2006-09-27 18:37:30 +0200 (Wed, 27 Sep 2006) | 1 line Add news item for rev. 51815 ........ r52018 | andrew.kuchling | 2006-09-27 21:23:05 +0200 (Wed, 27 Sep 2006) | 1 line Make examples do error checking on Py_InitModule ........ r52032 | brett.cannon | 2006-09-29 00:10:14 +0200 (Fri, 29 Sep 2006) | 2 lines Very minor grammatical fix in a comment. ........ r52048 | george.yoshida | 2006-09-30 07:14:02 +0200 (Sat, 30 Sep 2006) | 4 lines SF bug #1567976 : fix typo Will backport to 2.5. ........ r52051 | gregory.p.smith | 2006-09-30 08:08:20 +0200 (Sat, 30 Sep 2006) | 2 lines wording change ........ r52053 | georg.brandl | 2006-09-30 09:24:48 +0200 (Sat, 30 Sep 2006) | 2 lines Bug #1567375: a minor logical glitch in example description. ........ r52056 | georg.brandl | 2006-09-30 09:31:57 +0200 (Sat, 30 Sep 2006) | 3 lines Bug #1565661: in webbrowser, split() the command for the default GNOME browser in case it is a command with args. ........ r52058 | georg.brandl | 2006-09-30 10:43:30 +0200 (Sat, 30 Sep 2006) | 4 lines Patch #1567691: super() and new.instancemethod() now don't accept keyword arguments any more (previously they accepted them, but didn't use them). ........ r52061 | georg.brandl | 2006-09-30 11:03:42 +0200 (Sat, 30 Sep 2006) | 3 lines Bug #1566800: make sure that EnvironmentError can be called with any number of arguments, as was the case in Python 2.4. ........ r52063 | georg.brandl | 2006-09-30 11:06:45 +0200 (Sat, 30 Sep 2006) | 2 lines Bug #1566663: remove obsolete example from datetime docs. ........ r52065 | georg.brandl | 2006-09-30 11:13:21 +0200 (Sat, 30 Sep 2006) | 3 lines Bug #1566602: correct failure of posixpath unittest when $HOME ends with a slash. ........ r52068 | georg.brandl | 2006-09-30 12:58:01 +0200 (Sat, 30 Sep 2006) | 3 lines Bug #1457823: cgi.(Sv)FormContentDict's constructor now takes keep_blank_values and strict_parsing keyword arguments. ........ r52069 | georg.brandl | 2006-09-30 13:06:47 +0200 (Sat, 30 Sep 2006) | 3 lines Bug #1560617: in pyclbr, return full module name not only for classes, but also for functions. ........ r52072 | georg.brandl | 2006-09-30 13:17:34 +0200 (Sat, 30 Sep 2006) | 3 lines Bug #1556784: allow format strings longer than 127 characters in datetime's strftime function. ........ r52075 | georg.brandl | 2006-09-30 13:22:28 +0200 (Sat, 30 Sep 2006) | 3 lines Bug #1446043: correctly raise a LookupError if an encoding name given to encodings.search_function() contains a dot. ........ r52078 | georg.brandl | 2006-09-30 14:02:57 +0200 (Sat, 30 Sep 2006) | 3 lines Bug #1546052: clarify that PyString_FromString(AndSize) copies the string pointed to by its parameter. ........ r52080 | georg.brandl | 2006-09-30 14:16:03 +0200 (Sat, 30 Sep 2006) | 3 lines Convert test_import to unittest. ........ r52083 | kurt.kaiser | 2006-10-01 23:16:45 +0200 (Sun, 01 Oct 2006) | 5 lines Some syntax errors were being caught by tokenize during the tabnanny check, resulting in obscure error messages. Do the syntax check first. Bug 1562716, 1562719 ........ r52084 | kurt.kaiser | 2006-10-01 23:54:37 +0200 (Sun, 01 Oct 2006) | 3 lines Add comment explaining that error msgs may be due to user code when running w/o subprocess. ........ r52086 | martin.v.loewis | 2006-10-02 16:55:51 +0200 (Mon, 02 Oct 2006) | 3 lines Fix test for uintptr_t. Fixes #1568842. Will backport. ........ r52089 | martin.v.loewis | 2006-10-02 17:20:37 +0200 (Mon, 02 Oct 2006) | 3 lines Guard uintptr_t test with HAVE_STDINT_H, test for stdint.h. Will backport. ........ r52100 | vinay.sajip | 2006-10-03 20:02:37 +0200 (Tue, 03 Oct 2006) | 1 line Documentation omitted the additional parameter to LogRecord.__init__ which was added in 2.5. (See SF #1569622). ........ r52101 | vinay.sajip | 2006-10-03 20:20:26 +0200 (Tue, 03 Oct 2006) | 1 line Documentation clarified to mention optional parameters. ........ r52102 | vinay.sajip | 2006-10-03 20:21:56 +0200 (Tue, 03 Oct 2006) | 1 line Modified LogRecord.__init__ to make the func parameter optional. (See SF #1569622). ........ r52121 | brett.cannon | 2006-10-03 23:58:55 +0200 (Tue, 03 Oct 2006) | 2 lines Fix minor typo in a comment. ........ r52123 | brett.cannon | 2006-10-04 01:23:14 +0200 (Wed, 04 Oct 2006) | 2 lines Convert test_imp over to unittest. ........ r52128 | barry.warsaw | 2006-10-04 04:06:36 +0200 (Wed, 04 Oct 2006) | 3 lines decode_rfc2231(): As Christian Robottom Reis points out, it makes no sense to test for parts > 3 when we use .split(..., 2). ........ r52129 | jeremy.hylton | 2006-10-04 04:24:52 +0200 (Wed, 04 Oct 2006) | 9 lines Fix for SF bug 1569998: break permitted inside try. The compiler was checking that there was something on the fblock stack, but not that there was a loop on the stack. Fixed that and added a test for the specific syntax error. Bug fix candidate. ........ r52130 | martin.v.loewis | 2006-10-04 07:47:34 +0200 (Wed, 04 Oct 2006) | 4 lines Fix integer negation and absolute value to not rely on undefined behaviour of the C compiler anymore. Will backport to 2.5 and 2.4. ........ r52135 | martin.v.loewis | 2006-10-04 11:21:20 +0200 (Wed, 04 Oct 2006) | 1 line Forward port r52134: Add uuids for 2.4.4. ........ r52137 | armin.rigo | 2006-10-04 12:23:57 +0200 (Wed, 04 Oct 2006) | 3 lines Compilation problem caused by conflicting typedefs for uint32_t (unsigned long vs. unsigned int). ........ r52139 | armin.rigo | 2006-10-04 14:17:45 +0200 (Wed, 04 Oct 2006) | 23 lines Forward-port of r52136,52138: a review of overflow-detecting code. * unified the way intobject, longobject and mystrtoul handle values around -sys.maxint-1. * in general, trying to entierely avoid overflows in any computation involving signed ints or longs is extremely involved. Fixed a few simple cases where a compiler might be too clever (but that's all guesswork). * more overflow checks against bad data in marshal.c. * 2.5 specific: fixed a number of places that were still confusing int and Py_ssize_t. Some of them could potentially have caused "real-world" breakage. * list.pop(x): fixing overflow issues on x was messy. I just reverted to PyArg_ParseTuple("n"), which does the right thing. (An obscure test was trying to give a Decimal to list.pop()... doesn't make sense any more IMHO) * trying to write a few tests... ........ r52147 | andrew.kuchling | 2006-10-04 15:42:43 +0200 (Wed, 04 Oct 2006) | 6 lines Cause a PyObject_Malloc() failure to trigger a MemoryError, and then add 'if (PyErr_Occurred())' checks to various places so that NULL is returned properly. 2.4 backport candidate. ........ r52148 | martin.v.loewis | 2006-10-04 17:25:28 +0200 (Wed, 04 Oct 2006) | 1 line Add MSVC8 project files to create wininst-8.exe. ........ r52196 | brett.cannon | 2006-10-06 00:02:31 +0200 (Fri, 06 Oct 2006) | 7 lines Clarify what "re-initialization" means for init_builtin() and init_dynamic(). Also remove warning about re-initialization as possibly raising an execption as both call _PyImport_FindExtension() which pulls any module that was already imported from the Python process' extension cache and just copies the __dict__ into the module stored in sys.modules. ........ r52200 | fred.drake | 2006-10-06 02:03:45 +0200 (Fri, 06 Oct 2006) | 3 lines - update links - remove Sleepycat name now that they have been bought ........ r52204 | andrew.kuchling | 2006-10-06 12:41:01 +0200 (Fri, 06 Oct 2006) | 1 line Case fix ........ r52208 | georg.brandl | 2006-10-06 14:46:08 +0200 (Fri, 06 Oct 2006) | 3 lines Fix name. ........ r52211 | andrew.kuchling | 2006-10-06 15:18:26 +0200 (Fri, 06 Oct 2006) | 1 line [Bug #1545341] Allow 'classifier' parameter to be a tuple as well as a list. Will backport. ........ r52212 | armin.rigo | 2006-10-06 18:33:22 +0200 (Fri, 06 Oct 2006) | 4 lines A very minor bug fix: this code looks like it is designed to accept any hue value and do the modulo itself, except it doesn't quite do it in all cases. At least, the "cannot get here" comment was wrong. ........ r52213 | andrew.kuchling | 2006-10-06 20:51:55 +0200 (Fri, 06 Oct 2006) | 1 line Comment grammar ........ r52218 | skip.montanaro | 2006-10-07 13:05:02 +0200 (Sat, 07 Oct 2006) | 6 lines Note that the excel_tab class is registered as the "excel-tab" dialect. Fixes 1572471. Make a similar change for the excel class and clean up references to the Dialects and Formatting Parameters section in a few places. ........ r52221 | georg.brandl | 2006-10-08 09:11:54 +0200 (Sun, 08 Oct 2006) | 3 lines Add missing NEWS entry for rev. 52129. ........ r52223 | hyeshik.chang | 2006-10-08 15:48:34 +0200 (Sun, 08 Oct 2006) | 3 lines Bug #1572832: fix a bug in ISO-2022 codecs which may cause segfault when encoding non-BMP unicode characters. (Submitted by Ray Chason) ........ r52227 | ronald.oussoren | 2006-10-08 19:37:58 +0200 (Sun, 08 Oct 2006) | 4 lines Add version number to the link to the python documentation in /Developer/Documentation/Python, better for users that install multiple versions of python. ........ r52229 | ronald.oussoren | 2006-10-08 19:40:02 +0200 (Sun, 08 Oct 2006) | 2 lines Fix for bug #1570284 ........ r52233 | ronald.oussoren | 2006-10-08 19:49:52 +0200 (Sun, 08 Oct 2006) | 6 lines MacOSX: distutils changes the values of BASECFLAGS and LDFLAGS when using a universal build of python on OSX 10.3 to ensure that those flags can be used to compile code (the universal build uses compiler flags that aren't supported on 10.3). This patches gives the same treatment to CFLAGS, PY_CFLAGS and BLDSHARED. ........ r52236 | ronald.oussoren | 2006-10-08 19:51:46 +0200 (Sun, 08 Oct 2006) | 5 lines MacOSX: The universal build requires that users have the MacOSX10.4u SDK installed to build extensions. This patch makes distutils emit a warning when the compiler should use an SDK but that SDK is not installed, hopefully reducing some confusion. ........ r52238 | ronald.oussoren | 2006-10-08 20:18:26 +0200 (Sun, 08 Oct 2006) | 3 lines MacOSX: add more logic to recognize the correct startup file to patch to the shell profile patching post-install script. ........ r52242 | andrew.kuchling | 2006-10-09 19:10:12 +0200 (Mon, 09 Oct 2006) | 1 line Add news item for rev. 52211 change ........ r52245 | andrew.kuchling | 2006-10-09 20:05:19 +0200 (Mon, 09 Oct 2006) | 1 line Fix wording in comment ........ r52251 | georg.brandl | 2006-10-09 21:03:06 +0200 (Mon, 09 Oct 2006) | 2 lines Patch #1572724: fix typo ('=' instead of '==') in _msi.c. ........ r52255 | barry.warsaw | 2006-10-09 21:43:24 +0200 (Mon, 09 Oct 2006) | 2 lines List gc.get_count() in the module docstring. ........ r52257 | martin.v.loewis | 2006-10-09 22:44:25 +0200 (Mon, 09 Oct 2006) | 1 line Bug #1565150: Fix subsecond processing for os.utime on Windows. ........ r52268 | ronald.oussoren | 2006-10-10 09:55:06 +0200 (Tue, 10 Oct 2006) | 2 lines MacOSX: fix permission problem in the generated installer ........ r52293 | georg.brandl | 2006-10-12 09:38:04 +0200 (Thu, 12 Oct 2006) | 2 lines Bug #1575746: fix typo in property() docs. ........ r52295 | georg.brandl | 2006-10-12 09:57:21 +0200 (Thu, 12 Oct 2006) | 3 lines Bug #813342: Start the IDLE subprocess with -Qnew if the parent is started with that option. ........ r52297 | georg.brandl | 2006-10-12 10:22:53 +0200 (Thu, 12 Oct 2006) | 2 lines Bug #1565919: document set types in the Language Reference. ........ r52299 | georg.brandl | 2006-10-12 11:20:33 +0200 (Thu, 12 Oct 2006) | 3 lines Bug #1550524: better heuristics to find correct class definition in inspect.findsource(). ........ r52301 | georg.brandl | 2006-10-12 11:47:12 +0200 (Thu, 12 Oct 2006) | 4 lines Bug #1548891: The cStringIO.StringIO() constructor now encodes unicode arguments with the system default encoding just like the write() method does, instead of converting it to a raw buffer. ........ r52303 | georg.brandl | 2006-10-12 13:14:40 +0200 (Thu, 12 Oct 2006) | 2 lines Bug #1546628: add a note about urlparse.urljoin() and absolute paths. ........ r52305 | georg.brandl | 2006-10-12 13:27:59 +0200 (Thu, 12 Oct 2006) | 3 lines Bug #1545497: when given an explicit base, int() did ignore NULs embedded in the string to convert. ........ r52307 | georg.brandl | 2006-10-12 13:41:11 +0200 (Thu, 12 Oct 2006) | 3 lines Add a note to fpectl docs that it's not built by default (bug #1556261). ........ r52309 | georg.brandl | 2006-10-12 13:46:57 +0200 (Thu, 12 Oct 2006) | 3 lines Bug #1560114: the Mac filesystem does have accurate information about the case of filenames. ........ r52311 | georg.brandl | 2006-10-12 13:59:27 +0200 (Thu, 12 Oct 2006) | 2 lines Small grammar fix, thanks Sjoerd. ........ r52313 | georg.brandl | 2006-10-12 14:03:07 +0200 (Thu, 12 Oct 2006) | 2 lines Fix tarfile depending on buggy int('1\0', base) behavior. ........ r52315 | georg.brandl | 2006-10-12 14:33:07 +0200 (Thu, 12 Oct 2006) | 2 lines Bug #1283491: follow docstring convention wrt. keyword-able args in sum(). ........ r52316 | georg.brandl | 2006-10-12 15:08:16 +0200 (Thu, 12 Oct 2006) | 3 lines Bug #1560179: speed up posixpath.(dir|base)name ........ r52327 | brett.cannon | 2006-10-14 08:36:45 +0200 (Sat, 14 Oct 2006) | 3 lines Clean up the language of a sentence relating to the connect() function and user-defined datatypes. ........ r52332 | neal.norwitz | 2006-10-14 23:33:38 +0200 (Sat, 14 Oct 2006) | 3 lines Update the peephole optimizer to remove more dead code (jumps after returns) and inline jumps to returns. ........ r52333 | martin.v.loewis | 2006-10-15 09:54:40 +0200 (Sun, 15 Oct 2006) | 4 lines Patch #1576954: Update VC6 build directory; remove redundant files in VC7. Will backport to 2.5. ........ r52335 | martin.v.loewis | 2006-10-15 10:43:33 +0200 (Sun, 15 Oct 2006) | 1 line Patch #1576166: Support os.utime for directories on Windows NT+. ........ r52336 | martin.v.loewis | 2006-10-15 10:51:22 +0200 (Sun, 15 Oct 2006) | 2 lines Patch #1577551: Add ctypes and ET build support for VC6. Will backport to 2.5. ........ r52338 | martin.v.loewis | 2006-10-15 11:35:51 +0200 (Sun, 15 Oct 2006) | 1 line Loosen the test for equal time stamps. ........ r52339 | martin.v.loewis | 2006-10-15 11:43:39 +0200 (Sun, 15 Oct 2006) | 2 lines Bug #1567666: Emulate GetFileAttributesExA for Win95. Will backport to 2.5. ........ r52341 | martin.v.loewis | 2006-10-15 13:02:07 +0200 (Sun, 15 Oct 2006) | 2 lines Round to int, because some systems support sub-second time stamps in stat, but not in utime. Also be consistent with modifying only mtime, not atime. ........ r52342 | martin.v.loewis | 2006-10-15 13:57:40 +0200 (Sun, 15 Oct 2006) | 2 lines Set the eol-style for project files to "CRLF". ........ r52343 | martin.v.loewis | 2006-10-15 13:59:56 +0200 (Sun, 15 Oct 2006) | 3 lines Drop binary property on dsp files, set eol-style to CRLF instead. ........ r52344 | martin.v.loewis | 2006-10-15 14:01:43 +0200 (Sun, 15 Oct 2006) | 2 lines Remove binary property, set eol-style to CRLF instead. ........ r52346 | martin.v.loewis | 2006-10-15 16:30:38 +0200 (Sun, 15 Oct 2006) | 2 lines Mention the bdist_msi module. Will backport to 2.5. ........ r52354 | brett.cannon | 2006-10-16 05:09:52 +0200 (Mon, 16 Oct 2006) | 3 lines Fix turtle so that you can launch the demo2 function on its own instead of only when the module is launched as a script. ........ r52356 | martin.v.loewis | 2006-10-17 17:18:06 +0200 (Tue, 17 Oct 2006) | 2 lines Patch #1457736: Update VC6 to use current PCbuild settings. Will backport to 2.5. ........ r52360 | martin.v.loewis | 2006-10-17 20:09:55 +0200 (Tue, 17 Oct 2006) | 2 lines Remove obsolete file. Will backport. ........ r52363 | martin.v.loewis | 2006-10-17 20:59:23 +0200 (Tue, 17 Oct 2006) | 4 lines Forward-port r52358: - Bug #1578513: Cross compilation was broken by a change to configure. Repair so that it's back to how it was in 2.4.3. ........ r52365 | thomas.heller | 2006-10-17 21:30:48 +0200 (Tue, 17 Oct 2006) | 6 lines ctypes callback functions only support 'fundamental' result types. Check this and raise an error when something else is used - before this change ctypes would hang or crash when such a callback was called. This is a partial fix for #1574584. Will backport to release25-maint. ........ r52377 | tim.peters | 2006-10-18 07:06:06 +0200 (Wed, 18 Oct 2006) | 2 lines newIobject(): repaired incorrect cast to quiet MSVC warning. ........ r52378 | tim.peters | 2006-10-18 07:09:12 +0200 (Wed, 18 Oct 2006) | 2 lines Whitespace normalization. ........ r52379 | tim.peters | 2006-10-18 07:10:28 +0200 (Wed, 18 Oct 2006) | 2 lines Add missing svn:eol-style to text files. ........ r52387 | martin.v.loewis | 2006-10-19 12:58:46 +0200 (Thu, 19 Oct 2006) | 3 lines Add check for the PyArg_ParseTuple format, and declare it if it is supported. ........ r52388 | martin.v.loewis | 2006-10-19 13:00:37 +0200 (Thu, 19 Oct 2006) | 3 lines Fix various minor errors in passing arguments to PyArg_ParseTuple. ........ r52389 | martin.v.loewis | 2006-10-19 18:01:37 +0200 (Thu, 19 Oct 2006) | 2 lines Restore CFLAGS after checking for __attribute__ ........ r52390 | andrew.kuchling | 2006-10-19 23:55:55 +0200 (Thu, 19 Oct 2006) | 1 line [Bug #1576348] Fix typo in example ........ r52414 | walter.doerwald | 2006-10-22 10:59:41 +0200 (Sun, 22 Oct 2006) | 2 lines Port test___future__ to unittest. ........ r52415 | ronald.oussoren | 2006-10-22 12:45:18 +0200 (Sun, 22 Oct 2006) | 3 lines Patch #1580674: with this patch os.readlink uses the filesystem encoding to decode unicode objects and returns an unicode object when the argument is one. ........ r52416 | martin.v.loewis | 2006-10-22 12:46:18 +0200 (Sun, 22 Oct 2006) | 3 lines Patch #1580872: Remove duplicate declaration of PyCallable_Check. Will backport to 2.5. ........ r52418 | martin.v.loewis | 2006-10-22 12:55:15 +0200 (Sun, 22 Oct 2006) | 4 lines - Patch #1560695: Add .note.GNU-stack to ctypes' sysv.S so that ctypes isn't considered as requiring executable stacks. Will backport to 2.5. ........ r52420 | martin.v.loewis | 2006-10-22 15:45:13 +0200 (Sun, 22 Oct 2006) | 3 lines Remove passwd.adjunct.byname from list of maps for test_nis. Will backport to 2.5. ........ r52431 | georg.brandl | 2006-10-24 18:54:16 +0200 (Tue, 24 Oct 2006) | 2 lines Patch [ 1583506 ] tarfile.py: 100-char filenames are truncated ........ r52446 | andrew.kuchling | 2006-10-26 21:10:46 +0200 (Thu, 26 Oct 2006) | 1 line [Bug #1579796] Wrong syntax for PyDateTime_IMPORT in documentation. Reported by David Faure. ........ r52449 | andrew.kuchling | 2006-10-26 21:16:46 +0200 (Thu, 26 Oct 2006) | 1 line Typo fix ........ r52452 | martin.v.loewis | 2006-10-27 08:16:31 +0200 (Fri, 27 Oct 2006) | 3 lines Patch #1549049: Rewrite type conversion in structmember. Fixes #1545696 and #1566140. Will backport to 2.5. ........ r52454 | martin.v.loewis | 2006-10-27 08:42:27 +0200 (Fri, 27 Oct 2006) | 2 lines Check for values.h. Will backport. ........ r52456 | martin.v.loewis | 2006-10-27 09:06:52 +0200 (Fri, 27 Oct 2006) | 2 lines Get DBL_MAX from float.h not values.h. Will backport. ........ r52458 | martin.v.loewis | 2006-10-27 09:13:28 +0200 (Fri, 27 Oct 2006) | 2 lines Patch #1567274: Support SMTP over TLS. ........ r52459 | andrew.kuchling | 2006-10-27 13:33:29 +0200 (Fri, 27 Oct 2006) | 1 line Set svn:keywords property ........ r52460 | andrew.kuchling | 2006-10-27 13:36:41 +0200 (Fri, 27 Oct 2006) | 1 line Add item ........ r52461 | andrew.kuchling | 2006-10-27 13:37:01 +0200 (Fri, 27 Oct 2006) | 1 line Some wording changes and markup fixes ........ r52462 | andrew.kuchling | 2006-10-27 14:18:38 +0200 (Fri, 27 Oct 2006) | 1 line [Bug #1585690] Note that line_num was added in Python 2.5 ........ r52464 | andrew.kuchling | 2006-10-27 14:50:38 +0200 (Fri, 27 Oct 2006) | 1 line [Bug #1583946] Reword description of server and issuer ........ r52466 | andrew.kuchling | 2006-10-27 15:06:25 +0200 (Fri, 27 Oct 2006) | 1 line [Bug #1562583] Mention the set_reuse_addr() method ........ r52469 | andrew.kuchling | 2006-10-27 15:22:46 +0200 (Fri, 27 Oct 2006) | 4 lines [Bug #1542016] Report PCALL_POP value. This makes the return value of sys.callstats() match its docstring. Backport candidate. Though it's an API change, this is a pretty obscure portion of the API. ........ r52473 | andrew.kuchling | 2006-10-27 16:53:41 +0200 (Fri, 27 Oct 2006) | 1 line Point users to the subprocess module in the docs for os.system, os.spawn*, os.popen2, and the popen2 and commands modules ........ r52476 | andrew.kuchling | 2006-10-27 18:39:10 +0200 (Fri, 27 Oct 2006) | 1 line [Bug #1576241] Let functools.wraps work with built-in functions ........ r52478 | andrew.kuchling | 2006-10-27 18:55:34 +0200 (Fri, 27 Oct 2006) | 1 line [Bug #1575506] The _singlefileMailbox class was using the wrong file object in its flush() method, causing an error ........ r52480 | andrew.kuchling | 2006-10-27 19:06:16 +0200 (Fri, 27 Oct 2006) | 1 line Clarify docstring ........ r52481 | andrew.kuchling | 2006-10-27 19:11:23 +0200 (Fri, 27 Oct 2006) | 5 lines [Patch #1574068 by Scott Dial] urllib and urllib2 were using base64.encodestring() for encoding authentication data. encodestring() can include newlines for very long input, which produced broken HTTP headers. ........ r52483 | andrew.kuchling | 2006-10-27 20:13:46 +0200 (Fri, 27 Oct 2006) | 1 line Check db_setup_debug for a few print statements; change sqlite_setup_debug to False ........ r52484 | andrew.kuchling | 2006-10-27 20:15:02 +0200 (Fri, 27 Oct 2006) | 1 line [Patch #1503717] Tiny patch from Chris AtLee to stop a lengthy line from being printed ........ r52485 | thomas.heller | 2006-10-27 20:31:36 +0200 (Fri, 27 Oct 2006) | 5 lines WindowsError.str should display the windows error code, not the posix error code; with test. Fixes #1576174. Will backport to release25-maint. ........ r52487 | thomas.heller | 2006-10-27 21:05:53 +0200 (Fri, 27 Oct 2006) | 4 lines Modulefinder now handles absolute and relative imports, including tests. Will backport to release25-maint. ........ r52488 | georg.brandl | 2006-10-27 22:39:43 +0200 (Fri, 27 Oct 2006) | 2 lines Patch #1552024: add decorator support to unparse.py demo script. ........ r52492 | walter.doerwald | 2006-10-28 12:47:12 +0200 (Sat, 28 Oct 2006) | 2 lines Port test_bufio to unittest. ........ r52493 | georg.brandl | 2006-10-28 15:10:17 +0200 (Sat, 28 Oct 2006) | 6 lines Convert test_global, test_scope and test_grammar to unittest. I tried to enclose all tests which must be run at the toplevel (instead of inside a method) in exec statements. ........ r52494 | georg.brandl | 2006-10-28 15:11:41 +0200 (Sat, 28 Oct 2006) | 3 lines Update outstanding bugs test file. ........ r52495 | georg.brandl | 2006-10-28 15:51:49 +0200 (Sat, 28 Oct 2006) | 3 lines Convert test_math to unittest. ........ r52496 | georg.brandl | 2006-10-28 15:56:58 +0200 (Sat, 28 Oct 2006) | 3 lines Convert test_opcodes to unittest. ........ r52497 | georg.brandl | 2006-10-28 18:04:04 +0200 (Sat, 28 Oct 2006) | 2 lines Fix nth() itertool recipe. ........ r52500 | georg.brandl | 2006-10-28 22:25:09 +0200 (Sat, 28 Oct 2006) | 2 lines make test_grammar pass with python -O ........ r52501 | neal.norwitz | 2006-10-28 23:15:30 +0200 (Sat, 28 Oct 2006) | 6 lines Add some asserts. In sysmodule, I think these were to try to silence some warnings from Klokwork. They verify the assumptions of the format of svn version output. The assert in the thread module helped debug a problem on HP-UX. ........ r52502 | neal.norwitz | 2006-10-28 23:16:54 +0200 (Sat, 28 Oct 2006) | 5 lines Fix warnings with HP's C compiler. It doesn't recognize that infinite loops are, um, infinite. These conditions should not be able to happen. Will backport. ........ r52503 | neal.norwitz | 2006-10-28 23:17:51 +0200 (Sat, 28 Oct 2006) | 5 lines Fix crash in test on HP-UX. Apparently, it's not possible to delete a lock if it's held (even by the current thread). Will backport. ........ r52504 | neal.norwitz | 2006-10-28 23:19:07 +0200 (Sat, 28 Oct 2006) | 6 lines Fix bug #1565514, SystemError not raised on too many nested blocks. It seems like this should be a different error than SystemError, but I don't have any great ideas and SystemError was raised in 2.4 and earlier. Will backport. ........ r52505 | neal.norwitz | 2006-10-28 23:20:12 +0200 (Sat, 28 Oct 2006) | 4 lines Prevent crash if alloc of garbage fails. Found by Typo.pl. Will backport. ........ r52506 | neal.norwitz | 2006-10-28 23:21:00 +0200 (Sat, 28 Oct 2006) | 4 lines Don't inline Py_ADDRESS_IN_RANGE with gcc 4+ either. Will backport. ........ r52513 | neal.norwitz | 2006-10-28 23:56:49 +0200 (Sat, 28 Oct 2006) | 2 lines Fix test_modulefinder so it doesn't fail when run after test_distutils. ........ r52514 | neal.norwitz | 2006-10-29 00:12:26 +0200 (Sun, 29 Oct 2006) | 4 lines From SF 1557890, fix problem of using wrong type in example. Will backport. ........ r52517 | georg.brandl | 2006-10-29 09:39:22 +0100 (Sun, 29 Oct 2006) | 4 lines Fix codecs.EncodedFile which did not use file_encoding in 2.5.0, and fix all codecs file wrappers to work correctly with the "with" statement (bug #1586513). ........ r52519 | georg.brandl | 2006-10-29 09:47:08 +0100 (Sun, 29 Oct 2006) | 3 lines Clean up a leftover from old listcomp generation code. ........ r52520 | georg.brandl | 2006-10-29 09:53:06 +0100 (Sun, 29 Oct 2006) | 4 lines Bug #1586448: the compiler module now emits the same bytecode for list comprehensions as the builtin compiler, using the LIST_APPEND opcode. ........ r52521 | georg.brandl | 2006-10-29 10:01:01 +0100 (Sun, 29 Oct 2006) | 3 lines Remove trailing comma. ........ r52522 | georg.brandl | 2006-10-29 10:05:04 +0100 (Sun, 29 Oct 2006) | 3 lines Bug #1357915: allow all sequence types for shell arguments in subprocess. ........ r52524 | georg.brandl | 2006-10-29 10:16:12 +0100 (Sun, 29 Oct 2006) | 3 lines Patch #1583880: fix tarfile's problems with long names and posix/ GNU modes. ........ r52526 | georg.brandl | 2006-10-29 10:18:00 +0100 (Sun, 29 Oct 2006) | 3 lines Test assert if __debug__ is true. ........ r52527 | georg.brandl | 2006-10-29 10:32:16 +0100 (Sun, 29 Oct 2006) | 2 lines Fix the new EncodedFile test to work with big endian platforms. ........ r52529 | georg.brandl | 2006-10-29 15:39:09 +0100 (Sun, 29 Oct 2006) | 2 lines Bug #1586613: fix zlib and bz2 codecs' incremental en/decoders. ........ r52532 | georg.brandl | 2006-10-29 19:01:08 +0100 (Sun, 29 Oct 2006) | 2 lines Bug #1586773: extend hashlib docstring. ........ r52534 | neal.norwitz | 2006-10-29 19:30:10 +0100 (Sun, 29 Oct 2006) | 4 lines Update comments, remove commented out code. Move assembler structure next to assembler code to make it easier to move it to a separate file. ........ r52535 | georg.brandl | 2006-10-29 19:31:42 +0100 (Sun, 29 Oct 2006) | 3 lines Bug #1576657: when setting a KeyError for a tuple key, make sure that the tuple isn't used as the "exception arguments tuple". ........ r52537 | georg.brandl | 2006-10-29 20:13:40 +0100 (Sun, 29 Oct 2006) | 3 lines Convert test_mmap to unittest. ........ r52538 | georg.brandl | 2006-10-29 20:20:45 +0100 (Sun, 29 Oct 2006) | 3 lines Convert test_poll to unittest. ........ r52539 | georg.brandl | 2006-10-29 20:24:43 +0100 (Sun, 29 Oct 2006) | 3 lines Convert test_nis to unittest. ........ r52540 | georg.brandl | 2006-10-29 20:35:03 +0100 (Sun, 29 Oct 2006) | 3 lines Convert test_types to unittest. ........ r52541 | georg.brandl | 2006-10-29 20:51:16 +0100 (Sun, 29 Oct 2006) | 3 lines Convert test_cookie to unittest. ........ r52542 | georg.brandl | 2006-10-29 21:09:12 +0100 (Sun, 29 Oct 2006) | 3 lines Convert test_cgi to unittest. ........ r52543 | georg.brandl | 2006-10-29 21:24:01 +0100 (Sun, 29 Oct 2006) | 3 lines Completely convert test_httplib to unittest. ........ r52544 | georg.brandl | 2006-10-29 21:28:26 +0100 (Sun, 29 Oct 2006) | 2 lines Convert test_MimeWriter to unittest. ........ r52545 | georg.brandl | 2006-10-29 21:31:17 +0100 (Sun, 29 Oct 2006) | 3 lines Convert test_openpty to unittest. ........ r52546 | georg.brandl | 2006-10-29 21:35:12 +0100 (Sun, 29 Oct 2006) | 3 lines Remove leftover test output file. ........ r52547 | georg.brandl | 2006-10-29 22:54:18 +0100 (Sun, 29 Oct 2006) | 3 lines Move the check for openpty to the beginning. ........ r52548 | walter.doerwald | 2006-10-29 23:06:28 +0100 (Sun, 29 Oct 2006) | 2 lines Add tests for basic argument errors. ........ r52549 | walter.doerwald | 2006-10-30 00:02:27 +0100 (Mon, 30 Oct 2006) | 3 lines Add tests for incremental codecs with an errors argument. ........ r52550 | neal.norwitz | 2006-10-30 00:39:03 +0100 (Mon, 30 Oct 2006) | 1 line Fix refleak ........ r52552 | neal.norwitz | 2006-10-30 00:58:36 +0100 (Mon, 30 Oct 2006) | 1 line I'm assuming this is correct, it fixes the tests so they pass again ........ r52555 | vinay.sajip | 2006-10-31 18:32:37 +0100 (Tue, 31 Oct 2006) | 1 line Change to improve speed of _fixupChildren ........ r52556 | vinay.sajip | 2006-10-31 18:34:31 +0100 (Tue, 31 Oct 2006) | 1 line Added relativeCreated to Formatter doc (has been in the system for a long time - was unaccountably left out of the docs and not noticed until now). ........ r52588 | thomas.heller | 2006-11-02 20:48:24 +0100 (Thu, 02 Nov 2006) | 5 lines Replace the XXX marker in the 'Arrays and pointers' reference manual section with a link to the tutorial sections. Will backport to release25-maint. ........ r52592 | thomas.heller | 2006-11-02 21:22:29 +0100 (Thu, 02 Nov 2006) | 6 lines Fix a code example by adding a missing import. Fixes #1557890. Will backport to release25-maint. ........ r52598 | tim.peters | 2006-11-03 03:32:46 +0100 (Fri, 03 Nov 2006) | 2 lines Whitespace normalization. ........ r52619 | martin.v.loewis | 2006-11-04 19:14:06 +0100 (Sat, 04 Nov 2006) | 4 lines - Patch #1060577: Extract list of RPM files from spec file in bdist_rpm Will backport to 2.5. ........ r52621 | neal.norwitz | 2006-11-04 20:25:22 +0100 (Sat, 04 Nov 2006) | 4 lines Bug #1588287: fix invalid assertion for `1,2` in debug builds. Will backport ........ r52630 | andrew.kuchling | 2006-11-05 22:04:37 +0100 (Sun, 05 Nov 2006) | 1 line Update link ........ r52631 | skip.montanaro | 2006-11-06 15:34:52 +0100 (Mon, 06 Nov 2006) | 1 line note that user can control directory location even if default dir is used ........ r52644 | ronald.oussoren | 2006-11-07 16:53:38 +0100 (Tue, 07 Nov 2006) | 2 lines Fix a number of typos in strings and comments (sf#1589070) ........ r52647 | ronald.oussoren | 2006-11-07 17:00:34 +0100 (Tue, 07 Nov 2006) | 2 lines Whitespace changes to make the source more compliant with PEP8 (SF#1589070) ........ r52651 | thomas.heller | 2006-11-07 19:01:18 +0100 (Tue, 07 Nov 2006) | 3 lines Fix markup. Will backport to release25-maint. ........ r52653 | thomas.heller | 2006-11-07 19:20:47 +0100 (Tue, 07 Nov 2006) | 3 lines Fix grammatical error as well. Will backport to release25-maint. ........ r52657 | andrew.kuchling | 2006-11-07 21:39:16 +0100 (Tue, 07 Nov 2006) | 1 line Add missing word ........ r52662 | martin.v.loewis | 2006-11-08 07:46:37 +0100 (Wed, 08 Nov 2006) | 4 lines Correctly forward exception in instance_contains(). Fixes #1591996. Patch contributed by Neal Norwitz. Will backport. ........ r52664 | martin.v.loewis | 2006-11-08 07:48:36 +0100 (Wed, 08 Nov 2006) | 2 lines News entry for 52662. ........ r52665 | martin.v.loewis | 2006-11-08 08:35:55 +0100 (Wed, 08 Nov 2006) | 2 lines Patch #1351744: Add askyesnocancel helper for tkMessageBox. ........ r52666 | georg.brandl | 2006-11-08 08:45:59 +0100 (Wed, 08 Nov 2006) | 2 lines Patch #1592072: fix docs for return value of PyErr_CheckSignals. ........ r52668 | georg.brandl | 2006-11-08 11:04:29 +0100 (Wed, 08 Nov 2006) | 3 lines Bug #1592533: rename variable in heapq doc example, to avoid shadowing "sorted". ........ r52671 | andrew.kuchling | 2006-11-08 14:35:34 +0100 (Wed, 08 Nov 2006) | 1 line Add section on the functional module ........ r52672 | andrew.kuchling | 2006-11-08 15:14:30 +0100 (Wed, 08 Nov 2006) | 1 line Add section on operator module; make a few edits ........ r52673 | andrew.kuchling | 2006-11-08 15:24:03 +0100 (Wed, 08 Nov 2006) | 1 line Add table of contents; this required fixing a few headings. Some more smalle edits. ........ r52674 | andrew.kuchling | 2006-11-08 15:30:14 +0100 (Wed, 08 Nov 2006) | 1 line More edits ........ r52686 | martin.v.loewis | 2006-11-09 12:06:03 +0100 (Thu, 09 Nov 2006) | 3 lines Patch #838546: Make terminal become controlling in pty.fork(). Will backport to 2.5. ........ r52688 | martin.v.loewis | 2006-11-09 12:27:32 +0100 (Thu, 09 Nov 2006) | 2 lines Patch #1592250: Add elidge argument to Tkinter.Text.search. ........ r52690 | andrew.kuchling | 2006-11-09 14:27:07 +0100 (Thu, 09 Nov 2006) | 7 lines [Bug #1569790] mailbox.Maildir.get_folder() loses factory information Both the Maildir and MH classes had this bug; the patch fixes both classes and adds a test. Will backport to 25-maint. ........ r52692 | andrew.kuchling | 2006-11-09 14:51:14 +0100 (Thu, 09 Nov 2006) | 1 line [Patch #1514544 by David Watson] use fsync() to ensure data is really on disk ........ r52695 | walter.doerwald | 2006-11-09 17:23:26 +0100 (Thu, 09 Nov 2006) | 2 lines Replace C++ comment with C comment (fixes SF bug #1593525). ........ r52712 | andrew.kuchling | 2006-11-09 22:16:46 +0100 (Thu, 09 Nov 2006) | 11 lines [Patch #1514543] mailbox (Maildir): avoid losing messages on name clash Two changes: Where possible, use link()/remove() to move files into a directory; this makes it easier to avoid overwriting an existing file. Use _create_carefully() to create files in tmp/, which uses O_EXCL. Backport candidate. ........ r52716 | phillip.eby | 2006-11-10 01:33:36 +0100 (Fri, 10 Nov 2006) | 4 lines Fix SF#1566719: not creating site-packages (or other target directory) when installing .egg-info for a project that contains no modules or packages, while using --root (as in bdist_rpm). ........ r52719 | andrew.kuchling | 2006-11-10 14:14:01 +0100 (Fri, 10 Nov 2006) | 1 line Reword entry ........ r52725 | andrew.kuchling | 2006-11-10 15:39:01 +0100 (Fri, 10 Nov 2006) | 1 line [Feature request #1542920] Link to wsgi.org ........ r52731 | georg.brandl | 2006-11-11 19:29:11 +0100 (Sat, 11 Nov 2006) | 2 lines Bug #1594742: wrong word in stringobject doc. ........ r52733 | georg.brandl | 2006-11-11 19:32:47 +0100 (Sat, 11 Nov 2006) | 2 lines Bug #1594758: wording improvement for dict.update() docs. ........ r52736 | martin.v.loewis | 2006-11-12 11:32:47 +0100 (Sun, 12 Nov 2006) | 3 lines Patch #1065257: Support passing open files as body in HTTPConnection.request(). ........ r52737 | martin.v.loewis | 2006-11-12 11:41:39 +0100 (Sun, 12 Nov 2006) | 2 lines Patch #1355023: support whence argument for GzipFile.seek. ........ r52738 | martin.v.loewis | 2006-11-12 19:24:26 +0100 (Sun, 12 Nov 2006) | 2 lines Bug #1067760: Deprecate passing floats to file.seek. ........ r52739 | martin.v.loewis | 2006-11-12 19:48:13 +0100 (Sun, 12 Nov 2006) | 3 lines Patch #1359217: Ignore 2xx response before 150 response. Will backport to 2.5. ........ r52741 | martin.v.loewis | 2006-11-12 19:56:03 +0100 (Sun, 12 Nov 2006) | 4 lines Patch #1360200: Use unmangled_version RPM spec field to deal with file name mangling. Will backport to 2.5. ........ r52753 | walter.doerwald | 2006-11-15 17:23:46 +0100 (Wed, 15 Nov 2006) | 2 lines Fix typo. ........ r52754 | georg.brandl | 2006-11-15 18:42:03 +0100 (Wed, 15 Nov 2006) | 2 lines Bug #1594809: add a note to README regarding PYTHONPATH and make install. ........ r52762 | georg.brandl | 2006-11-16 16:05:14 +0100 (Thu, 16 Nov 2006) | 2 lines Bug #1597576: mention that the new base64 api has been introduced in py2.4. ........ r52764 | georg.brandl | 2006-11-16 17:50:59 +0100 (Thu, 16 Nov 2006) | 3 lines Bug #1597824: return the registered function from atexit.register() to facilitate usage as a decorator. ........ r52765 | georg.brandl | 2006-11-16 18:08:45 +0100 (Thu, 16 Nov 2006) | 4 lines Bug #1588217: don't parse "= " as a soft line break in binascii's a2b_qp() function, instead leave it in the string as quopri.decode() does. ........ r52776 | andrew.kuchling | 2006-11-17 14:30:25 +0100 (Fri, 17 Nov 2006) | 17 lines Remove file-locking in MH.pack() method. This change looks massive but it's mostly a re-indenting after removing some try...finally blocks. Also adds a test case that does a pack() while the mailbox is locked; this test would have turned up bugs in the original code on some platforms. In both nmh and GNU Mailutils' implementation of MH-format mailboxes, no locking is done of individual message files when renaming them. The original mailbox.py code did do locking, which meant that message files had to be opened. This code was buggy on certain platforms (found through reading the code); there were code paths that closed the file object and then called _unlock_file() on it. Will backport to 25-maint once I see how the buildbots react to this patch. ........ r52780 | martin.v.loewis | 2006-11-18 19:00:23 +0100 (Sat, 18 Nov 2006) | 5 lines Patch #1538878: Don't make tkSimpleDialog dialogs transient if the parent window is withdrawn. This mirrors what dialog.tcl does. Will backport to 2.5. ........ r52782 | martin.v.loewis | 2006-11-18 19:05:35 +0100 (Sat, 18 Nov 2006) | 4 lines Patch #1594554: Always close a tkSimpleDialog on ok(), even if an exception occurs. Will backport to 2.5. ........ r52784 | martin.v.loewis | 2006-11-18 19:42:11 +0100 (Sat, 18 Nov 2006) | 3 lines Patch #1472877: Fix Tix subwidget name resolution. Will backport to 2.5. ........ r52786 | andrew.kuchling | 2006-11-18 23:17:33 +0100 (Sat, 18 Nov 2006) | 1 line Expand checking in test_sha ........ r52787 | georg.brandl | 2006-11-19 09:48:30 +0100 (Sun, 19 Nov 2006) | 3 lines Patch [ 1586791 ] better error msgs for some TypeErrors ........ r52788 | martin.v.loewis | 2006-11-19 11:41:41 +0100 (Sun, 19 Nov 2006) | 4 lines Make cStringIO.truncate raise IOError for negative arguments (even for -1). Fixes the last bit of #1359365. ........ r52789 | andrew.kuchling | 2006-11-19 19:40:01 +0100 (Sun, 19 Nov 2006) | 1 line Add a test case of data w/ bytes > 127 ........ r52790 | martin.v.loewis | 2006-11-19 19:51:54 +0100 (Sun, 19 Nov 2006) | 3 lines Patch #1070046: Marshal new-style objects like InstanceType in xmlrpclib. ........ r52792 | neal.norwitz | 2006-11-19 22:26:53 +0100 (Sun, 19 Nov 2006) | 4 lines Speed up function calls into the math module by using METH_O. There should be no functional changes. However, the error msgs are slightly different. Also verified that the module dict is not NULL on init. ........ r52794 | george.yoshida | 2006-11-20 03:24:48 +0100 (Mon, 20 Nov 2006) | 2 lines markup fix ........ r52795 | georg.brandl | 2006-11-20 08:12:58 +0100 (Mon, 20 Nov 2006) | 3 lines Further markup fix. ........ r52800 | andrew.kuchling | 2006-11-20 14:39:37 +0100 (Mon, 20 Nov 2006) | 2 lines Jython compatibility fix: if uu.decode() opened its output file, be sure to close it. ........ r52811 | neal.norwitz | 2006-11-21 06:26:22 +0100 (Tue, 21 Nov 2006) | 9 lines Bug #1599782: Fix segfault on bsddb.db.DB().type(). The problem is that _DB_get_type() can't be called without the GIL because it calls a bunch of PyErr_* APIs when an error occurs. There were no other cases in this file that it was called without the GIL. Removing the BEGIN/END THREAD around _DB_get_type() made everything work. Will backport. ........ r52814 | neal.norwitz | 2006-11-21 06:51:51 +0100 (Tue, 21 Nov 2006) | 1 line Oops, convert tabs to spaces ........ r52815 | neal.norwitz | 2006-11-21 07:23:44 +0100 (Tue, 21 Nov 2006) | 1 line Fix SF #1599879, socket.gethostname should ref getfqdn directly. ........ r52817 | martin.v.loewis | 2006-11-21 19:20:25 +0100 (Tue, 21 Nov 2006) | 4 lines Conditionalize definition of _CRT_SECURE_NO_DEPRECATE and _CRT_NONSTDC_NO_DEPRECATE. Will backport. ........ r52821 | martin.v.loewis | 2006-11-22 09:50:02 +0100 (Wed, 22 Nov 2006) | 4 lines Patch #1362975: Rework CodeContext indentation algorithm to avoid hard-coding pixel widths. Also make the text's scrollbar a child of the text frame, not the top widget. ........ r52826 | walter.doerwald | 2006-11-23 06:03:56 +0100 (Thu, 23 Nov 2006) | 3 lines Change decode() so that it works with a buffer (i.e. unicode(..., 'utf-8-sig')) SF bug #1601501. ........ r52833 | georg.brandl | 2006-11-23 10:55:07 +0100 (Thu, 23 Nov 2006) | 2 lines Bug #1601630: little improvement to getopt docs ........ r52835 | michael.hudson | 2006-11-23 14:54:04 +0100 (Thu, 23 Nov 2006) | 3 lines a test for an error condition not covered by existing tests (noticed this when writing the equivalent code for pypy) ........ r52839 | raymond.hettinger | 2006-11-23 22:06:03 +0100 (Thu, 23 Nov 2006) | 1 line Fix and/add typo ........ r52840 | raymond.hettinger | 2006-11-23 22:35:19 +0100 (Thu, 23 Nov 2006) | 1 line ... and the number of the counting shall be three. ........ r52841 | thomas.heller | 2006-11-24 19:45:39 +0100 (Fri, 24 Nov 2006) | 1 line Fix bug #1598620: A ctypes structure cannot contain itself. ........ r52843 | martin.v.loewis | 2006-11-25 16:39:19 +0100 (Sat, 25 Nov 2006) | 3 lines Disable _XOPEN_SOURCE on NetBSD 1.x. Will backport to 2.5 ........ r52845 | georg.brandl | 2006-11-26 20:27:47 +0100 (Sun, 26 Nov 2006) | 2 lines Bug #1603321: make pstats.Stats accept Unicode file paths. ........ r52850 | georg.brandl | 2006-11-27 19:46:21 +0100 (Mon, 27 Nov 2006) | 2 lines Bug #1603789: grammatical error in Tkinter docs. ........ r52855 | thomas.heller | 2006-11-28 21:21:54 +0100 (Tue, 28 Nov 2006) | 7 lines Fix #1563807: _ctypes built on AIX fails with ld ffi error. The contents of ffi_darwin.c must be compiled unless __APPLE__ is defined and __ppc__ is not. Will backport. ........ r52862 | armin.rigo | 2006-11-29 22:59:22 +0100 (Wed, 29 Nov 2006) | 3 lines Forgot a case where the locals can now be a general mapping instead of just a dictionary. (backporting...) ........ r52872 | guido.van.rossum | 2006-11-30 20:23:13 +0100 (Thu, 30 Nov 2006) | 2 lines Update version. ........ r52890 | walter.doerwald | 2006-12-01 17:59:47 +0100 (Fri, 01 Dec 2006) | 3 lines Move xdrlib tests from the module into a separate test script, port the tests to unittest and add a few new tests. ........ r52900 | raymond.hettinger | 2006-12-02 03:00:39 +0100 (Sat, 02 Dec 2006) | 1 line Add name to credits (for untokenize). ........ r52905 | martin.v.loewis | 2006-12-03 10:54:46 +0100 (Sun, 03 Dec 2006) | 2 lines Move IDLE news into NEWS.txt. ........ r52906 | martin.v.loewis | 2006-12-03 12:23:45 +0100 (Sun, 03 Dec 2006) | 4 lines Patch #1544279: Improve thread-safety of the socket module by moving the sock_addr_t storage out of the socket object. Will backport to 2.5. ........ r52908 | martin.v.loewis | 2006-12-03 13:01:53 +0100 (Sun, 03 Dec 2006) | 3 lines Patch #1371075: Make ConfigParser accept optional dict type for ordering, sorting, etc. ........ r52910 | matthias.klose | 2006-12-03 18:16:41 +0100 (Sun, 03 Dec 2006) | 2 lines - Fix build failure on kfreebsd and on the hurd. ........ r52915 | george.yoshida | 2006-12-04 12:41:54 +0100 (Mon, 04 Dec 2006) | 2 lines fix a versionchanged tag ........ r52917 | george.yoshida | 2006-12-05 06:39:50 +0100 (Tue, 05 Dec 2006) | 3 lines Fix pickle doc typo Patch #1608758 ........ r52938 | georg.brandl | 2006-12-06 23:21:18 +0100 (Wed, 06 Dec 2006) | 2 lines Patch #1610437: fix a tarfile bug with long filename headers. ........ r52945 | brett.cannon | 2006-12-07 00:38:48 +0100 (Thu, 07 Dec 2006) | 3 lines Fix a bad assumption that all objects assigned to '__loader__' on a module will have a '_files' attribute. ........ r52951 | georg.brandl | 2006-12-07 10:30:06 +0100 (Thu, 07 Dec 2006) | 3 lines RFE #1592899: mention string.maketrans() in docs for str.translate, remove reference to the old regex module in the former's doc. ........ r52962 | raymond.hettinger | 2006-12-08 04:17:18 +0100 (Fri, 08 Dec 2006) | 1 line Eliminate two redundant calls to PyObject_Hash(). ........ r52963 | raymond.hettinger | 2006-12-08 05:24:33 +0100 (Fri, 08 Dec 2006) | 3 lines Port Armin's fix for a dict resize vulnerability (svn revision 46589, sf bug 1456209). ........ r52964 | raymond.hettinger | 2006-12-08 05:57:50 +0100 (Fri, 08 Dec 2006) | 4 lines Port Georg's dictobject.c fix keys that were tuples got unpacked on the way to setting a KeyError (svn revision 52535, sf bug 1576657). ........ r52966 | raymond.hettinger | 2006-12-08 18:35:25 +0100 (Fri, 08 Dec 2006) | 2 lines Add test for SF bug 1576657 ........ r52970 | georg.brandl | 2006-12-08 21:46:11 +0100 (Fri, 08 Dec 2006) | 3 lines #1577756: svnversion doesn't react to LANG=C, use LC_ALL=C to force English output. ........ r52972 | georg.brandl | 2006-12-09 10:08:29 +0100 (Sat, 09 Dec 2006) | 3 lines Patch #1608267: fix a race condition in os.makedirs() is the directory to be created is already there. ........ r52975 | matthias.klose | 2006-12-09 13:15:27 +0100 (Sat, 09 Dec 2006) | 2 lines - Fix the build of the library reference in info format. ........ r52994 | neal.norwitz | 2006-12-11 02:01:06 +0100 (Mon, 11 Dec 2006) | 1 line Fix a typo ........ r52996 | georg.brandl | 2006-12-11 08:56:33 +0100 (Mon, 11 Dec 2006) | 2 lines Move errno imports back to individual functions. ........ r52998 | vinay.sajip | 2006-12-11 15:07:16 +0100 (Mon, 11 Dec 2006) | 1 line Patch by Jeremy Katz (SF #1609407) ........ r53000 | vinay.sajip | 2006-12-11 15:26:23 +0100 (Mon, 11 Dec 2006) | 1 line Patch by "cuppatea" (SF #1503765) ........
Diffstat (limited to 'Python')
-rw-r--r--Python/ast.c1542
-rw-r--r--Python/bltinmodule.c7
-rw-r--r--Python/ceval.c8
-rw-r--r--Python/compile.c158
-rw-r--r--Python/errors.c3
-rw-r--r--Python/getargs.c9
-rw-r--r--Python/import.c17
-rw-r--r--Python/marshal.c40
-rw-r--r--Python/modsupport.c2
-rw-r--r--Python/mystrtoul.c12
-rw-r--r--Python/peephole.c19
-rw-r--r--Python/pystate.c9
-rw-r--r--Python/pythonrun.c14
-rw-r--r--Python/structmember.c144
-rw-r--r--Python/sysmodule.c6
15 files changed, 1028 insertions, 962 deletions
diff --git a/Python/ast.c b/Python/ast.c
index 672a715..411c42f 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -15,12 +15,6 @@
#include <assert.h>
-/* XXX TO DO
- - re-indent this file (should be done)
- - internal error checking (freeing memory, etc.)
- - syntax errors
-*/
-
/* Data structure used internally */
struct compiling {
char *c_encoding; /* source encoding */
@@ -43,7 +37,7 @@ static PyObject *parsestr(const char *s, const char *encoding);
static PyObject *parsestrplus(struct compiling *, const node *n);
#ifndef LINENO
-#define LINENO(n) ((n)->n_lineno)
+#define LINENO(n) ((n)->n_lineno)
#endif
static identifier
@@ -68,7 +62,7 @@ ast_error(const node *n, const char *errstr)
{
PyObject *u = Py_BuildValue("zi", errstr, LINENO(n));
if (!u)
- return 0;
+ return 0;
PyErr_SetObject(PyExc_SyntaxError, u);
Py_DECREF(u);
return 0;
@@ -82,36 +76,36 @@ ast_error_finish(const char *filename)
assert(PyErr_Occurred());
if (!PyErr_ExceptionMatches(PyExc_SyntaxError))
- return;
+ return;
PyErr_Fetch(&type, &value, &tback);
errstr = PyTuple_GetItem(value, 0);
if (!errstr)
- return;
+ return;
Py_INCREF(errstr);
lineno = PyInt_AsLong(PyTuple_GetItem(value, 1));
if (lineno == -1) {
- Py_DECREF(errstr);
- return;
+ Py_DECREF(errstr);
+ return;
}
Py_DECREF(value);
loc = PyErr_ProgramText(filename, lineno);
if (!loc) {
- Py_INCREF(Py_None);
- loc = Py_None;
+ Py_INCREF(Py_None);
+ loc = Py_None;
}
tmp = Py_BuildValue("(zlOO)", filename, lineno, Py_None, loc);
Py_DECREF(loc);
if (!tmp) {
- Py_DECREF(errstr);
- return;
+ Py_DECREF(errstr);
+ return;
}
value = PyTuple_Pack(2, errstr, tmp);
Py_DECREF(errstr);
Py_DECREF(tmp);
if (!value)
- return;
+ return;
PyErr_Restore(type, value, tback);
}
@@ -246,7 +240,7 @@ PyAST_FromNode(const node *n, PyCompilerFlags *flags, const char *filename,
if (TYPE(CHILD(n, 0)) == NEWLINE) {
stmts = asdl_seq_new(1, arena);
if (!stmts)
- goto error;
+ goto error;
asdl_seq_SET(stmts, 0, Pass(n->n_lineno, n->n_col_offset,
arena));
return Interactive(stmts, arena);
@@ -256,11 +250,11 @@ PyAST_FromNode(const node *n, PyCompilerFlags *flags, const char *filename,
num = num_stmts(n);
stmts = asdl_seq_new(num, arena);
if (!stmts)
- goto error;
+ goto error;
if (num == 1) {
- s = ast_for_stmt(&c, n);
- if (!s)
- goto error;
+ s = ast_for_stmt(&c, n);
+ if (!s)
+ goto error;
asdl_seq_SET(stmts, 0, s);
}
else {
@@ -347,38 +341,38 @@ set_context(expr_ty e, expr_context_ty ctx, const node *n)
switch (e->kind) {
case Attribute_kind:
- if (ctx == Store &&
- !strcmp(PyString_AS_STRING(e->v.Attribute.attr), "None")) {
- return ast_error(n, "assignment to None");
- }
- e->v.Attribute.ctx = ctx;
- break;
+ if (ctx == Store &&
+ !strcmp(PyString_AS_STRING(e->v.Attribute.attr), "None")) {
+ return ast_error(n, "assignment to None");
+ }
+ e->v.Attribute.ctx = ctx;
+ break;
case Subscript_kind:
- e->v.Subscript.ctx = ctx;
- break;
+ e->v.Subscript.ctx = ctx;
+ break;
case Name_kind:
- if (ctx == Store &&
- !strcmp(PyString_AS_STRING(e->v.Name.id), "None")) {
- return ast_error(n, "assignment to None");
- }
- e->v.Name.ctx = ctx;
- break;
+ if (ctx == Store &&
+ !strcmp(PyString_AS_STRING(e->v.Name.id), "None")) {
+ return ast_error(n, "assignment to None");
+ }
+ e->v.Name.ctx = ctx;
+ break;
case List_kind:
- e->v.List.ctx = ctx;
- s = e->v.List.elts;
- break;
+ e->v.List.ctx = ctx;
+ s = e->v.List.elts;
+ break;
case Tuple_kind:
if (asdl_seq_LEN(e->v.Tuple.elts) == 0)
return ast_error(n, "can't assign to ()");
- e->v.Tuple.ctx = ctx;
- s = e->v.Tuple.elts;
- break;
+ e->v.Tuple.ctx = ctx;
+ s = e->v.Tuple.elts;
+ break;
case Lambda_kind:
expr_name = "lambda";
break;
case Call_kind:
expr_name = "function call";
- break;
+ break;
case BoolOp_kind:
case BinOp_kind:
case UnaryOp_kind:
@@ -428,12 +422,12 @@ set_context(expr_ty e, expr_context_ty ctx, const node *n)
context for all the contained elements.
*/
if (s) {
- int i;
+ int i;
- for (i = 0; i < asdl_seq_LEN(s); i++) {
- if (!set_context((expr_ty)asdl_seq_GET(s, i), ctx, n))
- return 0;
- }
+ for (i = 0; i < asdl_seq_LEN(s); i++) {
+ if (!set_context((expr_ty)asdl_seq_GET(s, i), ctx, n))
+ return 0;
+ }
}
return 1;
}
@@ -484,13 +478,13 @@ ast_for_comp_op(const node *n)
*/
REQ(n, comp_op);
if (NCH(n) == 1) {
- n = CHILD(n, 0);
- switch (TYPE(n)) {
+ n = CHILD(n, 0);
+ switch (TYPE(n)) {
case LESS:
return Lt;
case GREATER:
return Gt;
- case EQEQUAL: /* == */
+ case EQEQUAL: /* == */
return Eq;
case LESSEQUAL:
return LtE;
@@ -507,11 +501,11 @@ ast_for_comp_op(const node *n)
PyErr_Format(PyExc_SystemError, "invalid comp_op: %s",
STR(n));
return (cmpop_ty)0;
- }
+ }
}
else if (NCH(n) == 2) {
- /* handle "not in" and "is not" */
- switch (TYPE(CHILD(n, 0))) {
+ /* handle "not in" and "is not" */
+ switch (TYPE(CHILD(n, 0))) {
case NAME:
if (strcmp(STR(CHILD(n, 1)), "in") == 0)
return NotIn;
@@ -521,7 +515,7 @@ ast_for_comp_op(const node *n)
PyErr_Format(PyExc_SystemError, "invalid comp_op: %s %s",
STR(CHILD(n, 0)), STR(CHILD(n, 1)));
return (cmpop_ty)0;
- }
+ }
}
PyErr_Format(PyExc_SystemError, "invalid comp_op: has %d children",
NCH(n));
@@ -536,10 +530,11 @@ seq_for_testlist(struct compiling *c, const node *n)
expr_ty expression;
int i;
assert(TYPE(n) == testlist
- || TYPE(n) == listmaker
- || TYPE(n) == testlist_gexp
- || TYPE(n) == testlist_safe
- );
+ || TYPE(n) == listmaker
+ || TYPE(n) == testlist_gexp
+ || TYPE(n) == testlist_safe
+ || TYPE(n) == testlist1
+ );
seq = asdl_seq_new((NCH(n) + 1) / 2, c->c_arena);
if (!seq)
@@ -567,20 +562,37 @@ compiler_complex_args(struct compiling *c, const node *n)
if (!args)
return NULL;
+ /* fpdef: NAME | '(' fplist ')'
+ fplist: fpdef (',' fpdef)* [',']
+ */
REQ(n, fplist);
for (i = 0; i < len; i++) {
- const node *child = CHILD(CHILD(n, 2*i), 0);
+ const node *fpdef_node = CHILD(n, 2*i);
+ const node *child;
expr_ty arg;
+set_name:
+ /* fpdef_node is either a NAME or an fplist */
+ child = CHILD(fpdef_node, 0);
if (TYPE(child) == NAME) {
- if (!strcmp(STR(child), "None")) {
- ast_error(child, "assignment to None");
- return NULL;
- }
+ if (!strcmp(STR(child), "None")) {
+ ast_error(child, "assignment to None");
+ return NULL;
+ }
arg = Name(NEW_IDENTIFIER(child), Store, LINENO(child),
child->n_col_offset, c->c_arena);
- }
+ }
else {
- arg = compiler_complex_args(c, CHILD(CHILD(n, 2*i), 1));
+ assert(TYPE(fpdef_node) == fpdef);
+ /* fpdef_node[0] is not a name, so it must be a '(', get CHILD[1] */
+ child = CHILD(fpdef_node, 1);
+ assert(TYPE(child) == fplist);
+ /* NCH == 1 means we have (x), we need to elide the extra parens */
+ if (NCH(child) == 1) {
+ fpdef_node = CHILD(child, 0);
+ assert(TYPE(fpdef_node) == fpdef);
+ goto set_name;
+ }
+ arg = compiler_complex_args(c, child);
}
asdl_seq_SET(args, i, arg);
}
@@ -731,6 +743,7 @@ ast_for_arguments(struct compiling *c, const node *n)
ch = CHILD(n, i);
switch (TYPE(ch)) {
case fpdef:
+ handle_fpdef:
/* XXX Need to worry about checking if TYPE(CHILD(n, i+1)) is
anything other than EQUAL or a comma? */
/* XXX Should NCH(n) check be made a separate check? */
@@ -758,7 +771,11 @@ ast_for_arguments(struct compiling *c, const node *n)
compiler_complex_args(c, ch));
} else {
/* def foo((x)): setup for checking NAME below. */
+ /* Loop because there can be many parens and tuple
+ unpacking mixed in. */
ch = CHILD(ch, 0);
+ assert(TYPE(ch) == fpdef);
+ goto handle_fpdef;
}
}
if (TYPE(CHILD(ch, 0)) == NAME) {
@@ -773,7 +790,7 @@ ast_for_arguments(struct compiling *c, const node *n)
if (!name)
goto error;
asdl_seq_SET(posargs, k++, name);
-
+
}
i += 2; /* the name and the comma */
break;
@@ -847,15 +864,15 @@ ast_for_dotted_name(struct compiling *c, const node *n)
return NULL;
e = Name(id, Load, lineno, col_offset, c->c_arena);
if (!e)
- return NULL;
+ return NULL;
for (i = 2; i < NCH(n); i+=2) {
id = NEW_IDENTIFIER(CHILD(n, i));
- if (!id)
- return NULL;
- e = Attribute(e, id, Load, lineno, col_offset, c->c_arena);
- if (!e)
- return NULL;
+ if (!id)
+ return NULL;
+ e = Attribute(e, id, Load, lineno, col_offset, c->c_arena);
+ if (!e)
+ return NULL;
}
return e;
@@ -874,24 +891,24 @@ ast_for_decorator(struct compiling *c, const node *n)
name_expr = ast_for_dotted_name(c, CHILD(n, 1));
if (!name_expr)
- return NULL;
-
+ return NULL;
+
if (NCH(n) == 3) { /* No arguments */
- d = name_expr;
- name_expr = NULL;
+ d = name_expr;
+ name_expr = NULL;
}
else if (NCH(n) == 5) { /* Call with no arguments */
- d = Call(name_expr, NULL, NULL, NULL, NULL, LINENO(n),
+ d = Call(name_expr, NULL, NULL, NULL, NULL, LINENO(n),
n->n_col_offset, c->c_arena);
- if (!d)
- return NULL;
- name_expr = NULL;
+ if (!d)
+ return NULL;
+ name_expr = NULL;
}
else {
- d = ast_for_call(c, CHILD(n, 3), name_expr);
- if (!d)
- return NULL;
- name_expr = NULL;
+ d = ast_for_call(c, CHILD(n, 3), name_expr);
+ if (!d)
+ return NULL;
+ name_expr = NULL;
}
return d;
@@ -908,12 +925,12 @@ ast_for_decorators(struct compiling *c, const node *n)
decorator_seq = asdl_seq_new(NCH(n), c->c_arena);
if (!decorator_seq)
return NULL;
-
+
for (i = 0; i < NCH(n); i++) {
d = ast_for_decorator(c, CHILD(n, i));
- if (!d)
- return NULL;
- asdl_seq_SET(decorator_seq, i, d);
+ if (!d)
+ return NULL;
+ asdl_seq_SET(decorator_seq, i, d);
}
return decorator_seq;
}
@@ -931,28 +948,28 @@ ast_for_funcdef(struct compiling *c, const node *n)
REQ(n, funcdef);
if (NCH(n) == 6) { /* decorators are present */
- decorator_seq = ast_for_decorators(c, CHILD(n, 0));
- if (!decorator_seq)
- return NULL;
- name_i = 2;
+ decorator_seq = ast_for_decorators(c, CHILD(n, 0));
+ if (!decorator_seq)
+ return NULL;
+ name_i = 2;
}
else {
- name_i = 1;
+ name_i = 1;
}
name = NEW_IDENTIFIER(CHILD(n, name_i));
if (!name)
- return NULL;
+ return NULL;
else if (!strcmp(STR(CHILD(n, name_i)), "None")) {
- ast_error(CHILD(n, name_i), "assignment to None");
- return NULL;
+ ast_error(CHILD(n, name_i), "assignment to None");
+ return NULL;
}
args = ast_for_arguments(c, CHILD(n, name_i + 1));
if (!args)
- return NULL;
+ return NULL;
body = ast_for_suite(c, CHILD(n, name_i + 3));
if (!body)
- return NULL;
+ return NULL;
return FunctionDef(name, args, body, decorator_seq, LINENO(n),
n->n_col_offset, c->c_arena);
@@ -994,17 +1011,22 @@ ast_for_ifexpr(struct compiling *c, const node *n)
assert(NCH(n) == 5);
body = ast_for_expr(c, CHILD(n, 0));
if (!body)
- return NULL;
+ return NULL;
expression = ast_for_expr(c, CHILD(n, 2));
if (!expression)
- return NULL;
+ return NULL;
orelse = ast_for_expr(c, CHILD(n, 4));
if (!orelse)
- return NULL;
+ return NULL;
return IfExp(expression, body, orelse, LINENO(n), n->n_col_offset,
c->c_arena);
}
+/* XXX(nnorwitz): the listcomp and genexpr code should be refactored
+ so there is only a single version. Possibly for loops can also re-use
+ the code.
+*/
+
/* Count the number of 'for' loop in a list comprehension.
Helper for ast_for_listcomp().
@@ -1020,14 +1042,14 @@ count_list_fors(const node *n)
n_fors++;
REQ(ch, list_for);
if (NCH(ch) == 5)
- ch = CHILD(ch, 4);
+ ch = CHILD(ch, 4);
else
- return n_fors;
+ return n_fors;
count_list_iter:
REQ(ch, list_iter);
ch = CHILD(ch, 0);
if (TYPE(ch) == list_for)
- goto count_list_for;
+ goto count_list_for;
else if (TYPE(ch) == list_if) {
if (NCH(ch) == 3) {
ch = CHILD(ch, 2);
@@ -1055,12 +1077,12 @@ count_list_ifs(const node *n)
count_list_iter:
REQ(n, list_iter);
if (TYPE(CHILD(n, 0)) == list_for)
- return n_ifs;
+ return n_ifs;
n = CHILD(n, 0);
REQ(n, list_if);
n_ifs++;
if (NCH(n) == 2)
- return n_ifs;
+ return n_ifs;
n = CHILD(n, 2);
goto count_list_iter;
}
@@ -1092,61 +1114,65 @@ ast_for_listcomp(struct compiling *c, const node *n)
listcomps = asdl_seq_new(n_fors, c->c_arena);
if (!listcomps)
- return NULL;
+ return NULL;
ch = CHILD(n, 1);
for (i = 0; i < n_fors; i++) {
- comprehension_ty lc;
- asdl_seq *t;
+ comprehension_ty lc;
+ asdl_seq *t;
expr_ty expression;
+ node *for_ch;
- REQ(ch, list_for);
+ REQ(ch, list_for);
- t = ast_for_exprlist(c, CHILD(ch, 1), Store);
+ for_ch = CHILD(ch, 1);
+ t = ast_for_exprlist(c, for_ch, Store);
if (!t)
return NULL;
expression = ast_for_testlist(c, CHILD(ch, 3));
if (!expression)
return NULL;
- if (asdl_seq_LEN(t) == 1)
- lc = comprehension((expr_ty)asdl_seq_GET(t, 0), expression, NULL,
+ /* Check the # of children rather than the length of t, since
+ [x for x, in ... ] has 1 element in t, but still requires a Tuple. */
+ if (NCH(for_ch) == 1)
+ lc = comprehension((expr_ty)asdl_seq_GET(t, 0), expression, NULL,
c->c_arena);
- else
- lc = comprehension(Tuple(t, Store, LINENO(ch), ch->n_col_offset,
+ else
+ lc = comprehension(Tuple(t, Store, LINENO(ch), ch->n_col_offset,
c->c_arena),
expression, NULL, c->c_arena);
if (!lc)
return NULL;
- if (NCH(ch) == 5) {
- int j, n_ifs;
- asdl_seq *ifs;
+ if (NCH(ch) == 5) {
+ int j, n_ifs;
+ asdl_seq *ifs;
- ch = CHILD(ch, 4);
- n_ifs = count_list_ifs(ch);
+ ch = CHILD(ch, 4);
+ n_ifs = count_list_ifs(ch);
if (n_ifs == -1)
return NULL;
- ifs = asdl_seq_new(n_ifs, c->c_arena);
- if (!ifs)
- return NULL;
+ ifs = asdl_seq_new(n_ifs, c->c_arena);
+ if (!ifs)
+ return NULL;
- for (j = 0; j < n_ifs; j++) {
+ for (j = 0; j < n_ifs; j++) {
REQ(ch, list_iter);
- ch = CHILD(ch, 0);
- REQ(ch, list_if);
-
- asdl_seq_SET(ifs, j, ast_for_expr(c, CHILD(ch, 1)));
- if (NCH(ch) == 3)
- ch = CHILD(ch, 2);
- }
- /* on exit, must guarantee that ch is a list_for */
- if (TYPE(ch) == list_iter)
- ch = CHILD(ch, 0);
+ ch = CHILD(ch, 0);
+ REQ(ch, list_if);
+
+ asdl_seq_SET(ifs, j, ast_for_expr(c, CHILD(ch, 1)));
+ if (NCH(ch) == 3)
+ ch = CHILD(ch, 2);
+ }
+ /* on exit, must guarantee that ch is a list_for */
+ if (TYPE(ch) == list_iter)
+ ch = CHILD(ch, 0);
lc->ifs = ifs;
- }
- asdl_seq_SET(listcomps, i, lc);
+ }
+ asdl_seq_SET(listcomps, i, lc);
}
return ListComp(elt, listcomps, LINENO(n), n->n_col_offset, c->c_arena);
@@ -1161,34 +1187,34 @@ ast_for_listcomp(struct compiling *c, const node *n)
static int
count_gen_fors(const node *n)
{
- int n_fors = 0;
- node *ch = CHILD(n, 1);
+ int n_fors = 0;
+ node *ch = CHILD(n, 1);
count_gen_for:
- n_fors++;
- REQ(ch, gen_for);
- if (NCH(ch) == 5)
- ch = CHILD(ch, 4);
- else
- return n_fors;
+ n_fors++;
+ REQ(ch, gen_for);
+ if (NCH(ch) == 5)
+ ch = CHILD(ch, 4);
+ else
+ return n_fors;
count_gen_iter:
- REQ(ch, gen_iter);
- ch = CHILD(ch, 0);
- if (TYPE(ch) == gen_for)
- goto count_gen_for;
- else if (TYPE(ch) == gen_if) {
- if (NCH(ch) == 3) {
- ch = CHILD(ch, 2);
- goto count_gen_iter;
- }
- else
- return n_fors;
- }
-
- /* Should never be reached */
- PyErr_SetString(PyExc_SystemError,
- "logic error in count_gen_fors");
- return -1;
+ REQ(ch, gen_iter);
+ ch = CHILD(ch, 0);
+ if (TYPE(ch) == gen_for)
+ goto count_gen_for;
+ else if (TYPE(ch) == gen_if) {
+ if (NCH(ch) == 3) {
+ ch = CHILD(ch, 2);
+ goto count_gen_iter;
+ }
+ else
+ return n_fors;
+ }
+
+ /* Should never be reached */
+ PyErr_SetString(PyExc_SystemError,
+ "logic error in count_gen_fors");
+ return -1;
}
/* Count the number of 'if' statements in a generator expression.
@@ -1199,19 +1225,19 @@ count_gen_fors(const node *n)
static int
count_gen_ifs(const node *n)
{
- int n_ifs = 0;
-
- while (1) {
- REQ(n, gen_iter);
- if (TYPE(CHILD(n, 0)) == gen_for)
- return n_ifs;
- n = CHILD(n, 0);
- REQ(n, gen_if);
- n_ifs++;
- if (NCH(n) == 2)
- return n_ifs;
- n = CHILD(n, 2);
- }
+ int n_ifs = 0;
+
+ while (1) {
+ REQ(n, gen_iter);
+ if (TYPE(CHILD(n, 0)) == gen_for)
+ return n_ifs;
+ n = CHILD(n, 0);
+ REQ(n, gen_if);
+ n_ifs++;
+ if (NCH(n) == 2)
+ return n_ifs;
+ n = CHILD(n, 2);
+ }
}
/* TODO(jhylton): Combine with list comprehension code? */
@@ -1219,7 +1245,7 @@ static expr_ty
ast_for_genexp(struct compiling *c, const node *n)
{
/* testlist_gexp: test ( gen_for | (',' test)* [','] )
- argument: [test '='] test [gen_for] # Really [keyword '='] test */
+ argument: [test '='] test [gen_for] # Really [keyword '='] test */
expr_ty elt;
asdl_seq *genexps;
int i, n_fors;
@@ -1245,17 +1271,21 @@ ast_for_genexp(struct compiling *c, const node *n)
comprehension_ty ge;
asdl_seq *t;
expr_ty expression;
+ node *for_ch;
REQ(ch, gen_for);
- t = ast_for_exprlist(c, CHILD(ch, 1), Store);
+ for_ch = CHILD(ch, 1);
+ t = ast_for_exprlist(c, for_ch, Store);
if (!t)
return NULL;
expression = ast_for_expr(c, CHILD(ch, 3));
if (!expression)
return NULL;
- if (asdl_seq_LEN(t) == 1)
+ /* Check the # of children rather than the length of t, since
+ (x for x, in ...) has 1 element in t, but still requires a Tuple. */
+ if (NCH(for_ch) == 1)
ge = comprehension((expr_ty)asdl_seq_GET(t, 0), expression,
NULL, c->c_arena);
else
@@ -1312,57 +1342,57 @@ ast_for_atom(struct compiling *c, const node *n)
switch (TYPE(ch)) {
case NAME:
- /* All names start in Load context, but may later be
- changed. */
- return Name(NEW_IDENTIFIER(ch), Load, LINENO(n), n->n_col_offset, c->c_arena);
+ /* All names start in Load context, but may later be
+ changed. */
+ return Name(NEW_IDENTIFIER(ch), Load, LINENO(n), n->n_col_offset, c->c_arena);
case STRING: {
- PyObject *str = parsestrplus(c, n);
- if (!str)
- return NULL;
+ PyObject *str = parsestrplus(c, n);
+ if (!str)
+ return NULL;
- PyArena_AddPyObject(c->c_arena, str);
- return Str(str, LINENO(n), n->n_col_offset, c->c_arena);
+ PyArena_AddPyObject(c->c_arena, str);
+ return Str(str, LINENO(n), n->n_col_offset, c->c_arena);
}
case NUMBER: {
- PyObject *pynum = parsenumber(STR(ch));
- if (!pynum)
- return NULL;
+ PyObject *pynum = parsenumber(STR(ch));
+ if (!pynum)
+ return NULL;
- PyArena_AddPyObject(c->c_arena, pynum);
- return Num(pynum, LINENO(n), n->n_col_offset, c->c_arena);
+ PyArena_AddPyObject(c->c_arena, pynum);
+ return Num(pynum, LINENO(n), n->n_col_offset, c->c_arena);
}
case DOT:
/* Ellipsis */
return Ellipsis(LINENO(n), n->n_col_offset, c->c_arena);
case LPAR: /* some parenthesized expressions */
- ch = CHILD(n, 1);
-
- if (TYPE(ch) == RPAR)
- return Tuple(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena);
-
- if (TYPE(ch) == yield_expr)
- return ast_for_expr(c, ch);
-
- if ((NCH(ch) > 1) && (TYPE(CHILD(ch, 1)) == gen_for))
- return ast_for_genexp(c, ch);
-
- return ast_for_testlist_gexp(c, ch);
+ ch = CHILD(n, 1);
+
+ if (TYPE(ch) == RPAR)
+ return Tuple(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena);
+
+ if (TYPE(ch) == yield_expr)
+ return ast_for_expr(c, ch);
+
+ if ((NCH(ch) > 1) && (TYPE(CHILD(ch, 1)) == gen_for))
+ return ast_for_genexp(c, ch);
+
+ return ast_for_testlist_gexp(c, ch);
case LSQB: /* list (or list comprehension) */
- ch = CHILD(n, 1);
-
- if (TYPE(ch) == RSQB)
- return List(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena);
-
- REQ(ch, listmaker);
- if (NCH(ch) == 1 || TYPE(CHILD(ch, 1)) == COMMA) {
- asdl_seq *elts = seq_for_testlist(c, ch);
- if (!elts)
- return NULL;
+ ch = CHILD(n, 1);
+
+ if (TYPE(ch) == RSQB)
+ return List(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena);
+
+ REQ(ch, listmaker);
+ if (NCH(ch) == 1 || TYPE(CHILD(ch, 1)) == COMMA) {
+ asdl_seq *elts = seq_for_testlist(c, ch);
+ if (!elts)
+ return NULL;
- return List(elts, Load, LINENO(n), n->n_col_offset, c->c_arena);
- }
- else
- return ast_for_listcomp(c, ch);
+ return List(elts, Load, LINENO(n), n->n_col_offset, c->c_arena);
+ }
+ else
+ return ast_for_listcomp(c, ch);
case LBRACE: {
/* dictsetmaker: test ':' test (',' test ':' test)* [','] |
* test (',' test)* [','] */
@@ -1415,8 +1445,8 @@ ast_for_atom(struct compiling *c, const node *n)
}
}
default:
- PyErr_Format(PyExc_SystemError, "unhandled atom %d", TYPE(ch));
- return NULL;
+ PyErr_Format(PyExc_SystemError, "unhandled atom %d", TYPE(ch));
+ return NULL;
}
}
@@ -1440,31 +1470,31 @@ ast_for_slice(struct compiling *c, const node *n)
if (!step)
return NULL;
- return Index(step, c->c_arena);
+ return Index(step, c->c_arena);
}
if (TYPE(ch) == test) {
- lower = ast_for_expr(c, ch);
+ lower = ast_for_expr(c, ch);
if (!lower)
return NULL;
}
/* If there's an upper bound it's in the second or third position. */
if (TYPE(ch) == COLON) {
- if (NCH(n) > 1) {
- node *n2 = CHILD(n, 1);
+ if (NCH(n) > 1) {
+ node *n2 = CHILD(n, 1);
- if (TYPE(n2) == test) {
- upper = ast_for_expr(c, n2);
+ if (TYPE(n2) == test) {
+ upper = ast_for_expr(c, n2);
if (!upper)
return NULL;
}
- }
+ }
} else if (NCH(n) > 2) {
- node *n2 = CHILD(n, 2);
+ node *n2 = CHILD(n, 2);
- if (TYPE(n2) == test) {
- upper = ast_for_expr(c, n2);
+ if (TYPE(n2) == test) {
+ upper = ast_for_expr(c, n2);
if (!upper)
return NULL;
}
@@ -1495,13 +1525,13 @@ ast_for_slice(struct compiling *c, const node *n)
static expr_ty
ast_for_binop(struct compiling *c, const node *n)
{
- /* Must account for a sequence of expressions.
- How should A op B op C by represented?
- BinOp(BinOp(A, op, B), op, C).
- */
+ /* Must account for a sequence of expressions.
+ How should A op B op C by represented?
+ BinOp(BinOp(A, op, B), op, C).
+ */
- int i, nops;
- expr_ty expr1, expr2, result;
+ int i, nops;
+ expr_ty expr1, expr2, result;
operator_ty newoperator;
expr1 = ast_for_expr(c, CHILD(n, 0));
@@ -1516,17 +1546,17 @@ ast_for_binop(struct compiling *c, const node *n)
if (!newoperator)
return NULL;
- result = BinOp(expr1, newoperator, expr2, LINENO(n), n->n_col_offset,
+ result = BinOp(expr1, newoperator, expr2, LINENO(n), n->n_col_offset,
c->c_arena);
- if (!result)
+ if (!result)
return NULL;
- nops = (NCH(n) - 1) / 2;
- for (i = 1; i < nops; i++) {
- expr_ty tmp_result, tmp;
- const node* next_oper = CHILD(n, i * 2 + 1);
+ nops = (NCH(n) - 1) / 2;
+ for (i = 1; i < nops; i++) {
+ expr_ty tmp_result, tmp;
+ const node* next_oper = CHILD(n, i * 2 + 1);
- newoperator = get_operator(next_oper);
+ newoperator = get_operator(next_oper);
if (!newoperator)
return NULL;
@@ -1535,13 +1565,13 @@ ast_for_binop(struct compiling *c, const node *n)
return NULL;
tmp_result = BinOp(result, newoperator, tmp,
- LINENO(next_oper), next_oper->n_col_offset,
+ LINENO(next_oper), next_oper->n_col_offset,
c->c_arena);
- if (!tmp)
- return NULL;
- result = tmp_result;
- }
- return result;
+ if (!tmp)
+ return NULL;
+ result = tmp_result;
+ }
+ return result;
}
static expr_ty
@@ -1688,8 +1718,8 @@ ast_for_power(struct compiling *c, const node *n)
tmp = ast_for_trailer(c, ch, e);
if (!tmp)
return NULL;
- tmp->lineno = e->lineno;
- tmp->col_offset = e->col_offset;
+ tmp->lineno = e->lineno;
+ tmp->col_offset = e->col_offset;
e = tmp;
}
if (TYPE(CHILD(n, NCH(n) - 1)) == factor) {
@@ -1747,8 +1777,8 @@ ast_for_expr(struct compiling *c, const node *n)
return ast_for_lambdef(c, CHILD(n, 0));
else if (NCH(n) > 1)
return ast_for_ifexpr(c, n);
- /* Fallthrough */
- case or_test:
+ /* Fallthrough */
+ case or_test:
case and_test:
if (NCH(n) == 1) {
n = CHILD(n, 0);
@@ -1789,7 +1819,7 @@ ast_for_expr(struct compiling *c, const node *n)
else {
expr_ty expression;
asdl_int_seq *ops;
- asdl_seq *cmps;
+ asdl_seq *cmps;
ops = asdl_int_seq_new(NCH(n) / 2, c->c_arena);
if (!ops)
return NULL;
@@ -1803,12 +1833,12 @@ ast_for_expr(struct compiling *c, const node *n)
newoperator = ast_for_comp_op(CHILD(n, i));
if (!newoperator) {
return NULL;
- }
+ }
expression = ast_for_expr(c, CHILD(n, i + 1));
if (!expression) {
return NULL;
- }
+ }
asdl_seq_SET(ops, i / 2, newoperator);
asdl_seq_SET(cmps, i / 2, expression);
@@ -1816,7 +1846,7 @@ ast_for_expr(struct compiling *c, const node *n)
expression = ast_for_expr(c, CHILD(n, 0));
if (!expression) {
return NULL;
- }
+ }
return Compare(expression, ops, cmps, LINENO(n),
n->n_col_offset, c->c_arena);
@@ -1839,20 +1869,20 @@ ast_for_expr(struct compiling *c, const node *n)
}
return ast_for_binop(c, n);
case yield_expr: {
- expr_ty exp = NULL;
- if (NCH(n) == 2) {
- exp = ast_for_testlist(c, CHILD(n, 1));
- if (!exp)
- return NULL;
- }
- return Yield(exp, LINENO(n), n->n_col_offset, c->c_arena);
- }
+ expr_ty exp = NULL;
+ if (NCH(n) == 2) {
+ exp = ast_for_testlist(c, CHILD(n, 1));
+ if (!exp)
+ return NULL;
+ }
+ return Yield(exp, LINENO(n), n->n_col_offset, c->c_arena);
+ }
case factor:
if (NCH(n) == 1) {
n = CHILD(n, 0);
goto loop;
}
- return ast_for_factor(c, n);
+ return ast_for_factor(c, n);
case power:
return ast_for_power(c, n);
default:
@@ -1869,7 +1899,7 @@ ast_for_call(struct compiling *c, const node *n, expr_ty func)
/*
arglist: (argument ',')* (argument [',']| '*' test [',' '**' test]
| '**' test)
- argument: [test '='] test [gen_for] # Really [keyword '='] test
+ argument: [test '='] test [gen_for] # Really [keyword '='] test
*/
int i, nargs, nkeywords, ngens;
@@ -1883,20 +1913,20 @@ ast_for_call(struct compiling *c, const node *n, expr_ty func)
nkeywords = 0;
ngens = 0;
for (i = 0; i < NCH(n); i++) {
- node *ch = CHILD(n, i);
- if (TYPE(ch) == argument) {
- if (NCH(ch) == 1)
- nargs++;
- else if (TYPE(CHILD(ch, 1)) == gen_for)
- ngens++;
+ node *ch = CHILD(n, i);
+ if (TYPE(ch) == argument) {
+ if (NCH(ch) == 1)
+ nargs++;
+ else if (TYPE(CHILD(ch, 1)) == gen_for)
+ ngens++;
else
- nkeywords++;
- }
+ nkeywords++;
+ }
}
if (ngens > 1 || (ngens && (nargs || nkeywords))) {
ast_error(n, "Generator expression must be parenthesized "
- "if not sole argument");
- return NULL;
+ "if not sole argument");
+ return NULL;
}
if (nargs + nkeywords + ngens > 255) {
@@ -1913,32 +1943,32 @@ ast_for_call(struct compiling *c, const node *n, expr_ty func)
nargs = 0;
nkeywords = 0;
for (i = 0; i < NCH(n); i++) {
- node *ch = CHILD(n, i);
- if (TYPE(ch) == argument) {
- expr_ty e;
- if (NCH(ch) == 1) {
- if (nkeywords) {
- ast_error(CHILD(ch, 0),
- "non-keyword arg after keyword arg");
- return NULL;
- }
- e = ast_for_expr(c, CHILD(ch, 0));
+ node *ch = CHILD(n, i);
+ if (TYPE(ch) == argument) {
+ expr_ty e;
+ if (NCH(ch) == 1) {
+ if (nkeywords) {
+ ast_error(CHILD(ch, 0),
+ "non-keyword arg after keyword arg");
+ return NULL;
+ }
+ e = ast_for_expr(c, CHILD(ch, 0));
if (!e)
return NULL;
- asdl_seq_SET(args, nargs++, e);
- }
- else if (TYPE(CHILD(ch, 1)) == gen_for) {
- e = ast_for_genexp(c, ch);
+ asdl_seq_SET(args, nargs++, e);
+ }
+ else if (TYPE(CHILD(ch, 1)) == gen_for) {
+ e = ast_for_genexp(c, ch);
if (!e)
return NULL;
- asdl_seq_SET(args, nargs++, e);
+ asdl_seq_SET(args, nargs++, e);
}
- else {
- keyword_ty kw;
- identifier key;
+ else {
+ keyword_ty kw;
+ identifier key;
- /* CHILD(ch, 0) is test, but must be an identifier? */
- e = ast_for_expr(c, CHILD(ch, 0));
+ /* CHILD(ch, 0) is test, but must be an identifier? */
+ e = ast_for_expr(c, CHILD(ch, 0));
if (!e)
return NULL;
/* f(lambda x: x[0] = 3) ends up getting parsed with
@@ -1953,24 +1983,24 @@ ast_for_call(struct compiling *c, const node *n, expr_ty func)
ast_error(CHILD(ch, 0), "keyword can't be an expression");
return NULL;
}
- key = e->v.Name.id;
- e = ast_for_expr(c, CHILD(ch, 2));
+ key = e->v.Name.id;
+ e = ast_for_expr(c, CHILD(ch, 2));
if (!e)
return NULL;
- kw = keyword(key, e, c->c_arena);
+ kw = keyword(key, e, c->c_arena);
if (!kw)
return NULL;
- asdl_seq_SET(keywords, nkeywords++, kw);
- }
- }
- else if (TYPE(ch) == STAR) {
- vararg = ast_for_expr(c, CHILD(n, i+1));
- i++;
- }
- else if (TYPE(ch) == DOUBLESTAR) {
- kwarg = ast_for_expr(c, CHILD(n, i+1));
- i++;
- }
+ asdl_seq_SET(keywords, nkeywords++, kw);
+ }
+ }
+ else if (TYPE(ch) == STAR) {
+ vararg = ast_for_expr(c, CHILD(n, i+1));
+ i++;
+ }
+ else if (TYPE(ch) == DOUBLESTAR) {
+ kwarg = ast_for_expr(c, CHILD(n, i+1));
+ i++;
+ }
}
return Call(func, args, keywords, vararg, kwarg, func->lineno, func->col_offset, c->c_arena);
@@ -1994,12 +2024,12 @@ ast_for_testlist(struct compiling *c, const node* n)
TYPE(n) == testlist1);
}
if (NCH(n) == 1)
- return ast_for_expr(c, CHILD(n, 0));
+ return ast_for_expr(c, CHILD(n, 0));
else {
asdl_seq *tmp = seq_for_testlist(c, n);
if (!tmp)
return NULL;
- return Tuple(tmp, Load, LINENO(n), n->n_col_offset, c->c_arena);
+ return Tuple(tmp, Load, LINENO(n), n->n_col_offset, c->c_arena);
}
}
@@ -2010,7 +2040,7 @@ ast_for_testlist_gexp(struct compiling *c, const node* n)
/* argument: test [ gen_for ] */
assert(TYPE(n) == testlist_gexp || TYPE(n) == argument);
if (NCH(n) > 1 && TYPE(CHILD(n, 1)) == gen_for)
- return ast_for_genexp(c, n);
+ return ast_for_genexp(c, n);
return ast_for_testlist(c, n);
}
@@ -2044,23 +2074,23 @@ ast_for_expr_stmt(struct compiling *c, const node *n)
| ('=' (yield_expr|testlist))*)
testlist: test (',' test)* [',']
augassign: '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^='
- | '<<=' | '>>=' | '**=' | '//='
+ | '<<=' | '>>=' | '**=' | '//='
test: ... here starts the operator precendence dance
*/
if (NCH(n) == 1) {
- expr_ty e = ast_for_testlist(c, CHILD(n, 0));
+ expr_ty e = ast_for_testlist(c, CHILD(n, 0));
if (!e)
return NULL;
- return Expr(e, LINENO(n), n->n_col_offset, c->c_arena);
+ return Expr(e, LINENO(n), n->n_col_offset, c->c_arena);
}
else if (TYPE(CHILD(n, 1)) == augassign) {
expr_ty expr1, expr2;
operator_ty newoperator;
- node *ch = CHILD(n, 0);
+ node *ch = CHILD(n, 0);
- expr1 = ast_for_testlist(c, ch);
+ expr1 = ast_for_testlist(c, ch);
if (!expr1)
return NULL;
/* TODO(nas): Remove duplicated error checks (set_context does it) */
@@ -2089,13 +2119,13 @@ ast_for_expr_stmt(struct compiling *c, const node *n)
"assignment");
return NULL;
}
- set_context(expr1, Store, ch);
+ set_context(expr1, Store, ch);
- ch = CHILD(n, 2);
- if (TYPE(ch) == testlist)
- expr2 = ast_for_testlist(c, ch);
- else
- expr2 = ast_for_expr(c, ch);
+ ch = CHILD(n, 2);
+ if (TYPE(ch) == testlist)
+ expr2 = ast_for_testlist(c, ch);
+ else
+ expr2 = ast_for_expr(c, ch);
if (!expr2)
return NULL;
@@ -2103,45 +2133,45 @@ ast_for_expr_stmt(struct compiling *c, const node *n)
if (!newoperator)
return NULL;
- return AugAssign(expr1, newoperator, expr2, LINENO(n), n->n_col_offset, c->c_arena);
+ return AugAssign(expr1, newoperator, expr2, LINENO(n), n->n_col_offset, c->c_arena);
}
else {
- int i;
- asdl_seq *targets;
- node *value;
+ int i;
+ asdl_seq *targets;
+ node *value;
expr_ty expression;
- /* a normal assignment */
- REQ(CHILD(n, 1), EQUAL);
- targets = asdl_seq_new(NCH(n) / 2, c->c_arena);
- if (!targets)
- return NULL;
- for (i = 0; i < NCH(n) - 2; i += 2) {
- expr_ty e;
- node *ch = CHILD(n, i);
- if (TYPE(ch) == yield_expr) {
- ast_error(ch, "assignment to yield expression not possible");
- return NULL;
- }
- e = ast_for_testlist(c, ch);
-
- /* set context to assign */
- if (!e)
- return NULL;
-
- if (!set_context(e, Store, CHILD(n, i)))
- return NULL;
-
- asdl_seq_SET(targets, i / 2, e);
- }
- value = CHILD(n, NCH(n) - 1);
- if (TYPE(value) == testlist)
- expression = ast_for_testlist(c, value);
- else
- expression = ast_for_expr(c, value);
- if (!expression)
- return NULL;
- return Assign(targets, expression, LINENO(n), n->n_col_offset, c->c_arena);
+ /* a normal assignment */
+ REQ(CHILD(n, 1), EQUAL);
+ targets = asdl_seq_new(NCH(n) / 2, c->c_arena);
+ if (!targets)
+ return NULL;
+ for (i = 0; i < NCH(n) - 2; i += 2) {
+ expr_ty e;
+ node *ch = CHILD(n, i);
+ if (TYPE(ch) == yield_expr) {
+ ast_error(ch, "assignment to yield expression not possible");
+ return NULL;
+ }
+ e = ast_for_testlist(c, ch);
+
+ /* set context to assign */
+ if (!e)
+ return NULL;
+
+ if (!set_context(e, Store, CHILD(n, i)))
+ return NULL;
+
+ asdl_seq_SET(targets, i / 2, e);
+ }
+ value = CHILD(n, NCH(n) - 1);
+ if (TYPE(value) == testlist)
+ expression = ast_for_testlist(c, value);
+ else
+ expression = ast_for_expr(c, value);
+ if (!expression)
+ return NULL;
+ return Assign(targets, expression, LINENO(n), n->n_col_offset, c->c_arena);
}
}
@@ -2158,19 +2188,19 @@ ast_for_print_stmt(struct compiling *c, const node *n)
REQ(n, print_stmt);
if (NCH(n) >= 2 && TYPE(CHILD(n, 1)) == RIGHTSHIFT) {
- dest = ast_for_expr(c, CHILD(n, 2));
+ dest = ast_for_expr(c, CHILD(n, 2));
if (!dest)
return NULL;
- start = 4;
+ start = 4;
}
seq = asdl_seq_new((NCH(n) + 1 - start) / 2, c->c_arena);
if (!seq)
- return NULL;
+ return NULL;
for (i = start, j = 0; i < NCH(n); i += 2, ++j) {
expression = ast_for_expr(c, CHILD(n, i));
if (!expression)
return NULL;
- asdl_seq_SET(seq, j, expression);
+ asdl_seq_SET(seq, j, expression);
}
nl = (TYPE(CHILD(n, NCH(n) - 1)) == COMMA) ? false : true;
return Print(dest, seq, nl, LINENO(n), n->n_col_offset, c->c_arena);
@@ -2187,14 +2217,14 @@ ast_for_exprlist(struct compiling *c, const node *n, expr_context_ty context)
seq = asdl_seq_new((NCH(n) + 1) / 2, c->c_arena);
if (!seq)
- return NULL;
+ return NULL;
for (i = 0; i < NCH(n); i += 2) {
- e = ast_for_expr(c, CHILD(n, i));
- if (!e)
- return NULL;
- asdl_seq_SET(seq, i / 2, e);
- if (context && !set_context(e, context, CHILD(n, i)))
- return NULL;
+ e = ast_for_expr(c, CHILD(n, i));
+ if (!e)
+ return NULL;
+ asdl_seq_SET(seq, i / 2, e);
+ if (context && !set_context(e, context, CHILD(n, i)))
+ return NULL;
}
return seq;
}
@@ -2236,9 +2266,9 @@ ast_for_flow_stmt(struct compiling *c, const node *n)
case continue_stmt:
return Continue(LINENO(n), n->n_col_offset, c->c_arena);
case yield_stmt: { /* will reduce to yield_expr */
- expr_ty exp = ast_for_expr(c, CHILD(ch, 0));
- if (!exp)
- return NULL;
+ expr_ty exp = ast_for_expr(c, CHILD(ch, 0));
+ if (!exp)
+ return NULL;
return Expr(exp, LINENO(n), n->n_col_offset, c->c_arena);
}
case return_stmt:
@@ -2311,10 +2341,6 @@ alias_for_import_name(struct compiling *c, const node *n)
case import_as_name:
str = NULL;
if (NCH(n) == 3) {
- if (strcmp(STR(CHILD(n, 1)), "as") != 0) {
- ast_error(n, "must use 'as' in import");
- return NULL;
- }
str = NEW_IDENTIFIER(CHILD(n, 2));
}
return alias(NEW_IDENTIFIER(CHILD(n, 0)), str, c->c_arena);
@@ -2327,10 +2353,6 @@ alias_for_import_name(struct compiling *c, const node *n)
alias_ty a = alias_for_import_name(c, CHILD(n, 0));
if (!a)
return NULL;
- if (strcmp(STR(CHILD(n, 1)), "as") != 0) {
- ast_error(n, "must use 'as' in import");
- return NULL;
- }
assert(!a->asname);
a->asname = NEW_IDENTIFIER(CHILD(n, 2));
return a;
@@ -2365,13 +2387,13 @@ alias_for_import_name(struct compiling *c, const node *n)
--s;
*s = '\0';
PyString_InternInPlace(&str);
- PyArena_AddPyObject(c->c_arena, str);
+ PyArena_AddPyObject(c->c_arena, str);
return alias(str, NULL, c->c_arena);
}
break;
case STAR:
- str = PyString_InternFromString("*");
- PyArena_AddPyObject(c->c_arena, str);
+ str = PyString_InternFromString("*");
+ PyArena_AddPyObject(c->c_arena, str);
return alias(str, NULL, c->c_arena);
default:
PyErr_Format(PyExc_SystemError,
@@ -2403,69 +2425,69 @@ ast_for_import_stmt(struct compiling *c, const node *n)
n = CHILD(n, 0);
if (TYPE(n) == import_name) {
n = CHILD(n, 1);
- REQ(n, dotted_as_names);
- aliases = asdl_seq_new((NCH(n) + 1) / 2, c->c_arena);
- if (!aliases)
- return NULL;
- for (i = 0; i < NCH(n); i += 2) {
+ REQ(n, dotted_as_names);
+ aliases = asdl_seq_new((NCH(n) + 1) / 2, c->c_arena);
+ if (!aliases)
+ return NULL;
+ for (i = 0; i < NCH(n); i += 2) {
alias_ty import_alias = alias_for_import_name(c, CHILD(n, i));
if (!import_alias)
return NULL;
- asdl_seq_SET(aliases, i / 2, import_alias);
+ asdl_seq_SET(aliases, i / 2, import_alias);
}
- return Import(aliases, lineno, col_offset, c->c_arena);
+ return Import(aliases, lineno, col_offset, c->c_arena);
}
else if (TYPE(n) == import_from) {
int n_children;
- int idx, ndots = 0;
- alias_ty mod = NULL;
- identifier modname;
-
+ int idx, ndots = 0;
+ alias_ty mod = NULL;
+ identifier modname;
+
/* Count the number of dots (for relative imports) and check for the
optional module name */
- for (idx = 1; idx < NCH(n); idx++) {
- if (TYPE(CHILD(n, idx)) == dotted_name) {
- mod = alias_for_import_name(c, CHILD(n, idx));
- idx++;
- break;
- } else if (TYPE(CHILD(n, idx)) != DOT) {
- break;
- }
- ndots++;
- }
- idx++; /* skip over the 'import' keyword */
+ for (idx = 1; idx < NCH(n); idx++) {
+ if (TYPE(CHILD(n, idx)) == dotted_name) {
+ mod = alias_for_import_name(c, CHILD(n, idx));
+ idx++;
+ break;
+ } else if (TYPE(CHILD(n, idx)) != DOT) {
+ break;
+ }
+ ndots++;
+ }
+ idx++; /* skip over the 'import' keyword */
switch (TYPE(CHILD(n, idx))) {
case STAR:
/* from ... import * */
- n = CHILD(n, idx);
- n_children = 1;
- if (ndots) {
- ast_error(n, "'import *' not allowed with 'from .'");
- return NULL;
- }
- break;
- case LPAR:
- /* from ... import (x, y, z) */
- n = CHILD(n, idx + 1);
- n_children = NCH(n);
- break;
- case import_as_names:
- /* from ... import x, y, z */
- n = CHILD(n, idx);
- n_children = NCH(n);
+ n = CHILD(n, idx);
+ n_children = 1;
+ if (ndots) {
+ ast_error(n, "'import *' not allowed with 'from .'");
+ return NULL;
+ }
+ break;
+ case LPAR:
+ /* from ... import (x, y, z) */
+ n = CHILD(n, idx + 1);
+ n_children = NCH(n);
+ break;
+ case import_as_names:
+ /* from ... import x, y, z */
+ n = CHILD(n, idx);
+ n_children = NCH(n);
if (n_children % 2 == 0) {
ast_error(n, "trailing comma not allowed without"
" surrounding parentheses");
return NULL;
}
- break;
- default:
- ast_error(n, "Unexpected node-type in from-import");
- return NULL;
- }
+ break;
+ default:
+ ast_error(n, "Unexpected node-type in from-import");
+ return NULL;
+ }
- aliases = asdl_seq_new((n_children + 1) / 2, c->c_arena);
- if (!aliases)
+ aliases = asdl_seq_new((n_children + 1) / 2, c->c_arena);
+ if (!aliases)
return NULL;
/* handle "from ... import *" special b/c there's no children */
@@ -2473,14 +2495,14 @@ ast_for_import_stmt(struct compiling *c, const node *n)
alias_ty import_alias = alias_for_import_name(c, n);
if (!import_alias)
return NULL;
- asdl_seq_SET(aliases, 0, import_alias);
+ asdl_seq_SET(aliases, 0, import_alias);
}
else {
- for (i = 0; i < NCH(n); i += 2) {
+ for (i = 0; i < NCH(n); i += 2) {
alias_ty import_alias = alias_for_import_name(c, CHILD(n, i));
if (!import_alias)
return NULL;
- asdl_seq_SET(aliases, i / 2, import_alias);
+ asdl_seq_SET(aliases, i / 2, import_alias);
}
}
if (mod != NULL)
@@ -2507,12 +2529,12 @@ ast_for_global_stmt(struct compiling *c, const node *n)
REQ(n, global_stmt);
s = asdl_seq_new(NCH(n) / 2, c->c_arena);
if (!s)
- return NULL;
+ return NULL;
for (i = 1; i < NCH(n); i += 2) {
- name = NEW_IDENTIFIER(CHILD(n, i));
- if (!name)
- return NULL;
- asdl_seq_SET(s, i / 2, name);
+ name = NEW_IDENTIFIER(CHILD(n, i));
+ if (!name)
+ return NULL;
+ asdl_seq_SET(s, i / 2, name);
}
return Global(s, LINENO(n), n->n_col_offset, c->c_arena);
}
@@ -2526,7 +2548,7 @@ ast_for_assert_stmt(struct compiling *c, const node *n)
expr_ty expression = ast_for_expr(c, CHILD(n, 1));
if (!expression)
return NULL;
- return Assert(expression, NULL, LINENO(n), n->n_col_offset, c->c_arena);
+ return Assert(expression, NULL, LINENO(n), n->n_col_offset, c->c_arena);
}
else if (NCH(n) == 4) {
expr_ty expr1, expr2;
@@ -2538,7 +2560,7 @@ ast_for_assert_stmt(struct compiling *c, const node *n)
if (!expr2)
return NULL;
- return Assert(expr1, expr2, LINENO(n), n->n_col_offset, c->c_arena);
+ return Assert(expr1, expr2, LINENO(n), n->n_col_offset, c->c_arena);
}
PyErr_Format(PyExc_SystemError,
"improper number of parts to 'assert' statement: %d",
@@ -2560,53 +2582,53 @@ ast_for_suite(struct compiling *c, const node *n)
total = num_stmts(n);
seq = asdl_seq_new(total, c->c_arena);
if (!seq)
- return NULL;
+ return NULL;
if (TYPE(CHILD(n, 0)) == simple_stmt) {
- n = CHILD(n, 0);
- /* simple_stmt always ends with a NEWLINE,
- and may have a trailing SEMI
- */
- end = NCH(n) - 1;
- if (TYPE(CHILD(n, end - 1)) == SEMI)
- end--;
+ n = CHILD(n, 0);
+ /* simple_stmt always ends with a NEWLINE,
+ and may have a trailing SEMI
+ */
+ end = NCH(n) - 1;
+ if (TYPE(CHILD(n, end - 1)) == SEMI)
+ end--;
/* loop by 2 to skip semi-colons */
- for (i = 0; i < end; i += 2) {
- ch = CHILD(n, i);
- s = ast_for_stmt(c, ch);
- if (!s)
- return NULL;
- asdl_seq_SET(seq, pos++, s);
- }
+ for (i = 0; i < end; i += 2) {
+ ch = CHILD(n, i);
+ s = ast_for_stmt(c, ch);
+ if (!s)
+ return NULL;
+ asdl_seq_SET(seq, pos++, s);
+ }
}
else {
- for (i = 2; i < (NCH(n) - 1); i++) {
- ch = CHILD(n, i);
- REQ(ch, stmt);
- num = num_stmts(ch);
- if (num == 1) {
- /* small_stmt or compound_stmt with only one child */
- s = ast_for_stmt(c, ch);
- if (!s)
- return NULL;
- asdl_seq_SET(seq, pos++, s);
- }
- else {
- int j;
- ch = CHILD(ch, 0);
- REQ(ch, simple_stmt);
- for (j = 0; j < NCH(ch); j += 2) {
- /* statement terminates with a semi-colon ';' */
- if (NCH(CHILD(ch, j)) == 0) {
- assert((j + 1) == NCH(ch));
- break;
- }
- s = ast_for_stmt(c, CHILD(ch, j));
- if (!s)
- return NULL;
- asdl_seq_SET(seq, pos++, s);
- }
- }
- }
+ for (i = 2; i < (NCH(n) - 1); i++) {
+ ch = CHILD(n, i);
+ REQ(ch, stmt);
+ num = num_stmts(ch);
+ if (num == 1) {
+ /* small_stmt or compound_stmt with only one child */
+ s = ast_for_stmt(c, ch);
+ if (!s)
+ return NULL;
+ asdl_seq_SET(seq, pos++, s);
+ }
+ else {
+ int j;
+ ch = CHILD(ch, 0);
+ REQ(ch, simple_stmt);
+ for (j = 0; j < NCH(ch); j += 2) {
+ /* statement terminates with a semi-colon ';' */
+ if (NCH(CHILD(ch, j)) == 0) {
+ assert((j + 1) == NCH(ch));
+ break;
+ }
+ s = ast_for_stmt(c, CHILD(ch, j));
+ if (!s)
+ return NULL;
+ asdl_seq_SET(seq, pos++, s);
+ }
+ }
+ }
}
assert(pos == seq->size);
return seq;
@@ -2633,7 +2655,7 @@ ast_for_if_stmt(struct compiling *c, const node *n)
if (!suite_seq)
return NULL;
- return If(expression, suite_seq, NULL, LINENO(n), n->n_col_offset, c->c_arena);
+ return If(expression, suite_seq, NULL, LINENO(n), n->n_col_offset, c->c_arena);
}
s = STR(CHILD(n, 4));
@@ -2655,28 +2677,28 @@ ast_for_if_stmt(struct compiling *c, const node *n)
if (!seq2)
return NULL;
- return If(expression, seq1, seq2, LINENO(n), n->n_col_offset, c->c_arena);
+ return If(expression, seq1, seq2, LINENO(n), n->n_col_offset, c->c_arena);
}
else if (s[2] == 'i') {
- int i, n_elif, has_else = 0;
- asdl_seq *orelse = NULL;
- n_elif = NCH(n) - 4;
+ int i, n_elif, has_else = 0;
+ asdl_seq *orelse = NULL;
+ n_elif = NCH(n) - 4;
/* must reference the child n_elif+1 since 'else' token is third,
not fourth, child from the end. */
- if (TYPE(CHILD(n, (n_elif + 1))) == NAME
- && STR(CHILD(n, (n_elif + 1)))[2] == 's') {
- has_else = 1;
- n_elif -= 3;
- }
- n_elif /= 4;
-
- if (has_else) {
+ if (TYPE(CHILD(n, (n_elif + 1))) == NAME
+ && STR(CHILD(n, (n_elif + 1)))[2] == 's') {
+ has_else = 1;
+ n_elif -= 3;
+ }
+ n_elif /= 4;
+
+ if (has_else) {
expr_ty expression;
asdl_seq *seq1, *seq2;
- orelse = asdl_seq_new(1, c->c_arena);
- if (!orelse)
- return NULL;
+ orelse = asdl_seq_new(1, c->c_arena);
+ if (!orelse)
+ return NULL;
expression = ast_for_expr(c, CHILD(n, NCH(n) - 6));
if (!expression)
return NULL;
@@ -2687,20 +2709,20 @@ ast_for_if_stmt(struct compiling *c, const node *n)
if (!seq2)
return NULL;
- asdl_seq_SET(orelse, 0, If(expression, seq1, seq2,
- LINENO(CHILD(n, NCH(n) - 6)), CHILD(n, NCH(n) - 6)->n_col_offset,
+ asdl_seq_SET(orelse, 0, If(expression, seq1, seq2,
+ LINENO(CHILD(n, NCH(n) - 6)), CHILD(n, NCH(n) - 6)->n_col_offset,
c->c_arena));
- /* the just-created orelse handled the last elif */
- n_elif--;
- }
+ /* the just-created orelse handled the last elif */
+ n_elif--;
+ }
- for (i = 0; i < n_elif; i++) {
- int off = 5 + (n_elif - i - 1) * 4;
+ for (i = 0; i < n_elif; i++) {
+ int off = 5 + (n_elif - i - 1) * 4;
expr_ty expression;
asdl_seq *suite_seq;
- asdl_seq *newobj = asdl_seq_new(1, c->c_arena);
- if (!newobj)
- return NULL;
+ asdl_seq *newobj = asdl_seq_new(1, c->c_arena);
+ if (!newobj)
+ return NULL;
expression = ast_for_expr(c, CHILD(n, off));
if (!expression)
return NULL;
@@ -2708,14 +2730,14 @@ ast_for_if_stmt(struct compiling *c, const node *n)
if (!suite_seq)
return NULL;
- asdl_seq_SET(newobj, 0,
- If(expression, suite_seq, orelse,
- LINENO(CHILD(n, off)), CHILD(n, off)->n_col_offset, c->c_arena));
- orelse = newobj;
- }
- return If(ast_for_expr(c, CHILD(n, 1)),
- ast_for_suite(c, CHILD(n, 3)),
- orelse, LINENO(n), n->n_col_offset, c->c_arena);
+ asdl_seq_SET(newobj, 0,
+ If(expression, suite_seq, orelse,
+ LINENO(CHILD(n, off)), CHILD(n, off)->n_col_offset, c->c_arena));
+ orelse = newobj;
+ }
+ return If(ast_for_expr(c, CHILD(n, 1)),
+ ast_for_suite(c, CHILD(n, 3)),
+ orelse, LINENO(n), n->n_col_offset, c->c_arena);
}
PyErr_Format(PyExc_SystemError,
@@ -2739,7 +2761,7 @@ ast_for_while_stmt(struct compiling *c, const node *n)
suite_seq = ast_for_suite(c, CHILD(n, 3));
if (!suite_seq)
return NULL;
- return While(expression, suite_seq, NULL, LINENO(n), n->n_col_offset, c->c_arena);
+ return While(expression, suite_seq, NULL, LINENO(n), n->n_col_offset, c->c_arena);
}
else if (NCH(n) == 7) {
expr_ty expression;
@@ -2755,7 +2777,7 @@ ast_for_while_stmt(struct compiling *c, const node *n)
if (!seq2)
return NULL;
- return While(expression, seq1, seq2, LINENO(n), n->n_col_offset, c->c_arena);
+ return While(expression, seq1, seq2, LINENO(n), n->n_col_offset, c->c_arena);
}
PyErr_Format(PyExc_SystemError,
@@ -2775,7 +2797,7 @@ ast_for_for_stmt(struct compiling *c, const node *n)
REQ(n, for_stmt);
if (NCH(n) == 9) {
- seq = ast_for_suite(c, CHILD(n, 8));
+ seq = ast_for_suite(c, CHILD(n, 8));
if (!seq)
return NULL;
}
@@ -2787,9 +2809,9 @@ ast_for_for_stmt(struct compiling *c, const node *n)
/* Check the # of children rather than the length of _target, since
for x, in ... has 1 element in _target, but still requires a Tuple. */
if (NCH(node_target) == 1)
- target = (expr_ty)asdl_seq_GET(_target, 0);
+ target = (expr_ty)asdl_seq_GET(_target, 0);
else
- target = Tuple(_target, Store, LINENO(n), n->n_col_offset, c->c_arena);
+ target = Tuple(_target, Store, LINENO(n), n->n_col_offset, c->c_arena);
expression = ast_for_testlist(c, CHILD(n, 3));
if (!expression)
@@ -2814,7 +2836,7 @@ ast_for_except_clause(struct compiling *c, const node *exc, node *body)
if (!suite_seq)
return NULL;
- return excepthandler(NULL, NULL, suite_seq, LINENO(exc),
+ return excepthandler(NULL, NULL, suite_seq, LINENO(exc),
exc->n_col_offset, c->c_arena);
}
else if (NCH(exc) == 2) {
@@ -2828,16 +2850,16 @@ ast_for_except_clause(struct compiling *c, const node *exc, node *body)
if (!suite_seq)
return NULL;
- return excepthandler(expression, NULL, suite_seq, LINENO(exc),
+ return excepthandler(expression, NULL, suite_seq, LINENO(exc),
exc->n_col_offset, c->c_arena);
}
else if (NCH(exc) == 4) {
asdl_seq *suite_seq;
expr_ty expression;
- expr_ty e = ast_for_expr(c, CHILD(exc, 3));
- if (!e)
+ expr_ty e = ast_for_expr(c, CHILD(exc, 3));
+ if (!e)
return NULL;
- if (!set_context(e, Store, CHILD(exc, 3)))
+ if (!set_context(e, Store, CHILD(exc, 3)))
return NULL;
expression = ast_for_expr(c, CHILD(exc, 1));
if (!expression)
@@ -2846,7 +2868,7 @@ ast_for_except_clause(struct compiling *c, const node *exc, node *body)
if (!suite_seq)
return NULL;
- return excepthandler(expression, e, suite_seq, LINENO(exc),
+ return excepthandler(expression, e, suite_seq, LINENO(exc),
exc->n_col_offset, c->c_arena);
}
@@ -2901,8 +2923,8 @@ ast_for_try_stmt(struct compiling *c, const node *n)
}
if (n_except > 0) {
- int i;
- stmt_ty except_st;
+ int i;
+ stmt_ty except_st;
/* process except statements to create a try ... except */
asdl_seq *handlers = asdl_seq_new(n_except, c->c_arena);
if (handlers == NULL)
@@ -2916,17 +2938,17 @@ ast_for_try_stmt(struct compiling *c, const node *n)
asdl_seq_SET(handlers, i, e);
}
- except_st = TryExcept(body, handlers, orelse, LINENO(n),
+ except_st = TryExcept(body, handlers, orelse, LINENO(n),
n->n_col_offset, c->c_arena);
if (!finally)
- return except_st;
+ return except_st;
/* if a 'finally' is present too, we nest the TryExcept within a
TryFinally to emulate try ... except ... finally */
- body = asdl_seq_new(1, c->c_arena);
- if (body == NULL)
- return NULL;
- asdl_seq_SET(body, 0, except_st);
+ body = asdl_seq_new(1, c->c_arena);
+ if (body == NULL)
+ return NULL;
+ asdl_seq_SET(body, 0, except_st);
}
/* must be a try ... finally (except clauses are in body, if any exist) */
@@ -2938,10 +2960,6 @@ static expr_ty
ast_for_with_var(struct compiling *c, const node *n)
{
REQ(n, with_var);
- if (strcmp(STR(CHILD(n, 0)), "as") != 0) {
- ast_error(n, "expected \"with [expr] as [var]\"");
- return NULL;
- }
return ast_for_expr(c, CHILD(n, 1));
}
@@ -2961,9 +2979,9 @@ ast_for_with_stmt(struct compiling *c, const node *n)
if (!optional_vars) {
return NULL;
}
- if (!set_context(optional_vars, Store, n)) {
- return NULL;
- }
+ if (!set_context(optional_vars, Store, n)) {
+ return NULL;
+ }
suite_index = 4;
}
@@ -2972,7 +2990,7 @@ ast_for_with_stmt(struct compiling *c, const node *n)
return NULL;
}
return With(context_expr, optional_vars, suite_seq, LINENO(n),
- n->n_col_offset, c->c_arena);
+ n->n_col_offset, c->c_arena);
}
static stmt_ty
@@ -2984,23 +3002,23 @@ ast_for_classdef(struct compiling *c, const node *n)
REQ(n, classdef);
if (!strcmp(STR(CHILD(n, 1)), "None")) {
- ast_error(n, "assignment to None");
- return NULL;
+ ast_error(n, "assignment to None");
+ return NULL;
}
if (NCH(n) == 4) {
s = ast_for_suite(c, CHILD(n, 3));
if (!s)
return NULL;
- return ClassDef(NEW_IDENTIFIER(CHILD(n, 1)), NULL, s, LINENO(n),
+ return ClassDef(NEW_IDENTIFIER(CHILD(n, 1)), NULL, s, LINENO(n),
n->n_col_offset, c->c_arena);
}
/* check for empty base list */
if (TYPE(CHILD(n,3)) == RPAR) {
- s = ast_for_suite(c, CHILD(n,5));
- if (!s)
- return NULL;
- return ClassDef(NEW_IDENTIFIER(CHILD(n, 1)), NULL, s, LINENO(n),
+ s = ast_for_suite(c, CHILD(n,5));
+ if (!s)
+ return NULL;
+ return ClassDef(NEW_IDENTIFIER(CHILD(n, 1)), NULL, s, LINENO(n),
n->n_col_offset, c->c_arena);
}
@@ -3020,20 +3038,20 @@ static stmt_ty
ast_for_stmt(struct compiling *c, const node *n)
{
if (TYPE(n) == stmt) {
- assert(NCH(n) == 1);
- n = CHILD(n, 0);
+ assert(NCH(n) == 1);
+ n = CHILD(n, 0);
}
if (TYPE(n) == simple_stmt) {
- assert(num_stmts(n) == 1);
- n = CHILD(n, 0);
+ assert(num_stmts(n) == 1);
+ n = CHILD(n, 0);
}
if (TYPE(n) == small_stmt) {
REQ(n, small_stmt);
n = CHILD(n, 0);
/* small_stmt: expr_stmt | print_stmt | del_stmt | pass_stmt
| flow_stmt | import_stmt | global_stmt | assert_stmt
- */
- switch (TYPE(n)) {
+ */
+ switch (TYPE(n)) {
case expr_stmt:
return ast_for_expr_stmt(c, n);
case print_stmt:
@@ -3059,11 +3077,11 @@ ast_for_stmt(struct compiling *c, const node *n)
}
else {
/* compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt
- | funcdef | classdef
- */
- node *ch = CHILD(n, 0);
- REQ(n, compound_stmt);
- switch (TYPE(ch)) {
+ | funcdef | classdef
+ */
+ node *ch = CHILD(n, 0);
+ REQ(n, compound_stmt);
+ switch (TYPE(ch)) {
case if_stmt:
return ast_for_if_stmt(c, ch);
case while_stmt:
@@ -3083,144 +3101,144 @@ ast_for_stmt(struct compiling *c, const node *n)
"unhandled small_stmt: TYPE=%d NCH=%d\n",
TYPE(n), NCH(n));
return NULL;
- }
+ }
}
}
static PyObject *
parsenumber(const char *s)
{
- const char *end;
- long x;
- double dx;
+ const char *end;
+ long x;
+ double dx;
#ifndef WITHOUT_COMPLEX
- Py_complex c;
- int imflag;
+ Py_complex c;
+ int imflag;
#endif
- errno = 0;
- end = s + strlen(s) - 1;
+ errno = 0;
+ end = s + strlen(s) - 1;
#ifndef WITHOUT_COMPLEX
- imflag = *end == 'j' || *end == 'J';
+ imflag = *end == 'j' || *end == 'J';
#endif
- if (*end == 'l' || *end == 'L')
- return PyLong_FromString((char *)s, (char **)0, 0);
- if (s[0] == '0') {
- x = (long) PyOS_strtoul((char *)s, (char **)&end, 0);
- if (x < 0 && errno == 0) {
- return PyLong_FromString((char *)s,
- (char **)0,
- 0);
- }
- }
- else
- x = PyOS_strtol((char *)s, (char **)&end, 0);
- if (*end == '\0') {
- if (errno != 0)
- return PyLong_FromString((char *)s, (char **)0, 0);
- return PyInt_FromLong(x);
- }
- /* XXX Huge floats may silently fail */
+ if (*end == 'l' || *end == 'L')
+ return PyLong_FromString((char *)s, (char **)0, 0);
+ if (s[0] == '0') {
+ x = (long) PyOS_strtoul((char *)s, (char **)&end, 0);
+ if (x < 0 && errno == 0) {
+ return PyLong_FromString((char *)s,
+ (char **)0,
+ 0);
+ }
+ }
+ else
+ x = PyOS_strtol((char *)s, (char **)&end, 0);
+ if (*end == '\0') {
+ if (errno != 0)
+ return PyLong_FromString((char *)s, (char **)0, 0);
+ return PyInt_FromLong(x);
+ }
+ /* XXX Huge floats may silently fail */
#ifndef WITHOUT_COMPLEX
- if (imflag) {
- c.real = 0.;
- PyFPE_START_PROTECT("atof", return 0)
- c.imag = PyOS_ascii_atof(s);
- PyFPE_END_PROTECT(c)
- return PyComplex_FromCComplex(c);
- }
- else
+ if (imflag) {
+ c.real = 0.;
+ PyFPE_START_PROTECT("atof", return 0)
+ c.imag = PyOS_ascii_atof(s);
+ PyFPE_END_PROTECT(c)
+ return PyComplex_FromCComplex(c);
+ }
+ else
#endif
- {
- PyFPE_START_PROTECT("atof", return 0)
- dx = PyOS_ascii_atof(s);
- PyFPE_END_PROTECT(dx)
- return PyFloat_FromDouble(dx);
- }
+ {
+ PyFPE_START_PROTECT("atof", return 0)
+ dx = PyOS_ascii_atof(s);
+ PyFPE_END_PROTECT(dx)
+ return PyFloat_FromDouble(dx);
+ }
}
static PyObject *
decode_utf8(const char **sPtr, const char *end, char* encoding)
{
#ifndef Py_USING_UNICODE
- Py_FatalError("decode_utf8 should not be called in this build.");
+ Py_FatalError("decode_utf8 should not be called in this build.");
return NULL;
#else
- PyObject *u, *v;
- char *s, *t;
- t = s = (char *)*sPtr;
- /* while (s < end && *s != '\\') s++; */ /* inefficient for u".." */
- while (s < end && (*s & 0x80)) s++;
- *sPtr = s;
- u = PyUnicode_DecodeUTF8(t, s - t, NULL);
- if (u == NULL)
- return NULL;
- v = PyUnicode_AsEncodedString(u, encoding, NULL);
- Py_DECREF(u);
- return v;
+ PyObject *u, *v;
+ char *s, *t;
+ t = s = (char *)*sPtr;
+ /* while (s < end && *s != '\\') s++; */ /* inefficient for u".." */
+ while (s < end && (*s & 0x80)) s++;
+ *sPtr = s;
+ u = PyUnicode_DecodeUTF8(t, s - t, NULL);
+ if (u == NULL)
+ return NULL;
+ v = PyUnicode_AsEncodedString(u, encoding, NULL);
+ Py_DECREF(u);
+ return v;
#endif
}
static PyObject *
decode_unicode(const char *s, size_t len, int rawmode, const char *encoding)
{
- PyObject *v, *u;
- char *buf;
- char *p;
- const char *end;
- if (encoding == NULL) {
- buf = (char *)s;
- u = NULL;
- } else if (strcmp(encoding, "iso-8859-1") == 0) {
- buf = (char *)s;
- u = NULL;
- } else {
- /* "\XX" may become "\u005c\uHHLL" (12 bytes) */
- u = PyString_FromStringAndSize((char *)NULL, len * 4);
- if (u == NULL)
- return NULL;
- p = buf = PyString_AsString(u);
- end = s + len;
- while (s < end) {
- if (*s == '\\') {
- *p++ = *s++;
- if (*s & 0x80) {
- strcpy(p, "u005c");
- p += 5;
- }
- }
- if (*s & 0x80) { /* XXX inefficient */
- PyObject *w;
- char *r;
- Py_ssize_t rn, i;
- w = decode_utf8(&s, end, "utf-16-be");
- if (w == NULL) {
- Py_DECREF(u);
- return NULL;
- }
- r = PyString_AsString(w);
- rn = PyString_Size(w);
- assert(rn % 2 == 0);
- for (i = 0; i < rn; i += 2) {
- sprintf(p, "\\u%02x%02x",
- r[i + 0] & 0xFF,
- r[i + 1] & 0xFF);
- p += 6;
- }
- Py_DECREF(w);
- } else {
- *p++ = *s++;
- }
- }
- len = p - buf;
- s = buf;
- }
- if (rawmode)
- v = PyUnicode_DecodeRawUnicodeEscape(s, len, NULL);
- else
- v = PyUnicode_DecodeUnicodeEscape(s, len, NULL);
- Py_XDECREF(u);
- return v;
+ PyObject *v, *u;
+ char *buf;
+ char *p;
+ const char *end;
+ if (encoding == NULL) {
+ buf = (char *)s;
+ u = NULL;
+ } else if (strcmp(encoding, "iso-8859-1") == 0) {
+ buf = (char *)s;
+ u = NULL;
+ } else {
+ /* "\XX" may become "\u005c\uHHLL" (12 bytes) */
+ u = PyString_FromStringAndSize((char *)NULL, len * 4);
+ if (u == NULL)
+ return NULL;
+ p = buf = PyString_AsString(u);
+ end = s + len;
+ while (s < end) {
+ if (*s == '\\') {
+ *p++ = *s++;
+ if (*s & 0x80) {
+ strcpy(p, "u005c");
+ p += 5;
+ }
+ }
+ if (*s & 0x80) { /* XXX inefficient */
+ PyObject *w;
+ char *r;
+ Py_ssize_t rn, i;
+ w = decode_utf8(&s, end, "utf-16-be");
+ if (w == NULL) {
+ Py_DECREF(u);
+ return NULL;
+ }
+ r = PyString_AsString(w);
+ rn = PyString_Size(w);
+ assert(rn % 2 == 0);
+ for (i = 0; i < rn; i += 2) {
+ sprintf(p, "\\u%02x%02x",
+ r[i + 0] & 0xFF,
+ r[i + 1] & 0xFF);
+ p += 6;
+ }
+ Py_DECREF(w);
+ } else {
+ *p++ = *s++;
+ }
+ }
+ len = p - buf;
+ s = buf;
+ }
+ if (rawmode)
+ v = PyUnicode_DecodeRawUnicodeEscape(s, len, NULL);
+ else
+ v = PyUnicode_DecodeUnicodeEscape(s, len, NULL);
+ Py_XDECREF(u);
+ return v;
}
/* s is a Python string literal, including the bracketing quote characters,
@@ -3230,75 +3248,75 @@ decode_unicode(const char *s, size_t len, int rawmode, const char *encoding)
static PyObject *
parsestr(const char *s, const char *encoding)
{
- size_t len;
- int quote = Py_CHARMASK(*s);
- int rawmode = 0;
- int need_encoding;
- int unicode = 0;
-
- if (isalpha(quote) || quote == '_') {
- if (quote == 'u' || quote == 'U') {
- quote = *++s;
- unicode = 1;
- }
- if (quote == 'r' || quote == 'R') {
- quote = *++s;
- rawmode = 1;
- }
- }
- if (quote != '\'' && quote != '\"') {
- PyErr_BadInternalCall();
- return NULL;
- }
- s++;
- len = strlen(s);
- if (len > INT_MAX) {
- PyErr_SetString(PyExc_OverflowError,
- "string to parse is too long");
- return NULL;
- }
- if (s[--len] != quote) {
- PyErr_BadInternalCall();
- return NULL;
- }
- if (len >= 4 && s[0] == quote && s[1] == quote) {
- s += 2;
- len -= 2;
- if (s[--len] != quote || s[--len] != quote) {
- PyErr_BadInternalCall();
- return NULL;
- }
- }
+ size_t len;
+ int quote = Py_CHARMASK(*s);
+ int rawmode = 0;
+ int need_encoding;
+ int unicode = 0;
+
+ if (isalpha(quote) || quote == '_') {
+ if (quote == 'u' || quote == 'U') {
+ quote = *++s;
+ unicode = 1;
+ }
+ if (quote == 'r' || quote == 'R') {
+ quote = *++s;
+ rawmode = 1;
+ }
+ }
+ if (quote != '\'' && quote != '\"') {
+ PyErr_BadInternalCall();
+ return NULL;
+ }
+ s++;
+ len = strlen(s);
+ if (len > INT_MAX) {
+ PyErr_SetString(PyExc_OverflowError,
+ "string to parse is too long");
+ return NULL;
+ }
+ if (s[--len] != quote) {
+ PyErr_BadInternalCall();
+ return NULL;
+ }
+ if (len >= 4 && s[0] == quote && s[1] == quote) {
+ s += 2;
+ len -= 2;
+ if (s[--len] != quote || s[--len] != quote) {
+ PyErr_BadInternalCall();
+ return NULL;
+ }
+ }
#ifdef Py_USING_UNICODE
- if (unicode || Py_UnicodeFlag) {
- return decode_unicode(s, len, rawmode, encoding);
- }
+ if (unicode || Py_UnicodeFlag) {
+ return decode_unicode(s, len, rawmode, encoding);
+ }
#endif
- need_encoding = (encoding != NULL &&
- strcmp(encoding, "utf-8") != 0 &&
- strcmp(encoding, "iso-8859-1") != 0);
- if (rawmode || strchr(s, '\\') == NULL) {
- if (need_encoding) {
+ need_encoding = (encoding != NULL &&
+ strcmp(encoding, "utf-8") != 0 &&
+ strcmp(encoding, "iso-8859-1") != 0);
+ if (rawmode || strchr(s, '\\') == NULL) {
+ if (need_encoding) {
#ifndef Py_USING_UNICODE
- /* This should not happen - we never see any other
- encoding. */
- Py_FatalError(
+ /* This should not happen - we never see any other
+ encoding. */
+ Py_FatalError(
"cannot deal with encodings in this build.");
#else
- PyObject *v, *u = PyUnicode_DecodeUTF8(s, len, NULL);
- if (u == NULL)
- return NULL;
- v = PyUnicode_AsEncodedString(u, encoding, NULL);
- Py_DECREF(u);
- return v;
+ PyObject *v, *u = PyUnicode_DecodeUTF8(s, len, NULL);
+ if (u == NULL)
+ return NULL;
+ v = PyUnicode_AsEncodedString(u, encoding, NULL);
+ Py_DECREF(u);
+ return v;
#endif
- } else {
- return PyString_FromStringAndSize(s, len);
- }
- }
+ } else {
+ return PyString_FromStringAndSize(s, len);
+ }
+ }
- return PyString_DecodeEscape(s, len, NULL, unicode,
- need_encoding ? encoding : NULL);
+ return PyString_DecodeEscape(s, len, NULL, unicode,
+ need_encoding ? encoding : NULL);
}
/* Build a Python string object out of a STRING atom. This takes care of
@@ -3308,36 +3326,36 @@ parsestr(const char *s, const char *encoding)
static PyObject *
parsestrplus(struct compiling *c, const node *n)
{
- PyObject *v;
- int i;
- REQ(CHILD(n, 0), STRING);
- if ((v = parsestr(STR(CHILD(n, 0)), c->c_encoding)) != NULL) {
- /* String literal concatenation */
- for (i = 1; i < NCH(n); i++) {
- PyObject *s;
- s = parsestr(STR(CHILD(n, i)), c->c_encoding);
- if (s == NULL)
- goto onError;
- if (PyString_Check(v) && PyString_Check(s)) {
- PyString_ConcatAndDel(&v, s);
- if (v == NULL)
- goto onError;
- }
+ PyObject *v;
+ int i;
+ REQ(CHILD(n, 0), STRING);
+ if ((v = parsestr(STR(CHILD(n, 0)), c->c_encoding)) != NULL) {
+ /* String literal concatenation */
+ for (i = 1; i < NCH(n); i++) {
+ PyObject *s;
+ s = parsestr(STR(CHILD(n, i)), c->c_encoding);
+ if (s == NULL)
+ goto onError;
+ if (PyString_Check(v) && PyString_Check(s)) {
+ PyString_ConcatAndDel(&v, s);
+ if (v == NULL)
+ goto onError;
+ }
#ifdef Py_USING_UNICODE
- else {
- PyObject *temp = PyUnicode_Concat(v, s);
- Py_DECREF(s);
- Py_DECREF(v);
- v = temp;
- if (v == NULL)
- goto onError;
- }
+ else {
+ PyObject *temp = PyUnicode_Concat(v, s);
+ Py_DECREF(s);
+ Py_DECREF(v);
+ v = temp;
+ if (v == NULL)
+ goto onError;
+ }
#endif
- }
- }
- return v;
+ }
+ }
+ return v;
onError:
- Py_XDECREF(v);
- return NULL;
+ Py_XDECREF(v);
+ return NULL;
}
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 8d7147b..73b0220 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -539,7 +539,7 @@ PyDoc_STRVAR(eval_doc,
Evaluate the source in the context of globals and locals.\n\
The source may be a string representing a Python expression\n\
or a code object as returned by compile().\n\
-The globals must be a dictionary and locals can be any mappping,\n\
+The globals must be a dictionary and locals can be any mapping,\n\
defaulting to the current globals and locals.\n\
If only globals is given, locals defaults to it.\n");
@@ -1972,10 +1972,11 @@ builtin_sum(PyObject *self, PyObject *args)
}
PyDoc_STRVAR(sum_doc,
-"sum(sequence, start=0) -> value\n\
+"sum(sequence[, start]) -> value\n\
\n\
Returns the sum of a sequence of numbers (NOT strings) plus the value\n\
-of parameter 'start'. When the sequence is empty, returns start.");
+of parameter 'start' (which defaults to 0). When the sequence is\n\
+empty, returns start.");
static PyObject *
diff --git a/Python/ceval.c b/Python/ceval.c
index 2ae12c3..82aa668 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -184,10 +184,10 @@ static int pcall[PCALL_NUM];
PyObject *
PyEval_GetCallStats(PyObject *self)
{
- return Py_BuildValue("iiiiiiiiii",
+ return Py_BuildValue("iiiiiiiiiii",
pcall[0], pcall[1], pcall[2], pcall[3],
pcall[4], pcall[5], pcall[6], pcall[7],
- pcall[8], pcall[9]);
+ pcall[8], pcall[9], pcall[10]);
}
#else
#define PCALL(O)
@@ -4043,8 +4043,10 @@ import_all_from(PyObject *locals, PyObject *v)
value = PyObject_GetAttr(v, name);
if (value == NULL)
err = -1;
- else
+ else if (PyDict_CheckExact(locals))
err = PyDict_SetItem(locals, name, value);
+ else
+ err = PyObject_SetItem(locals, name, value);
Py_DECREF(name);
Py_XDECREF(value);
if (err != 0)
diff --git a/Python/compile.c b/Python/compile.c
index 1ab315b..bdafd92 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -6,9 +6,10 @@
* object:
* 1. Checks for future statements. See future.c
* 2. Builds a symbol table. See symtable.c.
- * 3. Generate code for basic blocks. See compiler_mod() in this file.
+ * 3. Generate code for basic blocks. See compiler_mod() in this file.
* 4. Assemble the basic blocks into final code. See assemble() in
- * this file.
+ * this file.
+ * 5. Optimize the byte code (peephole optimizations). See peephole.c
*
* Note that compiler_mod() suggests module, but the module ast type
* (mod_ty) has cases for expressions and interactive statements.
@@ -16,7 +17,8 @@
* CAUTION: The VISIT_* macros abort the current function when they
* encounter a problem. So don't invoke them when there is memory
* which needs to be released. Code blocks are OK, as the compiler
- * structure takes care of releasing those.
+ * structure takes care of releasing those. Use the arena to manage
+ * objects.
*/
#include "Python.h"
@@ -32,16 +34,6 @@
int Py_OptimizeFlag = 0;
-/*
- ISSUES:
-
- opcode_stack_effect() function should be reviewed since stack depth bugs
- could be really hard to find later.
-
- Dead code is being generated (i.e. after unconditional jumps).
- XXX(nnorwitz): not sure this is still true
-*/
-
#define DEFAULT_BLOCK_SIZE 16
#define DEFAULT_BLOCKS 8
#define DEFAULT_CODE_SIZE 128
@@ -116,11 +108,11 @@ struct compiler_unit {
int u_argcount; /* number of arguments for block */
int u_kwonlyargcount; /* number of keyword only arguments for block */
- /* Pointer to the most recently allocated block. By following b_list
- members, you can reach all early allocated blocks. */
+ /* Pointer to the most recently allocated block. By following b_list
+ members, you can reach all early allocated blocks. */
basicblock *u_blocks;
basicblock *u_curblock; /* pointer to current block */
- int u_tmpname; /* temporary variables for list comps */
+ int u_tmpname; /* temporary variables for list comps */
int u_nfblocks;
struct fblockinfo u_fblock[CO_MAXBLOCKS];
@@ -153,17 +145,6 @@ struct compiler {
PyArena *c_arena; /* pointer to memory allocation arena */
};
-struct assembler {
- PyObject *a_bytecode; /* string containing bytecode */
- int a_offset; /* offset into bytecode */
- int a_nblocks; /* number of reachable blocks */
- basicblock **a_postorder; /* list of blocks in dfs postorder */
- PyObject *a_lnotab; /* string containing lnotab */
- int a_lnotab_off; /* offset into lnotab */
- int a_lineno; /* last lineno of emitted instruction */
- int a_lineno_off; /* bytecode offset of last lineno */
-};
-
static int compiler_enter_scope(struct compiler *, identifier, void *, int);
static void compiler_free(struct compiler *);
static basicblock *compiler_new_block(struct compiler *);
@@ -188,6 +169,8 @@ static int compiler_push_fblock(struct compiler *, enum fblocktype,
basicblock *);
static void compiler_pop_fblock(struct compiler *, enum fblocktype,
basicblock *);
+/* Returns true if there is a loop on the fblock stack. */
+static int compiler_in_loop(struct compiler *);
static int inplace_binop(struct compiler *, operator_ty);
static int expr_constant(expr_ty e);
@@ -395,47 +378,6 @@ dictbytype(PyObject *src, int scope_type, int flag, int offset)
return dest;
}
-/*
-
-Leave this debugging code for just a little longer.
-
-static void
-compiler_display_symbols(PyObject *name, PyObject *symbols)
-{
-PyObject *key, *value;
-int flags;
-Py_ssize_t pos = 0;
-
-fprintf(stderr, "block %s\n", PyString_AS_STRING(name));
-while (PyDict_Next(symbols, &pos, &key, &value)) {
-flags = PyInt_AsLong(value);
-fprintf(stderr, "var %s:", PyString_AS_STRING(key));
-if (flags & DEF_GLOBAL)
-fprintf(stderr, " declared_global");
-if (flags & DEF_LOCAL)
-fprintf(stderr, " local");
-if (flags & DEF_PARAM)
-fprintf(stderr, " param");
-if (flags & DEF_STAR)
-fprintf(stderr, " stararg");
-if (flags & DEF_DOUBLESTAR)
-fprintf(stderr, " starstar");
-if (flags & DEF_INTUPLE)
-fprintf(stderr, " tuple");
-if (flags & DEF_FREE)
-fprintf(stderr, " free");
-if (flags & DEF_FREE_GLOBAL)
-fprintf(stderr, " global");
-if (flags & DEF_FREE_CLASS)
-fprintf(stderr, " free/class");
-if (flags & DEF_IMPORT)
-fprintf(stderr, " import");
-fprintf(stderr, "\n");
-}
- fprintf(stderr, "\n");
-}
-*/
-
static void
compiler_unit_check(struct compiler_unit *u)
{
@@ -610,7 +552,7 @@ compiler_new_block(struct compiler *c)
return NULL;
}
memset((void *)b, 0, sizeof(basicblock));
- /* Extend the singly linked list of blocks with new block. */
+ /* Extend the singly linked list of blocks with new block. */
b->b_list = u->u_blocks;
u->u_blocks = b;
return b;
@@ -649,7 +591,7 @@ compiler_use_next_block(struct compiler *c, basicblock *block)
/* Returns the offset of the next instruction in the current block's
b_instr array. Resizes the b_instr as necessary.
Returns -1 on failure.
- */
+*/
static int
compiler_next_instr(struct compiler *c, basicblock *b)
@@ -693,7 +635,7 @@ compiler_next_instr(struct compiler *c, basicblock *b)
already been set. If it has been set, the call has no effect.
Every time a new node is b
- */
+*/
static void
compiler_set_lineno(struct compiler *c, int off)
@@ -1053,8 +995,8 @@ compiler_addop_j(struct compiler *c, int opcode, basicblock *b, int absolute)
from the current block to the new block.
*/
-/* XXX The returns inside these macros make it impossible to decref
- objects created in the local function.
+/* The returns inside these macros make it impossible to decref objects
+ created in the local function. Local objects should use the arena.
*/
@@ -1722,6 +1664,8 @@ static int
compiler_continue(struct compiler *c)
{
static const char LOOP_ERROR_MSG[] = "'continue' not properly in loop";
+ static const char IN_FINALLY_ERROR_MSG[] =
+ "'continue' not supported inside 'finally' clause";
int i;
if (!c->u->u_nfblocks)
@@ -1733,15 +1677,18 @@ compiler_continue(struct compiler *c)
break;
case EXCEPT:
case FINALLY_TRY:
- while (--i >= 0 && c->u->u_fblock[i].fb_type != LOOP)
- ;
+ while (--i >= 0 && c->u->u_fblock[i].fb_type != LOOP) {
+ /* Prevent continue anywhere under a finally
+ even if hidden in a sub-try or except. */
+ if (c->u->u_fblock[i].fb_type == FINALLY_END)
+ return compiler_error(c, IN_FINALLY_ERROR_MSG);
+ }
if (i == -1)
return compiler_error(c, LOOP_ERROR_MSG);
ADDOP_JABS(c, CONTINUE_LOOP, c->u->u_fblock[i].fb_block);
break;
case FINALLY_END:
- return compiler_error(c,
- "'continue' not supported inside 'finally' clause");
+ return compiler_error(c, IN_FINALLY_ERROR_MSG);
}
return 1;
@@ -2084,7 +2031,7 @@ compiler_visit_stmt(struct compiler *c, stmt_ty s)
{
int i, n;
- /* Always assign a lineno to the next instruction for a stmt. */
+ /* Always assign a lineno to the next instruction for a stmt. */
c->u->u_lineno = s->lineno;
c->u->u_lineno_set = false;
@@ -2168,7 +2115,7 @@ compiler_visit_stmt(struct compiler *c, stmt_ty s)
case Pass_kind:
break;
case Break_kind:
- if (!c->u->u_nfblocks)
+ if (!compiler_in_loop(c))
return compiler_error(c, "'break' outside loop");
ADDOP(c, BREAK_LOOP);
break;
@@ -2522,7 +2469,6 @@ compiler_compare(struct compiler *c, expr_ty e)
}
return 1;
}
-#undef CMPCAST
static int
compiler_call(struct compiler *c, expr_ty e)
@@ -2622,7 +2568,7 @@ compiler_listcomp_generator(struct compiler *c, PyObject *tmpname,
}
ADDOP_JABS(c, JUMP_ABSOLUTE, start);
compiler_use_next_block(c, anchor);
- /* delete the append method added to locals */
+ /* delete the temporary list name added to locals */
if (gen_index == 1)
if (!compiler_nameop(c, tmpname, Del))
return 0;
@@ -2635,15 +2581,9 @@ compiler_listcomp(struct compiler *c, expr_ty e)
{
identifier tmp;
int rc = 0;
- static identifier append;
asdl_seq *generators = e->v.ListComp.generators;
assert(e->kind == ListComp_kind);
- if (!append) {
- append = PyString_InternFromString("append");
- if (!append)
- return 0;
- }
tmp = compiler_new_tmpname(c);
if (!tmp)
return 0;
@@ -2944,9 +2884,9 @@ compiler_visit_expr(struct compiler *c, expr_ty e)
{
int i, n;
- /* If expr e has a different line number than the last expr/stmt,
- set a new line number for the next instruction.
- */
+ /* If expr e has a different line number than the last expr/stmt,
+ set a new line number for the next instruction.
+ */
if (e->lineno > c->u->u_lineno) {
c->u->u_lineno = e->lineno;
c->u->u_lineno_set = false;
@@ -2995,14 +2935,6 @@ compiler_visit_expr(struct compiler *c, expr_ty e)
case Yield_kind:
if (c->u->u_ste->ste_type != FunctionBlock)
return compiler_error(c, "'yield' outside function");
- /*
- for (i = 0; i < c->u->u_nfblocks; i++) {
- if (c->u->u_fblock[i].fb_type == FINALLY_TRY)
- return compiler_error(
- c, "'yield' not allowed in a 'try' "
- "block with a 'finally' clause");
- }
- */
if (e->v.Yield.value) {
VISIT(c, expr, e->v.Yield.value);
}
@@ -3140,8 +3072,11 @@ static int
compiler_push_fblock(struct compiler *c, enum fblocktype t, basicblock *b)
{
struct fblockinfo *f;
- if (c->u->u_nfblocks >= CO_MAXBLOCKS)
+ if (c->u->u_nfblocks >= CO_MAXBLOCKS) {
+ PyErr_SetString(PyExc_SystemError,
+ "too many statically nested blocks");
return 0;
+ }
f = &c->u->u_fblock[c->u->u_nfblocks++];
f->fb_type = t;
f->fb_block = b;
@@ -3158,6 +3093,16 @@ compiler_pop_fblock(struct compiler *c, enum fblocktype t, basicblock *b)
assert(u->u_fblock[u->u_nfblocks].fb_block == b);
}
+static int
+compiler_in_loop(struct compiler *c) {
+ int i;
+ struct compiler_unit *u = c->u;
+ for (i = 0; i < u->u_nfblocks; ++i) {
+ if (u->u_fblock[i].fb_type == LOOP)
+ return 1;
+ }
+ return 0;
+}
/* Raises a SyntaxError and returns 0.
If something goes wrong, a different exception may be raised.
*/
@@ -3316,7 +3261,6 @@ compiler_visit_nested_slice(struct compiler *c, slice_ty s,
return 1;
}
-
static int
compiler_visit_slice(struct compiler *c, slice_ty s, expr_context_ty ctx)
{
@@ -3358,12 +3302,26 @@ compiler_visit_slice(struct compiler *c, slice_ty s, expr_context_ty ctx)
return compiler_handle_subscr(c, kindname, ctx);
}
+
+/* End of the compiler section, beginning of the assembler section */
+
/* do depth-first search of basic block graph, starting with block.
post records the block indices in post-order.
XXX must handle implicit jumps from one block to next
*/
+struct assembler {
+ PyObject *a_bytecode; /* string containing bytecode */
+ int a_offset; /* offset into bytecode */
+ int a_nblocks; /* number of reachable blocks */
+ basicblock **a_postorder; /* list of blocks in dfs postorder */
+ PyObject *a_lnotab; /* string containing lnotab */
+ int a_lnotab_off; /* offset into lnotab */
+ int a_lineno; /* last lineno of emitted instruction */
+ int a_lineno_off; /* bytecode offset of last lineno */
+};
+
static void
dfs(struct compiler *c, basicblock *b, struct assembler *a)
{
diff --git a/Python/errors.c b/Python/errors.c
index 48ed05c..28c1ea5 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -560,7 +560,8 @@ PyErr_NewException(char *name, PyObject *base, PyObject *dict)
goto failure;
}
if (PyDict_GetItemString(dict, "__module__") == NULL) {
- modulename = PyString_FromStringAndSize(name, (int)(dot-name));
+ modulename = PyString_FromStringAndSize(name,
+ (Py_ssize_t)(dot-name));
if (modulename == NULL)
goto failure;
if (PyDict_SetItemString(dict, "__module__", modulename) != 0)
diff --git a/Python/getargs.c b/Python/getargs.c
index 8dc5e78..f6ddfaa 100644
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -816,7 +816,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
#endif
else
return converterr("string", arg, msgbuf, bufsize);
- if ((int)strlen(*p) != PyString_Size(arg))
+ if ((Py_ssize_t)strlen(*p) != PyString_Size(arg))
return converterr("string without null bytes",
arg, msgbuf, bufsize);
}
@@ -883,7 +883,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
format++;
}
else if (*p != NULL &&
- (int)strlen(*p) != PyString_Size(arg))
+ (Py_ssize_t)strlen(*p) != PyString_Size(arg))
return converterr(
"string without null bytes or None",
arg, msgbuf, bufsize);
@@ -1030,7 +1030,8 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
PyMem_Free()ing it after usage
*/
- if ((int)strlen(PyString_AS_STRING(s)) != size) {
+ if ((Py_ssize_t)strlen(PyString_AS_STRING(s))
+ != size) {
Py_DECREF(s);
return converterr(
"(encoded string without NULL bytes)",
@@ -1746,7 +1747,7 @@ PyArg_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t m
/* For type constructors that don't take keyword args
*
* Sets a TypeError and returns 0 if the kwds dict is
- * not emtpy, returns 1 otherwise
+ * not empty, returns 1 otherwise
*/
int
_PyArg_NoKeywords(const char *funcname, PyObject *kw)
diff --git a/Python/import.c b/Python/import.c
index 4c6c05a..9e46e02 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -64,6 +64,8 @@ extern time_t PyOS_GetLastModificationTime(char *, FILE *);
Python 2.5b3: 62111 (fix wrong code: x += yield)
Python 2.5c1: 62121 (fix wrong lnotab with for loops and
storing constants that should have been removed)
+ Python 2.5c2: 62131 (fix wrong code: for x, in ... in listcomp/genexp)
+ Python 2.6a0: 62141 (peephole optimizations)
Python 3000: 3000
3010 (removed UNARY_CONVERT)
3020 (added BUILD_SET)
@@ -799,14 +801,16 @@ parse_source_module(const char *pathname, FILE *fp)
{
PyCodeObject *co = NULL;
mod_ty mod;
- PyArena *arena = PyArena_New();
+ PyArena *arena = PyArena_New();
+ if (arena == NULL)
+ return NULL;
mod = PyParser_ASTFromFile(fp, pathname, Py_file_input, 0, 0, 0,
NULL, arena);
if (mod) {
co = PyAST_Compile(mod, pathname, NULL, arena);
}
- PyArena_Free(arena);
+ PyArena_Free(arena);
return co;
}
@@ -1030,7 +1034,7 @@ is_builtin(char *name)
/* Return an importer object for a sys.path/pkg.__path__ item 'p',
possibly by fetching it from the path_importer_cache dict. If it
- wasn't yet cached, traverse path_hooks until it a hook is found
+ wasn't yet cached, traverse path_hooks until a hook is found
that can handle the path item. Return None if no hook could;
this tells our caller it should fall back to the builtin
import mechanism. Cache the result in path_importer_cache.
@@ -1802,7 +1806,7 @@ load_module(char *name, FILE *fp, char *buf, int type, PyObject *loader)
/* Initialize a built-in module.
- Return 1 for succes, 0 if the module is not found, and -1 with
+ Return 1 for success, 0 if the module is not found, and -1 with
an exception set if the initialization failed. */
static int
@@ -2117,7 +2121,7 @@ get_parent(PyObject *globals, char *buf, Py_ssize_t *p_buflen, int level)
size_t len;
if (lastdot == NULL && level > 0) {
PyErr_SetString(PyExc_ValueError,
- "Relative importpath too deep");
+ "Attempted relative import in non-package");
return NULL;
}
if (lastdot == NULL)
@@ -2136,7 +2140,8 @@ get_parent(PyObject *globals, char *buf, Py_ssize_t *p_buflen, int level)
char *dot = strrchr(buf, '.');
if (dot == NULL) {
PyErr_SetString(PyExc_ValueError,
- "Relative importpath too deep");
+ "Attempted relative import beyond "
+ "toplevel package");
return NULL;
}
*dot = '\0';
diff --git a/Python/marshal.c b/Python/marshal.c
index 2667b65..4e02ac6 100644
--- a/Python/marshal.c
+++ b/Python/marshal.c
@@ -547,6 +547,11 @@ r_object(RFILE *p)
int size;
PyLongObject *ob;
n = r_long(p);
+ if (n < -INT_MAX || n > INT_MAX) {
+ PyErr_SetString(PyExc_ValueError,
+ "bad marshal data");
+ return NULL;
+ }
size = n<0 ? -n : n;
ob = _PyLong_New(size);
if (ob == NULL)
@@ -655,7 +660,7 @@ r_object(RFILE *p)
case TYPE_INTERNED:
case TYPE_STRING:
n = r_long(p);
- if (n < 0) {
+ if (n < 0 || n > INT_MAX) {
PyErr_SetString(PyExc_ValueError, "bad marshal data");
return NULL;
}
@@ -690,7 +695,7 @@ r_object(RFILE *p)
char *buffer;
n = r_long(p);
- if (n < 0) {
+ if (n < 0 || n > INT_MAX) {
PyErr_SetString(PyExc_ValueError, "bad marshal data");
return NULL;
}
@@ -711,7 +716,7 @@ r_object(RFILE *p)
case TYPE_TUPLE:
n = r_long(p);
- if (n < 0) {
+ if (n < 0 || n > INT_MAX) {
PyErr_SetString(PyExc_ValueError, "bad marshal data");
return NULL;
}
@@ -734,7 +739,7 @@ r_object(RFILE *p)
case TYPE_LIST:
n = r_long(p);
- if (n < 0) {
+ if (n < 0 || n > INT_MAX) {
PyErr_SetString(PyExc_ValueError, "bad marshal data");
return NULL;
}
@@ -833,11 +838,12 @@ r_object(RFILE *p)
v = NULL;
- argcount = r_long(p);
- kwonlyargcount = r_long(p);
- nlocals = r_long(p);
- stacksize = r_long(p);
- flags = r_long(p);
+ /* XXX ignore long->int overflows for now */
+ argcount = (int)r_long(p);
+ kwonlyargcount = (int)r_long(p);
+ nlocals = (int)r_long(p);
+ stacksize = (int)r_long(p);
+ flags = (int)r_long(p);
code = r_object(p);
if (code == NULL)
goto code_error;
@@ -862,7 +868,7 @@ r_object(RFILE *p)
name = r_object(p);
if (name == NULL)
goto code_error;
- firstlineno = r_long(p);
+ firstlineno = (int)r_long(p);
lnotab = r_object(p);
if (lnotab == NULL)
goto code_error;
@@ -1035,10 +1041,16 @@ PyMarshal_WriteObjectToString(PyObject *x, int version)
wf.strings = (version > 0) ? PyDict_New() : NULL;
w_object(x, &wf);
Py_XDECREF(wf.strings);
- if (wf.str != NULL)
- _PyString_Resize(&wf.str,
- (int) (wf.ptr -
- PyString_AS_STRING((PyStringObject *)wf.str)));
+ if (wf.str != NULL) {
+ char *base = PyString_AS_STRING((PyStringObject *)wf.str);
+ if (wf.ptr - base > PY_SSIZE_T_MAX) {
+ Py_DECREF(wf.str);
+ PyErr_SetString(PyExc_OverflowError,
+ "too much marshall data for a string");
+ return NULL;
+ }
+ _PyString_Resize(&wf.str, (Py_ssize_t)(wf.ptr - base));
+ }
if (wf.error) {
Py_XDECREF(wf.str);
PyErr_SetString(PyExc_ValueError,
diff --git a/Python/modsupport.c b/Python/modsupport.c
index e291014..1aa3df2 100644
--- a/Python/modsupport.c
+++ b/Python/modsupport.c
@@ -421,7 +421,7 @@ do_mkvalue(const char **p_format, va_list *p_va, int flags)
"string too long for Python string");
return NULL;
}
- n = (int)m;
+ n = (Py_ssize_t)m;
}
v = PyString_FromStringAndSize(str, n);
}
diff --git a/Python/mystrtoul.c b/Python/mystrtoul.c
index 0dda4be..f007057 100644
--- a/Python/mystrtoul.c
+++ b/Python/mystrtoul.c
@@ -195,13 +195,10 @@ overflowed:
return (unsigned long)-1;
}
-/* Checking for overflow in PyOS_strtol is a PITA since C doesn't define
- * anything about what happens when a signed integer operation overflows,
- * and some compilers think they're doing you a favor by being "clever"
- * then. Python assumes a 2's-complement representation, so that the bit
- * pattern for the largest postive signed long is LONG_MAX, and for
- * the smallest negative signed long is LONG_MAX + 1.
+/* Checking for overflow in PyOS_strtol is a PITA; see comments
+ * about PY_ABS_LONG_MIN in longobject.c.
*/
+#define PY_ABS_LONG_MIN (0-(unsigned long)LONG_MIN)
long
PyOS_strtol(char *str, char **ptr, int base)
@@ -224,8 +221,7 @@ PyOS_strtol(char *str, char **ptr, int base)
if (sign == '-')
result = -result;
}
- else if (sign == '-' && uresult == (unsigned long)LONG_MAX + 1) {
- assert(LONG_MIN == -LONG_MAX-1);
+ else if (sign == '-' && uresult == PY_ABS_LONG_MIN) {
result = LONG_MIN;
}
else {
diff --git a/Python/peephole.c b/Python/peephole.c
index 1459960..28e4c4c 100644
--- a/Python/peephole.c
+++ b/Python/peephole.c
@@ -514,6 +514,13 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
case SETUP_EXCEPT:
case SETUP_FINALLY:
tgt = GETJUMPTGT(codestr, i);
+ /* Replace JUMP_* to a RETURN into just a RETURN */
+ if (UNCONDITIONAL_JUMP(opcode) &&
+ codestr[tgt] == RETURN_VALUE) {
+ codestr[i] = RETURN_VALUE;
+ memset(codestr+i+1, NOP, 2);
+ continue;
+ }
if (!UNCONDITIONAL_JUMP(codestr[tgt]))
continue;
tgttgt = GETJUMPTGT(codestr, tgt);
@@ -531,12 +538,16 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
goto exitUnchanged;
/* Replace RETURN LOAD_CONST None RETURN with just RETURN */
+ /* Remove unreachable JUMPs after RETURN */
case RETURN_VALUE:
- if (i+4 >= codelen ||
- codestr[i+4] != RETURN_VALUE ||
- !ISBASICBLOCK(blocks,i,5))
+ if (i+4 >= codelen)
continue;
- memset(codestr+i+1, NOP, 4);
+ if (codestr[i+4] == RETURN_VALUE &&
+ ISBASICBLOCK(blocks,i,5))
+ memset(codestr+i+1, NOP, 4);
+ else if (UNCONDITIONAL_JUMP(codestr[i+1]) &&
+ ISBASICBLOCK(blocks,i,4))
+ memset(codestr+i+1, NOP, 3);
break;
}
}
diff --git a/Python/pystate.c b/Python/pystate.c
index f591a59..cc25e3e 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -309,9 +309,14 @@ PyThreadState_Swap(PyThreadState *newts)
*/
#if defined(Py_DEBUG) && defined(WITH_THREAD)
if (newts) {
+ /* This can be called from PyEval_RestoreThread(). Similar
+ to it, we need to ensure errno doesn't change.
+ */
+ int err = errno;
PyThreadState *check = PyGILState_GetThisThreadState();
if (check && check->interp == newts->interp && check != newts)
Py_FatalError("Invalid thread state for this thread");
+ errno = err;
}
#endif
return oldts;
@@ -496,7 +501,7 @@ _PyGILState_Fini(void)
{
PyThread_delete_key(autoTLSkey);
autoTLSkey = 0;
- autoInterpreterState = NULL;;
+ autoInterpreterState = NULL;
}
/* When a thread state is created for a thread by some mechanism other than
@@ -504,7 +509,7 @@ _PyGILState_Fini(void)
it so it doesn't try to create another thread state for the thread (this is
a better fix for SF bug #1010677 than the first one attempted).
*/
-void
+static void
_PyGILState_NoteThreadState(PyThreadState* tstate)
{
/* If autoTLSkey is 0, this must be the very first threadstate created
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index e170090..15fad81 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -527,11 +527,15 @@ Py_NewInterpreter(void)
bimod = _PyImport_FindExtension("__builtin__", "__builtin__");
if (bimod != NULL) {
interp->builtins = PyModule_GetDict(bimod);
+ if (interp->builtins == NULL)
+ goto handle_error;
Py_INCREF(interp->builtins);
}
sysmod = _PyImport_FindExtension("sys", "sys");
if (bimod != NULL && sysmod != NULL) {
interp->sysdict = PyModule_GetDict(sysmod);
+ if (interp->sysdict == NULL)
+ goto handle_error;
Py_INCREF(interp->sysdict);
PySys_SetPath(Py_GetPath());
PyDict_SetItemString(interp->sysdict, "modules",
@@ -545,6 +549,7 @@ Py_NewInterpreter(void)
if (!PyErr_Occurred())
return tstate;
+handle_error:
/* Oops, it didn't work. Undo it all. */
PyErr_Print();
@@ -718,6 +723,15 @@ PyRun_InteractiveLoopFlags(FILE *fp, const char *filename, PyCompilerFlags *flag
((flags) ? ((((flags)->cf_flags & PyCF_DONT_IMPLY_DEDENT) ? \
PyPARSE_DONT_IMPLY_DEDENT : 0)) : 0)
+#if 0
+/* Keep an example of flags with future keyword support. */
+#define PARSER_FLAGS(flags) \
+ ((flags) ? ((((flags)->cf_flags & PyCF_DONT_IMPLY_DEDENT) ? \
+ PyPARSE_DONT_IMPLY_DEDENT : 0) \
+ | ((flags)->cf_flags & CO_FUTURE_WITH_STATEMENT ? \
+ PyPARSE_WITH_IS_KEYWORD : 0)) : 0)
+#endif
+
int
PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags)
{
diff --git a/Python/structmember.c b/Python/structmember.c
index 688a4b8..2bb6e4e 100644
--- a/Python/structmember.c
+++ b/Python/structmember.c
@@ -62,29 +62,28 @@ PyMember_GetOne(const char *addr, PyMemberDef *l)
addr += l->offset;
switch (l->type) {
case T_BYTE:
- v = PyInt_FromLong(
- (long) (((*(char*)addr & 0xff) ^ 0x80) - 0x80));
+ v = PyInt_FromLong(*(char*)addr);
break;
case T_UBYTE:
- v = PyInt_FromLong((long) *(char*)addr & 0xff);
+ v = PyLong_FromUnsignedLong(*(unsigned char*)addr);
break;
case T_SHORT:
- v = PyInt_FromLong((long) *(short*)addr);
+ v = PyInt_FromLong(*(short*)addr);
break;
case T_USHORT:
- v = PyInt_FromLong((long) *(unsigned short*)addr);
+ v = PyLong_FromUnsignedLong(*(unsigned short*)addr);
break;
case T_INT:
- v = PyInt_FromLong((long) *(int*)addr);
+ v = PyInt_FromLong(*(int*)addr);
break;
case T_UINT:
- v = PyInt_FromLong((long) *(unsigned int*)addr);
+ v = PyLong_FromUnsignedLong(*(unsigned int*)addr);
break;
case T_LONG:
v = PyInt_FromLong(*(long*)addr);
break;
case T_ULONG:
- v = PyLong_FromDouble((double) *(unsigned long*)addr);
+ v = PyLong_FromUnsignedLong(*(unsigned long*)addr);
break;
case T_FLOAT:
v = PyFloat_FromDouble((double)*(float*)addr);
@@ -179,68 +178,107 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v)
}
addr += l->offset;
switch (l->type) {
- case T_BYTE:
- case T_UBYTE:
- if (!PyInt_Check(v)) {
- PyErr_BadArgument();
+ case T_BYTE:{
+ long long_val;
+ long_val = PyInt_AsLong(v);
+ if ((long_val == -1) && PyErr_Occurred())
return -1;
- }
- *(char*)addr = (char) PyInt_AsLong(v);
+ /* XXX: For compatibility, only warn about truncations
+ for now. */
+ if ((long_val > CHAR_MAX) || (long_val < CHAR_MIN))
+ PyErr_Warn(PyExc_RuntimeWarning, "Truncation of value to char");
+ *(char*)addr = (char)long_val;
break;
- case T_SHORT:
- case T_USHORT:
- if (!PyInt_Check(v)) {
- PyErr_BadArgument();
- return -1;
}
- *(short*)addr = (short) PyInt_AsLong(v);
+ case T_UBYTE:{
+ long long_val;
+ long_val = PyInt_AsLong(v);
+ if ((long_val == -1) && PyErr_Occurred())
+ return -1;
+ if ((long_val > UCHAR_MAX) || (long_val < 0))
+ PyErr_Warn(PyExc_RuntimeWarning, "Truncation of value to unsigned char");
+ *(unsigned char*)addr = (unsigned char)long_val;
break;
- case T_UINT:
- case T_INT:
- if (!PyInt_Check(v)) {
- PyErr_BadArgument();
+ }
+ case T_SHORT:{
+ long long_val;
+ long_val = PyInt_AsLong(v);
+ if ((long_val == -1) && PyErr_Occurred())
return -1;
+ if ((long_val > SHRT_MAX) || (long_val < SHRT_MIN))
+ PyErr_Warn(PyExc_RuntimeWarning, "Truncation of value to short");
+ *(short*)addr = (short)long_val;
+ break;
}
- *(int*)addr = (int) PyInt_AsLong(v);
+ case T_USHORT:{
+ long long_val;
+ long_val = PyInt_AsLong(v);
+ if ((long_val == -1) && PyErr_Occurred())
+ return -1;
+ if ((long_val > USHRT_MAX) || (long_val < 0))
+ PyErr_Warn(PyExc_RuntimeWarning, "Truncation of value to unsigned short");
+ *(unsigned short*)addr = (unsigned short)long_val;
break;
- case T_LONG:
- if (!PyInt_Check(v)) {
- PyErr_BadArgument();
+ }
+ case T_INT:{
+ long long_val;
+ long_val = PyInt_AsLong(v);
+ if ((long_val == -1) && PyErr_Occurred())
return -1;
+ if ((long_val > INT_MAX) || (long_val < INT_MIN))
+ PyErr_Warn(PyExc_RuntimeWarning, "Truncation of value to int");
+ *(int *)addr = (int)long_val;
+ break;
+ }
+ case T_UINT:{
+ unsigned long ulong_val;
+ ulong_val = PyLong_AsUnsignedLong(v);
+ if ((ulong_val == (unsigned int)-1) && PyErr_Occurred()) {
+ /* XXX: For compatibility, accept negative int values
+ as well. */
+ PyErr_Clear();
+ ulong_val = PyLong_AsLong(v);
+ if ((ulong_val == (unsigned int)-1) && PyErr_Occurred())
+ return -1;
+ PyErr_Warn(PyExc_RuntimeWarning, "Writing negative value into unsigned field");
}
- *(long*)addr = PyInt_AsLong(v);
+ if (ulong_val > UINT_MAX)
+ PyErr_Warn(PyExc_RuntimeWarning, "Truncation of value to unsigned int");
+ *(unsigned int *)addr = (unsigned int)ulong_val;
break;
- case T_ULONG:
- if (PyInt_Check(v))
- *(long*)addr = PyInt_AsLong(v);
- else if (PyLong_Check(v))
- *(long*)addr = PyLong_AsLong(v);
- else {
- PyErr_BadArgument();
+ }
+ case T_LONG:{
+ *(long*)addr = PyLong_AsLong(v);
+ if ((*(long*)addr == -1) && PyErr_Occurred())
return -1;
+ break;
+ }
+ case T_ULONG:{
+ *(unsigned long*)addr = PyLong_AsUnsignedLong(v);
+ if ((*(unsigned long*)addr == (unsigned long)-1)
+ && PyErr_Occurred()) {
+ /* XXX: For compatibility, accept negative int values
+ as well. */
+ PyErr_Clear();
+ *(unsigned long*)addr = PyLong_AsLong(v);
+ if ((*(unsigned long*)addr == (unsigned int)-1) && PyErr_Occurred())
+ return -1;
+ PyErr_Warn(PyExc_RuntimeWarning, "Writing negative value into unsigned field");
}
break;
- case T_FLOAT:
- if (PyInt_Check(v))
- *(float*)addr =
- (float) PyInt_AsLong(v);
- else if (PyFloat_Check(v))
- *(float*)addr =
- (float) PyFloat_AsDouble(v);
- else {
- PyErr_BadArgument();
- return -1;
}
+ case T_FLOAT:{
+ double double_val;
+ double_val = PyFloat_AsDouble(v);
+ if ((double_val == -1) && PyErr_Occurred())
+ return -1;
+ *(float*)addr = (float)double_val;
break;
+ }
case T_DOUBLE:
- if (PyInt_Check(v))
- *(double*)addr = (double) PyInt_AsLong(v);
- else if (PyFloat_Check(v))
- *(double*)addr = PyFloat_AsDouble(v);
- else {
- PyErr_BadArgument();
+ *(double*)addr = PyFloat_AsDouble(v);
+ if ((*(double*)addr == -1) && PyErr_Occurred())
return -1;
- }
break;
case T_OBJECT:
case T_OBJECT_EX:
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index a2df669..b74a440 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -979,6 +979,8 @@ svnversion_init(void)
br_start = python + 8;
br_end = strchr(br_start, '/');
+ assert(br_end);
+
/* Works even for trunk,
as we are in trunk/Python/sysmodule.c */
br_end2 = strchr(br_end+1, '/');
@@ -991,6 +993,8 @@ svnversion_init(void)
}
else if (istag || strncmp(br_start, "branches", 8) == 0) {
len = br_end2 - br_start;
+ assert(len >= 13);
+ assert(len < (sizeof(patchlevel_revision) - 13));
strncpy(branch, br_start, len);
branch[len] = '\0';
@@ -1221,7 +1225,7 @@ makepathobject(char *path, int delim)
p = strchr(path, delim);
if (p == NULL)
p = strchr(path, '\0'); /* End of string */
- w = PyString_FromStringAndSize(path, (int) (p - path));
+ w = PyString_FromStringAndSize(path, (Py_ssize_t) (p - path));
if (w == NULL) {
Py_DECREF(v);
return NULL;