Commit Graph

1689 Commits

Author SHA1 Message Date
Jack Jansen 398c236c1b Added tests expected to be skipped on Mac OS X. 2001-12-02 21:41:36 +00:00
Tim Peters 82285dad8e Whitespace normalization. 2001-12-01 04:11:16 +00:00
Jack Jansen b3be216b41 Merged changes made on r22b2-branch between r22b2 and r22b2-mac (the
changes from start of branch upto r22b2 were already merged, of course).
2001-11-30 14:16:36 +00:00
Marc-André Lemburg 41f01994c4 Adding test for Unicode repr()-output. 2001-11-28 14:03:14 +00:00
Barry Warsaw 00859c0538 __format(): Applied SF patch #482003 by Skip to fix multiline dict
output.

Patch includes additional test case test_basic_line_wrap().

This patch is a candidate for Python 2.1.2.
2001-11-28 05:49:39 +00:00
Barry Warsaw e274864004 test_formatdate(): Integrating Jack's 22b2 branch fix for Mac epoch:
More changes to the formatdate epoch test: the Mac epoch is in
    localtime, so east of GMT it falls in 1903:-( Changed the test to
    obtain the epoch in both local time and GMT, and do the right
    thing in the comparisons. As a sanity measure also check that
    day/month is Jan 1.
2001-11-27 07:12:35 +00:00
Guido van Rossum 90c45142d7 - Change all remaining assertions into verify() and vereq() calls.
- Add tests for the recent fixes to copy_reg.py:
  __getstate__/__setstate__ and mixed inheritance from new+classic
  classes.
2001-11-24 21:07:01 +00:00
Marc-André Lemburg 72f8213ba4 Fix for bug #438164: %-formatting using Unicode objects.
This patch also does away with an incompatibility between Jython
and CPython.
2001-11-20 15:18:49 +00:00
Marc-André Lemburg 0c4d8d05a8 Fix for bug #480188: printing unicode objects 2001-11-20 15:17:25 +00:00
Barry Warsaw 4586d2c91c test_formatdate(): Remove the unnecessary ldate calculation.
test_formatdate_zoneoffsets() => test_formatdate_localtime(): Do the
sign corrected calculation of the zone offset.
2001-11-19 18:38:42 +00:00
Barry Warsaw 75a40fcc3a test_formatdate(), test_formatdate_zoneoffsets(): Two changes. First,
use the correct way to test for epoch, by looking at the year
component of gmtime(0).  Add clause for Unix epoch and Mac epoch (Tim,
what is Windows epoch?).

Also, get rid of the strptime() test, it was way too problematic given
that strptime() is missing on many platforms and issues with locales.
Instead, simply test that formatdate() gets the numeric timezone
calculation correct for the altzone and timezone.
2001-11-19 16:31:06 +00:00
Barry Warsaw 7a1bea64f8 test_formatdate(): A test that has a mild hope of working on Mac,
which has a different epoch than *nix.  Jack may need to twiddle the
details.
2001-11-18 23:15:58 +00:00
Tim Peters 144b98dab8 More simple test cases for mixed classic+new multiple inheritance. 2001-11-14 23:56:45 +00:00
Tim Peters a91e9646e0 Changing diapers reminded Guido that he wanted to allow for some measure
of multiple inheritance from a mix of new- and classic-style classes.
This is his patch, plus a start at some test cases from me.  Will check
in more, plus a NEWS blurb, later tonight.
2001-11-14 23:32:33 +00:00
Tim Peters 00cafa0f76 Removed print that executes only on Unix boxes; that made it impossible
to have single "expected output" file.
2001-11-13 23:39:47 +00:00
Tim Peters 5ebfd36afa CVS patch #477161: New "access" keyword for mmap, from Jay T Miller.
This gives mmap() on Windows the ability to create read-only, write-
through and copy-on-write mmaps.  A new keyword argument is introduced
because the mmap() signatures diverged between Windows and Unix, so
while they (now) both support this functionality, there wasn't a way to
spell it in a common way without introducing a new spelling gimmick.
The old spellings are still accepted, so there isn't a backward-
compatibility issue here.
2001-11-13 23:11:19 +00:00
Jeremy Hylton 79b5b5b7fb Don't munge __debug__ and leave it that way. 2001-11-13 22:03:20 +00:00
Tim Peters 8876848323 Whitespace normalization. 2001-11-13 21:51:26 +00:00
Barry Warsaw 135cce8718 A specific test for bug #481221, getaddrlist() failing on long
addresses.  Commented out because it still takes too long to run.
2001-11-13 21:33:52 +00:00
Barry Warsaw 3ca656f1be Committing the second part of patch #480902, an improved test suite
for dumbdbm.py, by Skip Montanaro.  The first half of Skip's patch has
been postponed until Py2.3 since it adds new features.
2001-11-13 20:16:52 +00:00
Barry Warsaw 19c10caaa4 Add tests for bug #478115, parsedate_tz() IndexError when a Date:
field exists with an empty value.
2001-11-13 18:01:37 +00:00
Barry Warsaw 4279346a9f getnameinfo() appears to raise socket.error instead of
socket.gaierror. :( This allows test_socket to pass on a RH6.1-ish
Linux system.
2001-11-09 20:37:43 +00:00
Jeremy Hylton 8edd5402f0 Fix SF buf #480096: Assign to __debug__ still allowed
Easy enough to catch assignment in the compiler.  The perverse user
can still change the value of __debug__, but that may be the least he
can do.
2001-11-09 20:37:13 +00:00
Jeremy Hylton 778e265462 Fix SF buf #480096: Assign to __debug__ still allowed
Easy enough to catch assignment in the compiler.  The perverse user
can still change the value of __debug__, but that may be the least he
can do.
2001-11-09 19:50:08 +00:00
Jeremy Hylton 734c7fb131 Fiddle with new test cases -- verify that we get a sensible error
message for bad mode argument -- so that it doesn't fail on Windows.

It's hack.  We know that errno is set to 0 in this case on Windows, so
check for that specifically.
2001-11-09 19:34:43 +00:00
Barry Warsaw a4e5c71962 test_formatdate(): Dang. Typo. 2001-11-09 19:31:34 +00:00
Barry Warsaw 7edd71a9f5 test_formatdate(): Don't do the localtime test if we don't have
strptime() -- I'm too lazy to code it otherwise.
2001-11-09 19:30:58 +00:00
Barry Warsaw 75edc6a033 test_formatdate(): A test for email.Utils.formatdate(). 2001-11-09 17:46:17 +00:00
Jeremy Hylton 41c8321252 Fix SF buf #476953: Bad more for opening file gives bad msg.
If fopen() fails with EINVAL it means that the mode argument is
invalid.  Return the mode in the error message instead of the
filename.
2001-11-09 16:17:24 +00:00
Fred Drake 752eda459a Add a regression test for SF bug #478536: If a value cannot be weakly
referenced, WeakKeyDictionary.has_key() should return 0 instead of raising
TypeError.
2001-11-06 16:38:34 +00:00
Tim Peters e5a611c1bc A couple more test cases to ensure join() doesn't add an "extra" backslash
in the presence of empty-string arguments.
2001-11-05 21:33:04 +00:00
Tim Peters 6a3e5f14a6 SF bug 478425: Change in os.path.join (ntpath.py)
ntpath.join('a', '') was producing 'a' instead of 'a\\' as in 2.1.
Impossible to guess what was ever *intended*, but since split('a\\')
produces ('a', ''), I think it's best if join('a', '') gives 'a\\' back.
2001-11-05 21:25:02 +00:00
Fred Drake 526286725d Add regression test for SF bug #476616 -- make sure copy of a derived class
does not share data with the original.
2001-11-05 17:41:48 +00:00
Martin v. Löwis 06b1d21e7d Correct getnameinfo refcounting and tuple parsing. Fixes #476648. 2001-11-02 23:34:52 +00:00
Andrew M. Kuchling f792bba98f [Patch #477336] Add an extensive PyUnit based testsuite for the hmac
module
2001-11-02 21:49:59 +00:00
Andrew M. Kuchling a0b6035a54 [Patch #476612] Add test suite for PEP247 compliance 2001-11-02 21:46:17 +00:00
Andrew M. Kuchling a2085cb7f7 Fix comment typo 2001-11-02 21:45:39 +00:00
Tim Peters 7e0f81e631 Huh. In an effort to be less thorough <wink>, seems I checked in a new
test that wouldn't even compile,
2001-10-31 03:46:14 +00:00
Tim Peters c2fe618575 Fix bad bug in structseq slicing (NULL pointers in result). Reported by
Jack Jansen on python-dev.
Add simple test case.
Move vereq() from test_descr to test_support (it's handy!).
2001-10-30 23:20:46 +00:00
Tim Peters 1633a2e345 Whitespace normalization. 2001-10-30 05:56:40 +00:00
Tim Peters 9e6a399b14 To cover a recent checkin, added a test to ensure dir(None) == dir(Ellipsis). 2001-10-30 05:45:26 +00:00
Tim Peters fe677e2012 Just changed some continued-line indentation to read better, due to
the earlier s/dictionary/dict/ change.
2001-10-30 05:41:07 +00:00
Guido van Rossum fa699126b5 Fix SF bug #456386: test_commands regression failure (Andrew Dalke)
test_commands does not work on IRIX

    It assumes the output of "ls /bin/ls" is a line
    that starts with a '-'. On IRIX that file is
    a symbolic link, so the first character is an l.
    This causes test_getstatus to fail.
2001-10-30 03:17:30 +00:00
Guido van Rossum ed87ad876b Minimal test for __del__ hook. 2001-10-30 02:33:02 +00:00
Tim Peters a427a2b8d0 Rename "dictionary" (type and constructor) to "dict". 2001-10-29 22:25:45 +00:00
Tim Peters c57a285cb4 SF bug #476138: tempfile behavior across platforms
Ensure that a tempfile can be closed any number of times without error.
This wasn't true on Windows.
2001-10-29 21:46:08 +00:00
Fred Drake f3c54d6fc7 Add a test for the insertion of user-provided ADD_INFO records. 2001-10-29 20:54:01 +00:00
Guido van Rossum 9bd1401bbb Use sendall() in the stream test instead of send(). 2001-10-29 07:18:02 +00:00
Guido van Rossum cb65688218 Test sendall(). 2001-10-29 07:14:10 +00:00
Fredrik Lundh b7747e2a2d added finditer sanity check 2001-10-28 20:15:40 +00:00
Tim Peters 4d85953fe6 dictionary() constructor:
+ Change keyword arg name from "x" to "items".  People passing a mapping
  object can stretch their imaginations <wink>.
+ Simplify the docstring text.
2001-10-27 18:27:48 +00:00
Tim Peters 9fda73cdd1 dict_constructor(): The last test was passing for the wrong reason (it
was intended to verify that sub-sequences of lengths 1 and 3 raise
ValueError, but was actually testing string lengths).
2001-10-26 20:57:38 +00:00
Tim Peters 1fc240e851 Generalize dictionary() to accept a sequence of 2-sequences. At the
outer level, the iterator protocol is used for memory-efficiency (the
outer sequence may be very large if fully materialized); at the inner
level, PySequence_Fast() is used for time-efficiency (these should
always be sequences of length 2).

dictobject.c, new functions PyDict_{Merge,Update}FromSeq2.  These are
wholly analogous to PyDict_{Merge,Update}, but process a sequence-of-2-
sequences argument instead of a mapping object.  For now, I left these
functions file static, so no corresponding doc changes.  It's tempting
to change dict.update() to allow a sequence-of-2-seqs argument too.

Also changed the name of dictionary's keyword argument from "mapping"
to "x".  Got a better name?  "mapping_or_sequence_of_pairs" isn't
attractive, although more so than "mosop" <wink>.

abstract.h, abstract.tex:  Added new PySequence_Fast_GET_SIZE function,
much faster than going thru the all-purpose PySequence_Size.

libfuncs.tex:
- Document dictionary().
- Fiddle tuple() and list() to admit that their argument is optional.
- The long-winded repetitions of "a sequence, a container that supports
  iteration, or an iterator object" is getting to be a PITA.  Many
  months ago I suggested factoring this out into "iterable object",
  where the definition of that could include being explicit about
  generators too (as is, I'm not sure a reader outside of PythonLabs
  could guess that "an iterator object" includes a generator call).
- Please check my curly braces -- I'm going blind <0.9 wink>.

abstract.c, PySequence_Tuple():  When PyObject_GetIter() fails, leave
its error msg alone now (the msg it produces has improved since
PySequence_Tuple was generalized to accept iterable objects, and
PySequence_Tuple was also stomping on the msg in cases it shouldn't
have even before PyObject_GetIter grew a better msg).
2001-10-26 05:06:50 +00:00
Guido van Rossum 6661be3bed Allow assignment to newinstance.__dict__. 2001-10-26 04:26:12 +00:00
Barry Warsaw 2539cf5aad A fix for SF bug #472560, extra newlines returned by get_param() when
the separating semi-colon shows up on a continuation line (legal, but
weird).

Bug reported and fixed by Matthew Cowles.  Test case and sample email
included.
2001-10-25 22:43:46 +00:00
Barry Warsaw 107771a228 Applying proposed patch for bug #474583, optional support for
non-standard but common types.  Including Martin's suggestion to add
rejected non-standard types from patch #438790.  Specifically,

guess_type(), guess_extension(): Both the functions and the methods
grow an optional "strict" flag, defaulting to true, which determines
whether to recognize non-standard, but commonly found types or not.

Also, I sorted, reformatted, and culled duplicates from the big
types_map dictionary.  Note that there are a few non-equivalent
duplicates (e.g. .cdf and .xls) for which the first will just get
thrown away.  I didn't remove those though.

Finally, use of the module as a script as grown the -l and -e options
to toggle strictness and to do guess_extension(), respectively.

Doc and unittest updates too.
2001-10-25 21:49:18 +00:00
Fred Drake b112481f12 Ignore the posixfile deprecation warning for the test suite. 2001-10-25 18:11:10 +00:00
Guido van Rossum e2ae77b8b8 SF patch #474590 -- RISC OS support 2001-10-24 20:42:55 +00:00
Guido van Rossum f66dacdb01 test_curses is an expected skip on Linux too. 2001-10-23 15:10:55 +00:00
Tim Peters d703057752 Record that test_curses doesn't run on win32. 2001-10-22 22:06:08 +00:00
Fred Drake 4bf018b138 Fixed denial-of-weak-ref-support test; Jeremy changed the error message
used by the weakref code since he didn't like the word "referencable".
Is it really necessary to be more specific than to test for TypeError here,
though?
2001-10-22 21:45:25 +00:00
Andrew M. Kuchling 2158df0b4d Patch #473187: Add a test script that exercises most of the functions in
the curses module.  It's not run automatically; '-u curses' must be
    specified as an argument to regrtest
2001-10-22 15:26:09 +00:00
Fredrik Lundh f864aa8fd9 sre.split should return the last segment, even if empty
(sorry, barry)
2001-10-22 06:01:56 +00:00
Guido van Rossum 56ff387a7e Fix for SF bug #472940: can't getattr() attribute shown by dir()
There really isn't a good reason for instance method objects to have
their own __dict__, __doc__ and __name__ properties that just delegate
the request to the function (callable); the default attribute behavior
already does this.

The test suite had to be fixed because the error changes from
TypeError to AttributeError.
2001-10-22 02:00:09 +00:00
Guido van Rossum c8e5645f15 Methods of built-in types now properly check for keyword arguments
(formerly these were silently ignored).  The only built-in methods
that take keyword arguments are __call__, __init__ and __new__.
2001-10-22 00:43:43 +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
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
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
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
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
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
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
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 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
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
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
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
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
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
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
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
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
Barry Warsaw bf7a59d94b Add a test for the HeaderParser class. 2001-10-11 15:44:50 +00:00
Jeremy Hylton de7c1923c7 Add test of hexlify on Unicode strings 2001-10-11 14:09:03 +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
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
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 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
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
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
Guido van Rossum 9475a2310d Enable GC for new-style instances. This touches lots of files, since
many types were subclassable but had a xxx_dealloc function that
called PyObject_DEL(self) directly instead of deferring to
self->ob_type->tp_free(self).  It is permissible to set tp_free in the
type object directly to _PyObject_Del, for non-GC types, or to
_PyObject_GC_Del, for GC types.  Still, PyObject_DEL was a tad faster,
so I'm fearing that our pystone rating is going down again.  I'm not
sure if doing something like

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

is any faster than always calling the else branch, so I haven't
attempted that -- however those types whose own dealloc is fancier
(int, float, unicode) do use this pattern.
2001-10-05 20:51:39 +00:00
Fred Drake 4e7cdb57f9 Non-failing test for SF bug #467059. 2001-10-04 20:05:10 +00:00
Fred Drake 266410355f run_suite(): If testclass is not available, provide an even more general
error message.
run_unittest():  Provide the testclass to run_suite() so it can construct
                 the error message.
This closes SF bug #467763.
2001-10-04 19:46:07 +00:00
Barry Warsaw d1de6eacf2 TestIterators: Tim Peters suggests a more succinct spelling of
"listify an iterator".
2001-10-04 18:18:37 +00:00
Barry Warsaw c4496f886b More test data for test_email.py 2001-10-04 17:59:42 +00:00
Barry Warsaw 08a534d476 test_header_splitter(), test_body_line_iterator(): Move the test data
into tests/data/msg_*.txt files.
2001-10-04 17:58:50 +00:00
Fred Drake 7c0a93d966 Updated to reflect the rationalized profiler event reporting. 2001-10-04 14:49:46 +00:00
Tim Peters c59fb2d230 This test relied on hard tab characters, so failed after whitespace
normalization.  Now uses \t in strings instead of hard tabs.
2001-10-04 06:26:17 +00:00
Tim Peters 4fb1fe8bd2 class_docstrings(): The new-style class tests should use new-style
classes (sheesh!).
2001-10-04 05:48:13 +00:00
Tim Peters 527e64fd68 Whitespace normalization. 2001-10-04 05:36:56 +00:00
Tim Peters 2f93e28a19 SF bug [#467331] ClassType.__doc__ always None.
For a dynamically constructed type object, fill in the tp_doc slot with
a copy of the argument dict's "__doc__" value, provided the latter exists
and is a string.
NOTE:  I don't know what to do if it's a Unicode string, so in that case
tp_doc is left NULL (which shows up as Py_None if you do Class.__doc__).
Note that tp_doc holds a char*, not a general PyObject*.
2001-10-04 05:27:00 +00:00
Guido van Rossum f137f75ab8 Hopefully fix the profiler right. Add a test suite that checks that
it deals correctly with some anomalous cases; according to this test
suite I've fixed it right.

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

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

Where obj is an instance from a class like this:

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

The profiler sees the following sequence of events:

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

Previously, the profiler would assume the return event returned from
__getattr__. An if statement checking for this condition and raising
an exception was commented out...  This version does the right thing.
2001-10-04 00:58:24 +00:00
Fred Drake 0099ba73de Add some more test cases to be sure we do the right thing in various cases. 2001-10-03 21:15:32 +00:00
Guido van Rossum 4a5a2bc2b6 dynamics(): add a dummy __getattr__ method to the C class so that the
test for modifying __getattr__ works, now that slot_tp_getattr_hook
zaps the slot if there's no hook.  Added an XXX comment with a ref
back to slot_tp_getattr_hook.
2001-10-03 13:59:54 +00:00
Tim Peters 1b0e5490c5 Made the classmethod docstring test a bit less trivial. 2001-10-03 04:15:28 +00:00
Tim Peters 17111f3b24 SF bug [#467336] doctest failures w/ new-style classes.
Taught doctest about static methods, class methods, and property docstrings
in new-style classes.  As for inspect.py/pydoc.py before it, the new stuff
needed didn't really fit into the old architecture (but was less of a
strain to force-fit here).
New-style class docstrings still aren't found, but that's the subject
of a different bug and I want to fix that right instead of hacking around
it in doctest.
2001-10-03 04:08:26 +00:00
Guido van Rossum 048eb75c2d Add Garbage Collection support to new-style classes (not yet to their
instances).

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

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

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

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

Also added an extra call to gc.collect() at the start of test_all().
This will be needed when I check in the changes to add GC to new-style
classes.
2001-10-02 19:49:47 +00:00
Tim Peters 7402f791a4 SF patch [#466616] Exclude imported items from doctest,
from Tim Hochberg.  Also mucho fiddling to change the way doctest
determines whether a thing is a function, module or class.  Under 2.2,
this really requires the functions in inspect.py (e.g., types.ClassType
is close to meaningless now, if not outright misleading).
2001-10-02 03:53:41 +00:00
Skip Montanaro 419abdaff2 simple dumps/loads test case for xmlrpclib 2001-10-01 17:47:44 +00:00
Martin v. Löwis 16dc7f44b1 Patch #462190, patch #464070: Support quoted printable in the binascii module.
Decode and encode underscores for header style encoding. Fixes bug #463996.
2001-09-30 20:32:11 +00:00
Guido van Rossum 751c4c864c Add a few ``__dynamic__ = 0'' lines in classes that need to preserve
staticness when __dynamic__ = 1 becomes the default:

- Some classes which are used to test the difference between static
  and dynamic.

- Subclasses of complex: complex uses old-style numbers and the slot
  wrappers used by dynamic classes only support new-style numbers.
  (Ideally, the complex type should be fixed, but that looks like a
  labor-intensive job.)
2001-09-29 00:40:25 +00:00
Guido van Rossum 4bb1e36eec It's a fact: for binary operators, *under certain circumstances*,
__rop__ now takes precendence over __op__.  Those circumstances are:

  - Both arguments are new-style classes
  - Both arguments are new-style numbers
  - Their implementation slots for tp_op differ
  - Their types differ
  - The right argument's type is a subtype of the left argument's type

Also did this for the ternary operator (pow) -- only the binary case
is dealt with properly though, since __rpow__ is not supported anyway.
2001-09-28 23:49:48 +00:00
Fred Drake 946f7b1b24 Update the xml.dom.minidom tests to cover the DOM-compliant parts of the
NodeList interface.
2001-09-28 20:31:50 +00:00
Fred Drake 88a56857f6 Remove an infelicitous space. 2001-09-28 20:16:30 +00:00
Tim Peters 9390cc15da regrtest's -g option stopped working, during the changes to improve
error-reporting for the classic compare-expected-output tests.
Curiously, the bug consisted of not simplifying the logic enough!
2001-09-28 20:14:46 +00:00
Fred Drake b2ad1c8b4d Reflect recent refinements of the regression testing framework. 2001-09-28 20:05:25 +00:00
Guido van Rossum 6cef6d5d62 Changes to copy() and deepcopy() in copy.py to support __reduce__ as a
fallback for objects that are neither supported by our dispatch table
nor have a __copy__ or __deepcopy__ method.

Changes to _reduce() in copy_reg.py to support reducing objects that
don't have a __dict__ -- copy.copy(complex()) now invokes _reduce().

Add tests for copy.copy() and copy.deepcopy() to test_regrtest.py.
2001-09-28 18:13:29 +00:00
Fred Drake 39cd603fc8 More test cases, including something that simulates what the profiler
probably *should* be doing.
2001-09-26 21:00:33 +00:00
Tim Peters 38a50f9065 A file just to look at (using pydoc). 2001-09-26 20:31:52 +00:00
Jeremy Hylton ede049b2d3 Add tests for new PyErr_NormalizeException() behavior
Add raise_exception() to the _testcapi module.  It isn't a test, but
the C API exists only to support test_exceptions.  raise_exception()
takes two arguments -- an exception class and an integer specifying
how many arguments it should be called with.

test_exceptions uses BadException() to test the interpreter's behavior
when there is a problem instantiating the exception.  test_capi1()
calls it with too many arguments.  test_capi2() causes an exception to
be raised in the Python code of the constructor.
2001-09-26 20:01:13 +00:00
Thomas Wouters 80d373cbd0 Test case for SF bugs #463359 and #462937, added to test_grammar for lack of
a better place. Excessively fragile code, but at least it breaks when
something in this area changes!
2001-09-26 12:43:39 +00:00
Barry Warsaw 65279d0242 Update the tests for the current incarnation of the email package, and
added some new tests of message/delivery-status content type messages.
2001-09-26 05:47:08 +00:00
Barry Warsaw 0e416cd88e More test messages for test_email.py 2001-09-26 05:45:17 +00:00
Barry Warsaw 45653503ec test_iterator(): Don't do a type comparison to see if it's an
iterator, just test to make sure it has the two required iterator
protocol methods __iter__() and next() -- actually just test
hasattr-ness.
2001-09-25 21:40:04 +00:00
Fred Drake cc91ac09ef Factor out the protect-from-exceptions helpers and make capture_events()
use it.  This simplifies the individual tests a little.

Added some new tests related to exception handling.
2001-09-25 20:48:14 +00:00
Tim Peters 8dee809410 Guido points out that sys.__stdout__ is a bit bucket under IDLE. So keep
the local save/modify/restore of sys.stdout, but add machinery so that
regrtest can tell test_support the value of sys.stdout at the time
regrtest.main() started, and test_support can pass that out later to anyone
who needs a "visible" stdout.
2001-09-25 20:05:11 +00:00
Tim Peters d48004f4f0 test_support should be imported directly, not via test.test_support. 2001-09-25 19:29:35 +00:00
Tim Peters 342ca75d95 Get rid of the increasingly convoluted global tricks w/ sys.stdout, in
favor of local save/modify/restore.  The test suite should run fine again.
2001-09-25 19:13:20 +00:00
Guido van Rossum 3926a63d05 - Provisional support for pickling new-style objects. (*)
- Made cls.__module__ writable.

- Ensure that obj.__dict__ is returned as {}, not None, even upon first
  reference; it simply springs into life when you ask for it.

(*) The pickling support is provisional for the following reasons:

- It doesn't support classes with __slots__.

- It relies on additional support in copy_reg.py: the C method
  __reduce__, defined in the object class, really calls calling
  copy_reg._reduce(obj).  Eventually the Python code in copy_reg.py
  needs to be migrated to C, but I'd like to experiment with the
  Python implementation first.  The _reduce() code also relies on an
  additional helper function, _reconstructor(), defined in
  copy_reg.py; this should also be reimplemented in C.
2001-09-25 16:25:58 +00:00
Guido van Rossum ad39aba2f6 Set sys.save_stdout (to sys.stdout), so doctest-using tests can be run
standalone.
2001-09-25 16:21:39 +00:00
Guido van Rossum a4cb78874c Change repr() of a new-style class to say <class 'ClassName'> rather
than <type 'ClassName'>.  Exception: if it's a built-in type or an
extension type, continue to call it <type 'ClassName>.  Call me a
wimp, but I don't want to break more user code than necessary.
2001-09-25 03:56:29 +00:00
Guido van Rossum 5c294fb0e6 Make __class__ assignment possible, when the object structures are the
same.  I hope the test for structural equivalence is stringent enough.
It only allows the assignment if the old and new types:

- have the same basic size
- have the same item size
- have the same dict offset
- have the same weaklist offset
- have the same GC flag bit
- have a common base that is the same except for maybe the dict and
  weaklist (which may have been added separately at the same offsets
  in both types)
2001-09-25 03:43:42 +00:00
Tim Peters 66c1a525e0 Make properties discoverable from Python:
- property() now takes 4 keyword arguments:  fget, fset, fdel, doc.
  Note that the real purpose of the 'f' prefix is to make fdel fit in
  ('del' is a keyword, so can't used as a keyword argument name).

- These map to visible readonly attributes 'fget', 'fset', 'fdel',
  and '__doc__' in the property object.

- fget/fset/fdel weren't discoverable from Python before.

- __doc__ is new, and allows to associate a docstring with a property.
2001-09-24 21:17:50 +00:00
Fred Drake 30c4849169 Added several new tests to check the behavior with respect to doctype
declarations and weird markup that we used to accept & ignore that recent
versions raised an exception for; the original behavior has been restored
and augmented (the user can decide what to do if they care; the default is
to ignore it as done in early versions).
2001-09-24 20:22:09 +00:00
Fred Drake e822049efc Adapt to use the test_main() approach. 2001-09-24 20:19:08 +00:00
Guido van Rossum 3d45d8f12e Another comparison patch-up: comparing a type with a dynamic metatype
to one with a static metatype raised an obscure error.
2001-09-24 18:47:40 +00:00
Fred Drake 2d879017b3 Add more tests showing the relationship between exceptions raised & caught
and the information provided to the profiler.  This stuff is a mess!
2001-09-24 18:44:11 +00:00
Guido van Rossum 2205642fe0 Do the same thing to complex that I did to str: the rich comparison
function returns NotImplemented when comparing objects whose
tp_richcompare slot is not itself.
2001-09-24 17:52:04 +00:00
Marc-André Lemburg e47df7a211 StringIO patch #462596: let's [c]StringIO accept read buffers on
input to .write() too.
2001-09-24 17:34:52 +00:00
Guido van Rossum bb77e6801e Change string comparison so that it applies even when one (or both)
arguments are subclasses of str, as long as they don't override rich
comparison.
2001-09-24 16:51:54 +00:00
Guido van Rossum ff0e6d6ef5 Fix the baffler that Tim reported: sometimes the repr() of an object
looks like <X object at ...>, sometimes it says <X instance at ...>.
Make this uniformly say <X object at ...>.
2001-09-24 16:03:59 +00:00
Tim Peters 2c9aa5ea8d Generalize file.writelines() to allow iterable objects. 2001-09-23 04:06:05 +00:00
Barry Warsaw d31db7e939 The test data (mostly example messages) for the email package test
suite.  Note that other tests can put input data in this directory.
2001-09-23 03:19:33 +00:00
Barry Warsaw 4107585a67 An extensive test suite for the email package. 2001-09-23 03:18:13 +00:00
Tim Peters 13b49d3374 New function classify_class_attrs(). As a number of SF bug reports
point out, pydoc doesn't tell you where class attributes were defined,
gets several new 2.2 features wrong, and isn't aware of some new features
checked in on Thursday <wink>.  pydoc is hampered in part because
inspect.py has the same limitations.  Alas, I can't think of a way to
fix this within the current architecture of inspect/pydoc:  it's simply
not possible in 2.2 to figure out everything needed just from examining
the object you get back from class.attr.  You also need the class
context, and the method resolution order, and tests against various things
that simply didn't exist before.  OTOH, knowledge of how to do that is
getting quite complex, so doesn't belong in pydoc.

classify_class_attrs takes a different approach, analyzing all
the class attrs "at once", and returning the most interesting stuff for
each, all in one gulp.  pydoc needs to be reworked to use this for
classes (instead of the current "filter dir(class) umpteen times against
assorted predicates" approach).
2001-09-23 02:00:29 +00:00
Tim Peters e0b2d7ac9a Add a function to compute a class's method resolution order. This is
easy for 2.2 new-style classes, but trickier for classic classes, and
different approaches are needed "depending".  The function will allow
later code to treat all flavors of classes uniformly.
2001-09-22 06:10:55 +00:00
Tim Peters c377b16d12 Since the most likely failure mode for an expected-output test is a change
somewhere inside a line, use ndiff so that intraline difference marking
can point out what changed within a line.  I don't remember diff-style
abbreviations either (haven't used it since '94, except to produce
patches), so say the rest in English too.
2001-09-22 05:31:03 +00:00
Barry Warsaw 7f8ff471f8 Converted test_StringIO.py to use unittest, so
Lib/test/output/test_StringIO is no longer necessary.

Also, added a test of the iterator protocol that's just been added to
StringIO's and cStringIO's.
2001-09-22 04:33:47 +00:00
Fred Drake 3208d4b387 Start of a test to make sure the profiler/tracer support in the core
interpreter is reporting what we expect to see.
2001-09-22 04:28:19 +00:00
Guido van Rossum 19c1cd5b35 Add the __getattr__ hook back. The rules are now:
- if __getattribute__ exists, it is called first;
  if it doesn't exists, PyObject_GenericGetAttr is called first.
- if the above raises AttributeError, and __getattr__ exists,
  it is called.
2001-09-21 21:24:49 +00:00
Guido van Rossum cf691935bb reportdiff(): print a "plain diff" style diff.
XXX This should really be a unified diff, but I can't be bothered.
2001-09-21 21:06:22 +00:00
Guido van Rossum 0a07639779 Oops. I didn't expect that some tests (test_cookie) have expected
output *and* doctest stuff.  Assuming the doctest stuff comes after the
expected output, this fixes that.
2001-09-21 20:45:44 +00:00
Guido van Rossum 0fcca4e815 Change the way unexpected output is reported: rather than stopping at
the first difference, let the test run till completion, then gather
all the output and compare it to the expected output using difflib.

XXX Still to do: produce diff output that only shows the sections that
differ; currently it produces ndiff-style output because that's the
easiest to produce with difflib, but this becomes a liability when the
output is voluminous and there are only a few differences.
2001-09-21 20:31:52 +00:00
Guido van Rossum 867a8d2e26 Change the name of the __getattr__ special method for new-style
classes to __getattribute__, to make it crystal-clear that it doesn't
have the same semantics as overriding __getattr__ on classic classes.

This is a halfway checkin -- I'll proceed to add a __getattr__ hook
that works the way it works in classic classes.
2001-09-21 19:29:08 +00:00
Guido van Rossum dbb718fa87 Make these modules work when Python is compiled without Unicode support. 2001-09-21 19:22:34 +00:00
Guido van Rossum 11310bf867 Add tests for repr() of strings containing string quotes as well. 2001-09-21 15:46:41 +00:00
Guido van Rossum e4874aeab0 Test basic functioning of unicode repr(). (If this breaks Jython,
please let me know and we'll figure out how to fix the test.)
2001-09-21 15:36:41 +00:00
Guido van Rossum 8b9cc7e69e Add a small test to verify that member and getset descriptors now have
docstrings (using file.closed and file.name as examples).
2001-09-20 21:49:53 +00:00
Guido van Rossum a56b42b1ba Change testdescr.py to use the test_main() approach. 2001-09-20 21:39:07 +00:00
Fred Drake 2e2be3760c Change the PyUnit-based tests to use the test_main() approach. This
allows using the tests with unittest.py as a script.  The tests will
still run when run as a script themselves.
2001-09-20 21:33:42 +00:00
Marc-André Lemburg 3508e30861 Fix Unicode .join() method to raise a TypeError for sequence
elements which are not Unicode objects or strings. (This matches
the string.join() behaviour.)

Fix a memory leak in the .join() method which occurs in case
the Unicode resize fails.

Restore the test_unicode output.
2001-09-20 17:22:58 +00:00
Marc-André Lemburg 5e89bd656f Update test output after the unicode() change. 2001-09-20 16:37:23 +00:00
Marc-André Lemburg 6871f6ac57 Implement the changes proposed in patch #413333. unicode(obj) now
works just like str(obj) in that it tries __str__/tp_str on the object
in case it finds that the object is not a string or buffer.
2001-09-20 12:53:16 +00:00
Marc-André Lemburg c60e6f7771 Patch #435971: UTF-7 codec by Brian Quinlan. 2001-09-20 10:35:46 +00:00
Barry Warsaw c88425e2b2 run_suite(): Oops, update a docstring. 2001-09-20 06:31:22 +00:00
Barry Warsaw c10d690744 run_suite(): Factor this out of run_unittest() for tests that build
their own test suite from a multitude of classes (like test_email.py
will be doing).

run_unittest(): Call run_suite() after making a suite from the
testclass.
2001-09-20 06:30:41 +00:00
Guido van Rossum 1952e388ca Add additional coercion support for "self subtypes" to int, long,
float (compare the recent checkin to complex).  Added tests for these.
2001-09-19 01:25:16 +00:00
Guido van Rossum d5d8e4a436 Enable two checks for comparing a complex to a complex subtype
instance.

Split a string comparison test in two halves, replacing "a==b==a" with
separate tests for a==b and b==a.  (Reason: while experimenting, this
test failed, and I wanted to know if it was the first or the second ==
operator that failed.)
2001-09-19 01:16:16 +00:00
Tim Peters 50fda6c21f Enable some comparison tests that failed before. Still having problems
with subsclasses of complex and string.
2001-09-18 21:24:18 +00:00
Guido van Rossum 0639f59859 Add a similar test for rich comparisons. 2001-09-18 21:06:04 +00:00
Fredrik Lundh 59b68656f8 fixed #449964: sre.sub raises an exception if the template contains a
\g<x> group reference followed by a character escape

(also restructured a few things on the way to fixing #449000)
2001-09-18 20:55:24 +00:00
Guido van Rossum ab3b0343b8 Hopefully fix 3-way comparisons. This unfortunately adds yet another
hack, and it's even more disgusting than a PyInstance_Check() call.
If the tp_compare slot is the slot used for overrides in Python,
it's always called.

Add some tests that show what should work too.
2001-09-18 20:38:53 +00:00
Guido van Rossum eb94905265 Get rid of a superfluous space after "--" in the message printed for a
skipped test -- the print command already supplies a space.
2001-09-18 20:34:19 +00:00
Guido van Rossum 843daa8cad Test for the safety check in wrap_cmpfunc(). 2001-09-18 20:04:26 +00:00
Fredrik Lundh 21009b9c6f an SRE bugfix a day keeps Guido away...
#462270: sub-tle difference between pre.sub and sre.sub.  PRE ignored
an empty match at the previous location, SRE didn't.

also synced with Secret Labs "sreopen" codebase.
2001-09-18 18:47:09 +00:00
Guido van Rossum db2a902dee Undo some (but not all) of the more lenient acceptance of
(AttributeError, TypeError) -- the leniency wasn't needed everywhere.
2001-09-18 03:55:22 +00:00
Guido van Rossum bd13149711 - Some tests that check that assignments are not allowed expect this
to raise TypeError.  In practice, a disallowed attribute assignment
  can raise either TypeError or AttributeError (and it's unclear which
  is better).  So allow either.  (Yes, this is in anticipation of a
  code change that switches the exception raised. :-)

- Add a utility function, cantset(), which verifies that setting a
  particular attribute to a given value is disallowed, and also that
  deleting that same attribute is disallowed.  Use this in the
  test_func_*() tests.

- Add a new set of tests that test conformance of various instance
  method attributes.  (Also in anticipation of code that changes their
  implementation.)
2001-09-18 03:28:54 +00:00
Tim Peters b64bec3ec0 Whitespace normalization. 2001-09-18 02:26:39 +00:00
Tim Peters a86f0c17a1 Make test_socketserver require the network resource.
Add it back to the list of tests we expect to skip on Windows.
2001-09-18 02:18:57 +00:00
Tim Peters 7a76d4b4e4 I don't expect test_socketserver to get skipped on Windows anymore. 2001-09-18 00:24:10 +00:00
Tim Peters a9f6f22f72 Rework akin to test_threaded_import, so that this can run under regrtest.
Also raise TestSkipped (intead of appearing to fail) if the import lock
is held.
2001-09-17 23:56:20 +00:00
Guido van Rossum d9d1d4ac6f Rewrite function attributes to use the generic routines properly.
This uses the new "restricted" feature of structmember, and getset
descriptors for some of the type checks.
2001-09-17 23:46:56 +00:00
Tim Peters 305b5857f6 PyObject_Dir(): Merge in __members__ and __methods__ too (if they exist,
and are lists, and then just the string elements (if any)).

There are good and bad reasons for this.  The good reason is to support
dir() "like before" on objects of extension types that haven't migrated
to the class introspection API yet.  The bad reason is that Python's own
method objects are such a type, and this is the quickest way to get their
im_self etc attrs to "show up" via dir().  It looks much messier to move
them to the new scheme, as their current getattr implementation presents
a view of their attrs that's a untion of their own attrs plus their
im_func's attrs.  In particular, methodobject.__dict__ actually returns
methodobject.im_func.__dict__, and if that's important to preserve it
doesn't seem to fit the class introspection model at all.
2001-09-17 02:38:46 +00:00
Tim Peters e0007821cd Since we had a bug with multiplication of dynamic long subclasses, add a
little test to make sure it doesn't come back.
2001-09-15 06:35:55 +00:00
Guido van Rossum 7e35d57c0c A fix for SF bug #461546 (bug in long_mul).
Both int and long multiplication are changed to be more careful in
their assumptions about when one of the arguments is a sequence: the
assumption that at least one of the arguments must be an int (or long,
respectively) is still held, but the assumption that these don't smell
like sequences is no longer true: a subtype of int or long may well
have a sequence-repeat thingie!
2001-09-15 03:14:32 +00:00
Tim Peters 0891ac017d The 'p' (Pascal string) pack code acts unreasonably when the string size
and count exceed 255.  Changed to preserve as much of the string as
possible (instead of count%256 characters).
2001-09-15 02:35:15 +00:00
Jeremy Hylton dd32138e7d limit prefix test for lambda
the compiler package generates a module-unique trailing suffix for
each lambda
2001-09-14 23:01:49 +00:00
Tim Peters 0ab085c4cb Changed the dict implementation to take "string shortcuts" only when
keys are true strings -- no subclasses need apply.  This may be debatable.

The problem is that a str subclass may very well want to override __eq__
and/or __hash__ (see the new example of case-insensitive strings in
test_descr), but go-fast shortcuts for strings are ubiquitous in our dicts
(and subclass overrides aren't even looked for then).  Another go-fast
reason for the change is that PyCheck_StringExact() is a quicker test
than PyCheck_String(), and we make such a test on virtually every access
to every dict.

OTOH, a str subclass may also be perfectly happy using the base str eq
and hash, and this change slows them a lot.  But those cases are still
hypothetical, while Python's own reliance on true-string dicts is not.
2001-09-14 00:25:33 +00:00
Tim Peters 8fa45677c1 Now that file objects are subclassable, you can get at the file constructor
just by doing type(f) where f is any file object.  This left a hole in
restricted execution mode that rexec.py can't plug by itself (although it
can plug part of it; the rest is plugged in fileobject.c now).
2001-09-13 21:01:29 +00:00
Tim Peters 561f899d19 Use the keyword form of file() instead of open() to create TESTFN. 2001-09-13 19:36:36 +00:00
Tim Peters 808b94eb45 Added simple tests of keyword arguments in the basic type constructors. 2001-09-13 19:33:07 +00:00
Tim Peters 3f996e7266 type_call(): Change in policy. The keyword args (if any) are now passed
on to the tp_new slot (if non-NULL), as well as to the tp_init slot (if
any).  A sane type implementing both tp_new and tp_init should probably
pay attention to the arguments in only one of them.
2001-09-13 19:18:27 +00:00
Tim Peters 59c9a645e2 SF bug [#460467] file objects should be subclassable.
Preliminary support.  What's here works, but needs fine-tuning.
2001-09-13 05:38:56 +00:00
Tim Peters 4f467e8057 Added subclass equality tests. Almost all of these are commented out now,
because they don't work yet.
2001-09-12 19:53:15 +00:00
Tim Peters 2400fa4ad1 Again perhaps the end of [#460020] bug or feature: unicode() and subclasses.
Inhibited complex unary plus optimization when applied to a complex subtype.
Added PyComplex_CheckExact macro.  Some comments and minor code fiddling.
2001-09-12 19:12:49 +00:00
Tim Peters 111f60964e If interning an instance of a string subclass, intern a real string object
with the same value instead.  This ensures that a string (or string
subclass) object's ob_sinterned pointer is always a str (or NULL), and
that the dict of interned strings only has strs as keys.
2001-09-12 07:54:51 +00:00
Tim Peters af90b3e610 str_subtype_new, unicode_subtype_new:
+ These were leaving the hash fields at 0, which all string and unicode
  routines believe is a legitimate hash code.  As a result, hash() applied
  to str and unicode subclass instances always returned 0, which in turn
  confused dict operations, etc.
+ Changed local names "new"; no point to antagonizing C++ compilers.
2001-09-12 05:18:58 +00:00
Tim Peters 7a29bd5861 More on bug 460020: disable many optimizations of unicode subclasses. 2001-09-12 03:03:31 +00:00
Tim Peters 8fa5dd0601 More bug 460020: lots of string optimizations inhibited for string
subclasses, all "the usual" ones (slicing etc), plus replace, translate,
ljust, rjust, center and strip.  I don't know how to be sure they've all
been caught.

Question:  Should we complain if someone tries to intern an instance of
a string subclass?  I hate to slow any code on those paths.
2001-09-12 02:18:30 +00:00
Tim Peters 69c2de3ad6 More bug 460020. Disable a number of long optimizations for long subclasses. 2001-09-11 22:31:33 +00:00
Tim Peters 0280cf79a7 More bug 460020: when F is a subclass of float, disable the unary plus
optimization (+F(whatever)).
2001-09-11 21:53:35 +00:00
Tim Peters 73a1dfe367 More bug 460020. When I is a subclass of int, disable the +I(whatever),
I(0) << whatever, I(0) >> whatever, I(whatever) << 0 and I(whatever) >> 0
optimizations.
2001-09-11 21:44:14 +00:00
Tim Peters 7b07a41e9f The endless 460020 bug.
Disable t[:], t*0, t*1 optimizations when t is of a tuple subclass type.
2001-09-11 19:48:03 +00:00
Guido van Rossum f166994b83 Test for new hmac module. 2001-09-11 15:54:16 +00:00
Guido van Rossum dc795b82aa Fix the second reincarnation of SF #456395 -- failure on IRIX. This
time use .replace() to change all \r\n into \n, not just the last one.
2001-09-11 14:24:35 +00:00
Guido van Rossum 779ce4a73a Restore the comparisons that I initially put in the test but that Tim
XXX'ed out.  Turns out that after fixing the constructors, the
comparisons in fact succeed.  E.g. int(hexint(12345)) returns an int
with value 12345.
2001-09-11 14:02:22 +00:00
Tim Peters 78e0fc74bc Possibly the end of SF [#460020] bug or feature: unicode() and subclasses.
Changed unicode(i) to return a true Unicode object when i is an instance of
a unicode subclass.  Added PyUnicode_CheckExact macro.
2001-09-11 03:07:38 +00:00
Tim Peters c636f565b4 Added another test of str() applied to a string subclass instance,
involving embedded null bytes, since it's possible to screw that up w/o
screwing up cases w/o embedded nulls.
2001-09-11 01:52:02 +00:00
Tim Peters 5a49ade70e More on SF bug [#460020] bug or feature: unicode() and subclasses.
Repaired str(i) to return a genuine string when i is an instance of a str
subclass.  New PyString_CheckExact() macro.
2001-09-11 01:41:59 +00:00
Tim Peters 4c3a0a35cd More on SF bug [#460020] bug or feature: unicode() and subclasses.
tuple(i) repaired to return a true tuple when i is an instance of a
tuple subclass.
Added PyTuple_CheckExact macro.
PySequence_Tuple():  if a tuple-like object isn't exactly a tuple, it's
not safe to return the object as-is -- make a new tuple of it instead.
2001-09-10 23:37:46 +00:00
Tim Peters caaff8d95d test_dir(): Add tests for dir(i) where i is a module subclass. 2001-09-10 23:12:14 +00:00
Tim Peters 7a50f2536e More for SF bug [#460020] bug or feature: unicode() and subclasses
Repair float constructor to return a true float when passed a subclass
instance.  New PyFloat_CheckExact macro.
2001-09-10 21:28:20 +00:00
Tim Peters 64b5ce3a69 SF bug #460020: bug or feature: unicode() and subclasses.
Given an immutable type M, and an instance I of a subclass of M, the
constructor call M(I) was just returning I as-is; but it should return a
new instance of M.  This fixes it for M in {int, long}.  Strings, floats
and tuples remain to be done.
Added new macros PyInt_CheckExact and PyLong_CheckExact, to more easily
distinguish between "is" and "is a" (i.e., only an int passes
PyInt_CheckExact, while any sublass of int passes PyInt_Check).
Added private API function _PyLong_Copy.
2001-09-10 20:52:51 +00:00
Guido van Rossum f49dcea233 Remove two XXX comments that have been resolved. 2001-09-10 15:03:48 +00:00
Guido van Rossum a31ddbbd7b Move the global variables 'size' and 'name' to the top -- these are
"module parameters", and used in the Windows test (which crashed
because size was undefined -- sigh).
2001-09-10 15:03:18 +00:00
Guido van Rossum 47f40343b3 Change the criteria for skipping the test.
If on Windows, we require the 'largefile' resource.

If not on Windows, we use a test that actually writes a byte beyond
the 2BG limit -- seeking alone is not sufficient, since on some
systems (e.g. Linux with glibc 2.2) the sytem call interface supports
large seek offsets but not all filesystem implementations do.

Note that on Windows, we do not use the write test: on Win2K, that
test can take a minute trying to zero all those blocks on disk, and on
Windows our code always supports large seek offsets (but again, not
all filesystems do).  This may mean that on Win95, or on certain other
backward filesystems, test_largefile will *fail*.
2001-09-10 13:34:12 +00:00
Jeremy Hylton f649195560 Test the failed-unicode-decoding bug in PyArg_ParseTuple(). 2001-09-10 01:57:12 +00:00
Tim Peters bea3fb83a7 Repair late-night doc typos. 2001-09-10 01:39:21 +00:00
Tim Peters a0a6222509 Teach regrtest how to pass on doctest failure msgs. This is done via a
horridly inefficient hack in regrtest's Compare class, but it's about as
clean as can be:  regrtest has to set up the Compare instance before
importing a test module, and by the time the module *is* imported it's too
late to change that decision.  The good news is that the more tests we
convert to unittest and doctest, the less the inefficiency here matters.
Even now there are few tests with large expected-output files (the new
cost here is a Python-level call per .write() when there's an expected-
output file).
2001-09-09 06:12:01 +00:00
Tim Peters 90ba8d9c80 Force "test." into the start of the module name, inherited by class and
type reprs, to accomodate the way Jack runs tests on the Mac.
2001-09-09 01:21:31 +00:00
Tim Peters 16a77adfbd Generalize operator.indexOf (PySequence_Index) to work with any
iterable object.  I'm not sure how that got overlooked before!

Got rid of the internal _PySequence_IterContains, introduced a new
internal _PySequence_IterSearch, and rewrote all the iteration-based
"count of", "index of", and "is the object in it or not?" routines to
just call the new function.  I suppose it's slower this way, but the
code duplication was getting depressing.
2001-09-08 04:00:12 +00:00
Tim Peters 2d84f2c95a It appears that unittest was changed to stop hoarding raw exception data,
saving instead a traceback string, but test_support's run_unittest was
still peeking into unittest internals and trying to pick apart unittest's
errors and failures vectors as if they contained exc_info() tuples instead
of strings.
Whatever, when a unittest-based test failed, test_support blew up.  I'm
not sure this is the right way to fix it; it simply gets me unstuck.
2001-09-08 03:37:56 +00:00
Tim Peters 9652de9d82 Fix typo in error reporting. This doesn't need to go into the release
branch (if it ever gets to the typo, the test is failing anyway).
2001-09-07 00:47:00 +00:00
Tim Peters c5b235c59c Reverting to rev 1.2. Apparently gcc doesn't use the extended-precision
capabilities of the Pentium FPU, so what should have been (and were on
Windows) exact results got fuzzy.  Then it turns out test_support.fcmp()
isn't tolerant of tiny errors when *one* of the comparands is 0, but
test_complex's old check_close_real() is.  Rather than fix gcc <wink>,
easier to revert this test and revisit after the release.
2001-09-06 23:00:21 +00:00
Tim Peters 419670dc60 Rewrite to use test_support's fine fcmp instead -- I didn't know that
existed when I wrote this test.
2001-09-06 22:07:50 +00:00
Tim Peters 4bd810aaf2 Added some underflow-to-0.0 long/long true division tests. 2001-09-06 22:03:36 +00:00
Guido van Rossum 8bce4acb17 Rename 'getset' to 'property'. 2001-09-06 21:56:42 +00:00
Guido van Rossum fe3f6969f5 Two small changes to the resource usage option:
(1) Allow multiple -u options to extend each other (and the initial
    value of use_resources passed into regrtest.main()).

(2) When a test is run stand-alone (not via regrtest.py), needed
    resources are always granted.
2001-09-06 16:09:41 +00:00
Fred Drake ccc7562315 Added tests for key deletion for both Weak*Dictionary flavors.
This covers regression on SF bug #458860.
2001-09-06 14:52:39 +00:00
Guido van Rossum 7b219b4a92 Skip instead of fail this test if the socket module has no ssl
support.
2001-09-06 09:54:47 +00:00