merge 3.2 (#3787e896dbe9)
authorBenjamin Peterson <benjamin@python.org>
Thu, 8 Mar 2012 00:52:52 +0000 (18:52 -0600)
committerBenjamin Peterson <benjamin@python.org>
Thu, 8 Mar 2012 00:52:52 +0000 (18:52 -0600)
1  2 
Lib/test/test_descr.py
Misc/NEWS
Objects/typeobject.c

index d64af69dbfb2393bc0eae7b8c9ad32619f1218db,4aeb77fd0f202a2bb80c42e8907c710adca39725..45fd05dd4badbb4fca5e7e8a1efd9f80e4fbb225
@@@ -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 a8769afe9db9853bd2b07c45ac9ccdeadcf0e593,119dfd71bfb7bcd955f5a6a39aceb86991cb8605..451b803b671d8e941cea1d573785612d28f7e01e
+++ 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).
  
Simple merge