Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > > Can anybody suggest where to find (within the standard library) or how > > to easily make (e.g. in a C extension) a type without a __mro__, except ^^^^^^ > > for those (such as types.InstanceType) which are explicitly recorded in > > the dispatch table copy._deepcopy_dispatch...? > > something like this? > > >>> import re > >>> x = re.compile("") > >>> x > <_sre.SRE_Pattern object at 0x00B2F7A0> > >>> x.__mro__ > Traceback (most recent call last): > File "<stdin>", line 1, in ? > AttributeError: __mro__
Alas, no -- wish it were so easy! It does need to be a TYPE, not just any object, to reproduce the bug that was reported about 2.3.5c1's copy.py. The relevant code in copy.py does the equivalent of: >>> type(x).__mro__ (<type '_sre.SRE_Pattern'>, <type 'object'>) >>> not of just x.__mro__, which would easily be made to fail. How a type(whatever) can end up without a __mro__ in 2.3.* is rather murky to me; looks like something strange must be happening wrt the type's flags, or something. Normal types such as _sre.SRE_Pattern, or the Copyable type I put in _testcapi, just sprout an __mro__ without even trying. Ah well, thanks anyway -- guess I'll commit the fix (using inspect.getmro(cls) rather than cls.__mro__) even though I don't have a unit test to show it's necessary and sufficient:-( Alex -- http://mail.python.org/mailman/listinfo/python-list