Commit Graph

5385 Commits

Author SHA1 Message Date
Guido van Rossum 2f3ca6eeb6 Completely get rid of __dynamic__ and the corresponding
Py_TPFLAGS_DYNAMICTYPE bit.  There is no longer a performance benefit,
and I don't really see the use case any more.
2001-10-15 21:05:10 +00:00
Guido van Rossum 1346e83eb0 Patch 471400: escape single-dot lines; by Jason Hildebrand.
RFC 2049 recommends never outputting a line consisting of a single
dot.
2001-10-15 18:44:26 +00:00
Guido van Rossum c0f1bfec05 SF bug #469910 by Alfonso Baciero: Bugfix for imaplib for macintosh
Pass binary mode to makefile().
2001-10-15 13:47:08 +00:00
Barry Warsaw cdc632cfdb test_typed_subpart_iterator_default_type(): Test for when the message
has no Content-Type: header, it should be treated as text/plain.
2001-10-15 04:39:02 +00:00
Barry Warsaw 0164b6bf22 typed_subpart_iterator(): When getting the main type use 'text' as the
failobj, and when getting the subtype use 'plain' as the failobj.
text/plain is supposed to be the default if the message contains no
Content-Type: header.
2001-10-15 04:38:22 +00:00
Fred Drake 4c85da4d16 "ib" should be "boundary"; reported by Neal Norwitz. 2001-10-13 18:38:53 +00:00
Fred Drake c680ae8002 Added missing parameter in call to http_error_default();
reported by Neal Norwitz.
2001-10-13 18:37:07 +00:00
Fred Drake 2f8f4d3678 SMTPError should be SMTPException; reported by Neal Norwitz. 2001-10-13 18:35:32 +00:00
Fred Drake f902296a18 Ignore execfile() return value; reported by Neal Norwitz. 2001-10-13 18:34:42 +00:00
Fred Drake 95b0eb7cb3 "f" should be "self"; reported by Neal Norwitz. 2001-10-13 18:33:51 +00:00
Fred Drake 16623fe3e6 _os should be os; reported by Neal Norwitz. 2001-10-13 16:00:52 +00:00
Fred Drake 3d32be192c Remove extra param from call to self.error().
Reported by Neal Norwitz.
2001-10-13 15:59:47 +00:00
Martin v. Löwis dc57909323 Move grid_location into Misc. Fixes bug #426892. 2001-10-13 09:33:51 +00:00
Fred Drake c687960496 Remove some unused imports.
Remove the log file after we are done with it.  This should clean up after
the test even on Windows, since the file is now closed before we attempt
removal.
2001-10-13 03:00:11 +00:00
Fred Drake d62f151a2c When we reach the end of the log file, close the logreader object. 2001-10-13 02:55:40 +00:00
Tim Peters 10603b8799 You can't unlink open files on Windows.
Simply commented it out, and then test_hotshot passes on Windows.
Leaving to Fred to fix "the right way" (it seems to be a feature of
unittest that all unittests try to unlink open files <wink>).
2001-10-13 00:19:39 +00:00
Martin v. Löwis 106bdd3b80 Correct __repr__: include module name, avoid extra space for empty status,
use 0x format for id. Proposed by Cesar Eduardo Barros in patch #470680.
2001-10-12 22:39:20 +00:00
Fred Drake f019324b5c Preliminary user-level interface to HotShot. We still need the analysis
tool; look for that on Monday.
2001-10-12 20:56:29 +00:00
Fred Drake de3cdcadce A most trivial test for HotShot -- make sure we get reasonable events
reported and can read the log back in.
2001-10-12 20:53:59 +00:00
Guido van Rossum ea32cbb24e Suggestion from SF patch #470433 to avoid clobbering TCL_LIBRARY et
al. if already set.  Also adds TIX_LIBRARY (just in case).
(Note that this is entirely Windows specific.)
2001-10-12 15:34:29 +00:00
Tim Peters fc57ccb982 SF bug [#470040] ParseTuple t# vs subclasses.
inherit_slots():  tp_as_buffer was getting inherited as if it were a
method pointer, rather than a pointer to a vector of method pointers.  As
a result, inheriting from a type that implemented buffer methods was
ineffective, leaving all the tp_as_buffer slots NULL in the subclass.
2001-10-12 02:38:24 +00:00
Guido van Rossum 875eeaa193 Another step in the right direction: when a new class's attribute
corresponding to a dispatch slot (e.g. __getitem__ or __add__) is set,
calculate the proper dispatch slot and propagate the change to all
subclasses.  Because of multiple inheritance, there's no easy way to
avoid always recursing down the tree of subclasses.  Who cares?

(There's more to do, but this works.  There's also a test for this now.)
2001-10-11 18:33:53 +00:00
Tim Peters f3623f310e Somebody checked in a version of httplib that doesn't even compile --
SyntaxError.  Fix it.
2001-10-11 18:15:51 +00:00
Jeremy Hylton 6459c8d067 Fix for SF buf #458835
Try to be systematic about dealing with socket and ssl exceptions in
FakeSocket.makefile().  The previous version of the code caught all
ssl errors and treated them as EOF, even though most of the errors
don't mean EOF.

An SSL error can mean on of three things:

    1. The SSL/TLS connection was closed.
    2. The operation should be retried.
    3. An error occurred.

Also, if a socket error occurred and the error was EINTR, retry the
call.  Otherwise, it was a legitimate error and the caller should
receive the exception.
2001-10-11 17:47:22 +00:00
Barry Warsaw bf7a59d94b Add a test for the HeaderParser class. 2001-10-11 15:44:50 +00:00
Barry Warsaw e552882960 HeaderParser: A new subclass of Parser which only parses the message
headers.  It does not parse the body of the message, instead simply
assigning it as a string to the container's payload.  This can be much
faster when you're only interested in a message's header.
2001-10-11 15:43:00 +00:00
Jeremy Hylton de7c1923c7 Add test of hexlify on Unicode strings 2001-10-11 14:09:03 +00:00
Skip Montanaro 5e9c71ba80 allow long ints to be marshalled as ints - no check is made to the incoming
value, so the programmer will have to catch OverflowError.  I'm not sure
what /F's perspective is on this.  Perhaps it should be caught and mapped to
an xmlrpclib-specific exception.  None of the other type-specific dump
methods seem to do any exception handling though.
2001-10-10 15:56:34 +00:00
Tim Peters cf5e6a4a5d SF bug [#469732] os.path.walk docstring inconsistent.
We have 5 implementations of walk(), and 5 different docstrings.  Combined
'em.  Let's see how long it takes before they're all different again!
2001-10-10 04:16:20 +00:00
Jeremy Hylton 7d3dff2b39 SF patch [ #468662 ] Allow jython to complete test_grammar
The behavior of co_varnames in the presence of nested argument tuples
is not consistent across Python and Jython.  Test each platform
separately.
2001-10-10 01:45:02 +00:00
Tim Peters e13cc92e6c Repair key stutter + auto-complete ugliness. 2001-10-09 21:01:31 +00:00
Fred Drake 3e5e661150 Remove obsolete email address. 2001-10-09 20:53:48 +00:00
Tim Peters 659a60311d Allow the profiler's calibration constant to be specified in the constructor
call, or via setting an instance or class vrbl.
Rewrote the calibration docs.
Modern boxes are so friggin' fast, and a profiler event does so much work
anyway, that the cost of looking up an instance vrbl (the bias constant)
per profile event just isn't a big deal.
2001-10-09 20:51:19 +00:00
Guido van Rossum 12b22ff6d7 Add a bunch of tests for a list subclass that would have caught the
previous embarrassment (typeobject.c checking crashing minidom).
2001-10-09 20:36:44 +00:00
Barry Warsaw 53f8fe4232 An audio/* class, like MIMEImage, contributed by Anthony Baxter.
Rewritten for style and the email package naming conventions by
Barry.
2001-10-09 19:41:18 +00:00
Guido van Rossum 7b9144b2ee Halfway checkin. This is still messy, but it's beginning to address
the problem that slots weren't inherited properly.  override_slots()
no longer exists; in its place comes fixup_slot_dispatchers() which
does more and different work and is table-based.  (Eventually I want
this table also to replace all the little tab_foo tables.)

Also add a wrapper for __delslice__; this required a change in
test_descrtut.py.
2001-10-09 19:39:46 +00:00
Barry Warsaw fee435af8b Added tests for MIMEAudio class/module 2001-10-09 19:23:57 +00:00
Barry Warsaw 2ae0b0163a Fix __all__ to the current list of exported modules (must pass the
tests in test_email.py).
2001-10-09 19:14:59 +00:00
Jeremy Hylton 8b78b99647 Fix [ #465502 ] urllib2: urlopen unicode problem
When checking for strings use,
!         if isinstance(uri, (types.StringType, types.UnicodeType)):

Also get rid of some dodgy code that tried to guess whether attributes
were callable or not.
2001-10-09 16:18:45 +00:00
Barry Warsaw 2f6a0b00a0 Add a test for get_all() returning failobj. msg_20.txt is a sample
message with multiple CC: fields, used in the get_all() test.
2001-10-09 15:49:35 +00:00
Barry Warsaw 9300a75c88 get_all(): We never returned failobj if we found no matching headers.
Fix that, and also make the docstring describe failobj.
2001-10-09 15:48:29 +00:00
Barry Warsaw 93a6327adf SMTPServer.__init__(): The asyncore.dispatcher base class has a method
set_reuse_addr() that does the setsockopt fiddling.  Use it instead.
2001-10-09 15:46:31 +00:00
Martin v. Löwis 3e048485f9 Add entry parameter to HList.item_cget. Fixes bug #466981. 2001-10-09 11:50:55 +00:00
Guido van Rossum 0eb2a6e974 It turned out not so difficult to support old-style numbers (those
without the Py_TPFLAGS_CHECKTYPES flag) in the wrappers.  This
required a few changes in test_descr.py to cope with the fact that the
complex type has __int__, __long__ and __float__ methods that always
raise an exception.
2001-10-09 11:07:24 +00:00
Martin v. Löwis 6ec9a36faf Patch #468647: Fix exception propagation in asyncore. 2001-10-09 10:10:33 +00:00
Tim Peters cce092d046 A brand new implementation of Profile.calibrate(). This measures an
actual run of the profiler, instead of timing a simplified simulation of
part of what the profiler does.  It computes a constant about 60% higher
on my Win98SE box than the old method, and the new constant appears much
more realistic.  Deleted the undocumented simple(), instrumented(), and
profiler_simulation() methods (which existed only to support the previous
calibration method).
2001-10-09 05:31:56 +00:00
Fred Drake 168beada91 Added tests that check getboolean() with the newly allowed values from
SF patch #467580.
2001-10-08 17:13:12 +00:00
Guido van Rossum 4570455813 Change all occurrences of verify(x == y) into vereq(x, y), since when
this type of test fails, vereq() does a better job of reporting than
verify().

Change vereq(x, y) to use "not x == y" rather than "x != y" -- it
makes a difference is some overloading tests.
2001-10-08 16:35:45 +00:00
Tim Peters 281084f798 Put the deprecated .ignore() method back where it was. 2001-10-08 06:28:18 +00:00
Tim Peters 7d01685738 Widespread random code cleanup.
Most of this code was old enough to vote.  Examples of cleanups:

+ Backslashes were used for line continuation even inside unclosed
  bracket structures, from back in the days that was still needed.

+ There was no use of % formats, and e.g. the old fpformat module was
  still used to format floats "by hand" in conjunction with rjust().

+ There was even use of a do-nothing .ignore() method to tack on to the
  end of a chain of method calls, else way back when Python would print
  the non-None result (as it does now in an interactive session -- it
  *used* to do that in batch mode too).

+ Perhaps controversial (although I can't imagine why for real <wink>),
  used augmented assignment where helpful.  Stuff like

      self.total_calls = self.total_calls + other.total_calls

  is just plain harder to follow than

      self.total_calls += other.total_calls
2001-10-08 06:13:19 +00:00
Steven M. Gava 1f733baa04 merged port binding error message patch 2001-10-07 11:44:49 +00:00
Steven M. Gava 4eb286874f merged win spawn patch 2001-10-07 11:26:48 +00:00
Steven M. Gava 898a365c27 merged status bar packing patch 2001-10-07 11:10:44 +00:00
Martin v. Löwis 322c0d187d Only close sockets if they have been created. Reported by Blake Winton. 2001-10-07 08:53:32 +00:00
Tim Peters fb163784ab Typo repair in comment. 2001-10-07 08:49:02 +00:00
Tim Peters 8d061ed75b Guido points out that the comments for self.cur[2] were subtly but
seriously wrong.  This started out by just fixing the docs, but then it
occurred to me that the doc confusion propagated into misleading vrbl names
too, so I also renamed those to match reality.  As a result, INO the time
computations are much easier to understand now (within the limitations of
vast quantities of 3-character names <wink>).
2001-10-07 08:35:44 +00:00
Tim Peters db1ed2aec3 At Guido's request, changed the code that's conceptually asserting stuff
to use assert stmts (was raising unexpected kinds of exceptions).
2001-10-07 04:30:53 +00:00
Tim Peters 6e22149cb6 Repair some longstanding comment errors:
+ The last index in the timing tuple is 4, not 5 (noted by Guido).

+ The poorly named trace_dispatch_i works with float return values too.
2001-10-07 04:02:36 +00:00
Tim Peters 0a1fc4e389 Remove code and docs for the OldProfile and HotProfile classes: code
hasn't worked in years, docs were wrong, and they aren't interesting
anymore regardless.
2001-10-07 03:12:08 +00:00
Tim Peters df5cfd884d The fix to profile semantics broke the miserable but advertised way to
derive Profile subclasses.  This patch repairs that, restoring
negative tuple indices.  Yuck?  You bet.
2001-10-05 23:15:10 +00:00
Fred Drake e029242d5c ReferenceError is now built-in, so pick it up from the right place.
It still needs to be here to preserve the API.
2001-10-05 21:54:09 +00:00
Guido van Rossum 39c785108f Martijn Pieters convinced me that when readline() strips the trailing
newline from a multifile part, it should also strip a trailing \r\n.
2001-10-05 21:22:21 +00:00
Guido van Rossum 9475a2310d Enable GC for new-style instances. This touches lots of files, since
many types were subclassable but had a xxx_dealloc function that
called PyObject_DEL(self) directly instead of deferring to
self->ob_type->tp_free(self).  It is permissible to set tp_free in the
type object directly to _PyObject_Del, for non-GC types, or to
_PyObject_GC_Del, for GC types.  Still, PyObject_DEL was a tad faster,
so I'm fearing that our pystone rating is going down again.  I'm not
sure if doing something like

void xxx_dealloc(PyObject *self)
{
	if (PyXxxCheckExact(self))
		PyObject_DEL(self);
	else
		self->ob_type->tp_free(self);
}

is any faster than always calling the else branch, so I haven't
attempted that -- however those types whose own dealloc is fancier
(int, float, unicode) do use this pattern.
2001-10-05 20:51:39 +00:00
Thomas Heller be63884d50 With Andrew's blessing: distutils version number is now 1.0.3. 2001-10-05 20:43:09 +00:00
Thomas Heller e138f369e6 Explicitely list the metadata attributes to show
in the gui.
Updated to include the new exe-file.
2001-10-05 20:40:48 +00:00
Barry Warsaw 4a8e9f4e42 SMTPServer.__init__(): Print the start information on the DEBUGSTREAM
so that it can be suppressed.
2001-10-05 17:10:31 +00:00
Fred Drake 4e7cdb57f9 Non-failing test for SF bug #467059. 2001-10-04 20:05:10 +00:00
Guido van Rossum fb06f75c5a Apply modified SF patch 467580: ConfigParser.getboolean(): FALSE, TRUE.
This patch allows ConfigParser.getboolean() to interpret TRUE,
    FALSE, YES, NO, ON and OFF instead just '0' and '1'.

    While just allowing '0' and '1' sounds more correct users often
    demand to use more descriptive directives in configuration
    files. Instead of forcing every programmer do brew his own
    solution a system should include the batteries for this.

[My modification to the patch is a slight rewording of the docstring
and use of lowercase instead of uppercase templates.  The code is
still case sensitive. GvR.]
2001-10-04 19:58:46 +00:00
Fred Drake 266410355f run_suite(): If testclass is not available, provide an even more general
error message.
run_unittest():  Provide the testclass to run_suite() so it can construct
                 the error message.
This closes SF bug #467763.
2001-10-04 19:46:07 +00:00
Barry Warsaw d1de6eacf2 TestIterators: Tim Peters suggests a more succinct spelling of
"listify an iterator".
2001-10-04 18:18:37 +00:00
Barry Warsaw c4496f886b More test data for test_email.py 2001-10-04 17:59:42 +00:00
Barry Warsaw 08a534d476 test_header_splitter(), test_body_line_iterator(): Move the test data
into tests/data/msg_*.txt files.
2001-10-04 17:58:50 +00:00
Barry Warsaw e968ead1dd Give me back my page breaks. 2001-10-04 17:05:11 +00:00
Barry Warsaw 0e8427e4f2 Script arguments localhost:localport and remotehost:remoteport are now
optional, and default to `localhost' and ports 8025 and 25
respectively.

SMTPChannel.__init__(): Calculate __fqdn using socket.getfqdn()
instead of gethostby*() and friends.  This allows us to run this
script even if we don't have access to dns (assuming the localhost is
configured properly).

Also, restore my precious page breaks.  Hands off, oh Whitespace
Normalizer!
2001-10-04 16:27:04 +00:00
Fred Drake 7c0a93d966 Updated to reflect the rationalized profiler event reporting. 2001-10-04 14:49:46 +00:00
Tim Peters c59fb2d230 This test relied on hard tab characters, so failed after whitespace
normalization.  Now uses \t in strings instead of hard tabs.
2001-10-04 06:26:17 +00:00
Tim Peters 4fb1fe8bd2 class_docstrings(): The new-style class tests should use new-style
classes (sheesh!).
2001-10-04 05:48:13 +00:00
Tim Peters 527e64fd68 Whitespace normalization. 2001-10-04 05:36:56 +00:00
Tim Peters 2f93e28a19 SF bug [#467331] ClassType.__doc__ always None.
For a dynamically constructed type object, fill in the tp_doc slot with
a copy of the argument dict's "__doc__" value, provided the latter exists
and is a string.
NOTE:  I don't know what to do if it's a Unicode string, so in that case
tp_doc is left NULL (which shows up as Py_None if you do Class.__doc__).
Note that tp_doc holds a char*, not a general PyObject*.
2001-10-04 05:27:00 +00:00
Guido van Rossum f137f75ab8 Hopefully fix the profiler right. Add a test suite that checks that
it deals correctly with some anomalous cases; according to this test
suite I've fixed it right.

The anomalous cases had to do with 'exception' events: these aren't
generated when they would be most helpful, and the profiler has to
work hard to recover the right information.  The problems occur when C
code (such as hasattr(), which is used as the example here) calls back
into Python code and clears an exception raised by that Python code.
Consider this example:

    def foo():
        hasattr(obj, "bar")

Where obj is an instance from a class like this:

    class C:
        def __getattr__(self, name):
            raise AttributeError

The profiler sees the following sequence of events:

    call (foo)
    call (__getattr__)
    exception (in __getattr__)
    return (from foo)

Previously, the profiler would assume the return event returned from
__getattr__. An if statement checking for this condition and raising
an exception was commented out...  This version does the right thing.
2001-10-04 00:58:24 +00:00
Fred Drake 0099ba73de Add some more test cases to be sure we do the right thing in various cases. 2001-10-03 21:15:32 +00:00
Fred Drake a0bc9993e7 Undo previous patch; it did not quite work out. 2001-10-03 21:12:32 +00:00
Andrew M. Kuchling 4602c1b702 Set .addr in a few more places (patch approved by Sam Rushing) 2001-10-03 17:07:25 +00:00
Guido van Rossum 4a5a2bc2b6 dynamics(): add a dummy __getattr__ method to the C class so that the
test for modifying __getattr__ works, now that slot_tp_getattr_hook
zaps the slot if there's no hook.  Added an XXX comment with a ref
back to slot_tp_getattr_hook.
2001-10-03 13:59:54 +00:00
Skip Montanaro ae3b1258e4 remove empty __del__ method from BaseRequestHandler to avoid cyclic garbage
loss for no reason.
2001-10-03 12:21:23 +00:00
Tim Peters 1b0e5490c5 Made the classmethod docstring test a bit less trivial. 2001-10-03 04:15:28 +00:00
Tim Peters 17111f3b24 SF bug [#467336] doctest failures w/ new-style classes.
Taught doctest about static methods, class methods, and property docstrings
in new-style classes.  As for inspect.py/pydoc.py before it, the new stuff
needed didn't really fit into the old architecture (but was less of a
strain to force-fit here).
New-style class docstrings still aren't found, but that's the subject
of a different bug and I want to fix that right instead of hacking around
it in doctest.
2001-10-03 04:08:26 +00:00
Tim Peters 4a9ac4a83c SF patch [#466616] Exclude imported items from doctest.
Another installment; the new functionality wasn't actually enabled in
normal use, only in the strained use checked by the test case.
2001-10-02 22:47:08 +00:00
Guido van Rossum 048eb75c2d Add Garbage Collection support to new-style classes (not yet to their
instances).

Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy.  (Only type objects have a tp_clear
field; the other types are.)

One change was necessary to the GC infrastructure.  We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header.  Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests...  In short, a mess.  So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not.  This slot is
only relevant for types that have the (new) GC flag bit set.  If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers.  This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).

I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs.  (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 21:24:57 +00:00
Guido van Rossum fe1fd0e6e9 pickles():
- The test for deepcopy() in pickles() was indented wrongly, so it got
  run twice (one for binary pickle mode, one for text pickle mode; but
  the test doesn't depend on the pickle mode).

- In verbose mode, show which subtest (pickle/cPickle/deepcopy, text/bin).
2001-10-02 19:58:32 +00:00
Guido van Rossum c907bd89de The error reporting here was a bit sparse. In verbose mode, the code
in run_test() referenced two non-existent variables, and in
non-verbose mode, the tests didn't report the actual number, when it
differed from the expected number.  Fixed this.

Also added an extra call to gc.collect() at the start of test_all().
This will be needed when I check in the changes to add GC to new-style
classes.
2001-10-02 19:49:47 +00:00
Guido van Rossum b855134a0d Under certain conditions (sometimes triggered by the test suite),
"from xml.parsers import expat" succeeds but the imported expat module
is an empty shell.  Make sure we don't be fooled by that.
2001-10-02 18:33:11 +00:00
Guido van Rossum e37e96df06 Correct the URL for the license (only used when the LICENSE[.txt] file
is not found).  Being fancy: insert the first 3 characters of
sys.version in the URL.
2001-10-02 18:27:09 +00:00
Tim Peters 7402f791a4 SF patch [#466616] Exclude imported items from doctest,
from Tim Hochberg.  Also mucho fiddling to change the way doctest
determines whether a thing is a function, module or class.  Under 2.2,
this really requires the functions in inspect.py (e.g., types.ClassType
is close to meaningless now, if not outright misleading).
2001-10-02 03:53:41 +00:00
Fredrik Lundh 1538c23dec restored 1.5.2 compatibility
added local escape method (made the dumps method some 50-80% faster)
minor tweaks to the unmarshalling code
2001-10-01 19:42:03 +00:00
Skip Montanaro fbacaf7298 approximately double dump performance by moving import of cgi.escape back to
top level.
2001-10-01 17:50:29 +00:00
Skip Montanaro 419abdaff2 simple dumps/loads test case for xmlrpclib 2001-10-01 17:47:44 +00:00
Martin v. Löwis c04f7a794e Undo last checkin, since it duplicated the code. 2001-10-01 17:02:49 +00:00
Guido van Rossum d1d584f4e8 SF patch #462628 (Travers Naran) NNTPLib supports saving BODY to a file.
I modified nntplib so the body method can accept an
  optional second parameter pointing to a filehandle or
  filename (string). This way, really long body
  articles can be stored to disk instead of kept in
  memory. The way I made the modification should make
  it easy to extend this functionality to other extended
  return methods.
2001-10-01 13:46:55 +00:00
Martin v. Löwis 2fa69d7984 Patch #426880: Implement Listbox itemcget and itemconfigure. 2001-10-01 10:09:31 +00:00
Martin v. Löwis 16dc7f44b1 Patch #462190, patch #464070: Support quoted printable in the binascii module.
Decode and encode underscores for header style encoding. Fixes bug #463996.
2001-09-30 20:32:11 +00:00
Martin v. Löwis 5f12d755a8 Properly detect recursive structures. Adopted from patch #465298. 2001-09-30 20:15:41 +00:00
Fred Drake d157237d51 For Python 2.2, do not use __getattr__(), only use computed properties.
This is probably a little bit faster, but mostly is just cleaner code.
The old-style support is still used for Python versions < 2.2 so this
source file can be shared with PyXML.
2001-09-29 04:58:32 +00:00
Fred Drake 787fd8cdeb _dispatch(): Do no re-define the resolve_dotted_atttribute() function
every time this gets called; move it out as a global helper function.
    Simplify the call to the _dispatch() method of the registered instance.
2001-09-29 04:54:33 +00:00
Guido van Rossum 751c4c864c 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.)
2001-09-29 00:40:25 +00:00
Guido van Rossum 4bb1e36eec 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.
2001-09-28 23:49:48 +00:00
Fred Drake 946f7b1b24 Update the xml.dom.minidom tests to cover the DOM-compliant parts of the
NodeList interface.
2001-09-28 20:31:50 +00:00
Fred Drake 575712eaca 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.
2001-09-28 20:25:45 +00:00
Fred Drake 88a56857f6 Remove an infelicitous space. 2001-09-28 20:16:30 +00:00
Tim Peters 9390cc15da 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!
2001-09-28 20:14:46 +00:00
Fred Drake b2ad1c8b4d Reflect recent refinements of the regression testing framework. 2001-09-28 20:05:25 +00:00
Fred Drake 746fe0fae5 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.
2001-09-28 19:01:26 +00:00
Guido van Rossum 8b9def3aac Add complex to the dispatch tables, to avoid going through the whole
rigmarole of __reduce__.
2001-09-28 18:16:13 +00:00
Guido van Rossum 6cef6d5d62 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.
2001-09-28 18:13:29 +00:00
Fred Drake 3ac6a09eed For Python 2.2 and newer, actually support the full NodeList interface by
subclassing list to add the length and item() attributes.
2001-09-28 04:33:06 +00:00
Fred Drake 5a28bfbbc7 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).
2001-09-27 16:28:42 +00:00
Andrew M. Kuchling 264e8186d5 Fix comment typo 2001-09-27 04:18:36 +00:00
Tim Peters 8ac8be5988 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).
2001-09-27 04:08:16 +00:00
Tim Peters 351e362d89 List class attrs in MRO order of defining class instead of by alphabetic
order of defining class's name.
2001-09-27 03:29:51 +00:00
Tim Peters 3ffeae130b 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).
2001-09-26 22:39:22 +00:00
Tim Peters c86f6ca2b6 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).
2001-09-26 21:31:51 +00:00
Fred Drake 39cd603fc8 More test cases, including something that simulates what the profiler
probably *should* be doing.
2001-09-26 21:00:33 +00:00
Tim Peters 38a50f9065 A file just to look at (using pydoc). 2001-09-26 20:31:52 +00:00
Jeremy Hylton ede049b2d3 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.
2001-09-26 20:01:13 +00:00
Jeremy Hylton 4f38c1e664 Don't export generators future info 2001-09-26 19:54:08 +00:00
Thomas Wouters 80d373cbd0 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!
2001-09-26 12:43:39 +00:00
Barry Warsaw 65279d0242 Update the tests for the current incarnation of the email package, and
added some new tests of message/delivery-status content type messages.
2001-09-26 05:47:08 +00:00
Barry Warsaw 0e416cd88e More test messages for test_email.py 2001-09-26 05:45:17 +00:00
Barry Warsaw 66971fbca5 _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.
2001-09-26 05:44:09 +00:00
Barry Warsaw beb5945c65 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).
2001-09-26 05:41:51 +00:00
Barry Warsaw 76fac8ed0e __init__(): Arguments major renamed to maintype and minor renamed to
subtype for consistency with the rest of the package.
2001-09-26 05:36:36 +00:00
Barry Warsaw 57758e3a02 Updated docstrings. Also,
typed_subpart_iterator(): Arguments major renamed to maintype and
    minor renamed to subtype for consistency with the rest of the
    package.
2001-09-26 05:35:47 +00:00
Barry Warsaw 3dd978dfff Image.py and class Image => MIMEImage.py and MIMEImage
Text.py and class Text => MIMEText.py and MIMEText

MessageRFC822.py and class MessageRFC822 => MIMEMessage.py and MIMEMessage

These are renamed so as to be more consistent; these are MIME specific
derived classes for when creating the object model out of whole cloth.
2001-09-26 05:34:30 +00:00
Barry Warsaw b384e01796 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.
2001-09-26 05:32:41 +00:00
Barry Warsaw 6f70c41923 cosmetic 2001-09-26 05:26:22 +00:00
Tim Peters 26991a7f77 SF [#463737] Add types.CallableIterType
Rather than add umpteen new obscure internal Iter types, got rid of all of
them.  See the new comment.
2001-09-25 22:02:03 +00:00
Barry Warsaw 45653503ec 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.
2001-09-25 21:40:04 +00:00
Fred Drake cc91ac09ef Factor out the protect-from-exceptions helpers and make capture_events()
use it.  This simplifies the individual tests a little.

Added some new tests related to exception handling.
2001-09-25 20:48:14 +00:00
Tim Peters 8dee809410 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.
2001-09-25 20:05:11 +00:00
Guido van Rossum 698acf98fd _reconstructor(): there's no need for tricks with assignment to
__class__.  The __new__ protocol is up to this.  (Thanks to Tim for
pointing this out.)
2001-09-25 19:46:05 +00:00
Tim Peters d48004f4f0 test_support should be imported directly, not via test.test_support. 2001-09-25 19:29:35 +00:00
Tim Peters 342ca75d95 Get rid of the increasingly convoluted global tricks w/ sys.stdout, in
favor of local save/modify/restore.  The test suite should run fine again.
2001-09-25 19:13:20 +00:00
Guido van Rossum 3926a63d05 - 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.
2001-09-25 16:25:58 +00:00
Guido van Rossum ad39aba2f6 Set sys.save_stdout (to sys.stdout), so doctest-using tests can be run
standalone.
2001-09-25 16:21:39 +00:00
Tim Peters f33532cfef + 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.
2001-09-25 06:30:51 +00:00
Guido van Rossum a4cb78874c 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.
2001-09-25 03:56:29 +00:00
Guido van Rossum 5c294fb0e6 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)
2001-09-25 03:43:42 +00:00
Tim Peters 2306d246e8 + 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.
2001-09-25 03:18:32 +00:00
Tim Peters 3e767d19e0 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.
2001-09-25 00:01:06 +00:00
Tim Peters f4aad8eb28 + Text-mode (but not yet GUI mode) pydoc now produces useful stuff for
properties:  the docstring (if any) is displayed, and the getter, setter
  and deleter (if any) functions are named.  All that is shown indented
  after the property name.

+ Text-mode pydoc class display now draws a horizontal line between
  class attribute groups (similar to GUI mode -- while visually more
  intrusive in text mode, it's still an improvement).
2001-09-24 22:40:47 +00:00