Skip to content

gh-128772: Fix - warnings.deprecated doesn't work well with pydoc#128781

Closed
srinivasreddy wants to merge 25 commits into
python:mainfrom
srinivasreddy:gh_128772
Closed

gh-128772: Fix - warnings.deprecated doesn't work well with pydoc#128781
srinivasreddy wants to merge 25 commits into
python:mainfrom
srinivasreddy:gh_128772

Conversation

@srinivasreddy

@srinivasreddy srinivasreddy commented Jan 13, 2025

Copy link
Copy Markdown
Contributor

@srinivasreddy srinivasreddy marked this pull request as ready for review January 15, 2025 14:04
@srinivasreddy srinivasreddy marked this pull request as draft January 15, 2025 14:07
@srinivasreddy srinivasreddy marked this pull request as ready for review January 16, 2025 09:38

@terryjreedy terryjreedy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new test for the change to the warnings module belongs in test.test_warnings.

Revert this change to the idlelib file. This idle test is strictly for testing that idle reverts its monkeypatching of warnings before it exits.

@bedevere-app

bedevere-app Bot commented Jan 16, 2025

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@terryjreedy

Copy link
Copy Markdown
Member

This probably should have a blurb and whoever merges may require one.

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to use exec()? Can the tests simply use local classes as other deprecated() tests? Is it necessary to create an instance of the deprecated class?

@srinivasreddy

srinivasreddy commented Jan 21, 2025

Copy link
Copy Markdown
Contributor Author
  1. bug occurs only when we run help(<module name>), in order to simulate separate module i have used exec. We cannot use classes in test cases because a class assumes __module__ of its containing test file. I am open to use other simpler approaches.
  2. For the first test case CODE_SIMPLE, yes it is required to create an instance. For the second it is not required.

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since test_warnings already has been converted to a package, and there is a subpackage data, it can be easy to add a file with deprecated classes.

I can reproduce the original issue without creating an instance of the class.

@Viicos

Viicos commented Jan 21, 2025

Copy link
Copy Markdown
Contributor

Alternatively, this can be fixed in pydoc, by accounting for methods without a __module__:

class A:
    def __new__(cls): pass

A.__new__.__module__ = None

# pydoc on A fails

warnings.deprecated just so happens to wrap object.__new__ which doesn't have a __module__, but the TypeError encountered in the issue can also happen in other cases.

… module and simplify the test that removes the need for exec function
@srinivasreddy

Copy link
Copy Markdown
Contributor Author

@serhiy-storchaka Done. Pls review again

@serhiy-storchaka

Copy link
Copy Markdown
Member

Alternatively, this can be fixed in pydoc, by accounting for methods without a __module__:

You are right. This is a more correct way to fix this issue.

See #129177.

@srinivasreddy

Copy link
Copy Markdown
Contributor Author

@serhiy-storchaka Nice. Can we close this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants