[issue37521] importlib examples have their exec_module()/sys.modules assignment lines reversed

2019-07-17 Thread Benjamin Mintz


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, False, True though.

--

___
Python tracker 
<https://bugs.python.org/issue37521>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37521] importlib examples have their exec_module()/sys.modules assignment lines reversed

2019-07-16 Thread Benjamin Mintz


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/issue37521>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37521] importlib examples have their exec_module()/sys.modules assignment lines reversed

2019-07-13 Thread Benjamin Mintz


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/issue37521>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37521] importlib.util.module_from_spec return value is not the same as in sys.modules

2019-07-09 Thread Benjamin Mintz


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

___
Python tracker 
<https://bugs.python.org/issue37521>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37521] importlib.util.module_from_spec return value is not the same as in sys.modules

2019-07-07 Thread Benjamin Mintz


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' has no attribute 'sub'

--
Added file: https://bugs.python.org/file48461/importsfucked.zip

___
Python tracker 
<https://bugs.python.org/issue37521>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37521] importlib.util.module_from_spec return value is not the same as in sys.modules

2019-07-07 Thread Benjamin Mintz


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 in sys.modules even though a fresh reference 
is already there. If you use that code on a package with a subpackage, the 
subpackage will not be set as an attribute on the package.

--
components: Library (Lib)
files: importsfucked.zip
messages: 347482
nosy: bmintz
priority: normal
severity: normal
status: open
title: importlib.util.module_from_spec return value is not the same as in 
sys.modules
versions: Python 3.7
Added file: https://bugs.python.org/file48460/importsfucked.zip

___
Python tracker 
<https://bugs.python.org/issue37521>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34635] inspect: add tools for inspecting subclasses

2018-09-13 Thread Benjamin Mintz


Change by Benjamin Mintz :


--
stage: patch review -> resolved
status: open -> closed

___
Python tracker 
<https://bugs.python.org/issue34635>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34635] inspect: add tools for inspecting subclasses

2018-09-13 Thread Benjamin Mintz


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 subclasses in 
code, so I wrote getsubclasstree.

--

___
Python tracker 
<https://bugs.python.org/issue34635>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34635] inspect: add tools for inspecting subclasses

2018-09-11 Thread Benjamin Mintz


Change by Benjamin Mintz :


--
keywords: +patch
pull_requests: +8623
stage:  -> patch review

___
Python tracker 
<https://bugs.python.org/issue34635>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34635] inspect: add tools for inspecting subclasses

2018-09-11 Thread Benjamin Mintz


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
severity: normal
status: open
title: inspect: add tools for inspecting subclasses
type: enhancement
versions: Python 3.8

___
Python tracker 
<https://bugs.python.org/issue34635>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com