Commit Graph

183 Commits

Author SHA1 Message Date
Guido van Rossum 298e421453 SF patch #685738 by Michael Stone.
This changes the default __new__ to refuse arguments iff tp_init is the
default __init__ implementation -- thus making it a TypeError when you
try to pass arguments to a constructor if the class doesn't override at
least __init__ or __new__.
2003-02-13 16:30:16 +00:00
Guido van Rossum a89d10edc9 Implement another useful feature for proxies: in super(X, x), x may
now be a proxy for an X instance, as long as issubclass(x.__class__, X).
2003-02-12 03:58:38 +00:00
Guido van Rossum 03bc7d3c4d SF #532767: isinstance(x, X) should work when x is a proxy for an X
instance, as long as x.__class__ is X or a subclass thereof.
Did a little cleanup of PyObject_IsInstance() too.
2003-02-12 03:32:58 +00:00
Guido van Rossum b6e5a0c658 Put proper tests in classmethod_get(). Remove the type argument to
descr_check(); it wasn't useful.  Change the type argument of the
various _get() methods to PyObject * because the call signature of
tp_descr_get doesn't guarantee its type.
2003-02-11 18:44:42 +00:00
Guido van Rossum 3f50cdc05e Get rid of the "bozo" __getstate__ that was inserted when __slots__
was used.  This simplifies some logic in copy_reg.py (used by
pickling).  It also broke a test, but this was rewritten to test the
new feature. :-)
2003-02-10 21:31:27 +00:00
Neal Norwitz de8b94c3e1 Fix SF bug #683467, 'int' ability to generate longs not inherited
When subclassing from an int but not overriding __new__,
long values were not converted properly.  Try to convert
longs into an int.
2003-02-10 02:12:43 +00:00
Guido van Rossum f631859409 Add __getnewargs__ method to classes that need it.
(Yes, this is an incompatibility.  I'll document it in PEP 307.)
2003-02-07 14:59:13 +00:00
Neal Norwitz 1a9975014f Fix SF bug #667147, Segmentation fault printing str subclass
Fix infinite recursion which occurred when printing an object
whose __str__() returned self.

Will backport
2003-01-13 20:13:12 +00:00
Guido van Rossum 373c7412f2 Fix for SF bug #642358: only provide a new with a __dict__ or
__weaklist__ descriptor if we added __dict__ or __weaklist__,
respectively.  With unit test.
2003-01-07 13:41:37 +00:00
Guido van Rossum 613f24fd73 Add a test for a feature added in rev. 2.82 of typeobject.c:
- SLOT1BINFULL() macro: changed this to check for __rop__ overriding
  __op__, like binary_op1() in abstract.c -- the latter only calls the
  slot function once if both types use the same slot function, so the
  slot function must make both calls -- which it already did for the
  __op__, __rop__ order, but not yet for the __rop__, __op__ order
  when B.__class__ is a subclass of A.__class__.

Also test the refinement added in rev. 2.201 that fixes the problem
reported in SF bug #623669.

Also test a similar provision in abstract.c's binary_op1().
2003-01-06 23:00:59 +00:00
Guido van Rossum 2720b0dff8 Add some print statements in verbose mode to announce that the newest
tests are run.  (All tests in this module should have one of these at
the top.)
2003-01-06 21:26:44 +00:00
Guido van Rossum 4f37418d02 Disable the rexec test now that rexec is out of grace. 2003-01-06 16:03:43 +00:00
Tim Peters 6578dc925f Whitespace normalization. 2002-12-24 18:31:27 +00:00
Neal Norwitz 78ce6b10ed Add test for SF #658106. Will backport. 2002-12-24 15:26:42 +00:00
Guido van Rossum 3bbc0eea10 Tighten the tests for assignment to __bases__: disallow empty tuple. 2002-12-13 17:49:38 +00:00
Tim Peters bca1cbc6f8 SF 548651: Fix the METH_CLASS implementation.
Most of these patches are from Thomas Heller, with long lines folded
by Tim.  The change to test_descr.py is from Guido.  See the bug report.

Not a bugfix candidate -- METH_CLASS is new in 2.3.
2002-12-09 22:56:13 +00:00
Michael W. Hudson ade8c8b2c3 Nudge getting __module__ and __name__ for new-style classes so that
the results of *setting* __name__ are not so surprising.

If people can suggest more tests, that'd be grand, or is what's there
sufficient?
2002-11-27 16:29:26 +00:00
Michael W. Hudson 7e7c00db0c I don't know why staring at the email to python-checkins made me
see problems with my code that I didn't see before the checkin, but:

When a subtype .mro() fails, we need to reset the type whose __bases__
are being changed, too.  Fix + test.
2002-11-27 15:40:09 +00:00
Michael W. Hudson 586da8fddd Readjustments to the way we cope with exceptions from subclasses'
mro() methods.  Now any exception aborts the whole __bases__ change.

And more tests.
2002-11-27 15:20:19 +00:00
Michael W. Hudson caf17be1b7 I had the inheritance cycle stuff backwards. Oops! 2002-11-27 10:24:44 +00:00
Guido van Rossum a01fa26396 The MRO conflict error message depends on dictionary hash order.
Avoid depending on this in the test.
2002-11-27 04:00:59 +00:00
Michael W. Hudson 98bbc49c54 This is my patch:
[ 635933 ] make some type attrs writable

Plus a couple of extra tests beyond what's up there.

It hasn't been as carefully reviewed as it perhaps should, so all readers
are encouraged, nay exhorted, to give this a close reading.

There are still a couple of oddities related to assigning to __name__,
but I intend to solicit python-dev's opinions on these.
2002-11-26 14:47:27 +00:00
Guido van Rossum d32047f038 A tweaked version of Jeremy's patch #642489, to produce better error
messages about MRO conflicts.  (Tweaks here: don't print the message,
but compare it with an expected string.)
2002-11-25 21:38:52 +00:00
Neal Norwitz ca2953ea5c Remove duplicate test 2002-11-23 16:57:00 +00:00
Just van Rossum a797d8150d Patch #642500 with slight modifications: allow keyword arguments in
dict() constructor. Example:
  >>> dict(a=1, b=2)
  {'a': 1, 'b': 2}
  >>>
2002-11-23 09:45:04 +00:00
Guido van Rossum 9a81892100 Fix or disable some tests that were affected by the new C3 MRO
algorithm, and add some new tests for the C3 algorithm.
2002-11-14 19:50:14 +00:00
Neal Norwitz 673cd824ba Fix SF # 624982, Potential AV in slot_sq_item, by Greg Chapman
Don't crash when getting value of a property raises an exception
2002-10-18 16:33:13 +00:00
Guido van Rossum 6e5680fc83 For some reason (probably cut and paste), __ipow__ for new-style
classes was called with three arguments.  This makes no sense, there's
no way to pass in the "modulo" 3rd argument as for __pow__, and
classic classes don't do this.  [SF bug 620179]

I don't want to backport this to 2.2.2, because it could break
existing code that has developed a work-around.  Code in 2.2.2 that
wants to use __ipow__ and wants to be forward compatible with 2.3
should be written like this:

  def __ipow__(self, exponent, modulo=None):
      ...
2002-10-15 01:01:53 +00:00
Guido van Rossum 8b1a6d694f Code by Inyeol Lee, submitted to SF bug 595350, to implement
the string/unicode method .replace() with a zero-lengt first argument.
Inyeol contributed tests for this too.
2002-08-23 18:21:28 +00:00
Guido van Rossum 8b056da6c8 Add tests for including __dict__ and/or __weakref__ in __slots__.
Add some more rigor to slotmultipleinheritance().
2002-08-13 18:26:26 +00:00
Neal Norwitz f9dd0f1924 Add test for SF bug # 575229, multiple inheritance w/ slots dumps core
Fix already checked in by Guido
2002-08-13 17:16:49 +00:00
Guido van Rossum 40af889081 Disallow class assignment completely unless both old and new are heap
types.  This prevents nonsense like 2.__class__ = bool or
True.__class__ = int.
2002-08-10 05:42:07 +00:00
Guido van Rossum 0f5f0b8057 Test for Neil's fix to correctly invoke __rmul__. 2002-08-09 16:11:37 +00:00
Guido van Rossum 2d702465b3 Add testcase for SF bug 574207 (chained __slots__ dealloc segfault).
Fix forthcoming.
2002-08-06 21:28:28 +00:00
Guido van Rossum 0dbab4c560 SF patch 588728 (Nathan Srebro).
The __delete__ method wrapper for descriptors was not supported

(I added a test, too.)

2.2 bugfix candidate.
2002-08-01 14:39:25 +00:00
Barry Warsaw 04f357cffe Get rid of relative imports in all unittests. Now anything that
imports e.g. test_support must do so using an absolute package name
such as "import test.test_support" or "from test import test_support".

This also updates the README in Lib/test, and gets rid of the
duplicate data dirctory in Lib/test/data (replaced by
Lib/email/test/data).

Now Tim and Jack can have at it. :)
2002-07-23 19:04:11 +00:00
Tim Peters 72351b9649 subtype_resurrection(): Removed unused import. 2002-07-11 18:39:56 +00:00
Tim Peters 14cb1e1eff subtype_resurrection(): The test suite with -l properly reported the
immortal object here as a leak.  Made the object mortal again at the end.
2002-07-11 18:26:21 +00:00
Tim Peters 45228ca827 Repaired optimistic comment in new test. 2002-07-11 07:09:42 +00:00
Tim Peters 2484aaea15 Added a test that provokes the hypothesized (in my last checkin comment)
debug-build failure when an instance of a new-style class is resurrected
by a __del__ method -- we simply never had any code that tried this.

This is already fixed in 2.3 CVS.  In 2.2.1, it blows up via

    Fatal Python error: GC object already in linked list

I'll fix it in 2.2.1 CVS next.
2002-07-11 06:56:07 +00:00
Raymond Hettinger ab5dae35ca Fix SF bug 572567: Memory leak in object comparison. 2002-06-24 13:08:16 +00:00
Raymond Hettinger 0ae0c07661 SF 569257 -- Name mangle double underscored variable names in __slots__. 2002-06-20 22:23:15 +00:00
Guido van Rossum a96b0df624 Patch from SF bug 570483 (Tim Northover).
In a fresh interpreter, type.mro(tuple) would segfault, because
PyType_Ready() isn't called for tuple yet.  To fix, call
PyType_Ready(type) if type->tp_dict is NULL.
2002-06-18 16:49:45 +00:00
Guido van Rossum e7f3e24eeb Test for the bug in recurse_down_subclasses() that I just fixed. 2002-06-14 02:35:45 +00:00
Guido van Rossum 09638c16d8 Hopefully this addresses the remaining issues of SF bugs 459235 and
473985.  Through a subtle rearrangement of some members in the etype
struct (!), mapping methods are now preferred over sequence methods,
which is necessary to support str.__getitem__("hello", slice(4)) etc.
2002-06-13 19:17:46 +00:00
Guido van Rossum a48cb8f77d Fix from SF patch 565085: copy._reduction doesn't __setstate__.
Straightforward fix.  Will backport to 2.2.  If there's ever a new 2.1
release, this could be backported there too (since it's an issue with
anything that's got both a __reduce__ and a __setstate__).
2002-06-06 17:53:03 +00:00
Guido van Rossum 9923ffe2c0 Address SF bug 519621: slots weren't traversed by GC.
While I was at it, I added a tp_clear handler and changed the
tp_dealloc handler to use the clear_slots helper for the tp_clear
handler.

Also tightened the rules for slot names: they must now be proper
identifiers (ignoring the dirty little fact that <ctype.h> is locale
sensitive).

Also set mp->flags = READONLY for the __weakref__ pseudo-slot.

Most of this is a 2.2 bugfix candidate; I'll apply it there myself.
2002-06-04 19:52:53 +00:00
Guido van Rossum 1bdd9b033a Test repair now that module.__init__ requires a name and initializes
__name__ and __doc__.
2002-06-04 06:10:37 +00:00
Guido van Rossum 155a34d2e5 The warning filter was ineffective when this module was invoked as a
script.
2002-06-03 19:45:32 +00:00
Guido van Rossum 9fc8a29663 Fix for SF bug 551412. When _PyType_Lookup() is called on a type
whose tp_mro hasn't been initialized, it would dump core.  Fix this by
checking for NULL and calling PyType_Ready().  Will fix this in 2.2.1
too.
2002-05-24 21:40:08 +00:00