Skip to content

Conversation

@youknowone
Copy link
Contributor

@youknowone youknowone commented Dec 12, 2025

@bedevere-app bedevere-app bot added the tests Tests in the Lib/test dir label Dec 12, 2025
@aisk aisk added the skip news label Dec 12, 2025
Comment on lines +31 to +35
try:
import _pickle
MISSING_C_PICKLE = False
except ImportError:
MISSING_C_PICKLE = True
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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.

Copy link
Member

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?

@zware zware changed the title GH-142624 Make test_inspect's _pickle requirements optional gh-142624: Make test_inspect's _pickle requirement optional Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants