Commit Graph

2253 Commits

Author SHA1 Message Date
Jeremy Hylton 77f1bb2778 Real arena implementation
Replace the toy arena implementation with a real one,
based on allocating 8K chunks of memory by default.
2006-02-28 17:53:04 +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
Martin v. Löwis ace990cf5a Regenerate. 2006-02-28 00:32:31 +00:00
Brett Cannon a7446e3438 Check the return code for PyErr_Warn() when warning about raising string
exceptions.  This was triggered when 'warnings' had a filter set to "error"
that caught the string exception deprecation warning.
2006-02-27 23:39:10 +00:00
Tim Peters a7444f47b2 PyErr_ProgramText(): Grrrrrr.
In a Windows debug build, trying to open a file using
an empty string as the name causes assertion death
inside MS's C runtime code.  We probably need to worm
around that in many places.  I'm worming around it here
to stop the new test_with.py from assert-dying in the
Windows debug build (it calls compile() with an empty
string for "the file name", which indirectly leads to
C-level code in Python trying to fopen("", "r")).
2006-02-27 23:29:46 +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
Jeremy Hylton c7d37264bb Fix parsing of subscriptlist.
(Armin's SF bug report).
d = {}
d[1,] = 1
Now handled correctly
2006-02-27 17:29:29 +00:00
Tim Peters f4e6928c4d Patch 1413181, by Gabriel Becedillas.
PyThreadState_Delete():  if the auto-GIL-state machinery knows about
the thread state, forget it (since the thread state is being deleted,
continuing to remember it can't help, but can hurt if another thread
happens to get created with the same thread id).

I'll backport to 2.4 next.
2006-02-27 17:15:31 +00:00
Thomas Wouters 8622e93eab And some more cleanup. 2006-02-27 17:14:45 +00:00
Thomas Wouters 106203c6e0 Clean up from-import handling. 2006-02-27 17:05:19 +00:00
Jeremy Hylton 9ebfbf0a43 Simplify ast_for_trailer() in anticipation of more changes. 2006-02-27 16:50:35 +00:00
Thomas Wouters aa8b6c5855 Fix old not-reading-pep-308-right artifact. 2006-02-27 16:46:22 +00:00
Martin v. Löwis 15e62742fa Revert backwards-incompatible const changes. 2006-02-27 16:46:16 +00:00
Thomas Wouters fa443cda87 Fix assertion errors in debug build, brought on by PEP 308 patch. 2006-02-27 15:43:57 +00:00
Martin v. Löwis 577b5b960d Create _ast module.
Cleanup Python-ast.c generation.
2006-02-27 15:23:19 +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 d3a5f53a27 Avoid reinitializing the types twice. 2006-02-27 00:09:50 +00:00
Martin v. Löwis 8d0701daf1 Stop generating empty arrays. 2006-02-26 23:40:20 +00:00
Neal Norwitz 59090a7334 Oops, I forgot to check this in with the change to Grammar/Grammar.
Implement change suggested by Jiwon Seo on python-dev.
['(' gen_for ')'] is redundant with test, so remove it.
2006-02-26 22:29:38 +00:00
Martin v. Löwis 2b366e41c3 Check whether there are flags. 2006-02-26 22:12:35 +00:00
Martin v. Löwis ce1d5d2527 Fix iterating over cmpop_ty lists. 2006-02-26 20:51:25 +00:00
Martin v. Löwis bd260da900 Generate code to recursively copy an AST into
a tree of Python objects. Expose this through compile().
2006-02-26 19:42:26 +00:00
Neal Norwitz 9a27617239 Based on discussion with Martin and Thomas on python-checkins
add a Py_SAFE_DOWNCAST() to make the code correct.
2006-02-20 18:57:39 +00:00
Neal Norwitz 20dd93f427 Fix compiler warning on amd64. We can't use zd here since this is
ultimately going to snprintf() not the python string formatter.  Right?
2006-02-19 19:34:15 +00:00
Neal Norwitz a361bd8dce Fix compiler warning (int vs Py_ssize_t mismatch 2006-02-19 19:31:50 +00:00
Georg Brandl 1dc5a84aee Bug #801349: document that start/stop/step slice arguments can be None 2006-02-19 00:12:42 +00:00
Martin v. Löwis dde99d2633 Remove size constraints in SLICE opcodes. 2006-02-17 15:57:41 +00:00
Martin v. Löwis 67baee6287 Move cast to suppress warning. 2006-02-16 14:37:48 +00:00
Martin v. Löwis d96ee90993 Use Py_ssize_t to count the 2006-02-16 14:37:16 +00:00
Martin v. Löwis 720ddb625b Use PyString_FromFormat for formatting error messages. 2006-02-16 07:11:33 +00:00
Martin v. Löwis 18e165558b Merge ssize_t branch. 2006-02-15 17:27:45 +00:00
Armin Rigo f5b3e36493 Renamed _length_cue() to __length_hint__(). See:
http://mail.python.org/pipermail/python-dev/2006-February/060524.html
2006-02-11 21:32:43 +00:00
Georg Brandl b69406dc09 Update general copyright years to 2006. 2006-02-11 15:30:36 +00:00
Thomas Wouters 03ca23d892 Explain the clearing of the stack in a comment in Python/ceval.c's
call_function(), rather than commenting on the lack of an explanation in a
comment.
2006-02-10 22:51:45 +00:00
Brett Cannon 82a9394237 Add doc discussing how AST compiler is structured and designed.
It is out of date, though, thanks to lacking info on the arena API.  It also
should eventually be removed in favor of updating PEP 339.
2006-02-09 02:43:14 +00:00
Neal Norwitz 96e48d4698 Use C-style comment 2006-02-05 02:07:19 +00:00
Jeremy Hylton c960f26044 Improved handling of syntax errors.
Expand set of errors caught in set_context().  Some new errors, some
old error messages changed for consistency.

Fixed error checking in generator expression code.  The first set of
tests were impossible condition given the grammar.  In general, the
ast code uses REQ() for those sanity checks.

Fix some error handling for augmented assignments.  As comments in the
code explain, set_context() ought to work here, but I got unexpected
crashes when I tried it.  Should come back to this.

Add note to Grammar that yield expression is a special case.

Add doctest cases for SyntaxErrors raised by ast.c.
2006-01-27 15:18:39 +00:00
Georg Brandl d704817b66 typo 2006-01-20 17:53:27 +00:00
Neal Norwitz 1ac754fa10 Check return result from Py_InitModule*(). This API can fail.
Probably should be backported.
2006-01-19 06:09:39 +00:00
Tim Peters e93e64fb1a Repair bizarre indentation created by VC 7.1. 2006-01-08 02:28:41 +00:00
Tim Peters 5db42c4c50 alias_for_import_name(): Dueling compiler warnings ;-)
Squash new warnings from VC 7.1 about mixing signed and
unsigned types in comparisons.  I can see why `len` was
changed to size_t here, but don't see why `i` was also
changed.  Change `i` back to int.
2006-01-08 02:25:34 +00:00
Tim Peters d8fe7ab711 analyze_cells(): This no longer compiled under VC 7.1.
Move declaration of local `flags` to top of block.
2006-01-08 02:19:07 +00:00
Neal Norwitz 46b7bda9bc Fix icc warnings: conversion from "long" to "int" may lose significant bits 2006-01-08 01:06:06 +00:00
Neal Norwitz d39d861a36 Fix icc warnings: strlen() returns size_t 2006-01-08 01:03:36 +00:00
Neal Norwitz daf595f8a9 Fix icc warnings: shadowing local variable (i) and complex is set but not used, so remove 2006-01-07 21:24:54 +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
Neal Norwitz 406c640344 Fix icc warnings: shadowing local variables 2006-01-07 21:23:26 +00:00
Tim Peters e86e7a5b62 svnversion_init(): Use standard layout for function defn. 2006-01-06 02:42:46 +00:00