Commit Graph

2806 Commits

Author SHA1 Message Date
Andrew M. Kuchling b386f6a509 As part of fixing bug #829532, add a test case that exercises os.makedirs 2003-12-23 16:36:11 +00:00
Hye-Shik Chang 7fc4cf57b8 Fix unicode.rsplit()'s bug that ignores separater on the end of string when
using specialized splitter for 1 char sep.
2003-12-23 09:10:16 +00:00
Hye-Shik Chang 8d2e08dcdf Enable some unittests on FreeBSD.
test__locale: add typical POSIX-style full locale names.
test_locale: use en_US.US-ASCII on FreeBSD.
2003-12-19 01:16:03 +00:00
Jeremy Hylton e708fbd286 Remove methods that are no longer called by urllib2. 2003-12-17 20:47:28 +00:00
Raymond Hettinger 64958a15d7 Guido grants a Christmas wish:
sorted() becomes a regular function instead of a classmethod.
2003-12-17 20:43:33 +00:00
Jeremy Hylton df38ea9c29 Add methods to MockHTTPClass for modern httplib interface.
Replace lots of assert_(x == y) with assertEqual(x, y).
2003-12-17 20:42:38 +00:00
Hye-Shik Chang 3ae811b57d Add rsplit method for str and unicode builtin types.
SF feature request #801847.
Original patch is written by Sean Reifschneider.
2003-12-15 18:49:53 +00:00
Jeremy Hylton c1be59f40a SF patch 852995: add processors feature to urllib2
John J. Lee writes: "the patch makes it possible to implement
functionality like HTTP cookie handling, Refresh handling,
etc. etc. using handler objects. At the moment urllib2's handler
objects aren't quite up to the job, which results in a lot of
cut-n-paste and subclassing. I believe the changes are
backwards-compatible, with the exception of people who've
reimplemented build_opener()'s functionality -- those people would
need to call opener.add_handler(HTTPErrorProcessor).

The main change is allowing handlers to implement
methods like:

http_request(request)
http_response(request, response)

In addition to the usual

http_open(request)
http_error{_*}(...)
"

Note that the change isn't well documented at least in part because
handlers aren't well documented at all.  Need to fix this.

Add a bunch of new tests.  It appears that none of these tests
actually use the network, so they don't need to be guarded by a
resource flag.
2003-12-14 05:27:34 +00:00
Neal Norwitz 328f338196 SF #736962, port test_future to unittest, add a bit more coverage, by Walter Dörwald 2003-12-13 22:43:34 +00:00
Walter Dörwald b167b04a2e Add tests to test_weakref.py to bring code coverage in _weakref.c up to 100%.
Port test_md5.py to PyUnit.

(Written by Neal Norwitz; from SF patch 736962)

(Backport candidate)
2003-12-11 12:34:05 +00:00
Walter Dörwald 1dde95dffa Move list and tuple tests from test_types.py to their own scripts:
test_tuple.py and test_list.py. Common tests for tuple, list and UserList
are shared (in seq_tests.py and list_tests.py). Port tests to PyUnit.
(From SF patch #736962)
2003-12-08 11:38:45 +00:00
Raymond Hettinger d25c1c6351 Implement itertools.groupby()
Original idea by Guido van Rossum.
Idea for skipable inner iterators by Raymond Hettinger.
Idea for argument order and identity function default by Alex Martelli.
Implementation by Hye-Shik Chang (with tweaks by Raymond Hettinger).
2003-12-06 16:23:06 +00:00
Michael W. Hudson 9da1efb5ae Remove extra copy of test_key_with_exception that somehow appeared
during a CVS merge.
2003-12-04 11:41:24 +00:00
Michael W. Hudson 1df0f654e8 Fixes and tests for various "holding pointers when arbitrary Python code
can run" bugs as discussed in

[ 848856 ] couple of new list.sort bugs
2003-12-04 11:25:46 +00:00
Tim Peters c6c5ece7e2 Typo repair; added some comments and horizontal whitespace. 2003-12-04 05:39:43 +00:00
Mark Hammond 2e8624c21a Fix test_unicode_file errors on platforms without Unicode file support,
by setting TESTFN_UNICODE_UNENCODEABLE on these platforms.
test_unicode_file only attempts to use the name for testing if not None.
2003-12-03 22:16:47 +00:00
Walter Dörwald c8de4585a6 Add parameters indent, width and depth to pprint.pprint() and pprint.pformat()
and pass them along to the PrettyPrinter constructor.
2003-12-03 20:26:05 +00:00
Walter Dörwald 7a7ede54d4 Patch #750542: pprint now will pretty print subclasses of list, tuple
and dict too, as long as they don't overwrite __repr__().
2003-12-03 20:15:28 +00:00
Guido van Rossum 291481b4db Reduce the size of Big String and Big Binary tests to 2**14 (minus one
for Big String).  This should make the tests pass on Win98SE.  Note
that the docs only promise lengths up to 2048.  Unfortunately this no
longer tests for the segfault I was seeing earlier, but I'm confident
I've nailed that one. :-)  Fixes SF 852281.  Will backport to 2.3.
2003-12-03 15:24:02 +00:00
Mark Hammond 6d459725a3 Add test for bug "[ 846133 ] os.chmod/os.utime/shutil do not work with
unicode filenames"
Reorganize tests into functions so more combinations of
unicode/encoded/ascii can be tested, and while I was at it, upgrade to
unittest based test.
2003-12-03 01:29:56 +00:00
Mark Hammond b337dd903b Add TESTFN_UNICODE_UNENCODEABLE, a unicode filename that can not be
encoded using the default file system encoding.
2003-12-03 01:27:23 +00:00
Raymond Hettinger 166958b5df As discussed on python-dev, added two extractor functions to the
operator module.
2003-12-01 13:18:39 +00:00
Guido van Rossum 0a18552b29 Add testcases for _winreg segfault (SF 851056). 2003-11-30 22:46:18 +00:00
Guido van Rossum 457bf91a7f Fix a bug discovered by Kalle Svensson: comparing sys.maxint to
2**32-1 makes no sense.  Use 2**31-1 instead.
2003-11-29 23:55:09 +00:00
Guido van Rossum 6c9e130524 - Removed FutureWarnings related to hex/oct literals and conversions
and left shifts.  (Thanks to Kalle Svensson for SF patch 849227.)
  This addresses most of the remaining semantic changes promised by
  PEP 237, except for repr() of a long, which still shows the trailing
  'L'.  The PEP appears to promise warnings for operations that
  changed semantics compared to Python 2.3, but this is not
  implemented; we've suffered through enough warnings related to
  hex/oct literals and I think it's best to be silent now.
2003-11-29 23:52:13 +00:00
Raymond Hettinger 37e136373e Make sure the list.sort's decorate step unwinds itself before returning
an exception raised by the key function.
(Suggested by Michael Hudson.)
2003-11-28 21:43:02 +00:00
Raymond Hettinger 4f8f976576 Add optional fillchar argument to ljust(), rjust(), and center() string methods. 2003-11-26 08:21:35 +00:00
Raymond Hettinger f5f41bf087 * Checkin remaining documentation
* Add more tests
* Refactor and neaten the code a bit.
* Rename union_update() to update().
* Improve the algorithms (making them a closer to sets.py).
2003-11-24 02:57:33 +00:00
Barry Warsaw ceca5d2924 test_guess_all_types(): Use a more robust test for checking that
guess_all_extensions() returns (at least) what we expect.  As Jeff
Epler suggests in

http://mail.python.org/pipermail/python-dev/2003-September/038264.html

We use a set to test the results.  This fixes the test when
test_urllib2 is run before test_mimetypes.
2003-11-23 16:21:55 +00:00
Raymond Hettinger 49ba4c39c4 * Simplify hash function and add test to show effectiveness of the hash
function.

* Add a better test for deepcopying.

* Add tests to show the __init__() function works like it does for list
  and tuple.  Add related test.

* Have shallow copies of frozensets return self.  Add related test.

* Have frozenset(f) return f if f is already a frozenset. Add related test.

* Beefed-up some existing tests.
2003-11-23 02:49:05 +00:00
Raymond Hettinger bfd334a42d Extend temporary hashability to remove() and discard().
Brings the functionality back in line with sets.py.
2003-11-22 03:55:23 +00:00
Raymond Hettinger 19c2d77842 Allow temporary hashability for the __contains__ test.
(Requested by Alex Martelli.)
2003-11-21 18:36:54 +00:00
Raymond Hettinger 3fbec701ca issubset() and issuperset() to work with general iterables 2003-11-21 07:56:36 +00:00
Guido van Rossum 944a6c32d7 test_applesingle is an expected skip almost anywhere. 2003-11-20 22:11:29 +00:00
Tim Peters 403a203223 SF bug 839548: Bug in type's GC handling causes segfaults.
Also SF patch 843455.

This is a critical bugfix.
I'll backport to 2.3 maint, but not beyond that.  The bugs this fixes
have been there since weakrefs were introduced.
2003-11-20 21:21:46 +00:00
Raymond Hettinger 901dc98316 test_applesingle is an expected skip on Win32 2003-11-20 19:02:02 +00:00
Just van Rossum 5949854200 Fix for [ 765456 ]: testAFakeZlib failed on platforms that use a
statically linked zlib module, but since the problem it tests can't
exist on these systems, simply skip it then. Will backport.
2003-11-18 23:00:55 +00:00
Jack Jansen c0b2b72702 Test the applesingle decoder. 2003-11-18 22:36:12 +00:00
Raymond Hettinger 50a4bb325c Various fixups (most suggested by Armin Rigo). 2003-11-17 16:42:33 +00:00
Raymond Hettinger a690a9967e * Migrate set() and frozenset() from the sandbox.
* Install the unittests, docs, newsitem, include file, and makefile update.
* Exercise the new functions whereever sets.py was being used.

Includes the docs for libfuncs.tex.  Separate docs for the types are
forthcoming.
2003-11-16 16:17:49 +00:00
Tim Peters f7f9e9966b subtype_dealloc(): A more complete fix for critical bug 840829 +
expanded the test case with a piece that needs the more-complete fix.

I'll backport this to 2.3 maint.
2003-11-13 21:59:32 +00:00
Martin v. Löwis d4e48b7f61 Patch #839877: Remove unused lambda expression. 2003-11-13 07:45:39 +00:00
Tim Peters add09b4149 SF bug 840829: weakref callbacks and gc corrupt memory.
subtype_dealloc():  This left the dying object exposed to gc, so that
if cyclic gc triggered during the weakref callback, gc tried to delete
the dying object a second time.  That's a disaster.  subtype_dealloc()
had a (I hope!) unique problem here, as every normal dealloc routine
untracks the object (from gc) before fiddling with weakrefs etc.  But
subtype_dealloc has obscure technical reasons for re-registering the
dying object with gc (already explained in a large comment block at
the bottom of the function).

The fix amounts to simply refraining from reregistering the dying object
with gc until after the weakref callback (if any) has been called.

This is a critical bug (hard to predict, and causes seemingly random
memory corruption when it occurs).  I'll backport it to 2.3 later.
2003-11-12 20:43:28 +00:00
Raymond Hettinger ad983e79d6 Improve the implementation of itertools.tee().
Formerly, underlying queue was implemented in terms of two lists.  The
new queue is a series of singly-linked fixed length lists.

The new implementation runs much faster, supports multi-way tees, and
allows tees of tees without additional memory costs.

The root ideas for this structure were contributed by Andrew Koenig
and Guido van Rossum.
2003-11-12 14:32:26 +00:00
Raymond Hettinger af28e4b66b Update test to handle list.__reversed__(). 2003-11-08 12:39:53 +00:00
Raymond Hettinger b3af1813eb Convert heapq.py to a C implementation. 2003-11-08 10:24:38 +00:00
Martin v. Löwis d2171d2ba4 Overallocate target buffer for normalization more early. Fixes #834676.
Backported to 2.3.
2003-11-06 20:47:57 +00:00
Raymond Hettinger 85c20a41df Implement and apply PEP 322, reverse iteration 2003-11-06 14:06:48 +00:00
Gregory P. Smith a703a21b48 * Use weakref's of DBCursor objects for the iterator cursors to avoid a
memory leak that would've occurred for all iterators that were
  destroyed before having iterated until they raised StopIteration.

* Simplify some code.

* Add new test cases to check for the memleak and ensure that mixing
  iteration with modification of the values for existing keys works.
2003-11-03 01:04:41 +00:00
Gregory P. Smith dc113a8a06 * Fix the singlethreaded deadlocks occurring in the simple bsddb interface.
* Add support for multiple iterator/generator objects at once on the simple
  bsddb _DBWithCursor interface.
2003-11-02 09:10:16 +00:00