Commit Graph

3261 Commits

Author SHA1 Message Date
Edward Loper 74bca7aa44 - Changed option directives to be example-specific. (i.e., they now
modify option flags for a single example; they do not turn options
  on or off.)
- Added "indent" and "options" attributes for Example
- Got rid of add_newlines param to DocTestParser._parse_example (it's
  no longer needed; Example's constructor now takes care of it).
- Added some docstrings
2004-08-12 02:27:44 +00:00
Tim Peters 494aaee902 Whitespace normalization. 2004-08-09 18:54:11 +00:00
Tim Peters 6c542b731c Edward's latest checkins somehow managed to wipe out my previous latest
checkins.  Reapplying the latter changes.
2004-08-09 16:43:36 +00:00
Edward Loper a1ef6110ba - DocTest is now a simple container class; its constructor is no longer
responsible for parsing the string.
- Renamed Parser to DocTestParser
- DocTestParser.get_*() now accept the string & name as command-line
  arguments; the parser's constructor is now empty.
- Added DocTestParser.get_doctest() method
- Replaced "doctest_factory" argument to DocTestFinder with a "parser"
  argument (takes a DocTestParser).
- Changed _tag_msg to take an indentation string argument.
2004-08-09 16:14:41 +00:00
Tim Peters 413ced6c22 This started as a spelling and whitespace cleanup. The comment for
the set_trace fiddling didn't make sense to me, and I ended up reworking
that part of the code.  We really do want to save and restore
pdb.set_trace, so that each dynamically nested level of doctest gets
sys.stdout fiddled to what's appropriate for *it*.  The only "trick"
really needed is that these layers of set_trace wrappers each call the
original pdb.set_trace (instead of the current pdb.set_trace).
2004-08-09 15:43:47 +00:00
Jim Fulton 356fd19c31 Added support for pdb.set_trace. 2004-08-09 11:34:47 +00:00
Dave Cole 331708b226 Patch #1003700: Add socketpair function to socket module. 2004-08-09 04:51:41 +00:00
Tim Peters bb43147312 Drop the excruciating newline requirements on arguments to
Example.__init__.  The constructor now adds trailing newlines when
needed, and no longer distinguishes between multi- and single-line
cases for source.
2004-08-09 03:51:46 +00:00
Edward Loper 7c748469c7 Rewrote Parser, using regular expressions instead of walking though
the string one line at a time.  The resulting code is (in my opinion,
anyway), much easier to read.  In the process, I found and fixed a
bug in the orginal parser's line numbering in error messages (it was
inconsistant between 0-based and 1-based).  Also, check for missing
blank lines after the prompt on all prompt lines, not just PS1 lines
(test added).
2004-08-09 02:06:06 +00:00
Edward Loper 103d26e851 Fixed doctest error (wrong prompts) 2004-08-09 02:03:30 +00:00
Raymond Hettinger 955d2b2168 Add a test for Context.copy(). 2004-08-08 20:17:45 +00:00
Tim Peters 0955f29703 Tell unittest that source files with "badsyntax" in their names should
raise SyntaxError.  test_compiler passes now on WinXP, at least in a
release-build non-O run.
2004-08-08 16:43:59 +00:00
Tim Peters 2a5f656d0c Renamed locals to better reflect their meanings. 2004-08-08 16:37:37 +00:00
Tim Peters b6ecc165f2 In verbose mode, display the name of each file before trying to compile
it.  Else when this fails, there's no way to tell which file it was
chewing on.
2004-08-08 16:32:54 +00:00
Tim Peters feec4533e2 Bug 1003935: xrange overflows
Added XXX comment about why the undocumented PyRange_New() API function
is too broken to be worth the considerable pain of repairing.

Changed range_new() to stop using PyRange_New().  This fixes a variety
of bogus errors.  Nothing in the core uses PyRange_New() now.

Documented that xrange() is intended to be simple and fast, and that
CPython restricts its arguments, and length of its result sequence, to
native C longs.

Added some tests that failed before the patch, and repaired a test that
relied on a bogus OverflowError getting raised.
2004-08-08 07:17:39 +00:00
Tim Peters f3f57473ed Get rid of the ignore_imports argument to DocTestFinder.find().
This got slammed in when find() was fixed to stop grabbing doctests
from modules imported *by* the module being tested.  Such tests cannot
be expected to succeed, since they'll be run with the current module's
globals.  Dozens of Zope3 doctests were failing because of that.

It wasn't clear why ignore_imports got added then.  Maybe it's because
some existing tests failed when the change was made.  Whatever, it's
a Bad Idea so it's gone now.

The only use of it was exceedingly obscure, in test_doctest's "Duplicate
Removal" test.  It was "needed" there because, as an artifact of running
a doctest inside a doctest, the func_globals of functions compiled in
the second-level doctest don't match the module globals, and so the
test-finder believed these functions were from a foreign module and
skipped them.  But that took a long time to figure out, and I actually
understand some of this stuff <0.9 wink>.

That problem was resolved by moving the source code for the second-level
doctest into an actual module (test/doctest_aliases.py).

The only remaining difficulty was that the test for the deprecated
Tester.rundict() then failed, because the test finder doesn't take
module=None at face value, trying to guess which module the user really
intended then.  Its guess wasn't appropriate for what Tester.rundict
needs when module=None is given to *it*, which is "no, there is no
module here, and I mean it".  So now passing module=False means exactly
that.  This is hokey, but ignore_imports=False was really a hack to worm
around that there was no way to tell the test-finder that module=None
*sometimes* means what it says.  There was no use case for the combination
of passing a real module with ignore_imports=False.
2004-08-08 06:11:48 +00:00
Tim Peters f727c6c2c7 Deprecated testmod's useless & confusing isprivate gimmick.
Ripped out the docs for the new DocTestFinder's namefilter argument,
and renamed it to _namefilter; this only existed to support isprivate.
Removed the new DocTestFinder's objfilter argument.  No point adding
more cruft to a broken filtering design.
2004-08-08 01:48:59 +00:00
Tim Peters 9ca3f8551a Whitespace normalization. 2004-08-08 01:05:14 +00:00
Armin Rigo 8b2cbfd180 Let's not use string exceptions any more. 2004-08-07 21:27:43 +00:00
Armin Rigo 25847813c1 Removing tests that fail because of changes in PyString_InternInPlace(),
as discussed on IRC.  The equivalent tests for the new behavior are in
test_builtin.py.
2004-08-07 20:30:03 +00:00
Jeremy Hylton 4336eda886 Add a trivial test for the compiler package, guarded by compiler resource.
This test is insanely slow, so it requires a resource.  On my machine,
it also appears to dump core.  I think the problem is a stack
overflow, but haven't been able to confirm.
2004-08-07 19:25:33 +00:00
Jeremy Hylton 4c989ddc9c Subclasses of string can no longer be interned. The semantics of
interning were not clear here -- a subclass could be mutable, for
example -- and had bugs.  Explicitly interning a subclass of string
via intern() will raise a TypeError.  Internal operations that attempt
to intern a string subclass will have no effect.

Added a few tests to test_builtin that includes the old buggy code and
verifies that calls like PyObject_SetAttr() don't fail.  Perhaps these
tests should have gone in test_string.
2004-08-07 19:20:05 +00:00
Jeremy Hylton 5d9c3031c8 Fix urllib2.urlopen() handling of chunked content encoding.
The change to use the newer httplib interface admitted the possibility
that we'd get an HTTP/1.1 chunked response, but the code didn't handle
it correctly.  The raw socket object can't be pass to addinfourl(),
because it would read the undecoded response.  Instead, addinfourl()
must call HTTPResponse.read(), which will handle the decoding.

One extra wrinkle is that the HTTPReponse object can't be passed to
addinfourl() either, because it doesn't implement readline() or
readlines().  As a quick hack, use socket._fileobject(), which
implements those methods on top of a read buffer.  (suggested by mwh)

Finally, add some tests based on test_urllibnet.

Thanks to Andrew Sawyers for originally reporting the chunked problem.
2004-08-07 17:40:50 +00:00
Barry Warsaw e8bedeb45b Resolution of bug #997368, "strftime() backward compatibility".
Specifically, time.strftime() no longer accepts a 0 in the yday position of a
time tuple, since that can crash some platform strftime() implementations.

parsedate_tz(): Change the return value to return 1 in the yday position.

Update tests in test_rfc822.py and test_email.py
2004-08-07 16:38:40 +00:00
Jeremy Hylton 2c178253bd SF bug 874842 and patch 997626: httplib bugs
Hack httplib to work with broken Akamai proxies.
Make sure that httplib doesn't add extract Accept-Encoding or
Content-Length headers if the client has already set them.
2004-08-07 16:28:14 +00:00
Michael W. Hudson 2b3feec58f This is more-or-less:
[ 1005123 ] test_curses fails on MacOS X 10.3

Be a bit more guarded about what we expect a terminal to be capable
of.
2004-08-07 15:27:16 +00:00
Raymond Hettinger 654fcd531e Exercise DocTestSuite's search for __test__. 2004-08-07 06:15:12 +00:00
Tim Peters d1b7827216 Whitespace normalization. 2004-08-07 06:03:09 +00:00
Tim Peters 1e277ee3bd Bug 772091: doctest.DocTestSuite does not support __test__
This got fixed "by magic" as part of the refactoring, but wasn't tested
as such.  Now it is.
2004-08-07 05:37:52 +00:00
Raymond Hettinger 2a7dedef9e SF bug #1004669: Type returned from .keys() is not checked 2004-08-07 04:55:30 +00:00
Tim Peters 19397e5ec5 Merging from tim-doctest-branch, which is now closed.
This primarily adds more powerful ways to work with unittest, including
spiffy support for building suites out of doctests in non-Python
"text files".
2004-08-06 22:02:59 +00:00
Brett Cannon d09d9664e6 Changes the remote address used for tests in TimeoutTestCase from google.com to
python.org .  This way the delay should be great enough for
testConnectTimeout() to pass even when one has a really fast Net connection
that allows connections faster than .001 seconds.
2004-08-06 04:30:46 +00:00
Tim Peters 9b625d3037 Example.__init__: this cannot use assert, because that fails to trigger
in a -O run, and so test_doctest was failing under -O.  Simple cause,
simple cure.
2004-08-04 20:04:32 +00:00
Tim Peters 8485b56216 Edward Loper's cool and massive refactoring of doctest.py, merged from
the tim-doctest-merge-24a2 tag on the the tim-doctest-branch branch.
We did development on the branch in case it wouldn't land in time for
2.4a2, but the branch looked good:  Edward's tests passed there, ditto
Python's tests, and ditto the Zope3 tests.  Together, those hit doctest
heavily.
2004-08-04 18:46:34 +00:00
Michael W. Hudson 574a25127a To ever run this test "you must import TestSkipped" from the right
place! (can that please be it for silly mistakes in this file? :-) I
know I started it, but...).

Also, rearrangements to run repeatedly.
2004-08-04 14:22:56 +00:00
Vinay Sajip 6887c92b1e Close handlers and tidy up loggers by removing closed handlers - to avoid problems when run twice (SF #1002537) 2004-08-04 08:29:14 +00:00
Hye-Shik Chang e9ddfbb412 SF #989185: Drop unicode.iswide() and unicode.width() and add
unicodedata.east_asian_width().  You can still implement your own
simple width() function using it like this:
    def width(u):
        w = 0
        for c in unicodedata.normalize('NFC', u):
            cwidth = unicodedata.east_asian_width(c)
            if cwidth in ('W', 'F'): w += 2
            else: w += 1
        return w
2004-08-04 07:38:35 +00:00
Hye-Shik Chang b5047fd019 Add a workaround for a problem that UTF-8 strings can be corrupted
or broken by basic ctype functions in 4.4BSD descendants.  This
will be fixed in their future development branches but they'll keep
the POSIX-incompatibility for their backward-compatiblities in near
future.
2004-08-04 06:33:51 +00:00
Tim Peters 6db15d7307 Whitespace normalization. 2004-08-04 02:36:18 +00:00
Tim Peters cea2cc4a21 test_threadsignals is an expected skip on win32. 2004-08-04 02:32:03 +00:00
Tim Peters 81676dc520 To raise TestSkipped, you must import TestSkipped. 2004-08-04 02:30:45 +00:00
Fred Drake f901abdd62 allow ctime(), gmtime(), and localtime() to take None as equivalent to an omitted arg
(closes SF bug #658254, patch #663482)
2004-08-03 17:58:55 +00:00
Fred Drake 4818748b87 add missing import! 2004-08-03 16:14:13 +00:00
Fred Drake 4354ba3f76 avoid fragility: make sure POSIXLY_CORRECT is completely controlled
for the tests, and restored properly when done
2004-08-03 15:54:45 +00:00
Michael W. Hudson 34fba3b445 Add the same guard as test_signal. 2004-08-03 15:35:29 +00:00
Michael W. Hudson 43220ea26e Argh! This was meant to be part of patch #960406. 2004-08-03 14:37:14 +00:00
Michael W. Hudson 61147f63d9 Check in my refleak hunting code.
It's not the 100% solution -- it may not even be the 90% solution -- but
it does seem to help.
2004-08-03 11:33:28 +00:00
Anthony Baxter afd5ce1814 nice tests dont leave little suprises in the environ 2004-08-03 11:14:19 +00:00
Michael W. Hudson 5bf2516807 More "noone expected this to run twice"ness removal. 2004-08-03 11:14:09 +00:00
Michael W. Hudson fe27ff8936 make this test work when run repeatedly. 2004-08-03 11:08:32 +00:00
Anthony Baxter d2717217ae Removed use of 'cgi.initlog()' - the first call to cgi.log is actually
an initlog() (and initlog()'s docstring says "don't use this"!) This
allows test_cgi to be run repeatedly in a single run of the interpreter.
2004-08-03 11:05:04 +00:00
Michael W. Hudson fcc09bbad6 Don't exit test_main() with the lock 'done' held -- there's no cleaner
way to guarantee a deadlock on the next call!

If I've inadvertently done some damage to this test, sorry (but I don't
think I have).
2004-08-03 10:45:59 +00:00
Michael W. Hudson 3bfed9c225 Delete the items variable (and explain why). 2004-08-03 10:17:34 +00:00
Anthony Baxter 270fe88c68 and a unit test for the staticmethod-of-a-non-method failure just fixed 2004-08-02 11:34:10 +00:00
Raymond Hettinger 66bd233225 Completed the patch for Bug #215126.
* Fixes an incorrect variable in a PyDict_CheckExact.
* Allow general mapping locals arguments for the execfile() function
  and exec statement.
* Add tests.
2004-08-02 08:30:07 +00:00
Anthony Baxter c2a5a63654 PEP-0318, @decorator-style. In Guido's words:
"@ seems the syntax that everybody can hate equally"
Implementation by Mark Russell, from SF #979728.
2004-08-02 06:10:11 +00:00
Tim Peters 99d001ed0d Removed reliance on damaged module object appearing in sys.modules
after a failed import.

This is the last checkin in the "change import failure semantics" series.
2004-08-02 03:59:57 +00:00
Tim Peters 08138fdc7a New tests:
test_failing_import_sticks -- if an import raises an exception,
        ensure that trying to import it again continues raising exceptions
    test_failing_reload -- if a module loads OK, but a reload raises an
        exception, ensure that the module is still in sys.modules, and
        that its __dict__ reflects as much of the reload attempt as
        succeeded.  That doesn't seem like sane semantics, but it is
        backward-compatible semantics <wink>.
2004-08-02 03:58:27 +00:00
Tim Peters d464838ebc Removed no-longer-needed convolutions to recover from damaged modules
getting left beyind in sys.modules.
2004-08-02 03:55:18 +00:00
Tim Peters c0cbc8611b Whitespace normalization. 2004-07-31 21:17:37 +00:00
Tim Peters 579f7355fe Be more careful about reverting mutuations to system-wide (sys) variables.
This fixes 15 spurious test failures on Windows (probably all due to
the test leaving a wrong path in sys.argv[0], which then prevented
regrtest.py from finding the expected-output files for tests running
after test_optparse).
2004-07-31 21:14:28 +00:00
Greg Ward eba20e6015 Upgrade optparse module and tests to Optik 1.5a1:
* add expansion of default values in help text: the string
    "%default" in an option's help string is expanded to str() of
    that option's default value, or "none" if no default value.
  * bug #955889: option default values that happen to be strings are
    now processed in the same way as values from the command line; this
    allows generation of nicer help when using custom types.  Can
    be disabled with parser.set_process_default_values(False).
  * bug #960515: don't crash when generating help for callback
    options that specify 'type', but not 'dest' or 'metavar'.
  * feature #815264: change the default help format for short options
    that take an argument from e.g. "-oARG" to "-o ARG"; add
    set_short_opt_delimiter() and set_long_opt_delimiter() methods to
    HelpFormatter to allow (slight) customization of the formatting.
  * patch #736940: internationalize Optik: all built-in user-
    targeted literal strings are passed through gettext.gettext().  (If
    you want translations (.po files), they're not included with Python
    -- you'll find them in the Optik source distribution from
    http://optik.sourceforge.net/ .)
  * bug #878453: respect $COLUMNS environment variable for
    wrapping help output.
  * feature #988122: expand "%prog" in the 'description' passed
    to OptionParser, just like in the 'usage' and 'version' strings.
    (This is *not* done in the 'description' passed to OptionGroup.)
2004-07-31 16:15:44 +00:00
Armin Rigo 93677f075d * drop the unreasonable list invariant that ob_item should never come back
to NULL during the lifetime of the object.

* listobject.c nevertheless did not conform to the other invariants,
  either; fixed.

* listobject.c now uses list_clear() as the obvious internal way to clear
  a list, instead of abusing list_ass_slice() for that.  It makes it easier
  to enforce the invariant about ob_item == NULL.

* listsort() sets allocated to -1 during sort; any mutation will set it
  to a value >= 0, so it is a safe way to detect mutation.  A negative
  value for allocated does not cause a problem elsewhere currently.
  test_sort.py has a new test for this fix.

* listsort() leak: if items were added to the list during the sort, AND if
  these items had a __del__ that puts still more stuff into the list,
  then this more stuff (and the PyObject** array to hold them) were
  overridden at the end of listsort() and never released.
2004-07-29 12:40:23 +00:00
Neal Norwitz 014f103705 SF bug #999776, zlib home page wrong
Backport candidate.
2004-07-29 03:55:56 +00:00
Tim Peters 5cfb05eef0 Added a new fileno() method. ZODB's repozo.py wants this so it can
apply os.fsync() to the GzipFile backup files it creates.
2004-07-27 21:02:02 +00:00
Martin v. Löwis 544f1195b1 Patch #995766: Keyword argument support in cPickle. 2004-07-27 05:22:33 +00:00
Martin v. Löwis 32d0c1b458 Patch #995782: Add FreeBSD 5 expectations. Will backport to 2.3. 2004-07-26 12:09:13 +00:00
Skip Montanaro 5253da163c added test for bug #996359. 2004-07-24 19:56:03 +00:00
Marc-André Lemburg d25c650461 Let u'%s' % obj try obj.__unicode__() first and fallback to obj.__str__(). 2004-07-23 16:13:25 +00:00
Tim Peters aa1c7ff7e8 SF patch 995225: tarfile.py fix for bug #990325
Removes CVS keywords from this binary file, so that test_tarfile passes
regardless of whether Python is checked out with -kk.
2004-07-22 00:54:37 +00:00
Neal Norwitz a4f651a2ae SF #857297 and 916874, improve handling of hard links when extracting 2004-07-20 22:07:44 +00:00
Neal Norwitz 0662f8a5ea SF #846659, fix bufsize violation and GNU longname/longlink extensions 2004-07-20 21:54:18 +00:00
Neil Schemenauer 3a313e3655 Check the type of values returned by __int__, __float__, __long__,
__oct__, and __hex__.  Raise TypeError if an invalid type is
returned.  Note that PyNumber_Int and PyNumber_Long can still
return ints or longs.  Fixes SF bug #966618.
2004-07-19 16:29:17 +00:00
Neil Schemenauer 66edb6295f Don't return spurious empty fields if 'keep_empty_values' is True.
Fixes SF bug #990307.
2004-07-19 15:38:11 +00:00
Hye-Shik Chang 5ef601854e test_codecmaps_hk is also expected to be skipped when a mapping file
isn't available. (Spotted by Raymond Hettinger)
2004-07-19 06:39:37 +00:00
Neal Norwitz a0e0cd3013 Don't try to create the directory if it already exists, otherwise the test fails 2004-07-19 00:08:59 +00:00
Tim Peters beb7c0c434 test_sf_950057's gen1() used an assert statement, which caused the test
to fail when running with -O.  Changed to raise AssertionError instead.
2004-07-18 17:34:03 +00:00
Tim Peters 182b5aca27 Whitespace normalization, via reindent.py. 2004-07-18 06:16:08 +00:00
Hye-Shik Chang 2bb146f2f4 Bring CJKCodecs 1.1 into trunk. This completely reorganizes source
and installed layouts to make maintenance simple and easy.  And it
also adds four new codecs; big5hkscs, euc-jis-2004, shift-jis-2004
and iso2022-jp-2004.
2004-07-18 03:06:29 +00:00
Tim Peters 264c659197 Oops! Restored the pickle test to test_pyclbr, but changed types.py so
that pyclbr doesn't need to special-case modules that do "from types
import *".
2004-07-18 00:08:11 +00:00
Tim Peters fa7809df02 The Darwin-specific getproxies_internetconfig() was added to urllib,
causing test_pyclbr to fail on all other platforms.  Added that routine
to the urllib "ignore" list.
Removed the special case for "g" in the pickle module.  types.py deletes
"g" from its namespace; maybe it didn't always.  Whatever, the special
case isn't needed today.
2004-07-18 00:00:03 +00:00
Raymond Hettinger 11a70c79b9 Upgrade None assignment SyntaxWarning to a SyntaxError. 2004-07-17 21:46:25 +00:00
Jim Fulton d15dc06df0 Implemented thread-local data as proposed on python-dev:
http://mail.python.org/pipermail/python-dev/2004-June/045785.html
2004-07-14 19:11:50 +00:00
Raymond Hettinger b91af521fd * Hide a loop induction variable that was inadvertantly being picked up
by the locals() call in the context constructor.

* Remove unnecessary properties for int, exp, and sign which duplicated
  information returned by as_tuple().
2004-07-14 16:35:30 +00:00
Raymond Hettinger fed52963fc * Rename "Signals" to "_signals" making it non-public.
* Context.create_decimal can take a zero default just like Decimal().
* Fix typo in comment.
2004-07-14 15:41:57 +00:00
Guido van Rossum 8cec3ab0e4 - Bug #981530: Fix UnboundLocalError in shutil.rmtree(). This affects
the documented behavior: the function passed to the onerror()
  handler can now also be os.listdir.

[I could've sworn I checked this in, but apparently I didn't, or it
got lost???]
2004-07-14 00:48:58 +00:00
Brett Cannon 80e1f06594 It helps when doing checks if something is in a tuple of strings that if you
put everything in the tuple in caps to use str.upper() instead of str.lower().
2004-07-14 00:43:51 +00:00
Brett Cannon ee86a66dd8 Fixes a bug in testing code handling .pth files that did not restore the original
module that is removed for testing "import" lines.  Originally deleted the
entry from sys.modules and then just let other code that needed it to import it
again.  Problem with this solution is that it lead to code that had already
imported the module in question to have their own reference to a new copy of
the module in question that new code couldn't reach.  This lead to a failure in
test_strptime since it monkey-patched the 'time' module it had a reference to
while _strptime had its own reference to another copy of 'time' from being
imported by test___all__ that it was using for a calculation.

Also moved the testing code out of the PthFile class and into the actual test
class.  This was to stop using 'assert' which is useless with a -O execution.
2004-07-13 07:12:25 +00:00
Nicholas Bastin 12ac3e1f49 Using repr() generates entries that the current stats package can't
collate, so setting it back to the function name
2004-07-12 23:38:02 +00:00
Brett Cannon fdf7449ad2 Fix test case for when time.tzname[0] is either UTC or GMT. Also have test
output more telling details when there is a failure.
2004-07-12 19:34:02 +00:00
Michael W. Hudson 3f06189332 this is patch
[ 988698 ] compiler.transformer fix for (a, b) = 1, 2

fixing bug

[ 988613 ] compiler.transformer and tuple unpacking
2004-07-12 13:15:56 +00:00
Andrew MacIntyre 18bf43c4a4 FreeBSD's services file contains an additional echo service entry, with
a non-standard protocol and on a lower port than the tcp/udp entries,
which breaks the assumption that there will only be one service by a
given name on a given port when no protocol is specified.

Previous versions of this code have had other problems as a result of
different service definitions amongst common platforms.  As this platform
has an extra, unexpected, service entry, I've special cased the platform
rather than re-order the list of services checked to highlight the pitfall.
2004-07-12 12:10:30 +00:00
Kurt B. Kaiser 3f7cb5d9f5 Patch [ 972332 ] urllib2 FTPHandler bugs / John J. Lee
Modified Files:
	urllib2.py test/test_urllib2.py
2004-07-11 17:14:13 +00:00
Brett Cannon d2c5b4b549 SequenceMatcher(None, [], []).get_grouped_opcodes() now returns a generator
that behaves as if both lists has an empty string in each of them.

Closes bug #979794 (and duplicate bug #980117).
2004-07-10 23:54:07 +00:00
Brett Cannon bdc36273a2 Make ntpath compress multiple slashes between drive letter and the rest of the
path.  Also clarifies UNC handling and adds appropriate tests.

Applies patch #988607 to fix bug #980327.  Thanks Paul Moore.
2004-07-10 20:42:22 +00:00
Andrew M. Kuchling 85064ffd76 [Patch #988602] Move the urllib2 tests into the test framework 2004-07-10 19:46:40 +00:00
Raymond Hettinger bf4406971c Improve Context construction and representation:
* Rename "trap_enablers" to just "traps".
* Simplify names of "settraps" and "setflags" to just "traps" and "flags".
* Show "capitals" in the context representation
* Simplify the Context constructor to match its repr form so that only
  the set flags and traps need to be listed.
* Representation can now be run through eval().

Improve the error message when the Decimal constructor is given a float.

The test suite no longer needs a duplicate reset_flags method.
2004-07-10 14:14:37 +00:00
Marc-André Lemburg 3f41974525 Add generic codecs.encode() and .decode() APIs that don't impose
any restriction on the return type (like unicode.encode() et al. do).
2004-07-10 12:06:10 +00:00
Brett Cannon 64a8470246 Restructure testing of .pth files. Move previous functions into a class and
create a testing method that can be called to make sure that the handling of
the .pth file was correct.
2004-07-10 02:10:45 +00:00
Raymond Hettinger 5833587d14 Add some tests for corner cases. 2004-07-09 14:26:18 +00:00
Raymond Hettinger d87ac8f24d * Update the test suite to reflect that ConversionSyntax was no longer
public.
* Removed the non-signal conditions from __all__.
* Removed the XXX comment which was resolved.
* Use ^ instead of operator.xor
* Remove the threading lock which is no longer necessary.
2004-07-09 10:52:54 +00:00
Raymond Hettinger 5aa478badf Module and tests:
* Map conditions to related signals.
* Make contexts unhashable.
* Eliminate used "default" attribute in exception definitions.
* Eliminate the _filterfunc in favor of a straight list.

Docs:
* Eliminate documented references to conditions that are not signals.
* Eliminate parenthetical notes such as "1/0 --> Inf" which are no
  longer true with the new defaults.
2004-07-09 10:02:53 +00:00
Raymond Hettinger eae05de91b * fix the print test
* add more __init__ tests
2004-07-09 04:51:24 +00:00
Raymond Hettinger a435c53e13 * balance the left/right search for getitem.
* use assertions instead of tests after internal calls that can't fail.
* expand test coverage
2004-07-09 04:10:20 +00:00
Walter Dörwald 302fa6dc0d Add another bunch of test cases for calendars with Sunday as the
first day of the week.
2004-07-08 17:14:17 +00:00
Tim Peters 27f883687b Whitespace normalization. 2004-07-08 04:22:35 +00:00
Neal Norwitz 1c0423a2da Exercise xrange a bit 2004-07-08 01:59:55 +00:00
Neal Norwitz d7be118626 Exercise some error conditions 2004-07-08 01:56:46 +00:00
Neal Norwitz bdcb9410c2 SF bug #978308, Spurious errors taking bool of dead pro
Need to return -1 on error.

Needs backport.
2004-07-08 01:22:31 +00:00
Barry Warsaw 7ff7d2cb0b testGetServBy(): Use services that should be available both on *nix and
Windows (XP at least ;).  Test in this order: echo, daytime, domain.
2004-07-06 16:48:25 +00:00
Raymond Hettinger 513ffe8112 * Fix missing return after error message is set.
* Add a test case that would have caught it.
2004-07-06 13:44:41 +00:00
Raymond Hettinger 0aeac107ca * Add __eq__ and __ne__ so that things like list.index() work properly
for lists of mixed types.
* Test that sort works.
2004-07-05 22:53:03 +00:00
Raymond Hettinger 5548be2653 Test the logic for int(d). 2004-07-05 18:49:38 +00:00
Raymond Hettinger 6ea4845822 * Make the tests independent of the default precision.
* Change the default precision to 28 (to match VB's decimal type).
2004-07-03 12:26:21 +00:00
Raymond Hettinger d9c0a7ae94 Work through several open todos:
* Added test for pickling contexts
* Renamed ExceptionList to Signals (to match wording in the spec)
* Simplified Context constructor by allowing flags=None to automatically
  generate a zeroed-out flags dictionary.
* inlined _convertString() which was used only once
* _rounding_decision is private, so excluded its contants from __all__.
* added an XXX comment with concerns about subclassing signals results in
  a deviation from the spec (maybe important, maybe not).
* Taught the test_suite to determine its own directory (modeled after code
  in regrtest.py).  Enables it to be run when the current directory is not
  the test directory.
* Added a clear_flags() method to the Context API to make it easier to do
  a common operation with flags.
* Fixed the trap_enablers defaults in BasicDefaultContext to match the spec.
2004-07-03 10:02:28 +00:00
Walter Dörwald 59ad45689b Add tests that check the result of calendar.monthcalendar() for a set
of corner cases.
2004-07-02 19:00:09 +00:00
Fred Drake 0a4dd390bf Make weak references subclassable:
- weakref.ref and weakref.ReferenceType will become aliases for each
  other

- weakref.ref will be a modern, new-style class with proper __new__
  and __init__ methods

- weakref.WeakValueDictionary will have a lighter memory footprint,
  using a new weakref.ref subclass to associate the key with the
  value, allowing us to have only a single object of overhead for each
  dictionary entry (currently, there are 3 objects of overhead per
  entry: a weakref to the value, a weakref to the dictionary, and a
  function object used as a weakref callback; the weakref to the
  dictionary could be avoided without this change)

- a new macro, PyWeakref_CheckRefExact(), will be added

- PyWeakref_CheckRef() will check for subclasses of weakref.ref

This closes SF patch #983019.
2004-07-02 18:57:45 +00:00
Raymond Hettinger 214b1c3aae SF Bug #215126: Over restricted type checking on eval() function
The builtin eval() function now accepts any mapping for the locals argument.
Time sensitive steps guarded by PyDict_CheckExact() to keep from slowing
down the normal case.  My timings so no measurable impact.
2004-07-02 06:41:07 +00:00
Raymond Hettinger 75cc1cb7e0 Move Decimal from the sandbox into production. 2004-07-01 11:15:39 +00:00
Raymond Hettinger 7c85fa4a52 Move Decimal from the sandbox into production. 2004-07-01 11:01:35 +00:00
Andrew M. Kuchling 31352c5a30 Remove unused import. (If it's there for some deep, dark reason, it should have been commented.) 2004-06-29 13:17:29 +00:00
Andrew M. Kuchling bd3200fa2b Add test case for bug #912845: requesting an HTTP byte range doesn't work 2004-06-29 13:15:46 +00:00
Andrew M. Kuchling f1a2f9ec41 Docstring grammar fix 2004-06-29 13:07:53 +00:00
Raymond Hettinger 3b04ce824d Patch from Mark Hammond to fix a test error.
Now runs without exception on WinME/98.
2004-06-28 06:57:19 +00:00
Barry Warsaw 11b91a0ea3 Added socket.getservbyport(), and make its second argument and that of
getservbyname() optional.  Update the tests and the docs.
2004-06-28 00:50:43 +00:00
Raymond Hettinger ebd95222bf * Silence a test failure that resulted when test_site was run by
regrtest.py after it ran test_frozen.  This test was really only
  designed to be run immediately after startup.  Afterwards, other
  modules could be loaded when had not been fixed-up by site.py
  Took the chicken way out and only tested those modules known to
  be imported by site.py.

* Normalized whitespace.
2004-06-27 03:02:18 +00:00
Nicholas Bastin d858a7763a Massive performance improvement for C extension and builtin tracing code 2004-06-25 23:31:06 +00:00
Tim Peters 1b6f7a9057 Bug 975996: Add _PyTime_DoubleToTimet to C API
New include file timefuncs.h exports private API function
_PyTime_DoubleToTimet() from timemodule.c.  timemodule should export
some other functions too (look for painful bits in datetimemodule.c).

Added insane-argument checking to datetime's assorted fromtimestamp()
and utcfromtimestamp() methods.  Added insane-argument tests of these
to test_datetime, and insane-argument tests for ctime(), localtime()
and gmtime() to test_time.
2004-06-20 02:50:16 +00:00
Brett Cannon 1c3fa18be7 shutil.move() will raise an exception when trying to move a directory into
itself.

Closes bug #919012  .  Thanks Johannes Gijsbers.
2004-06-19 21:11:35 +00:00
Raymond Hettinger aefde435ef Reverse argument order for nsmallest() and nlargest().
Reads better when the iterable is a generator expression.
2004-06-15 23:53:35 +00:00
Fred Drake bb7c14461d One unit test for distutils is not much, but is more than we had yesterday.
We need to write more; hopefully the barrier is a little lower now.
2004-06-15 15:49:46 +00:00
Raymond Hettinger b67ad7e671 Patch #826074: cmath.log optional base argument, fixes #823209
(Contributed by Andrew Gaul.)
2004-06-14 07:40:10 +00:00
Raymond Hettinger 59efe363b6 Add heapq to list of __all__ checks. 2004-06-13 05:46:14 +00:00
Raymond Hettinger 2e3dfaf707 Install C version of heapq.nsmallest(). 2004-06-13 05:26:33 +00:00
Michael W. Hudson 84a7f0077c note a really bad test (no time to fix now) 2004-06-12 16:30:32 +00:00
Raymond Hettinger b25aa36f83 Improve the memory performance and speed of heapq.nsmallest() by using
an alternate algorithm when the number of selected items is small
relative to the full iterable.
2004-06-12 08:33:36 +00:00
Michael W. Hudson 5c26e86096 lightly modified version of my patch
[ 971323 ] make test_signal less annoying
after some comments on IRC from a highly opinionated australian who
wishes to remain anonymous.
2004-06-11 18:09:28 +00:00
Anthony Baxter 01e80b45d6 fix a poorly worded error message 2004-06-11 15:57:49 +00:00
Raymond Hettinger bce036b49e Convert test_heapq.py to unittests. 2004-06-10 05:07:18 +00:00
Raymond Hettinger 33ecffb65a SF patch #969791: Add nlargest() and nsmallest() to heapq. 2004-06-10 05:03:17 +00:00
Tim Peters 4182cfd7db test_devnull(): Use assertEqual() instead of an assert stmt. 2004-06-08 20:34:34 +00:00
Brett Cannon 6ccc9a99df Removed test_sitepackages test. Skip discovered that it only passed if Python
had already been installed previously.
2004-06-08 18:25:48 +00:00
Martin v. Löwis bdec50f027 Feature request #935915: Add os.path.devnull. 2004-06-08 08:29:33 +00:00
Tim Peters 604c013ef2 SF 952807: Unpickling pickled instances of subclasses of datetime.date,
datetime.datetime and datetime.time could yield insane objects.  Thanks
to Jiwon Seo for the fix.

Bugfix candidate.  I'll backport it to 2.3.
2004-06-07 23:04:33 +00:00
Neal Norwitz c28e7ad3d0 Try to improve test coverage for utime() 2004-06-06 20:27:05 +00:00
Neal Norwitz 7b0a5057af Look for the multibyte codec map files in the parent directory too
This is similar to test_normalization, so that many source trees
can reference the same test file(s).
2004-06-06 20:09:49 +00:00
Skip Montanaro 0179a18034 add -L flag to cause leaks(1) command to run just before exit 2004-06-06 15:53:18 +00:00
Neil Schemenauer 6412b121f6 Remove a number of tests that differ only in input data size. It seems
no bug motivated their inclusion and the chance of them triggering a
problem seems unlikely.  Refactor to reduce code duplication.  Rename
'hamlet_scene' to 'HAMLET_SCENE'.  Test is much faster now.  Closes #960995.
2004-06-05 19:34:28 +00:00
Neil Schemenauer 94afd3e7ae Remove lots of magic constants. 2004-06-05 19:02:52 +00:00
Skip Montanaro 58fc5d0813 Rewrote to use temporary files instead of StringIO objects in most places.
Goal is to work in the direction of universal newline support.
2004-06-05 17:03:20 +00:00
Andrew M. Kuchling b7d8ce0275 [Bug #921657] Allow '@' in unquoted HTML attributes. Not strictly legal according to the HTML REC, but HTMLParser is already a pretty loose parser. Reported by Bernd Zimmermann. 2004-06-05 15:31:45 +00:00
Andrew M. Kuchling ba8b6bc86f [Bug #954364] inspect.getframeinfo() sometimes produces incorrect traceback line #s; fix is to look at tb.tb_lineno, not tb.frame.f_lineno. Patch from Robin Becker and me. 2004-06-05 14:11:59 +00:00
Hye-Shik Chang 39aef79821 Fix a bug that robotparser starves memory when the server responses
in HTTP/0.9 due to dissonance of httplib.LineAndFileWrapper and
urllib.addbase.
2004-06-05 13:30:56 +00:00
Andrew M. Kuchling b12d97c275 [Bug #841757] Exercise handling of Unicode strings 2004-06-05 12:33:27 +00:00
Brett Cannon 0096e262ff Refactored site.py into functions. Also moved over to using sets.
New regression test suite.
2004-06-05 01:12:51 +00:00
Hye-Shik Chang 3c145449da Reuse width/iswide tests from strings_test. (Suggested by Walter Dörwald) 2004-06-04 04:24:54 +00:00
Hye-Shik Chang 7bd860655f Fix typo. 2004-06-04 03:19:17 +00:00
Hye-Shik Chang 5f5125997b Add iswide() and width() method for UserString according as the
addition to unicode objects.
2004-06-04 03:18:12 +00:00
Greg Ward 6186410db0 SF #965425: fix so hyphenated words surrounded by punctuation are
wrapped correctly.
2004-06-03 01:59:41 +00:00
Walter Dörwald 118f931d07 Rename class attribute containing the class to be tested, so the name is the
same as for the string and sequence tests.
2004-06-02 18:42:25 +00:00
Andrew M. Kuchling 4ad9723ed8 Remove pre module 2004-06-02 17:40:14 +00:00
Hye-Shik Chang 974ed7cfa5 - SF #962502: Add two more methods for unicode type; width() and
iswide() for east asian width manipulation. (Inspired by David
Goodger, Reviewed by Martin v. Loewis)
- Move _PyUnicode_TypeRecord.flags to the end of the struct so that
no padding is added for UCS-4 builds. (Suggested by Martin v. Loewis)
2004-06-02 16:49:17 +00:00
Vinay Sajip 7dc8ec9091 Copyright year changed 2004-06-02 10:51:05 +00:00
Tim Peters 1f4bcf9edd test_hash(): The test here is different enough from the one in the bug
report that the stats for expected # of collisions are a little higher.
Updated comments accordingly.
2004-06-01 18:58:04 +00:00
Andrew M. Kuchling 09e2cb0ba7 [Bug #962631] Fix typo reported by Bryan Blackburn 2004-06-01 12:48:19 +00:00
Raymond Hettinger 41bd02256f SF bug #942952: Weakness in tuple hash
(Basic approach and test concept by Tim Peters.)

* Improved the hash to reduce collisions.
* Added the torture test to the test suite.
2004-06-01 06:36:24 +00:00
Martin v. Löwis 2a6ba9097e Patch #963318: Add support for client-side cookie management. 2004-05-31 18:22:40 +00:00
Walter Dörwald 0a6d0ff8d9 Port the dictionary tests from test_types.py to unittest. Collect as much
mapping tests as possible in mapping_test.py and reuse the tests in
test_dict.py, test_userdict.py, test_weakref.py, test_os.py and test_shelve.py.
From SF patch #736962.
2004-05-31 16:29:04 +00:00
Raymond Hettinger 027bb633b6 Add weakref support to sockets and re pattern objects. 2004-05-31 03:09:25 +00:00
Raymond Hettinger cb87bc8e7e Add weakref support to array.array and file objects. 2004-05-31 00:35:52 +00:00
Raymond Hettinger 691d80532b Make sets and deques weak referencable. 2004-05-30 07:26:47 +00:00
Raymond Hettinger 1453e4aa75 * teach repr.repr() about collections.deque()
* rename a variable for clarity
2004-05-21 23:01:18 +00:00
Raymond Hettinger ba6cd3647f * Updated repr.py to handle set() and frozenset().
* Factored out common code to a single private function.
* Use str.join() instead of + concatenation
* Loop over elements directly instead of using indexing
* Use % operator for formatting
2004-05-21 10:00:15 +00:00
Raymond Hettinger 83ee79524a Add a test to verify an early call to iter() on the outermost for
expression.
2004-05-20 23:04:13 +00:00
Raymond Hettinger 354433a59d SF patch #872326: Generator expression implementation
(Code contributed by Jiwon Seo.)

The documentation portion of the patch is being re-worked and will be
checked-in soon.  Likewise, PEP 289 will be updated to reflect Guido's
rationale for the design decisions on binding behavior (as described in
in his patch comments and in discussions on python-dev).

The test file, test_genexps.py, is written in doctest format and is
meant to exercise all aspects of the the patch.  Further additions are
welcome from everyone.  Please stress test this new feature as much as
possible before the alpha release.
2004-05-19 08:20:33 +00:00
Fred Drake 82903148a8 ConfigParser:
- read() method returns a list of files parsed successfully
- add tests, documentation
(closes SF patch #677651)
2004-05-18 04:24:02 +00:00
Fred Drake abc086fb0d ConfigParser:
- don't allow setting options to non-string values; raise TypeError
  when the value is set, instead of raising an arbitrary exception
  later (such as when string interpolation is performed)
- add tests, documentation
(closes SF bug #810843)
2004-05-18 03:29:52 +00:00
Fred Drake bc12b01d83 ConfigParser:
- ensure that option names in interpolations are handled by
  self.optionxform in the same way that other references to option
  names
- add tests, documentation
(closes SF bug #857881, patch #865455)
2004-05-18 02:25:51 +00:00
Tim Peters ad9a7c4489 test_alias_nofallback(): Someone broke this test, after 2.3, by
converting it into assertRaises() form.  Restored the 2.3 code, and
explained why assertRaises() cannot be used instead.
2004-05-16 05:36:30 +00:00
Greg Ward f0ba764dbb SF #847346: merge from release23-maint branch: remove misguided
optimization for short input; beef up tests for fix_sentence_endings
feature.
2004-05-13 01:53:10 +00:00
Raymond Hettinger 0e371f2cb6 Make sure "del d[n]" is properly supported. Was necessary because the
same method that implements __setitem__ also implements __delitem__.
Also, there were several good use cases (removing items from a queue
and implementing Forth style stack ops).
2004-05-12 20:55:56 +00:00
Raymond Hettinger 300fa1d3b2 Temporarily disable doctest until genexps are in CVS 2004-05-10 14:08:42 +00:00
Raymond Hettinger e7169eb9ed Add more examples. 2004-05-09 01:15:01 +00:00
Raymond Hettinger 9d7c870c6d SF #950057: itertools.chain doesn't "process" exceptions as they occur
Both cycle() and chain() were handling exceptions only when switching
input sources.  The patch makes the handle more immediate.

Will backport.
2004-05-08 19:49:42 +00:00
Martin v. Löwis 7d9c6c7e8c Fix _sre.CODESIZE on 64-bit machines in UCS-4 mode. Fixes #931848.
Backported to 2.3.
2004-05-07 07:18:13 +00:00
Martin v. Löwis 9f1340b9f2 Do not use the default namespace for attributes.
Fixes http://bugs.debian.org/229885
Will backport to 2.3.
2004-05-02 20:37:13 +00:00
Walter Dörwald c60c203670 Add a test script for the colorsys module. 2004-04-28 17:07:50 +00:00
Hye-Shik Chang 9f62eccb66 SF #926075: Fixed the bug that returns a wrong pattern object for
a string or unicode object in sre.compile() when a different type
pattern with the same value exists.
2004-04-20 21:30:07 +00:00
Martin v. Löwis 61e40bd897 Special case normalization of empty strings. Fixes #924361.
Backported to 2.3.
2004-04-17 19:36:48 +00:00
Raymond Hettinger 7892b1c651 * Add unittests for iterators that report their length
* Document the differences between them
* Fix corner cases covered by the unittests
* Use Py_RETURN_NONE where possible for dictionaries
2004-04-12 18:10:01 +00:00
Andrew MacIntyre daedf21852 Fixes for AF_UNIX support on OS/2:
- return the full size of the sockaddr_un structure, without which
  bind() fails with EINVAL;
- set test_socketserver to use a socket name that meets the form
  required by the underlying implementation;
- don't bother exercising the forking AF_UNIX tests on EMX - its
  fork() can't handle the stress.
2004-04-11 12:03:57 +00:00
Andrew MacIntyre 4e10ed3b86 If a file is opened with an explicit buffer size >= 1, repeated
close() calls would attempt to free() the buffer already free()ed on
the first close().     [bug introduced with patch #788249]

Making sure that the buffer is free()ed in file object deallocation is
a belt-n-braces bit of insurance against a memory leak.
2004-04-04 07:01:35 +00:00
Fred Drake 456d3258d6 Fix support for the "prog" keyword to the OptionParser constructor, as well
as directly setting the .prog attribute (which should be supported based on
the class docstring).
Closes SF bug #850964.
2004-04-01 07:40:35 +00:00
Guido van Rossum 59db96f2a3 When /tmp has certain sticky bits set, newly created subdirectories
inherit those bits, causing the test_mkdtemp.test_mode() test to fail.
Remove those before comparing the actual mode to the expected mode.
2004-03-31 18:53:29 +00:00
Tim Peters 116d83ce71 SF bug 924242: socket._fileobject._getclosed() returns wrong value
The .closed property always returned the wrong result.

Bugfix candidate!
2004-03-28 02:20:45 +00:00
David Ascher 1c5701d36c Fix test failure for test_tcl on OS/X and Windows if a
version of Tcl other than ActiveTcl is installed (ActiveTcl
included TclX, other Tcl distros didn't).

I'm removing the package loading test because it's hard to
come up with a package that is guaranteed to be in any Tcl installation.

Special-casing darwin and windows is ok since that leaves the
only Tk platform (X) which the test was trying to address.
2004-03-26 15:10:25 +00:00
Armin Rigo 01ab279056 Marshal clean-up (SF patch #873224) 2004-03-26 15:09:27 +00:00
Phillip J. Eby 91a968af76 Ensure super() lookup of descriptor from classmethod works (SF #743627) 2004-03-25 02:19:34 +00:00
Nicholas Bastin c69ebe8d50 Enable the profiling of C functions (builtins and extensions) 2004-03-24 21:57:10 +00:00
Martin v. Löwis a1dde13389 Add test case for unicode(somestring, "idna"). 2004-03-24 16:48:24 +00:00
Nicholas Bastin 1eb4bfc657 Added global runctx function to profile to fix SF Bug #716587 2004-03-22 20:12:56 +00:00
Armin Rigo 706933821c The fix in ceval.c 2.386 allows iteration-by-iteration line tracing even in
single-line loops.
2004-03-22 19:30:39 +00:00
Nicholas Bastin ee6c9b8613 Fix (really) for tight loop line events 2004-03-22 19:23:46 +00:00
Nicholas Bastin fa7bec7e83 Test for tight loop line event fix, SF bug #765624 2004-03-22 19:21:47 +00:00
Nicholas Bastin aea9459cb1 Test for lack of implicit return line event 2004-03-22 18:30:42 +00:00
Tim Peters 3f60629242 SF bug 847019 datetime.datetime initialization needs more strict checking
It's possible to create insane datetime objects by using the constructor
"backdoor" inserted for fast unpickling.  Doing extensive range checking
would eliminate the backdoor's purpose (speed), but at least a little
checking can stop honest mistakes.

Bugfix candidate.
2004-03-21 23:38:41 +00:00
Nicholas Bastin 668034173b Normalized files in test_unicode_file to eliminate failure on OSX 2004-03-21 20:55:47 +00:00
Brett Cannon c82208eecb Deal with case of when locale time values has characters that can be mistaken
for regex syntax.
Fixes bug #883604 .
2004-03-20 23:09:40 +00:00
Brett Cannon 4f65331483 Limit the nesting depth of a tuple passed as the second argument to
isinstance() or issubclass() to the recursion limit of the interpreter.
2004-03-20 22:52:14 +00:00
Fred Drake 6fd0b0d5ba commit the portion of PyXML patch #919008 that is relevant to the
standard library:
str() of xml.sax.SAXParseException should not fail if the line and/or
column number returned by the locator are None
(tests added)
2004-03-20 08:15:30 +00:00
Walter Dörwald cd1e8a9485 Port test_binascii.py to PyUnit and enhance tests.
Code coverage for binascii.c is at 92%.
From SF patch #736962.
2004-03-15 12:07:38 +00:00
Raymond Hettinger 49f9bd15ff SF feature request #686323: Minor array module enhancements
array.extend() now accepts iterable arguments implements as a series
of appends.  Besides being a user convenience and matching the behavior
for lists, this the saves memory and cycles that would be used to
create a temporary array object.
2004-03-14 05:43:59 +00:00
Raymond Hettinger 3aa82c07f7 SF bug #910986: copy.copy fails for array.array
Added support for the copy module.
2004-03-13 18:18:51 +00:00
Neil Schemenauer 6cbba50a43 Make test_coercion.py less sensitive to platform fp quirks. Closes
SF bug #678265.
2004-03-10 17:30:03 +00:00
Raymond Hettinger ef9bf4031a Tidied up the implementations of reversed (including the custom ones
for xrange and list objects).

* list.__reversed__ now checks the length of the sequence object before
  calling PyList_GET_ITEM() because the mutable could have changed length.

* all three implementations are now tranparent with respect to length and
  maintain the invariant len(it) == len(list(it)) even when the underlying
  sequence mutates.

* __builtin__.reversed() now frees the underlying sequence as soon
  as the iterator is exhausted.

* the code paths were rearranged so that the most common paths
  do not require a jump.
2004-03-10 10:10:42 +00:00
Raymond Hettinger d2c36261a2 Eliminate the double reverse option. It's only use case
was academic and it was potentially confusing to use.
2004-03-10 08:32:47 +00:00
Raymond Hettinger 31017aed36 SF #904720: dict.update should take a 2-tuple sequence like dict.__init_
(Championed by Bob Ippolito.)

The update() method for mappings now accepts all the same argument forms
as the dict() constructor.  This includes item lists and/or keyword
arguments.
2004-03-04 08:25:44 +00:00
Brett Cannon d1080a3418 Have strftime() check its time tuple argument to make sure the tuple's values
are within proper boundaries as specified in the docs.

This can break possible code (datetime module needed changing, for instance)
that uses 0 for values that need to be greater 1 or greater (month, day, and
day of year).

Fixes bug #897625.
2004-03-02 04:38:10 +00:00
Raymond Hettinger 0a4977c2f3 Replace left(), right(), and __reversed__() with the more general purpose
__getitem__() and __setitem__().

Simplifies the API, reduces the code size, adds flexibility, and makes
deques work with bisect.bisect(), random.shuffle(), and random.sample().
2004-03-01 23:16:22 +00:00
Neal Norwitz 9a8d55e4a1 Cleanup: remove test file after it is used. 2004-02-29 15:37:50 +00:00
Raymond Hettinger 738ec90ca1 Improvements to collections.deque():
* Add doctests for the examples in the library reference.
* Add two methods, left() and right(), modeled after deques in C++ STL.
* Apply the new method to asynchat.py.
* Add comparison operators to make deques more substitutable for lists.
* Replace the LookupErrors with IndexErrors to more closely match lists.
2004-02-29 02:15:56 +00:00
Jeremy Hylton b3ee6f9921 Fix two bugs in the new do_open() implementation for HTTPHandler.
Invoke the standard error handlers for non-200 responses.

Always supply a "Connection: close" header to prevent the server from
leaving the connection open.  Downstream users of the socket may
attempt recv()/read() with no arguments, which would block if the
connection were kept open.
2004-02-24 19:40:35 +00:00
Samuele Pedroni 8036c83630 adding passing test. testing for g(*Nothing()) where Nothing is a user-defined iterator. 2004-02-21 21:03:30 +00:00
Vinay Sajip bb99058898 Socket handler closed prior to end of test. 2004-02-20 13:19:16 +00:00
Neal Norwitz 63dfece675 Get test to work when run from regrtest (add test_main), remove all CRs (^M)s 2004-02-19 02:37:29 +00:00
David Ascher e2b4b32025 Implementation of patch 869468
Allow the user to create Tkinter.Tcl objects which are
just like Tkinter.Tk objects except that they do not
initialize Tk. This is useful in circumstances where the
script is being run on machines that do not have an X
server running -- in those cases, Tk initialization fails,
even if no window is ever created.

Includes documentation change and tests.

Tested on Linux, Solaris and Windows.

Reviewed by Martin von Loewis.
2004-02-18 05:59:53 +00:00
Fred Drake 55cf434735 further testing indicates that the simplified version of the test
(re-using an existing test object class) no longer triggered the
original segfault when the fix was backed out; restoring the local
test object class to make the test effective

the assignment of the ref created at the end does not affect the test,
since the segfault happended before weakref.ref() returned; removing
the assignment
2004-02-13 19:21:57 +00:00
Fred Drake 61dafcb6ca use existing test object instead of defining a new class 2004-02-12 19:30:17 +00:00
Walter Dörwald 70a6b49821 Replace backticks with repr() or "%r"
From SF patch #852334.
2004-02-12 17:35:32 +00:00
Skip Montanaro 05eb40128e Fix indentation error in testGetServByName and rewrite loop to avoid clumsy
sentinel variable
2004-02-10 15:51:15 +00:00
Raymond Hettinger 029dba5a40 Make reversed() transparent with respect to length. 2004-02-10 09:33:39 +00:00
Raymond Hettinger 5cab2e3a88 Give itertools.repeat() a length method. 2004-02-10 09:25:40 +00:00
Raymond Hettinger 06353f76be Let reversed() work with itself. 2004-02-08 10:49:42 +00:00
Raymond Hettinger ee33b27ef0 Make deque.rotate() smarter. Beef-up related tests. 2004-02-08 04:05:26 +00:00
Barry Warsaw 3b6d025d9b Patch #868499, adds -T option for code coverage. The implementation is a
fairly simpleminded adaptation of Zope3's test.py -T flag.

I also changed some booleans to use True/False where appropriate.
2004-02-07 22:43:03 +00:00
Raymond Hettinger 5c5eb86347 * Incorporate Skip's suggestions for documentation (explain the word deque
comes from and show the differences from lists).
* Add a rotate() method.
2004-02-07 21:13:00 +00:00
Raymond Hettinger c058fd14a9 * Fix ref counting in extend() and extendleft().
* Let deques support reversed().
2004-02-07 02:45:22 +00:00
Raymond Hettinger 3ba85c2e8a Have deques support high volume loads. 2004-02-06 19:04:56 +00:00
Walter Dörwald 7dcf9f89d3 Fix test failure message (from SF patch #885008) 2004-02-06 18:30:31 +00:00
Walter Dörwald cd736e71a3 Fix reallocation bug in unicode.translate(): The code was comparing
characters instead of character pointers to determine space requirements.
2004-02-05 17:36:00 +00:00
Fred Drake bc875f5a36 Allocating a new weakref object can cause existing weakref objects for
the same object to be collected by the cyclic GC support if they are
only referenced by a cycle.  If the weakref being collected was one of
the weakrefs without callbacks, some local variables for the
constructor became invalid and have to be re-computed.

The test caused a segfault under a debug build without the fix applied.
2004-02-04 23:14:14 +00:00
Fred Drake ea2adc9c80 - add tests that exercise fixes for the PyWeakref_NewRef() and
PyWeakref_NewProxy() constructors from the C API
- elaborate the getweakrefcount() and getweakrefs() tests slightly
2004-02-03 19:56:46 +00:00
Hye-Shik Chang ff83c2bacc Fix input() builtin function to respect compiler flags.
(SF patch 876178, patch by mwh, unittest by perky)
2004-02-02 13:39:01 +00:00
Raymond Hettinger 756b3f3c15 * Move collections.deque() in from the sandbox
* Add unittests, newsitem, and whatsnew
* Apply to Queue.py mutex.py threading.py pydoc.py and shlex.py
* Docs are forthcoming
2004-01-29 06:37:52 +00:00
Raymond Hettinger 734fb5724f Add a Guido inspired example for groupby(). 2004-01-20 20:04:40 +00:00
Hye-Shik Chang a5e719e081 Test not the standard utf-8 codec but gb18030 which is the most complex
codec in multibytecodec consumers.
2004-01-20 09:11:48 +00:00
Tim Peters 1301892715 For whatever reason, these files had \r\r\n line endings on Windows,
meaning they must have been checked in to CVS from a Linuxish box with
Windowish \r\n line endings to begin with.
2004-01-18 21:03:23 +00:00
Tim Peters 58eb11cf62 Whitespace normalization. 2004-01-18 20:29:55 +00:00
Hye-Shik Chang 3e2a306920 Add CJK codecs support as discussed on python-dev. (SF #873597)
Several style fixes are suggested by Martin v. Loewis and
Marc-Andre Lemburg. Thanks!
2004-01-17 14:29:29 +00:00
Raymond Hettinger 0c4102760c SF Patch #864863: Bisect C implementation
(Contributed by Dmitry Vasiliev.)
2004-01-05 10:13:35 +00:00