[PATCH RFC] batching: new module to support batching of commands

Patrick Mézard pmezard at gmail.com
Thu Jun 2 14:02:30 CDT 2011


Le 02/06/11 20:46, Matt Mackall a écrit :
> On Thu, 2011-06-02 at 13:13 -0500, Augie Fackler wrote:
>>>>> +class batch:
>>>>
>>>> Inherit from object. We should probably make check-code complain about
>>>> using old-style classes.
>>>
>>> In 2.7:
>>>
>>>>>> class foo:
>>> ...  pass
>>> ...
>>>>>> isinstance(foo(), object)
>>> True
>>>
>>> ISTR this changed a while ago, perhaps as long ago as 2.4, but I can't
>>> find the doc right now and don't have 2.4 handy to test.
>>
>> Just found a 2.4 install, same result. So maybe it was fixed in 2.4?
> 
> $ python2.7
> Python 2.7.1+ (default, Apr 20 2011, 10:53:33) 
> [GCC 4.5.2] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> class foo: pass
> ... 
>>>> class bar(object): pass
> ... 
>>>> foo()
> <__main__.foo instance at 0x7f55512925f0>
>>>> bar()
> <__main__.bar object at 0x7f555128abd0>
>>>>
>>>> type(foo())
> <type 'instance'>
>>>> type(bar())
> <class '__main__.bar'>
>>>> isinstance(foo, object)
> True
>>>> isinstance(bar, object)
> True
>>>>
> 
> Seems isinstance is lying.

Yes, isinstance() is weird:

Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) 
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> class foo:
...     pass
... 
>>> class foo2(object):
...     pass
... 
>>> issubclass(foo, object)
False
>>> issubclass(foo2, object)
True

--
Patrick Mézard


More information about the Mercurial-devel mailing list