Skip to content
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

pyclbr module needs to be more flexible on loader support #70771

Open
ericsnowcurrently opened this issue Mar 17, 2016 · 1 comment
Open

pyclbr module needs to be more flexible on loader support #70771

ericsnowcurrently opened this issue Mar 17, 2016 · 1 comment
Labels
stdlib Python modules in the Lib dir topic-importlib type-bug An unexpected behavior, bug, or error

Comments

@ericsnowcurrently
Copy link
Member

BPO 26584
Nosy @terryjreedy, @ncoghlan, @ericsnowcurrently, @isidentical

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2016-03-17.18:20:00.045>
labels = ['type-bug', 'library']
title = 'pyclbr module needs to be more flexible on loader support'
updated_at = <Date 2020-11-05.00:38:28.143>
user = 'https://github.com/ericsnowcurrently'

bugs.python.org fields:

activity = <Date 2020-11-05.00:38:28.143>
actor = 'BTaskaya'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2016-03-17.18:20:00.045>
creator = 'eric.snow'
dependencies = []
files = []
hgrepos = []
issue_num = 26584
keywords = []
message_count = 1.0
messages = ['261924']
nosy_count = 4.0
nosy_names = ['terry.reedy', 'ncoghlan', 'eric.snow', 'BTaskaya']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'test needed'
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue26584'
versions = ['Python 3.6']

@ericsnowcurrently
Copy link
Member Author

(see bpo-26569)

The pyclbr module is showing its age (born 1995). It assumes there are only 2 module types (builtin and source-based), particularly in readmodule() and readmodule_ex(). Really it should be source-based and "everything else".

For instance, it does not handle namespace packages correctly, since the spec.loader is set to None there. It also doesn't handle frozen modules (e.g. "./python Lib/pyclbr.py _frozen_importlib"). This is likewise a problem for other/custom loaders that don't match the expectations of pyclbr.

Here are some things that should be done:

  • replace custom introspection code with newer tools like importlib.util.module_from_spec()
  • special-case namespace modules (since their spec.loader is None); this is probably a moot point if module_from_spec() gets used
  • ignore more than just builtins; explicitly check for importlib.abc.SourceLoader?
  • make use of similar tools in the inspect module?

@ericsnowcurrently ericsnowcurrently added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Mar 17, 2016
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir topic-importlib type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants