Commit Graph

1689 Commits

Author SHA1 Message Date
Walter Dörwald 068325ef92 Apply the second version of SF patch http://www.python.org/sf/536241
Add a method zfill to str, unicode and UserString and change
Lib/string.py accordingly.

This activates the zfill version in unicodeobject.c that was
commented out and implements the same in stringobject.c. It also
adds the test for unicode support in Lib/string.py back in and
uses repr() instead() of str() (as it was before Lib/string.py 1.62)
2002-04-15 13:36:47 +00:00
Guido van Rossum b6b8942f53 SF bug #541883 (Vincent Fiack).
A stupid bug in object_set_class(): didn't check for value==NULL
before checking its type.

Bugfix candidate.
2002-04-15 01:03:30 +00:00
Tim Peters 077f27141f SF bug 543840: complex(string) accepts strings with \0
complex_subtype_from_string():  this stopped parsing at the first 0
byte, as if that were the end of the input string.

Bugfix candidate.
2002-04-14 22:04:03 +00:00
Jack Jansen 518d261f63 Test suite for universal newline support. 2002-04-14 20:17:18 +00:00
Martin v. Löwis 2f6d4da278 Patch #542569: tp_print tp_repr tp_str in test_bool.py. 2002-04-14 10:22:29 +00:00
Guido van Rossum 018b0eb0f5 Partially implement SF feature request 444708.
Add optional arg to string methods strip(), lstrip(), rstrip().
The optional arg specifies characters to delete.

Also for UserString.

Still to do:

- Misc/NEWS
- LaTeX docs (I did the docstrings though)
- Unicode methods, and Unicode support in the string methods.
2002-04-13 00:56:08 +00:00
Guido van Rossum d854f3b3cc I am mad. This test never worked!
The test function's signature should be

    test(methodname, input, output, *args)

but the output argument was omitted.  This caused all tests to fail,
because the expected output was passed as the initial argument to the
method call.  But because of the way the test works (it compares the
results for a regular string to the results for a UserString instance
with the same value, and it's OK if both raise the same exception) the
test never failed!

I've fixed this, and also cleaned up a few warts in the verbose
output.  Finally, I've made it possible to run the test stand-alone in
verbose mode by passing -v as a command line argument.

Now, the test will report failure related to zfill.  That's not my
fault, that's a legitimate problem: the string_tests.py file contains
a test for the zfill() method (just added) but this method is not
implemented.  The responsible party will surely fix this soon now.
2002-04-12 16:25:39 +00:00
Guido van Rossum e027d9818f Add Raymond Hettinger's d.pop(). See SF patch 539949. 2002-04-12 15:11:59 +00:00
Fred Drake 04a8da5cdb Clean up the "all" support for -u. 2002-04-11 20:58:54 +00:00
Tim Peters a7c2b303d4 Since xmllib is deprecated now, suppress the DeprecationWarning its test
module necessarily raises.
2002-04-11 20:18:40 +00:00
Tim Peters b05cd496df Ignore more deprecation warnings. 2002-04-11 20:04:12 +00:00
Tim Peters 3c14efe696 Stop sucking up xmllib -- it's deprecated. 2002-04-11 19:54:11 +00:00
Tim Peters deb121aec7 I don't expect test_email_codecs to run on Windows. 2002-04-11 19:52:58 +00:00
Fred Drake 3a15dace36 Added the resource name "all" to enable all of the optional resource uses.
This is nice for use with "make TESTOPTS='-u all' test".
2002-04-11 16:39:16 +00:00
Fred Drake 43735da1bf Improve coverage of Objects/weakrefobject.c. 2002-04-11 03:59:42 +00:00
Barry Warsaw 409a4c08b5 Sync'ing with standalone email package 2.0.1. This adds support for
non-us-ascii character sets in headers and bodies.  Some API changes
(with DeprecationWarnings for the old APIs).  Better RFC-compliant
implementations of base64 and quoted-printable.

Updated test cases.  Documentation updates to follow (after I finish
writing them ;).
2002-04-10 21:01:31 +00:00
Marc-André Lemburg ce0b664af2 Added test case for UTF-8 encoding bug #541828. 2002-04-10 17:18:02 +00:00
Andrew M. Kuchling a9745611de Use random instead of whrandom 2002-04-10 14:54:39 +00:00
Guido van Rossum 8ace1ab53a - Changed new-style class instantiation so that when C's __new__
method returns something that's not a C instance, its __init__ is
  not called.  [SF bug #537450]
2002-04-06 01:05:01 +00:00
Guido van Rossum d1bfe5e5fd Add tests for binary pickles. 2002-04-05 20:57:02 +00:00
Guido van Rossum e276339cea Implement an idea by Paul Rubin:
Change pickling format for bools to use a backwards compatible
encoding.  This means you can pickle True or False on Python 2.3
and Python 2.2 or before will read it back as 1 or 0.  The code
used for pickling bools before would create pickles that could
not be read in previous Python versions.
2002-04-05 19:30:08 +00:00
Guido van Rossum 065fa4142a Add test case for SF bug 534347. 2002-04-04 16:27:04 +00:00
Guido van Rossum 5f8203679d Oops. Here are the new files. My apologies. 2002-04-03 23:01:45 +00:00
Guido van Rossum 77f6a65eb0 Add the 'bool' type and its values 'False' and 'True', as described in
PEP 285.  Everything described in the PEP is here, and there is even
some documentation.  I had to fix 12 unit tests; all but one of these
were printing Boolean outcomes that changed from 0/1 to False/True.
(The exception is test_unicode.py, which did a type(x) == type(y)
style comparison.  I could've fixed that with a single line using
issubtype(x, type(y)), but instead chose to be explicit about those
places where a bool is expected.

Still to do: perhaps more documentation; change standard library
modules to return False/True from predicates.
2002-04-03 22:41:51 +00:00
Mark Hammond e7fefbf68d Fix bugs:
457466: popenx() argument mangling hangs python
 226766: popen('python -c"...."') tends to hang

Fixes argument quoting in w9xpopen.exe for Windows 9x.  w9xpopen.exe
also never attempts to display a MessageBox when not executed
interactively.

Added test_popen() test.  This test currently just executes
"python -c ..." as a child process, and checks that the expected
arguments were all recieved correctly by the child process.  This
test succeeds for me on Win9x, win2k and Linux, and I hope it does
for other popen supported platforms too :)
2002-04-03 01:47:00 +00:00
Guido van Rossum 155db9aa22 SF patch 537536 by Phillip J. Eby, fix for SF bug 535444, super()
broken w/ classmethods.

Bugfix candidate.
2002-04-02 17:53:47 +00:00
Fred Drake aee113d368 Add an experimental mechanism to support extending the pprint formatting.
Partly responds to SF bug #505152.
2002-04-02 05:08:35 +00:00
Fred Drake 4993c51b94 Make test_commands work on more systems. This removes much of the dependency
on how a system is configured.
This closes SF bug #497160 (which has the patch) and #460613.

Bugfix candidate.
2002-04-01 23:56:03 +00:00
Neal Norwitz 05c09d08f9 Format strings (tuples,) appropriately 2002-04-01 19:01:39 +00:00
Neal Norwitz 28bb572ab4 Use attributes appropriately 2002-04-01 19:00:50 +00:00
Neal Norwitz b1295da59e There is no TestError, use TestFailed appropriately 2002-04-01 18:59:20 +00:00
Tim Peters de14a30d1d We expect to skip the new test_mpz on Windows. 2002-04-01 05:04:46 +00:00
Neal Norwitz 02098fa56b Get rid of all METH_OLDARGS & PyArg_Parse.
Fix floating point exception if mpz.powm(10, 1, 0) (modulus == 0).
Add a test.
2002-04-01 01:37:14 +00:00
Tim Peters 496563a514 Remove some now-obsolete generator future statements.
I left the email pkg alone; I'm not sure how Barry would like to handle
that.
2002-04-01 00:28:59 +00:00
Neal Norwitz 62f5a9d6c2 Convert file.readinto() to stop using METH_OLDARGS & PyArg_Parse.
Add test for file.readinto().
2002-04-01 00:09:00 +00:00
Andrew M. Kuchling eddd68d56c As part of fixing bug #536241, add a test case for string.zfill() with Unicode 2002-03-29 16:21:44 +00:00
Andrew M. Kuchling c6c9c4a10f Add two tests for string.zfill 2002-03-29 16:00:13 +00:00
Tim Peters d4ce758505 test_trashcan: reword obscure code.
Bugfix candidate.
2002-03-28 21:22:25 +00:00
Tim Peters d222559cdb New test_traschcan() test in test_gc, which reliably provokes segfaults
under 2.0, 2.1 and 2.2.

Bugfix candidate.
2002-03-28 21:08:30 +00:00
Fred Drake f841aa6fc0 Add a simple test of the METH_CLASS and METH_STATIC flags for type methods. 2002-03-28 15:49:54 +00:00
Walter Dörwald dbd2d2560c Add tests for the iterkeys, itervalues and iteritems
methods in dict-proxy objects.
2002-03-25 18:36:32 +00:00
Tim Peters 8e5fd53be0 SF bug 480215: softspace confused in nested print
This fixes the symptom, but PRINT_ITEM has no way to know what (if
anything) PyFile_WriteObject() writes unless the object being printed
is a string.  When the object isn't a string, this fix retains the
guess that softspace should be set after PyFile_WriteObject().
We might want to say that it's the job of filelike-object write methods
to leave the file's softspace in the correct state.  That would probably
be better -- but everyone relies on PRINT_ITEM to guess for them now.
2002-03-24 19:25:00 +00:00
Skip Montanaro 74e77e89de add test for InvalidURL 2002-03-24 16:54:38 +00:00
Skip Montanaro 03ff86da25 add test of InvalidURL 2002-03-24 16:54:16 +00:00
Neil Schemenauer eff724490f Add more tests for built-in types. Add tests for buffer objects.
Closes SF patch 494871.
2002-03-24 01:24:54 +00:00
Skip Montanaro 6ec967d066 added RFC 2396 tests from Aaron Swartz included in bug # 450225.
converted to use unittest
2002-03-23 05:32:10 +00:00
Skip Montanaro b1ba6b0044 no longer needed - converted test_urlparse.py to use unittest 2002-03-23 05:29:59 +00:00
Tim Peters 0c2c8e77fb SF bug 533234: tm_isdst > 1 Passed to strftime.
One more time on this turkey, but duller instead of cleverer.

Curious:  The docs say __getslice__ has been deprecated since 2.0, but
list.__getitem__ still doesn't work if you pass it a slice.  This makes
it a lot clearer to emulate a list by *being* a list <wink>.

Bugfix candidate.  Michael, just pile this patch on top of the others
that went by -- no need to try to pick these apart.
2002-03-23 03:26:53 +00:00
Andrew M. Kuchling 76fffd81e9 Add a simple test suite for netrc.py, and remove it from test_sundry 2002-03-22 02:48:57 +00:00
Martin v. Löwis 047c05ebc4 Do not insert characters for unicode-escape decoders if the error mode
is "ignore". Fixes #529104.
2002-03-21 08:55:28 +00:00
Michael W. Hudson bd3e771a97 amk's fix attached to
[ 516299 ] urlparse can get fragments wrong
2002-03-18 13:06:00 +00:00
Guido van Rossum 7e30548285 Fix for SF bug 528132 (Armin Rigo): classmethod().__get__() segfault
The proper fix is not quite what was submitted; it's really better to
take the class of the object passed rather than calling PyMethod_New
with NULL pointer args, because that can then cause other core dumps
later.

I also added a testcase for the fix to classmethods() in test_descr.py.

I've already applied this to the 2.2 branch.
2002-03-18 03:09:06 +00:00
Skip Montanaro 4894a97e22 initial test_anydbm module - based on test_dumbdbm.py 2002-03-18 03:00:37 +00:00
Skip Montanaro c08fe82b32 restructure a bit to not rely on test case execution ordering
add test case for bug #482460
2002-03-17 23:03:42 +00:00
Jack Jansen e89f128a60 Skip test_longexp for MacPython on Mac OS X. It triggers a pathological realloc slowdown. Some tests with shorter expressions lead me to the conclusion that it will eventually finish, but it may take a few weeks:-)
2.2.1 candidate.
2002-03-15 13:50:54 +00:00
Skip Montanaro 693c6c44c4 added test case to catch index errors with _localized_name class 2002-03-15 03:57:04 +00:00
Skip Montanaro b32302176e first cut at skip-list for hp-ux 11 based upon input from Bill Lawler at HP. 2002-03-15 02:54:03 +00:00
Guido van Rossum 8c84255316 "Fix" for SF bug #520644: __slots__ are not pickled.
As promised in my response to the bug report, I'm not really fixing
it; in fact, one could argule over what the proper fix should do.
Instead, I'm adding a little magic that raises TypeError if you try to
pickle an instance of a class that has __slots__ but doesn't define or
override __getstate__.  This is done by adding a bozo __getstate__
that always raises TypeError.

Bugfix candidate (also the checkin to typeobject.c, of course).
2002-03-14 23:05:54 +00:00
Guido van Rossum d70356729f Test for the fix I just checked in to moduleobject.c.
Bugfix candidate.
2002-03-12 20:43:31 +00:00
Tim Peters 8f01b680c8 Change Windows file.truncate() to (a) restore the original file position,
and (b) stop trying to prevent file growth.

Beef up the file.truncate() docs.

Change test_largefile.py to stop assuming that f.truncate() moves the
file pointer to the truncation point, and to verify instead that it leaves
the file position alone.  Remove the test for what happens when a
specified size exceeds the original file size (it's ill-defined, according
to the Single Unix Spec).
2002-03-12 03:04:44 +00:00
Neal Norwitz 1af5e35a98 Fix typo 2002-03-11 14:44:12 +00:00
Guido van Rossum c9e9e40b7b Add a check that SF bug 516727 is really fixed. 2002-03-11 13:21:25 +00:00
Tim Peters fb05db2cae file_truncate(): provide full "large file" support on Windows, by
dropping MS's inadequate _chsize() function.  This was inspired by
SF patch 498109 ("fileobject truncate support for win32"), which I
rejected.

libstdtypes.tex:  Someone who knows should update the availability
blurb.  For example, if it's available on Linux, it would be good to
say so.

test_largefile:  Uncommented the file.truncate() tests, and reworked to
do more.  The old comment about "permission errors" in the truncation
tests under Windows was almost certainly due to that the file wasn't open
for *write* access at this point, so of course MS wouldn't let you
truncate it.  I'd be appalled if a Unixish system did.

CAUTION:  Someone should run this test on Linux (etc) too.  The
truncation part was commented out before.  Note that test_largefile isn't
run by default.
2002-03-11 00:24:00 +00:00
Guido van Rossum 15d529aec5 Bugfix candidate.
Adapter from SF patch 528038; fixes SF bug 527816.

The wrapper for __nonzero__ should be wrap_inquiry rather than
wrap_unaryfunc, since the slot returns an int, not a PyObject *.
2002-03-11 00:07:13 +00:00
Tim Peters d674e17e96 SF patch 499062: Minor typo in test_generators.py.
There's no actual patch there.  It's an objection that Guido's example
doesn't actually generator "leaves", so change the comment that says
it does.
2002-03-10 07:59:13 +00:00
Jeremy Hylton 547a3167be Fix pyclbr test of httplib without really understanding pyclbr.
It seems that the new class HTTP11 in httplib.test() isn't
discoverable by pyclbr, which causes this test to fail.
2002-03-08 21:31:59 +00:00
Andrew M. Kuchling 1bf71172f8 As part of fixing bug #523301, add a simple test of ConfigParser.write() 2002-03-08 18:10:12 +00:00
Tim Peters c9ffa068d1 SF bug 515943: searching for data with \0 in mmap.
mmap_find_method():  this obtained the string to find via s#, but it
ignored its length, acting as if it were \0-terminated instead.

Someone please run on Linux too (the extended test_mmap works on Windows).

Bugfix candidate.
2002-03-08 05:43:32 +00:00
Michael W. Hudson 02b28ec316 Test for
[ 526039 ] devious code can crash structseqs

Bugfix candidate.
2002-03-06 17:18:15 +00:00
Michael W. Hudson 0e02530a79 Special support for pickling os.stat and os.stat_vfs results portably
(the types come from different modules on different platforms).

Added tests for pickling these types.

May be a bugfix candidate.
2002-03-06 17:11:18 +00:00
Michael W. Hudson 7bb466a1a5 A fix & test for
[ 496873 ] structseqs unpicklable

by adding a __reduce__ method to structseqs.

Will also commit this to the 2.2.1 branch momentarily.
2002-03-05 13:27:58 +00:00
Neal Norwitz 290d31e2fc SF #506611, fix sys.setprofile(), sys.settrace() core dumps
when no arguments are passed
2002-03-03 15:12:58 +00:00
Tim Peters 5329cdb3ce _PyLong_Copy(): was creating a copy of the absolute value, but should
copy the sign too.  Added a test to test_descr to ensure that it does.

Bugfix candidate.
2002-03-02 04:18:04 +00:00
Guido van Rossum 2eb0b87d14 SF patch 514641 (Naofumi Honda) - Negative ob_size of LongObjects
Due to the bizarre definition of _PyLong_Copy(), creating an instance
of a subclass of long with a negative value could cause core dumps
later on.  Unfortunately it looks like the behavior of _PyLong_Copy()
is quite intentional, so the fix is more work than feels comfortable.

This fix is almost, but not quite, the code that Naofumi Honda added;
in addition, I added a test case.
2002-03-01 22:24:49 +00:00
Martin v. Löwis 9986633609 Patch 520694: arraymodule.c improvements:
- make array.array a type
- add Py_UNICODE arrays
- support +=, *=
2002-03-01 10:27:01 +00:00
Martin v. Löwis 1c63f6e489 Correct various errors:
- Use substring search, not re search for user-agent and paths.
- Consider * entry last. Unquote, then requote URLs.
- Treat empty Disallow as "allow everything".
Add test cases. Fixes #523041
2002-02-28 15:24:47 +00:00
Guido van Rossum 06ee2531a8 SF patch #523169, by Samuele Pedroni.
There were never tests for the fact that list() always returns a *new*
list object, even when the argument is a list, while tuple() may
return a reference to the argument when it is a tuple.  Now there are.
2002-02-26 22:39:23 +00:00
Andrew MacIntyre 5cef57131f OS/2 EMX port Library and regression test changes:
Lib/
    os.py
    os2emxpath.py   // added - OS/2 EMX specific path manipulation routines
    popen2.py
    site.py
  Lib/test/
    test_fcntl.py
    test_longexp.py
2002-02-24 05:32:32 +00:00
Tim Peters 8044055d82 Somebody made list.__dict__ grow a '__doc__' key, but apparently didn't
run the test suite afterwards.  Either that, or whether '__doc__' shows
up is platform-dependent!
2002-02-19 04:25:19 +00:00
Tim Peters e4418609f7 Whitespace normalization. 2002-02-16 07:34:19 +00:00
Tim Peters 20882dd174 SF bug #516372: test_thread: unhandled exc. in thread
Fix exit races in test_thread.py and test_threaded_import.py.
I suspect the bug is provokable only under Linux (where child threads
seem to get lots of cycles before they get killed after the main thread
exits), or on multi-processor machines running other OSes.
Bugfix candidate.
2002-02-16 07:26:27 +00:00
Fred Drake 4a02f9542f Added regression test for start()/stop() returning bogus NULL. 2002-02-08 21:29:22 +00:00
Neal Norwitz af64263afc Fix typo 2002-02-08 20:13:53 +00:00
Marc-André Lemburg bd3be8f0ca Fix to the UTF-8 encoder: it failed on 0-length input strings.
Fix for the UTF-8 decoder: it will now accept isolated surrogates
(previously it raised an exception which causes round-trips to
fail).

Added new tests for UTF-8 round-trip safety (we rely on UTF-8 for
marshalling Unicode objects, so we better make sure it works for
all Unicode code points, including isolated surrogates).

Bumped the PYC magic in a non-standard way -- please review. This
was needed because the old PYC format used illegal UTF-8 sequences
for isolated high surrogates which now raise an exception.
2002-02-07 11:33:49 +00:00
Marc-André Lemburg 3688a882d3 Fix for the UTF-8 memory allocation bug and the UTF-8 encoding
bug related to lone high surrogates.
2002-02-06 18:09:02 +00:00
Tim Peters d9fbf353a1 This test left a new set of 3 junk files behind each time it was run. 2002-01-30 07:32:53 +00:00
Barry Warsaw 6423f8b884 Test case of a singleton multipart; i.e. a multipart/* with only one
subpart.
2002-01-27 06:49:26 +00:00
Barry Warsaw 763af4173d test_multipart_one_part(): Idempotency test case for a multipart/*
with only one subpart.
2002-01-27 06:48:47 +00:00
Guido van Rossum eaa0a22f43 Disable code intended for PEP 277. 2002-01-15 21:25:51 +00:00
Fred Drake 5e99731ab9 Only test ntpath.abspath() on Windows. This allows the rest of the module to
be tested regardless of the host platform.
2002-01-15 03:46:43 +00:00
Mark Hammond e843e482ce Ensure Unicode filenames work with glob - they already do, but the test seems worth keeping. 2002-01-07 02:11:43 +00:00
Marc-André Lemburg f853be980e Restore Python 2.1 StringIO.py behaviour: support concatenating
Unicode string snippets to larger Unicode strings.

This fix should also go into Python 2.2.1.
2002-01-06 17:15:05 +00:00
Fred Drake 1e2fb57b5f Remove unused imports, clean up trailing whitespace. 2002-01-05 17:12:57 +00:00
Martin v. Löwis ea752fbb86 Check for time.struct_time in addition to tuples. Use 3 characters
for zone hours. Fixes #499169.
2002-01-05 11:31:49 +00:00
Neal Norwitz 653d85fc86 SF Patch #494867 test file methods
Test that the file methods raise ValueError when called on a closed file.
Test .isatty()
Test name, closed attributes
2002-01-01 19:11:13 +00:00
Tim Peters 77902970c5 test_support: add a docstring to vereq().
test_complex:  repair new test's usage of vereq().
2001-12-29 17:34:57 +00:00
Neal Norwitz 5a0f010c67 SF Patch #497487 add test to compare conjugate of a complex number 2001-12-29 14:31:46 +00:00
Neal Norwitz fc37af85bf SF Patch #494873 add tests for complex numbers including calls to int()/long() 2001-12-29 01:02:21 +00:00
Neal Norwitz 32f41536cb SF Patch #494874 add tests for int()/long() invalid parameters 2001-12-29 00:35:20 +00:00
Neal Norwitz 707690132f SF Patch #494872 test repr() of a built-in module 2001-12-29 00:25:42 +00:00