[issue21436] Consider leaving importlib.abc.Loader.load_module()

2021-11-07 Thread Nick Coghlan


Nick Coghlan  added the comment:

FWIW, I think it would be desirable to retain/restore some form of API that 
allows the creation of modules from files without requiring the user to know 
about module specs (or loaders, or anything else).

My current preference would be for a "module_from_file_location" counterpart to 
"spec_from_file_location" that implements Brett's recipe from above. That code 
is visually short, but conceptually very dense,and hence far from being obvious 
to most people trying to make the "path to module" leap.

Such a function could also cross-reference runpy.run_path for cases where don't 
want a module at all, just the top level namespace.

--

___
Python tracker 

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



[issue21436] Consider leaving importlib.abc.Loader.load_module()

2021-11-04 Thread Sebastian Rittau


Sebastian Rittau  added the comment:

I would ask you to reconsider this. 
https://stackoverflow.com/questions/67631/how-to-import-a-module-given-the-full-path/67692#67692
 is a highly active question on StackOverflow, and my answer basically provided 
me all the karma I got there. For users that don't have intimate insight in how 
importlib works, the code posted by Brett is completely non-obvious and I 
believe that a convenience method would be very useful.

--

___
Python tracker 

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



[issue21436] Consider leaving importlib.abc.Loader.load_module()

2015-12-12 Thread Berker Peksag

Changes by Berker Peksag :


--
status: open -> closed

___
Python tracker 

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



[issue21436] Consider leaving importlib.abc.Loader.load_module()

2015-12-04 Thread Brett Cannon

Brett Cannon added the comment:

Python 3.5 lets you do:

  spec = importlib.util.spec_from_file_location('what.ever', 'foo.py')
  module = importlib.util.module_from_spec(spec)
  spec.loader.exec_module(module)

I am satisfied that case for loading from a file is easy enough to not warrant 
keeping load_module() around just for this use case.

--
resolution:  -> rejected
stage:  -> resolved

___
Python tracker 

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



[issue21436] Consider leaving importlib.abc.Loader.load_module()

2014-10-17 Thread Martin Panter

Changes by Martin Panter vadmium...@gmail.com:


--
nosy: +vadmium

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21436
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21436] Consider leaving importlib.abc.Loader.load_module()

2014-10-15 Thread Nikolay Bryskin

Changes by Nikolay Bryskin devel.n...@gmail.com:


--
nosy: +nikicat

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21436
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21436] Consider leaving importlib.abc.Loader.load_module()

2014-05-25 Thread Eric Snow

Eric Snow added the comment:

I'd rather see something like load_from_spec() added to importlib.util, a la 
issue #21235.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21436
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21436] Consider leaving importlib.abc.Loader.load_module()

2014-05-12 Thread Boris Dayma

Changes by Boris Dayma koush...@gmail.com:


--
nosy: +Borisd13

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21436
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21436] Consider leaving importlib.abc.Loader.load_module()

2014-05-11 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
nosy: +Arfrever

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21436
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21436] Consider leaving importlib.abc.Loader.load_module()

2014-05-05 Thread Brett Cannon

Brett Cannon added the comment:

So it's not quite as bad as you think as SourceFileLoader.load_module() doesn't 
need an argument (I've opened http://bugs.python.org/issue21438 to fix the 
documentation). Admittedly it is a longer command than imp.load_source() to 
type, but there is no extra information required or a necessity that you break 
the command up into multiple lines.

Plus imp.load_source() is just plain bad. The reason the imp module is 
deprecated in Python 3.4 is because it does not expose the low-level details of 
import in a way that makes any sense since Python 2.3 (and yes, I meant to 
write 2.3 instead of 3.3; the problem has persisted _that_ long).

That being said, talks are just starting to consider undoing the documented 
deprecation of load_module() such that you can continue to use that as a 
substitute for imp.load_source()/imp.load_module().

I'm going to leave this bug open, hijack its title, and refocus this as to 
consider leaving importlib.abc.Loader.load_module() in importlib as the 
all-powerful fallback API which also simplifies transitioning from imp.

--
assignee:  - brett.cannon
nosy: +ncoghlan
title: bring back importlib.load_source() et al. - Consider leaving 
importlib.abc.Loader.load_module()

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21436
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com