-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
gh-142624: Make test_inspect's _pickle requirement optional #142625
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
base: main
Are you sure you want to change the base?
Conversation
| try: | ||
| import _pickle | ||
| MISSING_C_PICKLE = False | ||
| except ImportError: | ||
| MISSING_C_PICKLE = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| try: | |
| import _pickle | |
| MISSING_C_PICKLE = False | |
| except ImportError: | |
| MISSING_C_PICKLE = True | |
| try: | |
| import _pickle | |
| except ImportError: | |
| _pickle = None |
This pattern is used more often in tests, as shown in the line below, it removes the need for a variable and makes the codebase more consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this, use @unittest.skipUnless(_pickle, "requires _pickle module") as the test decorator.
Or to pick a different pattern in use in this module, use _pickle = import_helper.import_module('_pickle') in the test (see some examples that use _testcapi).
As another option, is there a particular reason to use _pickle? Can/should something from _testcapi be used instead?
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can simply use other builtin, e.g. list.append. But you need to find also a method with flag METH_METHOD.
|
I applied the review about |
Uh oh!
There was an error while loading. Please reload this page.