Clarify the warning about the relative dates of Setup.dist and Setup;
Jeremy had seen the warning but not realized what he should do about
it. Add the hint "Usually, copying Setup.dist to Setup will work."
Add a few ``__dynamic__ = 0'' lines in classes that need to preserve
staticness when __dynamic__ = 1 becomes the default:
- Some classes which are used to test the difference between static
and dynamic.
- Subclasses of complex: complex uses old-style numbers and the slot
wrappers used by dynamic classes only support new-style numbers.
(Ideally, the complex type should be fixed, but that looks like a
labor-intensive job.)
It's a fact: for binary operators, *under certain circumstances*,
__rop__ now takes precendence over __op__. Those circumstances are:
- Both arguments are new-style classes
- Both arguments are new-style numbers
- Their implementation slots for tp_op differ
- Their types differ
- The right argument's type is a subtype of the left argument's type
Also did this for the ternary operator (pow) -- only the binary case
is dealt with properly though, since __rpow__ is not supported anyway.
Fred Drake [Fri, 28 Sep 2001 20:25:45 +0000 (20:25 +0000)]
Tighten up the new NodeList implementation.
Clean up a little; do not create an alias that is only used once, or store
attributes with constant values in an instance.
Tim Peters [Fri, 28 Sep 2001 20:14:46 +0000 (20:14 +0000)]
regrtest's -g option stopped working, during the changes to improve
error-reporting for the classic compare-expected-output tests.
Curiously, the bug consisted of not simplifying the logic enough!
Fred Drake [Fri, 28 Sep 2001 19:01:26 +0000 (19:01 +0000)]
Clean up circular references in the Weak*Dictionary classes; this avoids
depending on the cycle detector code in the library implementation.
This is a *slightly* different patch than SF patch #417795, but takes
the same approach. (This version avoids calling the __len__() method of
the dict in the remove() functions.)
This closes SF patch #417795.
Changes to copy() and deepcopy() in copy.py to support __reduce__ as a
fallback for objects that are neither supported by our dispatch table
nor have a __copy__ or __deepcopy__ method.
Changes to _reduce() in copy_reg.py to support reducing objects that
don't have a __dict__ -- copy.copy(complex()) now invokes _reduce().
Add tests for copy.copy() and copy.deepcopy() to test_regrtest.py.
Fred Drake [Fri, 28 Sep 2001 17:14:35 +0000 (17:14 +0000)]
Convert to string methods.
For the real document element, make sure the prolog is migrated into
the document element so it isn't left stranded.
Make fixup_trailing_whitespace() whitespace do what was really intended.
Add the *desc environments used in the C API manual to the list of
things that can exist at the paragraph level so they don't get wrapped
in <para>...</para>.
Fred Drake [Thu, 27 Sep 2001 17:01:59 +0000 (17:01 +0000)]
Do not distinguish \refmodule from \module in the generated output;
whether or not a link will be generated will depend on the link database.
Add a couple of explanatory comments for one of the stranger constructs
(giving input an empty name).
Fred Drake [Thu, 27 Sep 2001 16:28:42 +0000 (16:28 +0000)]
Change the sense of a test in how the profiler interprets exception events.
This should fix a bug in how time is allocated during exception propogation
(esp. in the presence of finally clauses).
Fred Drake [Thu, 27 Sep 2001 04:16:27 +0000 (04:16 +0000)]
Markup adjustment: \[...\] is math markup and does not translate well when
used with text as was done here. Fixed so that the typeset version wraps
the warning text and the HTML version does not create images of the warning
text.
Tim Peters [Thu, 27 Sep 2001 04:08:16 +0000 (04:08 +0000)]
docroutine() (both instances): Docstrings for class methods weren't
getting displayed, due to a special case here whose purpose I didn't
understand. So just disabled the doc suppression here.
Another special case here skips the docs when picking apart a method
and finding that the im_func is also in the class __dict__ under
the same name. That one I understood. It has a curious consequence,
though, wrt inherited properties: a static class copies inherited stuff
into the inheriting class's dict, and that affects whether or not this
special case triggers. The upshoot is that pydoc doesn't show the
function docstrings of getter/setter/deleter functions of inherited
properties in the property section when the class is static, but does
when the class is dynamic (bring up Lib/test/pydocfodder.py under
GUI pydoc to see this).
Tim Peters [Wed, 26 Sep 2001 22:39:22 +0000 (22:39 +0000)]
Removed no-longer-true comment about pydoc working under all versions of
Python since 1.5 (virtually everything I changed over the last week relies
on "modern" features, particularly nested scopes).
Tim Peters [Wed, 26 Sep 2001 21:31:51 +0000 (21:31 +0000)]
Display a class's method resolution order, if it's non-trivial. "Trivial"
here means it has no more than one base class to rummage through (in which
cases there's no potential confusion about resolution order).
Jeremy Hylton [Wed, 26 Sep 2001 20:01:13 +0000 (20:01 +0000)]
Add tests for new PyErr_NormalizeException() behavior
Add raise_exception() to the _testcapi module. It isn't a test, but
the C API exists only to support test_exceptions. raise_exception()
takes two arguments -- an exception class and an integer specifying
how many arguments it should be called with.
test_exceptions uses BadException() to test the interpreter's behavior
when there is a problem instantiating the exception. test_capi1()
calls it with too many arguments. test_capi2() causes an exception to
be raised in the Python code of the constructor.
Jeremy Hylton [Wed, 26 Sep 2001 19:58:38 +0000 (19:58 +0000)]
PyErr_NormalizeException()
If a new exception occurs while an exception instance is being
created, try harder to make sure there is a traceback. If the
original exception had a traceback associated with it and the new
exception does not, keep the old exception.
Of course, callers to PyErr_NormalizeException() must still be
prepared to have tb set to NULL.
XXX This isn't an ideal solution, but it's better than no traceback at
all. It occurs if, for example, the exception occurs when the call to
the constructor fails before any Python code is executed. Guido
suggests that it there is Python code that was about to be executed
-- but wasn't, say, because it was called with the wrong number of
arguments -- then we should point at the first line of the code object
anyway.
Jeremy Hylton [Wed, 26 Sep 2001 19:24:45 +0000 (19:24 +0000)]
Prevent a NULL pointer from being pushed onto the stack.
It's possible for PyErr_NormalizeException() to set the traceback
pointer to NULL. I'm not sure how to provoke this directly from
Python, although it may be possible. The error occurs when an
exception is set using PyErr_SetObject() and another exception occurs
while PyErr_NormalizeException() is creating the exception instance.
XXX As a result of this change, it's possible for an exception to
occur but sys.last_traceback to be left undefined. Not sure if this
is a problem.
Fred Drake [Wed, 26 Sep 2001 18:46:36 +0000 (18:46 +0000)]
Move the styling for the HTML version of \mailheader into the CSS file.
In both the HTML and typeset versions of the documentation, add a colon
after the name of a mail header so that it is more easily distinguished
from other text.
Fred Drake [Wed, 26 Sep 2001 18:43:20 +0000 (18:43 +0000)]
Note that the colon following a mail header name should not be included
when using the \mailheader markup.
Change a couple of inline examples to show the markup rather than the
result.
Fred Drake [Wed, 26 Sep 2001 17:01:58 +0000 (17:01 +0000)]
Move the \mailheader description to the right place.
Clarify the \mimetype description; it can be used to refer to a part of a
MIME type name, so \mimetype{text} or \mimetype{plain} can be used, not
just \mimetype{text/plain}.
Thomas Wouters [Wed, 26 Sep 2001 12:43:39 +0000 (12:43 +0000)]
Test case for SF bugs #463359 and #462937, added to test_grammar for lack of
a better place. Excessively fragile code, but at least it breaks when
something in this area changes!
Barry Warsaw [Wed, 26 Sep 2001 05:44:09 +0000 (05:44 +0000)]
_parsebody(): Use get_boundary() and get_type().
Also, add a clause to the big-if to handle message/delivery-status
content types. These create a message with subparts that are
Message instances, which best represent the header blocks of this
content type.
Barry Warsaw [Wed, 26 Sep 2001 05:41:51 +0000 (05:41 +0000)]
has_key(): Implement in terms of get().
get_type(): Use a compiled regular expression, which can be shared.
_get_params_preserve(): A helper method which extracts the header's
parameter list preserving value quoting. I'm not sure that this
needs to be a public method. It's necessary because we want
get_param() and friends to return the unquoted parameter value,
however we want the quote-preserved form for set_boundary().
get_params(), get_param(), set_boundary(): Implement in terms of
_get_params_preserve().
walk(): Yield ourself first, then recurse over our subparts (if any).
Barry Warsaw [Wed, 26 Sep 2001 05:32:41 +0000 (05:32 +0000)]
In class Generator:
_handle_text(): If the payload is None, then just return (i.e. don't
write anything). Subparts of message/delivery-status types
will have this property since they are just blocks of headers.
Also, when raising the TypeError, include the type of the
payload in the error message.
_handle_multipart(), _handle_message(): When creating a clone of self,
pass in our _mangle_from_ and maxheaderlen flags so the clone
has the same behavior.
_handle_message_delivery_status(): New method to do the proper
printing of message/delivery-status type messages. These have
to be handled differently than other message/* types because
their payloads are subparts containing just blocks of headers.
In class DecodedGenerator:
_dispatch(): Skip over multipart/* messages since we don't care
about them, and don't want the non-text format to appear in
the printed results.
Barry Warsaw [Tue, 25 Sep 2001 21:40:04 +0000 (21:40 +0000)]
test_iterator(): Don't do a type comparison to see if it's an
iterator, just test to make sure it has the two required iterator
protocol methods __iter__() and next() -- actually just test
hasattr-ness.
add_operators(): the __floordiv__ and __truediv__ descriptors (and
their 'i' and 'r' variants) were not being generated if the
corresponding nb_ slots were present in the type object. I bet this
is because floor and true division were introduced after I last
looked at that part of the code.
Tim Peters [Tue, 25 Sep 2001 20:05:11 +0000 (20:05 +0000)]
Guido points out that sys.__stdout__ is a bit bucket under IDLE. So keep
the local save/modify/restore of sys.stdout, but add machinery so that
regrtest can tell test_support the value of sys.stdout at the time
regrtest.main() started, and test_support can pass that out later to anyone
who needs a "visible" stdout.
Fred Drake [Tue, 25 Sep 2001 16:29:17 +0000 (16:29 +0000)]
Revise the example to be more resiliant in the face of continued use after
the object has been pickled; don't mutate the instance dict in the
__getstate__() method. Other minor changes for style. Broke up the
displayed interactive session to get better page-breaking behavior for
typeset versions, and to point out an important aspect of the example.
- Provisional support for pickling new-style objects. (*)
- Made cls.__module__ writable.
- Ensure that obj.__dict__ is returned as {}, not None, even upon first
reference; it simply springs into life when you ask for it.
(*) The pickling support is provisional for the following reasons:
- It doesn't support classes with __slots__.
- It relies on additional support in copy_reg.py: the C method
__reduce__, defined in the object class, really calls calling
copy_reg._reduce(obj). Eventually the Python code in copy_reg.py
needs to be migrated to C, but I'd like to experiment with the
Python implementation first. The _reduce() code also relies on an
additional helper function, _reconstructor(), defined in
copy_reg.py; this should also be reimplemented in C.
Fred Drake [Tue, 25 Sep 2001 15:12:41 +0000 (15:12 +0000)]
Fix a URL (closing SF patch #462195).
Cleaned up a bunch of XXX comments containing links to additional
information, replacing them with proper references.
Replaced "MacOS" with "Mac OS", since that's what the style guide says.
Tim Peters [Tue, 25 Sep 2001 06:30:51 +0000 (06:30 +0000)]
+ Display property functions in the same order they're specified to
property() (get, set, del; not set, get, del).
+ Change "Data defined/inherited in ..." header lines to
"Data and non-method functions defined/inherited in ...". Things like
the value of __class__, and __new__, and class vrbls like the i in
class C:
i = int
show up in this section too. I don't think it's worth a separate
section to distinguish them from non-callable attrs, and there's no
obvious reliable way to distinguish callable from non-callable attrs
anyway.
Change repr() of a new-style class to say <class 'ClassName'> rather
than <type 'ClassName'>. Exception: if it's a built-in type or an
extension type, continue to call it <type 'ClassName>. Call me a
wimp, but I don't want to break more user code than necessary.
Make __class__ assignment possible, when the object structures are the
same. I hope the test for structural equivalence is stringent enough.
It only allows the assignment if the old and new types:
- have the same basic size
- have the same item size
- have the same dict offset
- have the same weaklist offset
- have the same GC flag bit
- have a common base that is the same except for maybe the dict and
weaklist (which may have been added separately at the same offsets
in both types)
Tim Peters [Tue, 25 Sep 2001 03:18:32 +0000 (03:18 +0000)]
+ Got rid of all instances of <small>. Under IE5, GUI-mode pydoc has
always been close to useless, because the <small>-ified docstrings
were too small to read, even after cranking up my default font size
just for pydoc. Now it reads fine under my defaults (as does most
of the web <0.5 wink>). If it's thought important to play tricks
with font size, tough, then someone should rework pydoc to use style
sheets, and (more) predictable percentage-of-default size controls.
+ Tried to ensure that all <dt> and <dd> tags are closed. I've read (but
don't know) that some browsers get confused if they're not, and esp.
when style sheets are in use too.
Tim Peters [Tue, 25 Sep 2001 00:01:06 +0000 (00:01 +0000)]
GUI mode now displays useful stuff for properties. This is usually better
than text mode, since here we can hyperlink from the getter etc methods
back to their definitions.