Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doctest confused by super-instances in class-dicts #39977

Closed
tanzer mannequin opened this issue Feb 23, 2004 · 4 comments
Closed

doctest confused by super-instances in class-dicts #39977

tanzer mannequin opened this issue Feb 23, 2004 · 4 comments
Assignees
Labels
stdlib Python modules in the Lib dir

Comments

@tanzer
Copy link
Mannequin

tanzer mannequin commented Feb 23, 2004

BPO 902628
Nosy @tim-one
Files
  • confuse_doctest.py
  • doctest_patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/tim-one'
    closed_at = <Date 2004-08-08.06:14:16.000>
    created_at = <Date 2004-02-23.12:10:08.000>
    labels = ['library']
    title = 'doctest confused by super-instances in class-dicts'
    updated_at = <Date 2004-08-08.06:14:16.000>
    user = 'https://bugs.python.org/tanzer'

    bugs.python.org fields:

    activity = <Date 2004-08-08.06:14:16.000>
    actor = 'tim.peters'
    assignee = 'tim.peters'
    closed = True
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2004-02-23.12:10:08.000>
    creator = 'tanzer'
    dependencies = []
    files = ['1218', '1219']
    hgrepos = []
    issue_num = 902628
    keywords = []
    message_count = 4.0
    messages = ['20120', '20121', '20122', '20123']
    nosy_count = 3.0
    nosy_names = ['tim.peters', 'edloper', 'tanzer']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue902628'
    versions = ['Python 2.4']

    @tanzer
    Copy link
    Mannequin Author

    tanzer mannequin commented Feb 23, 2004

    In Python 2.3.3, doctest chokes on classes which
    contain an attribute of type super:

    Traceback (most recent call last):
      File "/ttt/private/tanzer/temp/confuse_doctest.py",
    line 14, in ?
        import doctest, confuse_doctest
      File
    "/Node/tttprime/ttt/private/tanzer/temp/confuse_doctest.py",
    line 15, in ?
        doctest.testmod(confuse_doctest)
      File "/usr/lib/python2.3/doctest.py", line 1148, in
    testmod
        f, t = tester.rundict(m.__dict__, name, m)
      File "/usr/lib/python2.3/doctest.py", line 908, in
    rundict
        f2, t2 = self.__runone(value, name + "." + thisname)
      File "/usr/lib/python2.3/doctest.py", line 1069, in
    __runone
        return self.rundoc(target, name)
      File "/usr/lib/python2.3/doctest.py", line 828, in rundoc
        f2, t2 = self.run__test__(d, name)
      File "/usr/lib/python2.3/doctest.py", line 937, in
    run__test__
        raise TypeError("Tester.run__test__: values in "
    TypeError: Tester.run__test__: values in dict must be
    strings, functions, methods, or classes; <super: <class
    'A'>, NULL>

    A simple example triggering the bug is attached.

    Python 2.3.3 (#2, Jan 13 2004, 00:47:05)
    [GCC 3.3.3 20040110 (prerelease) (Debian)] on linux2

    @tanzer tanzer mannequin closed this as completed Feb 23, 2004
    @tanzer tanzer mannequin assigned tim-one Feb 23, 2004
    @tanzer tanzer mannequin added the stdlib Python modules in the Lib dir label Feb 23, 2004
    @tanzer tanzer mannequin closed this as completed Feb 23, 2004
    @tanzer tanzer mannequin assigned tim-one Feb 23, 2004
    @tanzer tanzer mannequin added the stdlib Python modules in the Lib dir label Feb 23, 2004
    @tanzer
    Copy link
    Mannequin Author

    tanzer mannequin commented Feb 23, 2004

    Logged In: YES
    user_id=2402

    I patched doctest.py to avoid the traceback (see attached
    patch-file). I'm not sure if this is the right place to fix
    the bug, though. Maybe inspect.classify_class_attrs should
    be changed instead?

    The second chunk of the patch improves the traceback given
    by doctest by giving the name of the offending dict-item.

    @edloper
    Copy link
    Mannequin

    edloper mannequin commented Jul 16, 2004

    Logged In: YES
    user_id=195958

    The problem is that inspect.get_class_attrs()'s "method"
    classification is a bit hetergeneous: it contains methods,
    and any method descriptors *except* classmethod and
    staticmethod. The proposed patch will fix behavior for
    super(), but not for any other method descriptors. So
    perhaps it would be better to explicitly test "_isfunction(v)
    or _ismethod(v)" rather than "not isinstance(value,
    super)".

    @tim-one
    Copy link
    Member

    tim-one commented Aug 8, 2004

    Logged In: YES
    user_id=31435

    This got fixed as part of the massive doctest refactoring for
    2.4. I have no plan to backport any of that to the 2.3 line.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant