Move call_trace(..., PyTrace_CALL, ...) call to top of eval_frame. That
way it's called each time a generator is resumed. The tracing of normal
functions should be unaffected by this change.
Fred Drake [Tue, 4 Sep 2001 18:18:36 +0000 (18:18 +0000)]
Added documentation for sys.maxunicode and sys.warnoptions.
Fixed a markup error which caused an em dash to be presented as a minus sign.
This closes SF bug #458350.
Fred Drake [Tue, 4 Sep 2001 16:26:03 +0000 (16:26 +0000)]
HTMLParser is allowed to be more strict than sgmllib, so let's not
change their basic behavior: When parsing something that cannot possibly
be valid in either HTML or XHTML, raise an exception.
- Reverse the meaning of the -m option: warnings about multiple /
operators per line or statement are now on by default, and -m turns
these warnings off.
- Change the way multiple / operators are reported; a regular
recommendation is always emitted after the warning.
- Report ambiguous warnings (both int|long and float|complex used for
the same operator).
- Update the doc string again to clarify all this and describe the
possible messages more precisely.
Suppressing all DeprecationWarning messages was a bit of a problem for
the -Qwarnall option, so I've changed this to only filter out the one
warning that's a problem in practice.
Tim Peters [Tue, 4 Sep 2001 05:14:19 +0000 (05:14 +0000)]
Raise OverflowError when appropriate on long->float conversion. Most of
the fiddling is simply due to that no caller of PyLong_AsDouble ever
checked for failure (so that's fixing old bugs). PyLong_AsDouble is much
faster for big inputs now too, but that's more of a happy consequence
than a design goal.
PEP 238 documented -Qwarn as warning only for classic int or long
division, and this makes sense. Add -Qwarnall to warn for all
classic divisions, as required by the fixdiv.py tool.
Tim Peters [Tue, 4 Sep 2001 02:50:49 +0000 (02:50 +0000)]
Introduce new private API function _PyLong_AsScaledDouble. Not used yet,
but will be the foundation for Good Things:
+ Speed PyLong_AsDouble.
+ Give PyLong_AsDouble the ability to detect overflow.
+ Make true division of long/long nearly as accurate as possible (no
spurious infinities or NaNs).
+ Return non-insane results from math.log and math.log10 when passing a
long that can't be approximated by a double better than HUGE_VAL.
Tim Peters [Tue, 4 Sep 2001 01:20:04 +0000 (01:20 +0000)]
builtin_dir(): Treat classic classes like types. Use PyDict_Keys instead
of PyMapping_Keys because we know we have a real dict. Tolerate that
objects may have an attr named "__dict__" that's not a dict (Py_None
popped up during testing).
test_descr.py, test_dir(): Test the new classic-class behavior; beef up
the new-style class test similarly.
test_pyclbr.py, checkModule(): dir(C) is no longer a synonym for
C.__dict__.keys() when C is a classic class (looks like the same thing
that burned distutils! -- should it be *made* a synoym again? Then it
would be inconsistent with new-style class behavior.).
Tim Peters [Mon, 3 Sep 2001 08:35:41 +0000 (08:35 +0000)]
New restriction on pow(x, y, z): If z is not None, x and y must be of
integer types, and y must be >= 0. See discussion at
http://sf.net/tracker/index.php?func=detail&aid=457066&group_id=5470&atid=105470
Tim Peters [Mon, 3 Sep 2001 05:47:38 +0000 (05:47 +0000)]
Make dir() wordier (see the new docstring). The new behavior is a mixed
bag. It's clearly wrong for classic classes, at heart because a classic
class doesn't have a __class__ attribute, and I'm unclear on whether
that's feature or bug. I'll repair this once I find out (in the
meantime, dir() applied to classic classes won't find the base classes,
while dir() applied to a classic-class instance *will* find the base
classes but not *their* base classes).
Please give the new dir() a try and see whether you love it or hate it.
The new dir([]) behavior is something I could come to love. Here's
something to hate:
>>> class C:
... pass
...
>>> c = C()
>>> dir(c)
['__doc__', '__module__']
>>>
The idea that an instance has a __doc__ attribute is jarring (of course
it's really c.__class__.__doc__ == C.__doc__; likewise for __module__).
OTOH, the code already has too many special cases, and dir(x) doesn't
have a compelling or clear purpose when x isn't a module.
Implement what the docstring said: multiple slashes per line are
treated the same as single ones by default. Added -m option to issue
a warning for this case instead.
Tim Peters [Sun, 2 Sep 2001 08:22:48 +0000 (08:22 +0000)]
Make dictionary() a real constructor. Accepts at most one argument, "a
mapping object", in the same sense dict.update(x) requires of x (that x
has a keys() method and a getitem).
Questionable: The other type constructors accept a keyword argument, so I
did that here too (e.g., dictionary(mapping={1:2}) works). But type_call
doesn't pass the keyword args to the tp_new slot (it passes NULL), it only
passes them to the tp_init slot, so getting at them required adding a
tp_init slot to dicts. Looks like that makes the normal case (i.e., no
args at all) a little slower (the time it takes to call dict.tp_init and
have it figure out there's nothing to do).
Fred Drake [Sun, 2 Sep 2001 06:07:36 +0000 (06:07 +0000)]
Move the long minidom example to a separate file; \verbatiminput does the
right thing with page breaks in long examples, while the verbatim
environment does not. This causes the example to wrap to the next page
instead of overwriting the page footer and bottom margin.
Added more text to the docstring, updated the way the exit status is
percolated out, and some general cleanup. The output is still the
same, except it now prints "Index: <file>" instead of "Processing:
<file>", so that the output can be used as input for patch (but only
the diff-style parts of it).
Stephen Hansen reported via email that he didn't finish the port to
Borland C, so remove the old item saying it worked and add a new item
saying what I know; I've asked Stephen for more details.
The beginnings of a script to help finding / operators that may need
to be change to //. The code is pretty gross so far, and I promise
I'll work on this more, but I have to go eat now! :-)
Guido van Rossum [Fri, 31 Aug 2001 17:46:35 +0000 (17:46 +0000)]
Allow for the possibility that globals['__name__'] does not exist;
substitute "<string>" for the module name in that case. This actually
occurred when running test_descr.py with -Dwarn.
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 [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.
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.
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: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 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__.