Neil Schemenauer [Thu, 30 Aug 2001 00:05:51 +0000 (00:05 +0000)]
Make more things internal to this file. Remove
visit_finalizer_reachable since it's the same as visit_reachable.
Rename visit_reachable to visit_move. Objects can now have the GC type
flag set, reachable by tp_traverse and not be in a GC linked list. This
should make the collector more robust and easier to use by extension
module writers. Add memory management functions for container objects
(new, del, resize).
Neil Schemenauer [Wed, 29 Aug 2001 23:49:28 +0000 (23:49 +0000)]
Change the GC type flag since the API has changed. Allow types using
the old flag to still compile. Remove the PyType_BASICSIZE and
PyType_SET_BASICSIZE macros. Add PyObject_GC_New, PyObject_GC_NewVar,
PyObject_GC_Resize, PyObject_GC_Del, PyObject_GC_Track,
PyObject_GC_UnTrack. Part of SF patch #421893.
Jeremy Hylton [Wed, 29 Aug 2001 22:30:09 +0000 (22:30 +0000)]
Track the block stack more reasonably in order to handle continue in
try/except or try/finally.
Previous versions had only track SETUP_LOOP blocks and ignored the
exception part. This meant that it allowed continue inside a
try/except but generated buggy code. Now it does the right thing.
Tim Peters [Wed, 29 Aug 2001 21:37:10 +0000 (21:37 +0000)]
SF bug [#456252] Python should never stomp on [u]intptr_t.
pyport.h: typedef a new Py_intptr_t type.
DELICATE ASSUMPTION: That HAVE_UINTPTR_T implies intptr_t is
available as well as uintptr_t. If that turns out not to be
true, things must get uglier (C99 wants both, so I think it's
an assumption we're *likely* to get away with).
thread_nt.h, PyThread_start_new_thread: MS _beginthread is documented
as returning unsigned long; no idea why uintptr_t was being used.
Others: Always use Py_[u]intptr_t, never [u]intptr_t directly.
Jack Jansen [Wed, 29 Aug 2001 20:26:24 +0000 (20:26 +0000)]
Workaround by Tim Peters to skip this test if run from test.autotest,
in which case it will hang because the import lock is already held
by the main thread.
Jeremy Hylton [Wed, 29 Aug 2001 19:45:33 +0000 (19:45 +0000)]
Undo change from list to dict for handling varnames, consts, etc.
As the doc string for _lookupName() explains:
This routine uses a list instead of a dictionary, because a
dictionary can't store two different keys if the keys have the
same value but different types, e.g. 2 and 2L. The compiler
must treat these two separately, so it does an explicit type
comparison before comparing the values.
Jeremy Hylton [Wed, 29 Aug 2001 18:12:30 +0000 (18:12 +0000)]
Add support for // and //=.
Avoid if/elif/elif/else tests where the final else is supposed to
handle exactly one case instead of all other cases. When the list of
operators is extended, the catchall else treats all new operators as
the last operator in the set of tests. Instead, raise an exception if
an unexpected operator occurs.
Jeremy Hylton [Wed, 29 Aug 2001 18:08:02 +0000 (18:08 +0000)]
Revise implementations of getChildren() and getChildNodes().
Add support for floor division (// and //=)
The implementation of getChildren() and getChildNodes() is intended to
be faster, because it avoids calling flatten() on every return value.
But it's not clear that it is a lot faster, because constructing a
tuple with just the right values ends up being slow. (Too many
attribute lookups probably.)
The ast.txt file is much more complicated, with funny characters at
the ends of names (*, &, !) to indicate the types of each child node.
The astgen script is also much more complex, making me wonder if it's
still useful.
Guido van Rossum [Wed, 29 Aug 2001 15:47:06 +0000 (15:47 +0000)]
Fix super() so that it is usable for static methods (like __new__) as well.
In particular, the second argument can now be a subclass of the first
as well (normally it must be an instance though).
Jack Jansen [Wed, 29 Aug 2001 15:24:53 +0000 (15:24 +0000)]
GUSI on the Mac creates threads with a default stack size of 20KB, which is
not enough for Python. Increased the stacksize to a (somewhat arbitrary)
64KB.
Barry Warsaw [Wed, 29 Aug 2001 01:41:58 +0000 (01:41 +0000)]
On Fred's suggestion, convert sprintf() examples to use
PyString_FromFormat(). Also fixed one grammar problem, and a few
other mark-up issues. Sample code not checked.
Tim Peters [Tue, 28 Aug 2001 22:21:18 +0000 (22:21 +0000)]
pickle.py, load_int(): Match cPickle's just-repaired ability to unpickle
64-bit INTs on 32-bit boxes (where they become longs). Also exploit that
int(str) and long(str) will ignore a trailing newline (saves creating a
new string at the Python level).
pickletester.py: Simulate reading a pickle produced by a 64-bit box.
Guido van Rossum [Tue, 28 Aug 2001 17:47:51 +0000 (17:47 +0000)]
Change in policy: when a slot_tp_xxx function looks for the __xxx__ method,
don't use getattr, but only look in the dict of the type and base types.
This prevents picking up all sorts of weird stuff, including things defined
by the metaclass when the object is a class (type).
For this purpose, a helper function lookup_method() was added. One or two
other places also use this.
Jeremy Hylton [Tue, 28 Aug 2001 16:36:12 +0000 (16:36 +0000)]
XXX_NAME ops should affect varnames
varnames should list all the local variables (with arguments first).
The XXX_NAME ops typically occur at the module level and assignment
ops should create locals.
Jack Jansen [Mon, 27 Aug 2001 23:16:34 +0000 (23:16 +0000)]
Experimental feature: allow \n as well as \r as newline for text files, by breaking in to the lowlevel I/O system. Can be disabled by defining WITHOUT_UNIX_NEWLINES.
Jeremy Hylton [Mon, 27 Aug 2001 22:56:16 +0000 (22:56 +0000)]
Handle private names
(Hard to believe these were never handled before)
Add misc.mangle() that mangles based on the rules in compile.c.
XXX Need to test the corner cases
Update CodeGenerator with a class_name attribute bound to None. If a
particular instance is created within a class scope, the instance's
class_name is bound to that class's name.
Add mangle() method to CodeGenerator that mangles if the class_name
has a class_name in it.
Modify the FunctionCodeGenerator family to handle an extra argument--
the class_name.
Wrap all name ops and attrnames in calls to self.mangle()
Tim Peters [Mon, 27 Aug 2001 21:45:32 +0000 (21:45 +0000)]
Change test_overflow to test_no_overflow; looks like big int literals
are auto-coerced to longs now, but this test still expected OverflowError.
I can't imagine this test failure was unique to Windows.
Jack Jansen [Mon, 27 Aug 2001 21:21:07 +0000 (21:21 +0000)]
Module to help other modules locate their resources. It currently knows about
resources in applets and separate OS9 style resource files, but it will
eventually also be thought the hoops to jump through on OSX/MachO.
Jeremy Hylton [Mon, 27 Aug 2001 21:06:35 +0000 (21:06 +0000)]
Fix for sibling nodes that define the same free variable
Evan Simpson's fix. And his explanation:
If you defined two nested functions in a row that refer to the
same non-global variable, the second one will be generated as
though the variable were global.
Jeremy Hylton [Mon, 27 Aug 2001 21:02:51 +0000 (21:02 +0000)]
Add lookup_name() to optimize use of stack frames
The use of com_node() introduces a lot of extra stack frames, enough
to cause a stack overflow compiling test.test_parser with the standard
interpreter recursionlimit. The com_node() is a convenience function
that hides the dispatch details, but comes at a very high cost. It is
more efficient to dispatch directly in the callers. In these cases,
use lookup_node() and call the dispatched node directly.
Also handle yield_stmt in a way that will work with Python 2.1
(suggested by Shane Hathaway)