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)
Jack Jansen [Mon, 27 Aug 2001 14:30:55 +0000 (14:30 +0000)]
Fixes by Thomas Heller:
- make the selftests work again (they were apparently not used since
very early in bgen's development), with some minor cleanup by me
- make emacs python mode happier
Jack Jansen [Mon, 27 Aug 2001 14:01:05 +0000 (14:01 +0000)]
Refer to the toolbox modules by their official name (Carbon.AE), not the internal name (_AE). This can slow things down (once) but it's the only way I can get things to work on OSX, OS9 dynamically loaded and OS9 frozen.
Jack Jansen [Mon, 27 Aug 2001 13:59:35 +0000 (13:59 +0000)]
When we're freezing to sourcecode and one of the modules is a dynamic module that is in a package we freeze that module at toplevel (outside any package). Not optimal, but there is little more we can do as config.c has no way to specify a builtin module has to be dumped into a package.
Jack Jansen [Mon, 27 Aug 2001 10:55:41 +0000 (10:55 +0000)]
- A forgotten "from Carbon".
- Made the "killed unknown window" code dependent on a global var,
so you can easily turn the behaviour off for IDE debugging.
Barry Warsaw [Mon, 27 Aug 2001 03:11:09 +0000 (03:11 +0000)]
Two improvements suggested by Greg Stein:
PyString_FromFormatV(): In the final resize at the end, we can use
PyString_AS_STRING() since we know the object is a string and can
avoid the typechecking.
PyString_FromFormat(): GS sez: "For safety/propriety, you should call
va_end() on the vargs variable."
Tim Peters [Sat, 25 Aug 2001 03:02:28 +0000 (03:02 +0000)]
PyString_FromFormatV: Massage platform %p output to match what gcc does,
at least in the first two characters. %p is ill-defined, and people will
forever commit bad tests otherwise ("bad" in the sense that they fall
over (at least on Windows) for lack of a leading '0x'; 5 of the 7 tests
in test_repr.py failed on Windows for that reason this time around).
Barry Warsaw [Fri, 24 Aug 2001 19:11:57 +0000 (19:11 +0000)]
Quick and dirty fix for test_extcall failures trigged by Guido's
recent classobject.c change. When calling an unbound method with no
instances as first argument, the error message has changed. The
message now contains the class name, but the output text being
compared to is too generic, so skip printing it.
Guido van Rossum [Fri, 24 Aug 2001 18:48:27 +0000 (18:48 +0000)]
Improve the error message issued when an unbound method is called with
an inappropriate first argument. Now that there are more ways for
this to fail, make sure to report the name of the class of the
expected instance and of the actual instance.
Barry Warsaw [Fri, 24 Aug 2001 18:37:32 +0000 (18:37 +0000)]
Added lots of tests for reprs of "simple" objects, such as file,
lambda (anonymous functions?), function, xrange, buffer, cell (need to
fill in), and (some) descriptor types.
Also added a new test case for testing repr truncation fixes.
Barry Warsaw [Fri, 24 Aug 2001 18:32:06 +0000 (18:32 +0000)]
PyString_FromFormat() and PyString_FromFormatV(): Largely ripped from
PyErr_Format() these new C API methods can be used instead of
sprintf()'s into hardcoded char* buffers. This allows us to fix
many situation where long package, module, or class names get
truncated in reprs.
PyString_FromFormat() is the varargs variety.
PyString_FromFormatV() is the va_list variety
Original PyErr_Format() code was modified to allow %p and %ld
expansions.
Many reprs were converted to this, checkins coming soo. Not
changed: complex_repr(), float_repr(), float_print(), float_str(),
int_repr(). There may be other candidates not yet converted.
Guido van Rossum [Fri, 24 Aug 2001 15:23:20 +0000 (15:23 +0000)]
Change the getset type to take an optional third function argument:
the delete function. (Question: should the attribute name also be
recorded in the getset object? That makes the protocol more work, but
may give us better error messages.)
Guido van Rossum [Fri, 24 Aug 2001 10:17:36 +0000 (10:17 +0000)]
getset_descr_set(): guard against deletion (indicated by a set call
with a NULL value), in a somewhat lame way: call the set() function
with one argument. Should I add a 3rd function, 'del', instead?
Tim Peters [Thu, 23 Aug 2001 22:56:21 +0000 (22:56 +0000)]
SF bug [#454456] int overflow code needs tests.
Added tests for boundary cases in magical PEP 237 int->long auto-overflow,
but nothing here addresses the rest of the bug report so left it open.
Tim Peters [Thu, 23 Aug 2001 22:31:37 +0000 (22:31 +0000)]
float_pow: Put *all* of the burden on the libm pow in normal
cases.
powu: Deleted.
This started with a nonsensical error msg:
>>> x = -1.
>>> import sys
>>> x**(-sys.maxint-1L)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: negative number cannot be raised to a fractional power
>>>
The special-casing in float_pow was simply wrong in this case (there's
not even anything peculiar about these inputs), and I don't see any point
to it in *any* case: a decent libm pow should have worst-case error under
1 ULP, so in particular should deliver the exact result whenever the exact
result is representable (else its error is at least 1 ULP). Thus our
special fiddling for integral values "shouldn't" buy anything in accuracy,
and, to the contrary, repeated multiplication is less accurate than a
decent pow when the true result isn't exactly representable. So just
letting pow() do its job here (we may not be able to trust libm x-platform
in exceptional cases, but these are normal cases).
Greg Ward [Thu, 23 Aug 2001 20:53:27 +0000 (20:53 +0000)]
Patch #449054 to implement PEP 250. The standard install directory for
modules and extensions on Windows is now $PREFIX/Lib/site-packages.
Includes backwards compatibility code for pre-2.2 Pythons. Contributed
by Paul Moore.