From: Benjamin Peterson Date: Thu, 8 Mar 2012 00:52:52 +0000 (-0600) Subject: merge 3.2 (#3787e896dbe9) X-Git-Tag: v3.3.0a2~264 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9a6338651eb2f474661602a81ee42958fd42d5d4;p=thirdparty%2FPython%2Fcpython.git merge 3.2 (#3787e896dbe9) --- 9a6338651eb2f474661602a81ee42958fd42d5d4 diff --cc Lib/test/test_descr.py index d64af69dbfb2,4aeb77fd0f20..45fd05dd4bad --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@@ -4436,55 -4429,21 +4436,70 @@@ order (MRO) for bases "" foo = Foo() str(foo) + def test_slot_shadows_class_variable(self): + with self.assertRaises(ValueError) as cm: + class X: + __slots__ = ["foo"] + foo = None + m = str(cm.exception) + self.assertEqual("'foo' in __slots__ conflicts with class variable", m) + + def test_set_doc(self): + class X: + "elephant" + X.__doc__ = "banana" + self.assertEqual(X.__doc__, "banana") + with self.assertRaises(TypeError) as cm: + type(list).__dict__["__doc__"].__set__(list, "blah") + self.assertIn("can't set list.__doc__", str(cm.exception)) + with self.assertRaises(TypeError) as cm: + type(X).__dict__["__doc__"].__delete__(X) + self.assertIn("can't delete X.__doc__", str(cm.exception)) + self.assertEqual(X.__doc__, "banana") + + def test_qualname(self): + descriptors = [str.lower, complex.real, float.real, int.__add__] + types = ['method', 'member', 'getset', 'wrapper'] + + # make sure we have an example of each type of descriptor + for d, n in zip(descriptors, types): + self.assertEqual(type(d).__name__, n + '_descriptor') + + for d in descriptors: + qualname = d.__objclass__.__qualname__ + '.' + d.__name__ + self.assertEqual(d.__qualname__, qualname) + + self.assertEqual(str.lower.__qualname__, 'str.lower') + self.assertEqual(complex.real.__qualname__, 'complex.real') + self.assertEqual(float.real.__qualname__, 'float.real') + self.assertEqual(int.__add__.__qualname__, 'int.__add__') + + def test_qualname_dict(self): + ns = {'__qualname__': 'some.name'} + tp = type('Foo', (), ns) + self.assertEqual(tp.__qualname__, 'some.name') + self.assertEqual(tp.__dict__['__qualname__'], 'some.name') + self.assertEqual(ns, {'__qualname__': 'some.name'}) + + ns = {'__qualname__': 1} + self.assertRaises(TypeError, type, 'Foo', (), ns) + + def test_cycle_through_dict(self): + # See bug #1469629 + class X(dict): + def __init__(self): + dict.__init__(self) + self.__dict__ = self + x = X() + x.attr = 42 + wr = weakref.ref(x) + del x + support.gc_collect() + self.assertIsNone(wr()) + for o in gc.get_objects(): + self.assertIsNot(type(o), X) + + class DictProxyTests(unittest.TestCase): def setUp(self): class C(object): diff --cc Misc/NEWS index a8769afe9db9,119dfd71bfb7..451b803b671d --- a/Misc/NEWS +++ b/Misc/NEWS @@@ -10,41 -10,9 +10,44 @@@ What's New in Python 3.3.0 Alpha 2 Core and Builtins ----------------- + - Issue #1469629: Allow cycles through an object's __dict__ slot to be + collected. (For example if ``x.__dict__ is x``). + +- Issue #14205: dict lookup raises a RuntimeError if the dict is modified + during a lookup. + +- Issue #14220: When a generator is delegating to another iterator with the + yield from syntax, it needs to have its ``gi_running`` flag set to True. + +Library +------- + +- Issue #14168: Check for presence of Element._attrs in minidom before + accessing it. + +- Issue #12328: Fix multiprocessing's use of overlapped I/O on Windows. + Also, add a multiprocessing.connection.wait(rlist, timeout=None) function + for polling multiple objects at once. Patch by sbt. + +- Issue #14007: Accept incomplete TreeBuilder objects (missing start, end, + data or close method) for the Python implementation as well. + Drop the no-op TreeBuilder().xml() method from the C implementation. + +Extension Modules +----------------- + +- Issue #14212: The re module didn't retain a reference to buffers it was + scanning, resulting in segfaults. + + +What's New in Python 3.3.0 Alpha 1? +=================================== + +*Release date: 05-Mar-2012* + +Core and Builtins +----------------- + - Issue #14172: Fix reference leak when marshalling a buffer-like object (other than a bytes object).