Commit Graph

5385 Commits

Author SHA1 Message Date
Piers Lauder 0402dd18cb fix send method not noticing when partial sends happen 2001-10-21 20:26:37 +00:00
Fredrik Lundh 1296a8d77e sre.Scanner fixes (from Greg Chapman). also added a Scanner sanity
check to the test suite.

added a few missing exception checks in the _sre module
2001-10-21 18:04:11 +00:00
Fredrik Lundh bec95b9d88 rewrote the pattern.sub and pattern.subn methods in C
removed (conceptually flawed) getliteral helper; the new sub/subn code
uses a faster code path for literal replacement strings, but doesn't
(yet) look for literal patterns.

added STATE_OFFSET macro, and use it to convert state.start/ptr to
char indexes
2001-10-21 16:47:57 +00:00
Skip Montanaro 3e7bba9ac6 added tests for long ints and ints where they are > 32 bits.
should have been checked in as part of patch #470254.
2001-10-19 16:06:52 +00:00
Marc-André Lemburg b5507ecd3c Additional test and documentation for the unicode() changes.
This patch should also be applied to the 2.2b1 trunk.
2001-10-19 12:02:29 +00:00
Barry Warsaw 1f0fa92b0a Another merge from mimelib:
TestMIMEMessage.test_epilogue(), TestIdempotent.test_preamble_epilogue():
    Test cases for SF bug #472481.
2001-10-19 04:08:59 +00:00
Barry Warsaw 11ce550578 Another email package test file 2001-10-19 04:07:27 +00:00
Barry Warsaw 856c32b5f4 Another merge from mimelib:
_handle_multipart(): If there is an epilogue and the epilogue does
    not itself start with a newline, add a newline before writing the
    epilogue.  Closes SF bug #472481.
2001-10-19 04:06:39 +00:00
Guido van Rossum c524d952da SF patch #460805 by Chris Gonnerman: Support for unsetenv()
This adds unsetenv to posix, and uses it in the __delitem__ method of
os.environ.

(XXX Should we change the preferred name for putenv to setenv, for
consistency?)
2001-10-19 01:31:59 +00:00
Martin v. Löwis a660a34844 Assume a 64-bit start and len if O_LARGEFILE is available. 2001-10-18 22:07:48 +00:00
Tim Peters e0c446bb4a Whitespace normalization. 2001-10-18 21:57:37 +00:00
Guido van Rossum 1fff878c45 The assignment to result.st_rdev can raise AttributeError as well as
TypeError (on systems where it's not defined at all, it raises
AttributeError; when it's defined, assignment to it raises TypeError).
2001-10-18 21:19:31 +00:00
Fredrik Lundh a5e616510e changed misleading argument name 2001-10-18 20:58:25 +00:00
Guido van Rossum 98bf58f1c6 SF patch #462296: Add attributes to os.stat results; by Nick Mathewson.
This is a big one, touching lots of files.  Some of the platforms
aren't tested yet.  Briefly, this changes the return value of the
os/posix functions stat(), fstat(), statvfs(), fstatvfs(), and the
time functions localtime(), gmtime(), and strptime() from tuples into
pseudo-sequences.  When accessed as a sequence, they behave exactly as
before.  But they also have attributes like st_mtime or tm_year.  The
stat return value, moreover, has a few platform-specific attributes
that are not available through the sequence interface (because
everybody expects the sequence to have a fixed length, these couldn't
be added there).  If your platform's struct stat doesn't define
st_blksize, st_blocks or st_rdev, they won't be accessible from Python
either.

(Still missing is a documentation update.)
2001-10-18 20:34:25 +00:00
Tim Peters 8dd7adeb34 SF bug [#472347] pydoc and properties.
The GUI-mode code to display properties blew up if the property functions
(get, set, etc) weren't simply methods (or functions).

"The problem" here is really that the generic document() method dispatches
to one of .doc{routine, class, module, other}(), but all of those require
a different(!) number of arguments.  Thus document isn't general-purpose
at all:  you have to know exactly what kind of thing is it you're going
to document first, in order to pass the correct number of arguments to
.document for it to pass on.  As an expedient hack, just tacked "*ignored"
on to the end of the formal argument lists for the .docXXX routines so
that .document's caller doesn't have to know in advance which path
.document is going to take.
2001-10-18 19:56:17 +00:00
Fred Drake c10039c011 Do not expect line number events when running under "python -O".
The right fix is to generate line number events anyway ;-), but this will
have to do for now.
2001-10-18 19:34:00 +00:00
Fredrik Lundh 397a654791 SRE bug #441409:
compile should raise error for non-strings
SRE bug #432570, 448951:
    reset group after failed match

also bumped version number to 2.2.0
2001-10-18 19:30:16 +00:00
Fred Drake 3bb4d214a4 Add a test for calling a weakref proxy with a dictionary of keyword args. 2001-10-18 19:28:29 +00:00
Guido van Rossum 4114a4afec Fix the frozen bytecode for __hello__ (betcha didn't know that existed
:-).

Add a test that prevents the __hello__ bytecode from going stale
unnoticed again.

The test also tests the loophole noted in SF bug #404545.  This test
will fail right now; I'll check in the fix in a minute.
2001-10-18 18:49:37 +00:00
Fred Drake 39c27f1ffb Make sure we do not core dump when using proxies with the binary slot
handlers.  This was fixed in Objects/weakrefobject.c 1.2.
2001-10-18 18:06:05 +00:00
Guido van Rossum a5343ccd28 SF bug #471720: ThreadingMixIn/TCPServer forgets close
Solved with a helper method that calls finish_request() and then
close_request().  The code is by Max Neunhöffer.
2001-10-18 18:02:07 +00:00
Martin v. Löwis 29103c7b32 Reindent __repr__. 2001-10-18 17:33:19 +00:00
Jeremy Hylton cf672f15e0 Add test for local assigned to only in a nested list comp 2001-10-18 16:23:11 +00:00
Guido van Rossum f76de62f7d Fix SF bug #472234: type(obj) calls type->tp_init (Roeland Rengelink)
The fix is a band-aid: type_call() now makes the same exception for a
single-argument call to type() as type_new() was already making.
2001-10-18 15:49:21 +00:00
Martin v. Löwis eee80ee2ef Patch #470744: Simplify __repr__ error handling. 2001-10-18 11:39:34 +00:00
Jeremy Hylton 9f6c37df26 Add trivial test cases for RAND_add() and RAND_status().
(The rest of the test cases are trivial, so I don't feel too bad.)
2001-10-18 00:30:14 +00:00
Skip Montanaro 5449e08412 test for int and long int overflow (allows operation on 64-bit platforms)
closes patch 470254
2001-10-17 22:53:33 +00:00
Barry Warsaw 07227d1ec0 Two merges from the mimelib project:
test_no_semis_header_splitter(): This actually should still split.

    test_no_split_long_header(): An example of an unsplittable line.

    test_no_semis_header_splitter(): Test for SF bug # 471918, Generator
    splitting long headers.
2001-10-17 20:52:26 +00:00
Barry Warsaw d1eeecbd43 Two merges from the mimelib project:
_split_header(): Split on folding whitespace if the attempt to split
    on semi-colons failed.

    _split_header(): Patch by Matthew Cowles for fixing SF bug # 471918,
    Generator splitting long headers.
2001-10-17 20:51:42 +00:00
Guido van Rossum 1f74cb3575 Oops. Catching OverflowError from int() doesn't help, since it raises
ValueError on too-large inputs.
2001-10-17 17:21:47 +00:00
Jeremy Hylton 7a1ea0e880 Make sure the output lists are sorted, even if run with -r. 2001-10-17 13:45:28 +00:00
Jeremy Hylton 138d90eb73 Vastly improved stacksize calculation.
There are now no known cases where the compiler package computes a
stack depth lower than the one computed by the builtin compiler.  (To
achieve this state, we had to fix bugs in both compilers :-).

The chief change is to do the depth calculations with respect to basic
blocks.  The stack effect of block is calculated.  Then the flow graph
is traversed using breadth-first search to find the max weight path
through the graph.

Had to fix the StackDepthTracker to calculate the right info for
several opcodes: LOAD_ATTR, CALL_FUNCTION (and friends), MAKE_CLOSURE,
and DUP_TOPX.

XXX Still need to handle free variables in MAKE_CLOSURE.

XXX There are still a lot of places where the computed stack depth is
larger than for the builtin compiler.  These won't cause the
interpreter to overflow the frame, but they waste space.
2001-10-17 13:37:29 +00:00
Jeremy Hylton d114261608 Handle testlist_safe as if it were testlist. 2001-10-17 13:32:52 +00:00
Jeremy Hylton 4bf1fb63e4 track addition of testlist_safe to Grammar 2001-10-17 13:13:04 +00:00
Guido van Rossum bcbdc95e90 SF patch #467430.
- replace some log_error() calls with log_message()

- flush self.rfile before forking too (hope this works on Windows)
2001-10-17 06:45:56 +00:00
Guido van Rossum f93befc209 Folder.getlast(): avoid PyChecker warning. 2001-10-17 05:59:26 +00:00
Fred Drake 2a2d970ef9 Remove unused import; reported by Neal Norwitz. 2001-10-17 01:51:04 +00:00
Fred Drake d10ed8b179 Minor code cleanups based on comments from Neal Norwitz. 2001-10-17 01:49:50 +00:00
Jeremy Hylton 511e2cacc4 [ #403753 ] zlib decompress; uncontrollable memory usage
Mostly by Toby Dickenson and Titus Brown.

Add an optional argument to a decompression object's decompress()
method.  The argument specifies the maximum length of the return
value.  If the uncompressed data exceeds this length, the excess data
is stored as the unconsumed_tail attribute.  (Not to be confused with
unused_data, which is a separate issue.)

Difference from SF patch: Default value for unconsumed_tail is ""
rather than None.  It's simpler if the attribute is always a string.
2001-10-16 20:39:49 +00:00
Tim Peters c993315b18 SF bug [#468061] __str__ ignored in str subclass.
object.c, PyObject_Str:  Don't try to optimize anything except exact
string objects here; in particular, let str subclasses go thru tp_str,
same as non-str objects.  This allows overrides of tp_str to take
effect.

stringobject.c:
+ string_print (str's tp_print):  If the argument isn't an exact string
  object, get one from PyObject_Str.

+ string_str (str's tp_str):  Make a genuine-string copy of the object if
  it's of a proper str subclass type.  str() applied to a str subclass
  that doesn't override __str__ ends up here.

test_descr.py:  New str_of_str_subclass() test.
2001-10-16 20:18:24 +00:00
Guido van Rossum b6aca6afe2 Fix SF bug #459767: ftplib fails with files > 2GB
size(), parse150(): try int() first, catch OverflowError, fall back to
long().
2001-10-16 19:45:52 +00:00
Tim Peters a7e1f43bd9 Remove obsolete __dynamic__ distinction. 2001-10-15 22:59:59 +00:00
Tim Peters 6006629c3c Remove obsolete __dynamic__ distinction. 2001-10-15 22:53:29 +00:00
Tim Peters 1ce150c675 Remove obsolete __static__/__dynamic__ distinction. 2001-10-15 22:49:27 +00:00
Fred Drake 47cada7ab8 pstats-compatible analysis module.
hotshot.stats.load(logfilename) returns a pstats.Stats instance, which is
about as compatible as it gets.
2001-10-15 22:18:53 +00:00
Fred Drake e7d8a78b8e runcall(): Expose the return value of the profiled function; this allows
changing an application to collect profile data on one part of the
    app while still making use of the profiled component, without relying
    on side effects.
2001-10-15 22:14:29 +00:00
Fred Drake d5d5a04040 Avoid deep recursion when reading the header of the log file.
Add support for extracting function names from the log file, keeping the
extract-names-from-sources support as a fallback.
2001-10-15 22:05:32 +00:00
Guido van Rossum 687ae00460 Get rid of __defined__ and tp_defined -- there's no need to
distinguish __dict__ and __defined__ any more.  In the C structure,
tp_cache takes its place -- but this hasn't been implemented yet.
2001-10-15 22:03:32 +00:00
Jeremy Hylton 6642653875 Covert pickle tests to use unittest.
Extend tests to cover a few more cases.  For cPickle, test several of
the undocumented features.
2001-10-15 21:38:56 +00:00
Jeremy Hylton abe2c62bdb Use cStringIO when available.
Remove test code.  It's available in Lib/test/picklertester.py.
2001-10-15 21:29:28 +00:00
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