Skip to content

types._cell_factory is exposed, unlike other helpers #96415

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

Closed
sobolevn opened this issue Aug 30, 2022 · 0 comments
Closed

types._cell_factory is exposed, unlike other helpers #96415

sobolevn opened this issue Aug 30, 2022 · 0 comments
Assignees
Labels
type-bug An unexpected behavior, bug, or error

Comments

@sobolevn
Copy link
Member

types.py module has different helpers to get their types, like async def _c(): pass to get coroutine type or def _g(): yield 1 to get generator type, etc.

It has has these line to get CellType:

cpython/Lib/types.py

Lines 18 to 23 in 9625de6

def _cell_factory():
a = 1
def f():
nonlocal a
return f.__closure__[0]
CellType = type(_cell_factory())

Afterward, all helpers are deleted, except _cell_factory, which I think should be fixed. It is not good to expose such implementation details.

And this line agrees with me:

del sys, _f, _g, _C, _c, _ag # Not for export

Related:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant