Commit Graph

1417 Commits

Author SHA1 Message Date
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