Module inspect Bug

Discussion in 'Python' started by Tomas Zulberti, Oct 5, 2009.

  1. Hi. I have a class that extends collections.MutableMapping. I am
    checking if it is abstract, using the module inspect. But isabstract
    returns a number different from zero insted of True or False. The
    problem with that is that sometimes it returns False when the class
    isn't an abstract.

    >>> inspect.isabstract(collections.MutableMapping)

    1048576
    >>> inspect.isabstract(os)

    False

    Its true that the condition nevertheless will be True on the if, but
    the return value I think that should be boolean.

    Thanks,
    Tomas Zulberti

    pd: Sorry for my bad English...
     
    Tomas Zulberti, Oct 5, 2009
    #1
    1. Advertising

  2. En Mon, 05 Oct 2009 11:59:01 -0300, Tomas Zulberti <>
    escribió:

    > Hi. I have a class that extends collections.MutableMapping. I am
    > checking if it is abstract, using the module inspect. But isabstract
    > returns a number different from zero insted of True or False. The
    > problem with that is that sometimes it returns False when the class
    > isn't an abstract.
    >
    >>>> inspect.isabstract(collections.MutableMapping)

    > 1048576
    >>>> inspect.isabstract(os)

    > False
    >
    > Its true that the condition nevertheless will be True on the if, but
    > the return value I think that should be boolean.


    It would be nice if inspect.isabstract() returned True/False, but 1048576
    is as good as any other true value, ok? You should not rely on specific
    values, nor compare the result against True nor False directly.

    Anyway, given that no other isXXX function behaves that way, and
    inspect.isgeneratorfunction() uses a similar construct but always returns
    True/False, I've submitted a bug+patch: http://bugs.python.org/issue7069

    --
    Gabriel Genellina
     
    Gabriel Genellina, Oct 6, 2009
    #2
    1. Advertising

  3. On Oct 6, 1:36 am, "Gabriel Genellina" <> wrote:
    > En Mon, 05 Oct 2009 11:59:01 -0300, Tomas Zulberti <>  
    > escribió:
    >
    > > Hi. I have a class that extends collections.MutableMapping. I am
    > > checking if it is abstract, using the moduleinspect. But isabstract
    > > returns a number different from zero insted of True or False. The
    > > problem with that is that sometimes it returns False when the class
    > > isn't an abstract.

    >
    > >>>>inspect.isabstract(collections.MutableMapping)

    > > 1048576
    > >>>>inspect.isabstract(os)

    > > False

    >
    > > Its true that the condition nevertheless will be True on the if, but
    > > the return value I think that should be boolean.

    >
    > It would be nice ifinspect.isabstract() returned True/False, but 1048576  
    > is as good as any other true value, ok? You should not rely on specific  
    > values, nor compare the result against True nor False directly.
    >



    > Anyway, given that no other isXXX function behaves that way, and  inspect.isgeneratorfunction() uses a similar construct but always returns  
    > True/False, I've submitted a bug+patch:http://bugs.python.org/issue7069
    >


    Thanks for the help... I wasn't using that the returned value was a
    boolean, but the other methods returned a boolean, so I found that was
    strange...

    Thank you a lot,
    Tomas Zulberti
     
    Tomas Zulberti, Oct 6, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robin Becker

    bug in inspect (was cgitb vs traceback)

    Robin Becker, Jun 6, 2004, in forum: Python
    Replies:
    1
    Views:
    297
    Robin Becker
    Jun 6, 2004
  2. Fernando Perez

    Bug in inspect.py for python 2.3?

    Fernando Perez, Dec 17, 2004, in forum: Python
    Replies:
    2
    Views:
    296
    Fernando Perez
    Dec 18, 2004
  3. Stef Mientki

    Would this be called a bug in inspect ?

    Stef Mientki, Sep 30, 2008, in forum: Python
    Replies:
    0
    Views:
    234
    Stef Mientki
    Sep 30, 2008
  4. inhahe
    Replies:
    5
    Views:
    395
    Peter Decker
    Jan 2, 2010
  5. deluxstar
    Replies:
    5
    Views:
    868
    Terry Reedy
    Sep 25, 2010
Loading...

Share This Page