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

@cached_property is not checked for doctests #107995

Closed
2 tasks done
tjsmart opened this issue Aug 16, 2023 · 1 comment
Closed
2 tasks done

@cached_property is not checked for doctests #107995

tjsmart opened this issue Aug 16, 2023 · 1 comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@tjsmart
Copy link
Contributor

tjsmart commented Aug 16, 2023

Checklist

  • I am confident this is a bug in CPython, not a bug in a third-party project
  • I have searched the CPython issue tracker,
    and am confident this bug has not been reported before

CPython versions tested on:

3.10, CPython main branch

Operating systems tested on:

Linux

Output from running 'python -VV' on the command line:

Python 3.13.0a0 (heads/main:607f18c894, Aug 15 2023, 08:58:26) [GCC 11.4.0]

A clear and concise description of the bug:

Doctests belonging to a functools.cached_property are not ran by doctest.

Here is a minimal example (saved in a file t.py):

from functools import cached_property


class Foo:
    @cached_property
    def my_cached_property(self):
        """
        >>> assert False
        """
        return 1

If I then invoke doctest with this file, I'd expect to see an assertion error. Instead, this doctest is skipped:

$ python -m doctest t.py  # no failing output due to assertion error
$ echo $?  # zero exit code
0

Note, this issue was originally reported here: pytest-dev/pytest#11237.

Linked PRs

@tjsmart tjsmart added the type-bug An unexpected behavior, bug, or error label Aug 16, 2023
tjsmart added a commit to tjsmart/cpython that referenced this issue Aug 16, 2023
tjsmart added a commit to tjsmart/cpython that referenced this issue Aug 16, 2023
@AlexWaygood AlexWaygood added the stdlib Python modules in the Lib dir label Aug 16, 2023
tjsmart added a commit to tjsmart/cpython that referenced this issue Aug 18, 2023
tjsmart added a commit to tjsmart/cpython that referenced this issue Aug 18, 2023
AlexWaygood added a commit that referenced this issue Aug 18, 2023
#107996)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@AlexWaygood
Copy link
Member

Thanks for the bug report, and for the fix, @tjsmart!

Although the fix is very simple, and although I can't think of ways in which it might break people's code, it's the kind of thing that could have unexpected consequences. For that reason, I think we won't be backporting this fix, unfortunately -- you'll have to wait for Python 3.13 to see the fix. As such, I'm closing this issue out.

Thanks again for the PR!

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 type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants