New submission from Benjamin Mintz :
unzip the attached zip file and run main.py
expected output:
True
actual output:
False
So what?
If you follow these directions,
https://docs.python.org/3.7/library/importlib.html#checking-if-a-module-can-be-imported
, you will put a stale reference
Benjamin Mintz added the comment:
Updated main.py.
New expected output:
True
New actual output:
==
False
Traceback (most recent call last):
File "main.py", line 14, in
print(module.sub)
AttributeError: module 'testext' h
Benjamin Mintz added the comment:
Updated. Also removed some old code which had irrelevant imports that I thought
I removed already. The expected and actual output remain the same.
--
Added file:
https://bugs.python.org/file48463/importlib-util-module-from-spec-stale-reference.zip
Benjamin Mintz added the comment:
Hmm, why is the assignment to sys.modules necessary at all, if
module_from_spec() always does so?
--
___
Python tracker
<https://bugs.python.org/issue37
Benjamin Mintz added the comment:
I dunno, one of those three does. I suppose it's spec.loader.exec_module().
--
___
Python tracker
<https://bugs.python.org/is
Benjamin Mintz added the comment:
```
name = 'testext'
spec = importlib.util.find_spec(name)
print(name in sys.modules)
module = importlib.util.module_from_spec(spec)
print(name in sys.modules)
spec.loader.exec_module(module)
print(name in sys.modules)
```
This prints False, F
New submission from Benjamin Mintz :
Adds inspect.getsubclasses, inspect.getallsubclasses (recursive), and
inspect.getsubclasstree (recursive, maintains structure).
See documentation for more details.
--
components: Library (Lib)
messages: 325068
nosy: bmintz
priority: normal
Change by Benjamin Mintz :
--
keywords: +patch
pull_requests: +8623
stage: -> patch review
___
Python tracker
<https://bugs.python.org/issue34635>
___
___
Py
Benjamin Mintz added the comment:
I didn't have one in mind. I just noticed that there was a getmro which
accessed __mro__ but no corresponding method for __subclasses__.
That got me getsubclasses and getallsubclasses.
Then I thought it would be cool if you could walk the tree of subcl
Change by Benjamin Mintz :
--
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.org/issue34635>
___
___
Pyth
10 matches
Mail list logo