Commit Graph

153 Commits

Author SHA1 Message Date
Nick Coghlan d5cacbb1d9 PEP 489: Multi-phase extension module initialization
Known limitations of the current implementation:

- documentation changes are incomplete
- there's a reference leak I haven't tracked down yet

The leak is most visible by running:

  ./python -m test -R3:3 test_importlib

However, you can also see it by running:

  ./python -X showrefcount

Importing the array or _testmultiphase modules, and
then deleting them from both sys.modules and the local
namespace shows significant increases in the total
number of active references each cycle. By contrast,
with _testcapi (which continues to use single-phase
initialisation) the global refcounts stabilise after
a couple of cycles.
2015-05-23 22:24:10 +10:00
R David Murray deed215313 Merge: #24081: Remove obsolete caveat from import docs. 2015-05-02 14:58:32 -04:00
R David Murray 6d877ef026 #24081: Remove obsolete caveat from import docs.
Per Eric Snow's research, this changed in Python 2.4 in changeset 331e60d8ce,
but these docs were not updated.

Patch by Peter Viktorin.
2015-05-02 14:57:54 -04:00
Larry Hastings 770ce204ee Regenerated pydoc-topics and fixed bad/suspicious doc markup for Python 3.5.0a4. 2015-04-19 13:50:12 -07:00
Brett Cannon f299abdafa Issue #23731: Implement PEP 488.
The concept of .pyo files no longer exists. Now .pyc files have an
optional `opt-` tag which specifies if any extra optimizations beyond
the peepholer were applied.
2015-04-13 14:21:02 -04:00
Brett Cannon 3fa84224fd Issue #23422: Clarify some things around importlib.import_module() 2015-02-20 10:34:20 -05:00
Brett Cannon 02d8454002 Issue #23014: Make importlib.abc.Loader.create_module() required when
importlib.abc.Loader.exec_module() is also defined.

Before this change, create_module() was optional **and** could return
None to trigger default semantics. This change now reduces the
options for choosing default semantics to one and in the most
backporting-friendly way (define create_module() to return None).
2015-01-09 11:39:21 -05:00
Brett Cannon b6e2556d8f Issue #22834: Have import suppress FileNotFoundError when the current
working directory no longer exists.

Thanks to Martin Panter for the bug report.
2014-11-21 12:19:28 -05:00
Georg Brandl bad8d4bb53 merge with 3.4 2014-10-29 10:57:42 +01:00
Georg Brandl b7354a65ce Fixing broken links in doc, part 4: some more breaks and redirects 2014-10-29 10:57:37 +01:00
Georg Brandl cadc3fdcb5 Merge with 3.4 2014-10-29 08:37:29 +01:00
Georg Brandl e73778c1ac Use https:// URLs when referring to python.org hosts. 2014-10-29 08:36:35 +01:00
Brett Cannon 2a17bde930 Issue #20383: Introduce importlib.util.module_from_spec().
Along the way, dismantle importlib._bootstrap._SpecMethods as it was
no longer relevant and constructing the new function required
partially dismantling the class anyway.
2014-05-30 14:55:29 -04:00
Brett Cannon 6eaac13c92 Issue #21156: importlib.abc.InspectLoader.source_to_code() is now a
staticmethod.
2014-05-09 12:28:22 -04:00
Brett Cannon a237a98753 Merge for issue #21438 2014-05-09 11:56:07 -04:00
Brett Cannon 062fcac9a4 Issue #21438: Document what loaders don't require a module name for
load_module().
2014-05-09 11:55:49 -04:00
Brett Cannon a04dbe4fe7 Issue #17621: Introduce importlib.util.LazyLoader. 2014-04-04 13:53:38 -04:00
Andrew Svetlov 08af00047b Get rid of deprecated IOError in the doc 2014-04-01 01:13:30 +03:00
Georg Brandl df48b97855 Fix a few scoping issues with versionadded/versionchanged directives. 2014-03-24 09:06:18 +01:00
Larry Hastings 3732ed2414 Merge in all documentation changes since branching 3.4.0rc1. 2014-03-15 21:13:56 -07:00
Brett Cannon 3303b6abc8 Merge for issue #20488 2014-02-06 09:49:53 -05:00
Brett Cannon 07fbd78473 Issue #20488: Update docs to say importlib is *the* implementaiton of
import and not *an* implementation.
2014-02-06 09:46:08 -05:00
Eric Snow 6029e08691 Issue 19944: Fix importlib.find_spec() so it imports parents as needed.
The function is also moved to importlib.util.
2014-01-25 15:32:46 -07:00
R David Murray 0ae7ae1fc9 whatsnew: InspectLoader.get_code now concrete, b32decode raises binascii.Error.
And a news item rephrase.
2014-01-08 18:16:02 -05:00
Brett Cannon 8d942296bb Issue #19719: Update various finder and loader ABCs such that their
old methods now provide implementations when PEP 451 APIs are present.

This should help with backwards-compatibility with code which has not
been updated to work with PEP 451.
2014-01-07 15:52:42 -05:00
Eric Snow ca2d854df8 Issue #19713: Update importlib docs for module spec changes, including deprecations. 2013-12-16 23:06:52 -07:00
Brett Cannon 706a7296d7 merge for issue #19963 2013-12-13 13:58:47 -05:00
Brett Cannon 98620d87f2 Issue #19963: Document that importlib.import_module() will import
parent packages automatically.
2013-12-13 13:57:41 -05:00
Eric Snow b282b3d804 Issue #18864: Add a setter for ModuleSpec.has_location. 2013-12-10 22:16:41 -07:00
Serhiy Storchaka 0e90e99188 Issue #19795: Improved markup of True/False constants. 2013-11-29 12:19:53 +02:00
Serhiy Storchaka fbc1c26803 Issue #19795: Improved markup of True/False constants. 2013-11-29 12:17:13 +02:00
Serhiy Storchaka 889d24ee3a Revert unrelated changes introduced by changeset b2066bc8cab9 (issue #19795). 2013-11-29 23:40:35 +02:00
Eric Snow b523f8433a Implement PEP 451 (ModuleSpec). 2013-11-22 09:05:39 -07:00
Brett Cannon f6901c8baa Issue #19410: Put back in special-casing of '' for
importlib.machinery.FileFinder.

While originally moved to stop special-casing '' as PathFinder farther
up the typical call chain now uses the cwd in the instance of '', it
was deemed an unnecessary risk to breaking subclasses of FileFinder to
take the special-casing out.
2013-11-01 10:37:57 -04:00
Brett Cannon 8ad37860c9 Tweak some doc wording for importlib.reload 2013-10-25 13:52:46 -04:00
Georg Brandl 0f5bff24ab Doc markup fixes. 2013-10-19 17:46:38 +02:00
Brett Cannon 27e27f7ee1 Issue #18416: Have importlib.machinery.PathFinder treat '' as the cwd
and stop importlib.machinery.FileFinder treating '' as '.'.

Previous PathFinder transformed '' into '.' which led to __file__ for
modules imported from the cwd to always be relative paths. This meant
the values of the attribute were wrong as soon as the cwd changed.
This change now means that as long as the site module is run (which
makes all entries in sys.path absolute) then all values for __file__
will also be absolute unless it's for __main__ when specified by file
path in a relative way (modules imported by runpy will have an
absolute path).

Now that PathFinder is no longer treating '' as '.' it only makes
sense for FileFinder to stop doing so as well. Now no transformation
is performed for the directory given to the __init__ method.

Thanks to Madison May for the initial patch.
2013-10-18 11:39:04 -04:00
Serhiy Storchaka 98b28fddd8 Issue #18758: Fixed and improved cross-references. 2013-10-13 23:12:09 +03:00
Eric Snow dcd01b4932 [issue 19152] Add versionadded for ExtensionFileLoader.get_filename(). 2013-10-04 20:35:34 -06:00
Eric Snow 5c4b4c530f [issue19152] Revert 832579dbafd6. 2013-10-03 15:03:29 -06:00
Eric Snow af8566c847 [issue19152] Add ExtensionFileLoader.get_filename(). 2013-10-03 12:08:55 -06:00
Eric Snow 5179445520 [issue19152] Add ExtensionFileLoader.get_filename(). 2013-10-03 12:08:55 -06:00
Brett Cannon a87e31ca52 Issue #18955: clarify what is removed by importlib.util.module_for_loader. 2013-09-13 16:52:19 -04:00
Brett Cannon 27bc441f5e merge for issue #18278 2013-06-21 18:37:02 -04:00
Brett Cannon 29b2f174da Issue #18278: properly document how the loaders are called for FileFinder 2013-06-21 18:31:55 -04:00
Brett Cannon a81d527ca9 documentation suggesting something which doesn't exist 2013-06-16 19:17:12 -04:00
Brett Cannon 390f6c1bf7 Merge doc/argument name fix 2013-06-16 19:09:46 -04:00
Brett Cannon 1d75382e81 Fix a misnaming of a method and an argument 2013-06-16 19:06:55 -04:00
Brett Cannon f24fecd4ac Issue #18076: Introduce imoportlib.util.decode_source().
The helper function makes it easier to implement
imoprtlib.abc.InspectLoader.get_source() by making that function
require just the raw bytes for source code and handling all other
details.
2013-06-16 18:37:53 -04:00
Brett Cannon a3c96154d2 Issue #17907: touch up the code for imp.new_module(). 2013-06-14 22:26:30 -04:00