Guido van Rossum [Fri, 31 Aug 2001 17:40:15 +0000 (17:40 +0000)]
Add warning mode for classic division, almost exactly as specified in
PEP 238. Changes:
- add a new flag variable Py_DivisionWarningFlag, declared in
pydebug.h, defined in object.c, set in main.c, and used in
{int,long,float,complex}object.c. When this flag is set, the
classic division operator issues a DeprecationWarning message.
- add a new API PyRun_SimpleStringFlags() to match
PyRun_SimpleString(). The main() function calls this so that
commands run with -c can also benefit from -Dnew.
- While I was at it, I changed the usage message in main() somewhat:
alphabetized the options, split it in *four* parts to fit in under
512 bytes (not that I still believe this is necessary -- doc strings
elsewhere are much longer), and perhaps most visibly, don't display
the full list of options on each command line error. Instead, the
full list is only displayed when -h is used, and otherwise a brief
reminder of -h is displayed. When -h is used, write to stdout so
that you can do `python -h | more'.
Notes:
- I don't want to use the -W option to control whether the classic
division warning is issued or not, because the machinery to decide
whether to display the warning or not is very expensive (it involves
calling into the warnings.py module). You can use -Werror to turn
the warnings into exceptions though.
- The -Dnew option doesn't select future division for all of the
program -- only for the __main__ module. I don't know if I'll ever
change this -- it would require changes to the .pyc file magic
number to do it right, and a more global notion of compiler flags.
- You can usefully combine -Dwarn and -Dnew: this gives the __main__
module new division, and warns about classic division everywhere
else.
Guido van Rossum [Fri, 31 Aug 2001 16:11:15 +0000 (16:11 +0000)]
Fix a memory leak in str_subtype_new(). (All the other
xxx_subtype_new() functions are OK, but I goofed up in this one. :-( )
Guido van Rossum [Fri, 31 Aug 2001 04:35:14 +0000 (04:35 +0000)]
Correct name mangling algorithm, and add a comment.
Guido van Rossum [Thu, 30 Aug 2001 23:13:11 +0000 (23:13 +0000)]
Give 'super' a decent repr(), and readonly attributes to access the
type and obj properties. The "bogus super object" message is gone --
this will now just raise an AttributeError.
Jack Jansen [Thu, 30 Aug 2001 22:10:10 +0000 (22:10 +0000)]
Added all the new files in the right packages and file groups (I think, untested).
Tim Peters [Thu, 30 Aug 2001 22:05:26 +0000 (22:05 +0000)]
SF bug #456621: normpath on Win32 not collapsing c:\\..
I actually rewrote normpath quite a bit: it had no test cases, and as
soon as I starting writing some I found several cases that didn't make
sense.
Andrew M. Kuchling [Thu, 30 Aug 2001 21:30:16 +0000 (21:30 +0000)]
Add Jack Jansen's explanation of the MacOS X changes
Jack Jansen [Thu, 30 Aug 2001 21:29:57 +0000 (21:29 +0000)]
Superseded by the (generated) xx.mcp.
Jack Jansen [Thu, 30 Aug 2001 21:22:10 +0000 (21:22 +0000)]
Case mismatch in "import Types". Apparently nobody has looked at this for a looooong time. Reported by Chris Smith.
Jack Jansen [Thu, 30 Aug 2001 21:19:42 +0000 (21:19 +0000)]
We should look in the directory containing the module, not in the module itself, when we're looking for the resource file.
Guido van Rossum [Thu, 30 Aug 2001 21:18:04 +0000 (21:18 +0000)]
Group some projects into "Done" and "To do". Get rid of Tim's merge
scratchpad -- the merge is long behind us.
Guido van Rossum [Thu, 30 Aug 2001 20:52:40 +0000 (20:52 +0000)]
metaclass(): add some more examples of metaclasses, including one
using cooperative multiple inheritance.
inherits(): add a test for subclassing the unicode type.
Tim Peters [Thu, 30 Aug 2001 20:51:59 +0000 (20:51 +0000)]
SF patch #455966: Allow leading 0 in float/imag literals.
Consequences for Jython still unknown (but raised on Jython-Dev).
Guido van Rossum [Thu, 30 Aug 2001 20:26:05 +0000 (20:26 +0000)]
PyObject_Repr(): add missing ">" back at end of format string: "<%s
object at %p>".
Jeremy Hylton [Thu, 30 Aug 2001 20:25:55 +0000 (20:25 +0000)]
Fix _convert_NAME() so that it doesn't store locals for class bodies.
Fix list comp code generation -- emit GET_ITER instead of Const(0)
after the list.
Add CO_GENERATOR flag to generators.
Get CO_xxx flags from the new module
Tim Peters [Thu, 30 Aug 2001 20:07:55 +0000 (20:07 +0000)]
Squash new compiler wng.
Guido van Rossum [Thu, 30 Aug 2001 20:06:08 +0000 (20:06 +0000)]
Add testcases for inheritance from tricky builtins (numbers, strings,
tuples).
Guido van Rossum [Thu, 30 Aug 2001 20:00:07 +0000 (20:00 +0000)]
Pytype_GenericAlloc(): round up size so we zap all four bytes of the
__dict__ slot for string subtypes.
subtype_dealloc(): properly use _PyObject_GetDictPtr() to get the
(potentially negative) dict offset. Don't copy things into local
variables that are used only once.
type_new(): properly calculate a negative dict offset when tp_itemsize
is nonzero. The __dict__ attribute, if present, is now a calculated
attribute rather than a structure member.
Fred Drake [Thu, 30 Aug 2001 19:15:20 +0000 (19:15 +0000)]
Revert the previous patch to test_pow.py and move the test to test_unary.py
based on a suggestion from Tim Peters; also make sure that we're really
doing exponentiation and not multiplication.
Fred Drake [Thu, 30 Aug 2001 18:56:30 +0000 (18:56 +0000)]
Added a regression test for the negation-of-exponentiation optimization
bug from compile.c. (SF bug #456756.)
Fred Drake [Thu, 30 Aug 2001 18:53:25 +0000 (18:53 +0000)]
When re-writing a factor containing a unary negation of a literal, only
affect nodes without another operator. This was causing negated
exponentiations to drop the exponentiation. This closes SF bug #456756.
Guido van Rossum [Thu, 30 Aug 2001 18:31:30 +0000 (18:31 +0000)]
More stuff discovered while writing the simplest of testcases:
tupledealloc(): only feed the free list when the type is really a
tuple, not a subtype. Otherwise, use PyObject_GC_Del().
_PyTuple_Resize(): disallow using this for tuple subtypes.
Guido van Rossum [Thu, 30 Aug 2001 16:06:23 +0000 (16:06 +0000)]
Do the int inlining only if the type is really an int, not whenever
PyInt_Check() succeeds. That returns true for subtypes of int, which
may override __add__ or __sub__.
Guido van Rossum [Thu, 30 Aug 2001 15:54:44 +0000 (15:54 +0000)]
Ah, the joy of writing test cases...
long_subtype_new(): fix a typo (type->ob_size instead of
tmp->ob_size).
Jeremy Hylton [Thu, 30 Aug 2001 15:50:34 +0000 (15:50 +0000)]
spurious pop
Neil Schemenauer [Thu, 30 Aug 2001 15:38:01 +0000 (15:38 +0000)]
Add news about GC API change. Explain how to upgrade extension modules.
Neil Schemenauer [Thu, 30 Aug 2001 15:24:17 +0000 (15:24 +0000)]
Update documentation for GC API. Closes SF patch #421893.
Guido van Rossum [Thu, 30 Aug 2001 15:07:44 +0000 (15:07 +0000)]
win_getpass(): if sys.stdin is not sys.__stdin__, use
default_getpass(). This should prevent hanging when it is called in
IDLE.
Fixes SF bug #455648.
Michael W. Hudson [Thu, 30 Aug 2001 14:50:20 +0000 (14:50 +0000)]
fix for part of bug #453523: disable unmarshalling of code objects in
restricted execution mode.
Fred Drake [Thu, 30 Aug 2001 14:42:40 +0000 (14:42 +0000)]
Update the links to the FIPS document that defines the Secure Hash
Algorithm. This closes SF bug #454917.
Sjoerd Mullender [Thu, 30 Aug 2001 14:37:07 +0000 (14:37 +0000)]
Removed unreachable return to silence SGI compiler.
Sjoerd Mullender [Thu, 30 Aug 2001 14:15:38 +0000 (14:15 +0000)]
Removed an unreachable break statement to silence SGI compiler.
Sjoerd Mullender [Thu, 30 Aug 2001 14:06:45 +0000 (14:06 +0000)]
Removed unreachable goto statement to silence SGI compiler.
Sjoerd Mullender [Thu, 30 Aug 2001 14:05:20 +0000 (14:05 +0000)]
Removed some unreachable break statements to silence SGI compiler.
Sjoerd Mullender [Thu, 30 Aug 2001 13:58:58 +0000 (13:58 +0000)]
Removed some unreachable break statements to silence SGI compiler.
Jack Jansen [Thu, 30 Aug 2001 13:26:53 +0000 (13:26 +0000)]
Started on the 2.2a2 installer
Tim Peters [Thu, 30 Aug 2001 06:15:32 +0000 (06:15 +0000)]
Give the internal immutable list type .extend and .pop methods (they
"should have" been added here when they were added to lists).
Tim Peters [Thu, 30 Aug 2001 05:16:13 +0000 (05:16 +0000)]
Add a new function imp.lock_held(), and use it to skip test_threaded_import
when that test is doomed to deadlock.
Guido van Rossum [Thu, 30 Aug 2001 04:43:35 +0000 (04:43 +0000)]
Safety measures now that str and tuple are subclassable:
If tp_itemsize of the basetype is nonzero, only allow empty __slots__
(declaring that no __dict__ should be added), and don't add a weakref
offset.
Guido van Rossum [Thu, 30 Aug 2001 04:37:15 +0000 (04:37 +0000)]
Make 'super' subclassable. (Not sure how useful this is yet. :-)
Guido van Rossum [Thu, 30 Aug 2001 03:12:59 +0000 (03:12 +0000)]
Make unicode subclassable.
Guido van Rossum [Thu, 30 Aug 2001 03:11:59 +0000 (03:11 +0000)]
Make str and tuple types subclassable.
Guido van Rossum [Thu, 30 Aug 2001 03:10:36 +0000 (03:10 +0000)]
Make getset subclassable.
Guido van Rossum [Thu, 30 Aug 2001 03:09:31 +0000 (03:09 +0000)]
Fix typo: double semicolons.
Guido van Rossum [Thu, 30 Aug 2001 03:08:07 +0000 (03:08 +0000)]
Make the Py<type>_Check() macro use PyObject_TypeCheck().
Tim Peters [Thu, 30 Aug 2001 00:32:51 +0000 (00:32 +0000)]
Squash new compiler wng in debug build.
Neil Schemenauer [Thu, 30 Aug 2001 00:13:38 +0000 (00:13 +0000)]
gcmodule is now always compiled
Neil Schemenauer [Thu, 30 Aug 2001 00:12:32 +0000 (00:12 +0000)]
gcmodule is now enabled here
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:58:47 +0000 (23:58 +0000)]
Always build gcmodule.
Neil Schemenauer [Wed, 29 Aug 2001 23:57:22 +0000 (23:57 +0000)]
Flush output more aggressively. This makes things look better if
the setup script is running from inside Vim.
Neil Schemenauer [Wed, 29 Aug 2001 23:54:54 +0000 (23:54 +0000)]
Use new GC API. Remove usage of BASICSIZE macros.
Neil Schemenauer [Wed, 29 Aug 2001 23:54:21 +0000 (23:54 +0000)]
Use new GC API.
Neil Schemenauer [Wed, 29 Aug 2001 23:54:03 +0000 (23:54 +0000)]
Remove GC related code. It lives in gcmodule now.
Neil Schemenauer [Wed, 29 Aug 2001 23:52:17 +0000 (23:52 +0000)]
Make frames a PyVarObject. Use new GC API.
Neil Schemenauer [Wed, 29 Aug 2001 23:50:42 +0000 (23:50 +0000)]
Remove bogus PyGC_HEAD_SIZE.
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.
Neil Schemenauer [Wed, 29 Aug 2001 23:46:35 +0000 (23:46 +0000)]
Change the GC type flag since the API has changed. Allow types using
the old flag to still compile.
Neil Schemenauer [Wed, 29 Aug 2001 23:45:25 +0000 (23:45 +0000)]
Make frames a PyVarObject instead of a PyObject.
Neil Schemenauer [Wed, 29 Aug 2001 23:44:38 +0000 (23:44 +0000)]
Always compile gcmodule.
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.
Jeremy Hylton [Wed, 29 Aug 2001 22:27:14 +0000 (22:27 +0000)]
Improve stack depth computation for try/except and try/finally
Add CONTINUE_LOOP to the list of unconditional transfers
Jeremy Hylton [Wed, 29 Aug 2001 22:26:35 +0000 (22:26 +0000)]
Add __getitem__() handler for use by visitContinue()
Jack Jansen [Wed, 29 Aug 2001 22:08:06 +0000 (22:08 +0000)]
Added xx and xxsubtype modules, for completeness and because xxsubtype is used by the test suite.
Jack Jansen [Wed, 29 Aug 2001 22:04:08 +0000 (22:04 +0000)]
Started on release notes and readme for 2.2a2.
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.
Jeremy Hylton [Wed, 29 Aug 2001 20:57:43 +0000 (20:57 +0000)]
Generate SET_LINENO for list and tuple literals when the open paren
starts a new line.
Also fix undetected typo in visitDict() -- uncovered by recent change
to add lineno attrs to atoms.
Jeremy Hylton [Wed, 29 Aug 2001 20:56:30 +0000 (20:56 +0000)]
Make sure that atoms (Tuple, List, etc.) have lineno attributes
Jeremy Hylton [Wed, 29 Aug 2001 20:55:17 +0000 (20:55 +0000)]
Fix off-by-one errors in code to find depth of stack.
XXX The code is still widely inaccurate, but most (all?) of the time
it's an overestimate.
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:17:22 +0000 (18:17 +0000)]
Change default() to use getChildNodes() instead of getChildren()
Jeremy Hylton [Wed, 29 Aug 2001 18:14:39 +0000 (18:14 +0000)]
Support // and //=
Generate SET_LINENO for del statements.
Define klass=1 for PyFlowGraph constructor for a class statement. A
class has no varnames.
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:10:51 +0000 (18:10 +0000)]
Add generator detection to symbol table.
Fix bug in handling of statements like "l[x:y] = 2". The visitor was
treating this as assignments to l, x, and y!
Jeremy Hylton [Wed, 29 Aug 2001 18:09:50 +0000 (18:09 +0000)]
Modify name conversion to be (hopefully) a bit more efficient.
Use a dictionary instead of a list to map objects to their offsets in
a const/name tuple of a code object.
XXX The conversion is perhaps incomplete, in that we shouldn't have to
do the list2dict to start.
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.
Jeremy Hylton [Wed, 29 Aug 2001 18:02:21 +0000 (18:02 +0000)]
Add opcodes for floor division and true division (PEP 238)
Jeremy Hylton [Wed, 29 Aug 2001 17:50:27 +0000 (17:50 +0000)]
Add tests for augmented floor division
Jeremy Hylton [Wed, 29 Aug 2001 17:19:02 +0000 (17:19 +0000)]
Don't include doc string of class in its code child
Guido van Rossum [Wed, 29 Aug 2001 15:48:43 +0000 (15:48 +0000)]
Now that int is subclassable, have to change a test that tests for
non-subclassability. (More tests for number subclassing should follow.)
Guido van Rossum [Wed, 29 Aug 2001 15:47:46 +0000 (15:47 +0000)]
Make int, long and float subclassable.
This uses a slightly wimpy and wasteful approach, but it works. :-)
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).
Guido van Rossum [Wed, 29 Aug 2001 15:45:32 +0000 (15:45 +0000)]
Make the PyXXX_Check() macros for the numeric types inheritance-aware.
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.
Fred Drake [Wed, 29 Aug 2001 02:34:10 +0000 (02:34 +0000)]
Fix a minor markup typo.
Tim Peters [Wed, 29 Aug 2001 02:28:42 +0000 (02:28 +0000)]
marshal.c r_long64: When reading a TYPE_INT64 value on a box with 32-bit
ints, convert to PyLong (rather than throwing away the high-order 32 bits).
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.
Andrew M. Kuchling [Wed, 29 Aug 2001 01:16:54 +0000 (01:16 +0000)]
Add METH_O and METH_NOARGS change
Rewrite snprintf() item a bit
Bump version number
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.
Tim Peters [Tue, 28 Aug 2001 22:08:34 +0000 (22:08 +0000)]
load_int: The fallback to long ints was coded in such a way that it
couldn't succeed. Fixed.
Barry Warsaw [Tue, 28 Aug 2001 21:26:33 +0000 (21:26 +0000)]
Update an email address.
Tim Peters [Tue, 28 Aug 2001 20:56:27 +0000 (20:56 +0000)]
Note change in fp literal syntax (e.g. "3e-" worked by accident before).
Guido van Rossum [Tue, 28 Aug 2001 18:28:21 +0000 (18:28 +0000)]
Fix a typo in SLOT0 macro for the declaration of cache_str.
Dunno why I didn't catch this before.
Guido van Rossum [Tue, 28 Aug 2001 18:23:24 +0000 (18:23 +0000)]
Fix the test again due to fewer calls to __getattr__.
Guido van Rossum [Tue, 28 Aug 2001 18:22:14 +0000 (18:22 +0000)]
Finish the previous checkin: also avoid getattr when calling the method
directly.
Fred Drake [Tue, 28 Aug 2001 18:09:11 +0000 (18:09 +0000)]
Revise comments about TeX & LaTeX for accuracy.
This closes SF bug #456222.
Guido van Rossum [Tue, 28 Aug 2001 17:58:55 +0000 (17:58 +0000)]
Fix one test to reflect the change in method lookup policy.
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 17:28:33 +0000 (17:28 +0000)]
Make sure the JUMP_ABSOLUTE and POP_BLOCK at the end of a for loop are
contiguous.