Commit graph

2279 commits

Author SHA1 Message Date
Martin v. Löwis
03e5bc02c9 Fix memory leak on attributes. 2006-03-02 00:31:27 +00:00
Thomas Wouters
695934a0ef Make Py_ssize_t clean. 2006-03-01 23:49:13 +00:00
Martin v. Löwis
49c5da1d88 Patch #1440601: Add col_offset attribute to AST nodes. 2006-03-01 22:49:05 +00:00
Thomas Wouters
7464b43e41 Fix incompatible assignment warning from previous checkin. 2006-03-01 22:34:09 +00:00
Thomas Wouters
7f401ef73d Fix gcc (4.0.x) warning about use of uninitialized variables.
(PyMarshal_ReadShortFromFile() is only used in zipimport.c, I don't believe
the extra initializations will matter one way or another.)
2006-03-01 22:30:47 +00:00
Brett Cannon
54ac29497e Document PEP 352 changes. Also added GeneratorExit. 2006-03-01 22:10:49 +00:00
Thomas Wouters
65b3dab50e Fix uninitialized value. (Why are we using bools instead of ints, like we do
everywhere else?)
2006-03-01 22:06:23 +00:00
Martin v. Löwis
0b300be895 Fix more memory leaks. Will backport to 2.4. 2006-03-01 21:33:54 +00:00
Thomas Wouters
c3547a311e Fix C99-ism, and add XXX to comment 2006-03-01 21:31:21 +00:00
Martin v. Löwis
056a69cba6 Reconst parameters that lost their const in the AST merge. 2006-03-01 16:55:42 +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
Jeremy Hylton
224003baef Add missing DECREF. 2006-03-01 15:02:24 +00:00
Thomas Wouters
572a9f32dc Use %zd format characters for Py_ssize_t types. 2006-03-01 05:38:39 +00:00
Thomas Wouters
7f59732716 Put back the essence of Jeremy's original XXX comment. 2006-03-01 05:32:33 +00:00
Brett Cannon
bf36409e2a PEP 352 implementation. Creates a new base class, BaseException, which has an
added message attribute compared to the previous version of Exception.  It is
also a new-style class, making all exceptions now new-style.  KeyboardInterrupt
and SystemExit inherit from BaseException directly.  String exceptions now
raise DeprecationWarning.

Applies patch 1104669, and closes bugs 1012952 and 518846.
2006-03-01 04:25:17 +00:00
Martin v. Löwis
762467475d Use Py_ssize_t for PyArg_UnpackTuple arguments. 2006-03-01 04:06:10 +00:00
Neal Norwitz
53d960c010 Don't pollute namespace as bad as before. All the types are static now. 2006-02-28 22:47:29 +00:00
Thomas Wouters
8ae1295c5b Make 'as' an actual keyword when with's future statement is used. Not
actually necessary for functionality, but good for transition.
2006-02-28 22:42:15 +00:00
Neal Norwitz
090b3dde06 No need to export PySTEntry_New, it is only used in symtable.c 2006-02-28 22:36:46 +00:00
Guido van Rossum
1a5e21e033 Updates to the with-statement:
- New semantics for __exit__() -- it must re-raise the exception
  if type is not None; the with-statement itself doesn't do this.
  (See the updated PEP for motivation.)

- Added context managers to:
  - file
  - thread.LockType
  - threading.{Lock,RLock,Condition,Semaphore,BoundedSemaphore}
  - decimal.Context

- Added contextlib.py, which defines @contextmanager, nested(), closing().

- Unit tests all around; bot no docs yet.
2006-02-28 21:57:43 +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
Jeremy Hylton
56820c2bab Add some stats collection in debugging mode.
No good way to extract output yet.
2006-02-28 19:57:06 +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
Jeremy Hylton
99b4ee6373 Use simple PyList to implement list of PyObject pointers 2006-02-28 18:52:28 +00:00
Jeremy Hylton
08533fdad6 Tabify 2006-02-28 18:29:00 +00:00
Jeremy Hylton
a829313d7b Remove asdl_seq_APPEND() and simplify asdl seq implementation.
Clarify intended use of set_context() and check errors at all call sites.
2006-02-28 17:58:27 +00:00
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