gh-132775: Add _PyFunction_GetXIData() (gh-133481)

This commit is contained in:
Eric Snow 2025-05-12 16:10:56 -06:00 committed by GitHub
parent 121ed71f4e
commit 8cf4947b0f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 103 additions and 0 deletions

View file

@ -758,6 +758,40 @@ class CodeTests(_GetXIDataTests):
])
class ShareableFuncTests(_GetXIDataTests):
MODE = 'func'
def test_stateless(self):
self.assert_roundtrip_not_equal([
*defs.STATELESS_FUNCTIONS,
# Generators can be stateless too.
*defs.FUNCTION_LIKE,
])
def test_not_stateless(self):
self.assert_not_shareable([
*(f for f in defs.FUNCTIONS
if f not in defs.STATELESS_FUNCTIONS),
])
def test_other_objects(self):
self.assert_not_shareable([
None,
True,
False,
Ellipsis,
NotImplemented,
9999,
'spam',
b'spam',
(),
[],
{},
object(),
])
class PureShareableScriptTests(_GetXIDataTests):
MODE = 'script-pure'