Commit Graph

425 Commits

Author SHA1 Message Date
Jeremy Hylton 82271f13e7 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.
2006-10-04 02:24:52 +00:00
Neal Norwitz 4f096d9487 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.
2006-08-21 19:47:08 +00:00
Neal Norwitz 87557cd72a Add assert to make Klocwork happy (#276) 2006-08-21 18:01:30 +00:00
Jeremy Hylton 644dddcc3f Move peephole optimizer to separate file. 2006-08-21 16:19:37 +00:00
Neal Norwitz 84167d09cd Even though _Py_Mangle() isn't truly public anyone can call it and
there was no verification that privateobj was a PyString.  If it wasn't
a string, this could have allowed a NULL pointer to creep in below and crash.

I wonder if this should be PyString_CheckExact?  Must identifiers be strings
or can they be subclasses?

Klocwork #275
2006-08-12 01:45:47 +00:00
Neal Norwitz 0cbd805a10 Bug #1333982: string/number constants were inappropriately stored
in the byte code and co_consts even if they were not used, ie
immediately popped off the stack.
2006-08-04 05:09:28 +00:00
Neal Norwitz 4ffedadb10 Bug #1191458: tracing over for loops now produces a line event
on each iteration.  I'm not positive this is the best way to handle
this.  I'm also not sure that there aren't other cases where
the lnotab is generated incorrectly.  It would be great if people
that use pdb or tracing could test heavily.

Also:
 * Remove dead/duplicated code that wasn't used/necessary
   because we already handled the docstring prior to entering the loop.
 * add some debugging code into the compiler (#if 0'd out).
2006-08-04 04:58:47 +00:00
Neal Norwitz c173b488dc Add some asserts and update comments 2006-07-30 19:18:13 +00:00
Neal Norwitz f71847e645 If the for loop isn't entered, entryblock will be NULL. If passed
to stackdepth_walk it will be dereffed.

Not sure if I found with failmalloc or Klockwork #55.
2006-07-23 07:51:58 +00:00
Neal Norwitz b59d08c2fb Fix more memory allocation issues found with failmalloc. 2006-07-22 16:20:49 +00:00
Neal Norwitz d12bd012a6 Handle more memory allocation failures without crashing. 2006-07-21 07:59:47 +00:00
Neal Norwitz 84be93b2db Bug #1512814, Fix incorrect lineno's when code within a function
had more than 255 blank lines.  Byte codes need to go first, line #s second.
2006-07-16 01:50:38 +00:00
Neal Norwitz ed65755608 Bug #1512814, Fix incorrect lineno's when code at module scope
started after line 256.
2006-07-10 00:04:44 +00:00
Neil Schemenauer 0e07b60a4e Fix AST compiler bug #1501934: incorrect LOAD/STORE_GLOBAL generation. 2006-07-09 16:16:34 +00:00
Neal Norwitz 2585ad58e6 Fix indentation of case and a Py_ssize_t issue. 2006-06-12 02:09:34 +00:00
Georg Brandl ddbaa660d3 Patch #1346214: correctly optimize away "if 0"-style stmts
(thanks to Neal for review)
2006-06-04 21:56:52 +00:00
Georg Brandl 7784f12d74 Replace Py_BuildValue("OO") by PyTuple_Pack. 2006-05-26 20:04:44 +00:00
Guido van Rossum da5b701aee Get rid of __context__, per the latest changes to PEP 343 and python-dev
discussion.
There are two places of documentation that still mention __context__:
Doc/lib/libstdtypes.tex -- I wasn't quite sure how to rewrite that without
spending a whole lot of time thinking about it; and whatsnew, which Andrew
usually likes to change himself.
2006-05-02 19:47:52 +00:00
Martin v. Löwis 0cc56e5c59 Introduce asdl_int_seq, to hold cmpop_ty. 2006-04-13 12:29:43 +00:00
Skip Montanaro 869bacd465 revert - breaks build of Python/ast.c w/ gcc 2006-04-13 09:48:28 +00:00
Skip Montanaro b940671186 Use union to discriminate pointer types from enum/int types. 2006-04-13 09:37:01 +00:00
Anthony Baxter d691f1a35f casting nastiness to make C++ compiler happy 2006-04-13 01:23:28 +00:00
Anthony Baxter 2c33fc77fe per Jeremy's email, remove the _WITH_CAST versions of macros. g++
still has errors from the casts of asdl_seq_GET to cmpop_ty, but
otherwise it's C++ clean.
2006-04-12 00:43:09 +00:00
Anthony Baxter 7b782b61c5 more low-hanging fruit to make code compile under a C++ compiler. Not
entirely happy with the two new VISIT macros in compile.c, but I
couldn't see a better approach.
2006-04-11 12:01:56 +00:00
Neal Norwitz 14bc4e4d89 Use PyObject_* allocator since FutureFeatures is small 2006-04-10 06:57:06 +00:00
Neal Norwitz b183a25c29 Fix some warnings on HP-UX when using cc/aCC 2006-04-10 01:03:32 +00:00
Jeremy Hylton ed40ea1159 Generate line number table entries for except handlers.
Re-enable all the tests in test_trace.py except one.  Still not sure that these tests test what they used to test, but they pass.  One failing test seems to be caused by undocumented line number table behavior in Python 2.4.
2006-04-04 14:26:39 +00:00
Neal Norwitz cbce280d4f Don't abbreviate ABS, use long name ABSOLUTE. 2006-04-03 06:26:32 +00:00
Jeremy Hylton 12603c41da Expand comments on line numbers and blocks.
Reorder compiler_set_lineno() call for consistency.
2006-04-01 16:18:02 +00:00
Georg Brandl 5c170fd4a9 Fix some missing checks after PyTuple_New, PyList_New, PyDict_New 2006-03-17 19:03:25 +00:00
Nick Coghlan eadee9a744 Fix SF bug #1448804 and ad a test to ensure that all subscript operations continue to be handled correctly 2006-03-13 12:31:58 +00:00
Guido van Rossum f669436189 Um, I thought I'd already checked this in.
Anyway, this is the changes to the with-statement
so that __exit__ must return a true value in order
for a pending exception to be ignored.
The PEP (343) is already updated.
2006-03-10 02:28:35 +00:00
Neal Norwitz 10be2ea85d SF bug 1442442: LIST_APPEND optimization got lost in the AST merge.
Add it back.
2006-03-03 20:29:11 +00:00
Neal Norwitz d9cf85f421 Fix refleak if from __future__ import was not first 2006-03-02 08:08:42 +00:00
Neal Norwitz 3a5468efb0 Update known issues to reflect reality 2006-03-02 04:06:10 +00:00
Martin v. Löwis 49c5da1d88 Patch #1440601: Add col_offset attribute to AST nodes. 2006-03-01 22:49:05 +00:00
Jeremy Hylton e9357b21c0 Tabify and reflow some long lines.
Much of the peephole optimizer is now indented badly, but it's about
to be revised anyway.
2006-03-01 15:47:05 +00:00
Thomas Wouters 5e9f1fa706 Generally inehrit codeflags that are in PyCF_MASK, instead of writing it out
in multiple places. This makes compile()/eval()/etc also inherit the
absolute-import codeflag, like division and with-statement already were.
2006-02-28 20:02:27 +00:00
Thomas Wouters 34aa7ba114 from __future__ import with_statement addon for 'with', mostly written by
Neal.
2006-02-28 19:02:24 +00:00
Thomas Wouters f7f438ba3b SF patch #1438387, PEP 328: relative and absolute imports.
- IMPORT_NAME takes an extra argument from the stack: the relativeness of
   the import. Only passed to __import__ when it's not -1.

 - __import__() takes an optional 5th argument for the same thing; it
   __defaults to -1 (old semantics: try relative, then absolute)

 - 'from . import name' imports name (be it module or regular attribute)
   from the current module's *package*. Likewise, 'from .module import name'
   will import name from a sibling to the current module.

 - Importing from outside a package is not allowed; 'from . import sys' in a
   toplevel module will not work, nor will 'from .. import sys' in a
   (single-level) package.

 - 'from __future__ import absolute_import' will turn on the new semantics
   for import and from-import: imports will be absolute, except for
   from-import with dots.

Includes tests for regular imports and importhooks, parser changes and a
NEWS item, but no compiler-package changes or documentation changes.
2006-02-28 16:09:29 +00:00
Thomas Wouters 1175c43a12 Clarify C-style exception handling with proper label name. 2006-02-27 22:49:54 +00:00
Thomas Wouters bfe51ea5c8 Fix assertions. 2006-02-27 22:48:55 +00:00
Guido van Rossum c2e20744b2 PEP 343 -- the with-statement.
This was started by Mike Bland and completed by Guido
(with help from Neal).

This still needs a __future__ statement added;
Thomas is working on Michael's patch for that aspect.

There's a small amount of code cleanup and refactoring
in ast.c, compile.c and ceval.c (I fixed the lltrace
behavior when EXT_POP is used -- however I had to make
lltrace a static global).
2006-02-27 22:32:47 +00:00
Thomas Wouters dca3b9c797 PEP 308 implementation, including minor refdocs and some testcases. It
breaks the parser module, because it adds the if/else construct as well as
two new grammar rules for backward compatibility. If no one else fixes
parsermodule, I guess I'll go ahead and fix it later this week.

The TeX code was checked with texcheck.py, but not rendered. There is
actually a slight incompatibility:

>>> (x for x in lambda:0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: iteration over non-sequence

changes into

>>> (x for x in lambda: 0)
  File "<stdin>", line 1
    (x for x in lambda: 0)
                     ^
SyntaxError: invalid syntax

Since there's no way the former version can be useful, it's probably a
bugfix ;)
2006-02-27 00:24:13 +00:00
Martin v. Löwis 18e165558b Merge ssize_t branch. 2006-02-15 17:27:45 +00:00
Neal Norwitz 08b401f67a Fix icc warnings: single bit fields should be unsigned, shadowing local variables 2006-01-07 21:24:09 +00:00
Martin v. Löwis 94962615b7 Adjust usage of compiler_use_new_block to its return type. 2006-01-02 21:15:05 +00:00
Fredrik Lundh 93d69a7948 fixed compilation with an ordinary C89 compiler 2005-12-18 15:44:21 +00:00
Neal Norwitz 51abbc7b4a Fix Armin's bug 1333982. He found it, he didn't created it :-)
This code generated a C assertion:
        assert 1, ([s for s in x] +
                   [s for s in x])
        pass

assert was completely broken, it needed to use the proper block.
compiler_use_block() is now no longer used, so remove it.
2005-12-18 07:06:23 +00:00
Neal Norwitz 4e6bf49a5e Handle more error conditions with SystemError 2005-12-18 05:32:41 +00:00