Commit Graph

37 Commits

Author SHA1 Message Date
Eric Snow 46f97b85a8 Issue #15767: Use ModuleNotFoundError. 2016-09-07 16:56:15 -07:00
Brett Cannon 3f63483a30 Merge for issue #27712 2016-08-12 10:57:17 -07:00
Brett Cannon 6336fb2734 Issue #27712: Fix some typos in the import docs.
Thanks to Xiang Zhang for the patch.
2016-08-12 10:56:48 -07:00
Brett Cannon 849113af6b Issue #25791: Warn when __package__ != __spec__.parent.
In a previous change, __spec__.parent was prioritized over
__package__. That is a backwards-compatibility break, but we do
eventually want __spec__ to be the ground truth for module details. So
this change reverts the change in semantics and instead raises an
ImportWarning when __package__ != __spec__.parent to give people time
to adjust to using spec objects.
2016-01-22 15:25:50 -08:00
Brett Cannon 63b8505281 Issue #25791: Raise an ImportWarning when __spec__ or __package__ are
not defined for a relative import.

This is the start of work to try and clean up import semantics to rely
more on a module's spec than on the myriad attributes that get set on
a module. Thanks to Rose Ames for the patch.
2016-01-15 13:33:03 -08:00
Brett Cannon f4f25fe576 Issue #25500: Fix the language reference to not claim that import
statements search for __import__ in the global scope.

Thanks to Sergei Lebedev for finding the documentation bug.
2015-12-04 14:51:26 -08:00
Berker Peksag a1bddadddd Issue #24713: Use importlib.reload() in import reference document.
imp.reload() was deprecated in Python 3.4 and changed to call
importlib.reload().

Patch by Petr Viktorin.
2015-07-25 13:03:08 +03:00
Berker Peksag 7e732a7181 Issue #24713: Use importlib.reload() in import reference document.
imp.reload() was deprecated in Python 3.4 and changed to call
importlib.reload().

Patch by Petr Viktorin.
2015-07-25 13:02:37 +03:00
Barry Warsaw b5a3d9bebb Issue #24029: Document the name binding behavior for submodule imports. 2015-04-22 18:38:26 -04:00
Barry Warsaw 2097f53ec3 Issue #24029: Document the name binding behavior for submodule imports. 2015-04-22 18:29:16 -04: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 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
Brett Cannon d0c4ef175b Issue #22242: Try to make some import-related loader details clearer.
Thanks to Jon Poler for pointing this out.
2014-11-07 11:29:33 -05:00
Georg Brandl 525d355984 Fixing broken links in doc, part 3: the rest 2014-10-29 10:26:56 +01:00
Georg Brandl e73778c1ac Use https:// URLs when referring to python.org hosts. 2014-10-29 08:36:35 +01:00
Nick Coghlan 9aa00d1cd1 Issue #19697: document more __main__.__spec__ quirks 2014-03-29 15:39:42 +10:00
Eric Snow e50f9aa4bd Issue #19697: Document cases where __main__.__spec__ is None. 2014-03-28 18:10:33 -06:00
Larry Hastings bfd715ebd1 Regenerated pydoc/topics.py, and fix a "suspicious" doc error. 2014-01-05 04:35:56 -08:00
Serhiy Storchaka 2a6145290b Removed spaces before commas and periods. 2013-12-23 18:21:57 +02:00
Eric Snow 7cff4cd7e9 Issue #19713: Fix mistakes in the import page of language reference.
These mistakes were introduced by the initial PEP 451 merge.
2013-12-16 23:10:50 -07:00
Georg Brandl 472a65a710 Fix a few markup problems in the new import doc. 2013-11-24 12:39:56 +01:00
Eric Snow b523f8433a Implement PEP 451 (ModuleSpec). 2013-11-22 09:05:39 -07:00
Brett Cannon 82da8886cc Issue #15767: Revert 3a50025f1900 for ModuleNotFoundError 2013-07-04 17:48:16 -04:00
Brett Cannon 8f5ac5106e Issue #15767: Touch up ModuleNotFoundError usage by import.
Forgot to raise ModuleNotFoundError when None is found in sys.modules.
This led to introducing the C function PyErr_SetImportErrorSubclass()
to make setting ModuleNotFoundError easier.

Also updated the reference docs to mention ModuleNotFoundError
appropriately. Updated the docs for ModuleNotFoundError to mention the
None in sys.modules case.

Lastly, it was noticed that PyErr_SetImportError() was not setting an
exception when returning None in one case. That issue is now fixed.
2013-06-12 23:29:18 -04:00
Brett Cannon 4b4e38e7d4 Mention __cached__ in the import ref. 2013-05-25 11:32:50 -04:00
Brett Cannon b961955e95 merge 2013-05-25 11:33:13 -04:00
Brett Cannon 4c14b5de1c #17115,17116: Have modules initialize the __package__ and __loader__
attributes to None.

The long-term goal is for people to be able to rely on these
attributes existing and checking for None to see if they have been
set. Since import itself sets these attributes when a loader does not
the only instances when the attributes are None are from someone
overloading __import__() and not using a loader or someone creating a
module from scratch.

This patch also unifies module initialization. Before you could have
different attributes with default values depending on how the module
object was created. Now the only way to not get the same default set
of attributes is to circumvent initialization by calling
ModuleType.__new__() directly.
2013-05-04 13:56:58 -04:00
Georg Brandl 1bab7134a8 Merge with 3.3. 2013-03-28 13:28:55 +01:00
Georg Brandl 44ea77bd81 Closes #4159: add LaTeX tabular column specifications to tables that otherwise are cut off or have overlapping text. 2013-03-28 13:28:44 +01:00
Brett Cannon 4802becb16 Issue #17117: Have both import itself and importlib.util.set_loader()
set __loader__ on a module when set to None.

Thanks to Gökcen Eraslan for the fix.
2013-03-13 10:41:36 -07:00
Barry Warsaw 82c1c781c7 - Issue #16514: Fix regression causing a traceback when sys.path[0] is None
(actually, any non-string or non-bytes type).
2012-11-20 15:22:51 -05:00
Andrew Svetlov e2cf03e499 Issue #16144: Fix misleading sentence in reference/import.
Patch by Manuel Pégourié-Gonnard
2012-11-15 16:28:21 +02:00
Nick Coghlan 1685db011d s/path importer/path based finder/ (because the path based finder is not an importer and the simpler 'path finder' is too ambiguous) 2012-08-20 13:49:08 +10:00
Georg Brandl a81b481e3a Fix markup errors and update pydoc topics. 2012-08-11 08:43:59 +02:00
Nick Coghlan 4941774f59 Issue #15502: Bring the importlib.PathFinder docs and docstring more in line with the new import system documentation, and fix various parts of the new docs that weren't quite right given PEP 420 or were otherwise a bit misleading. Also note the key terminology problem still being discussed in the issue 2012-08-02 23:03:58 +10:00
Barry Warsaw dadebab42c Finally, a coherent set of terminology for all the lil' beasties involved. 2012-07-31 16:03:09 -04:00