Commit Graph

52 Commits

Author SHA1 Message Date
Géry Ogam ee88af3f4f Namespace packages _bootstrap.ModuleSpec.loader attributes are no longer None (#10376)
Namespace packages _bootstrap.ModuleSpec.loader attributes are no longer `None` _after_ calling the importlib._bootstrap._init_module_attrs function.

See:
* https://stackoverflow.com/questions/52869541/namespace-package-spec-loader-and-loader-attributes-not-set-to-none
* https://bugs.python.org/issue35181
2019-05-01 13:08:17 -07:00
Joannah Nanjekye 70bf713617 bpo-30840: Document relative imports (#12831)
* document relative imports

* 📜🤖 Added by blurb_it.

* fix indentation error

* remove indentation

* Document relative imports

* Document relative imports

* remove from ...package

* Document relative imports

* remove trailing space

* Document relative imports

* Document relative imports
2019-04-25 01:14:44 +10:00
Serhiy Storchaka 2b57c43f21
bpo-35506: Remove redundant and incorrect links from keywords. (GH-11174) 2018-12-19 08:09:46 +02:00
Andrés Delfino ea6a28c9f7 Mark -c and -O as command line options in reStructuredText. (GH-10103) 2018-11-07 19:06:45 +02:00
Serhiy Storchaka ddb961d2ab
bpo-35054: Add more index entries for symbols. (GH-10064) 2018-10-26 09:00:49 +03:00
Brett Cannon 441d945eb3
Clarify that __path__ can't be just any value (GH-6554) 2018-04-20 16:32:46 -07:00
Benjamin Peterson 42aa93b8ff
closes bpo-31650: PEP 552 (Deterministic pycs) implementation (#4575)
Python now supports checking bytecode cache up-to-dateness with a hash of the
source contents rather than volatile source metadata. See the PEP for details.

While a fairly straightforward idea, quite a lot of code had to be modified due
to the pervasiveness of pyc implementation details in the codebase. Changes in
this commit include:

- The core changes to importlib to understand how to read, validate, and
  regenerate hash-based pycs.

- Support for generating hash-based pycs in py_compile and compileall.

- Modifications to our siphash implementation to support passing a custom
  key. We then expose it to importlib through _imp.

- Updates to all places in the interpreter, standard library, and tests that
  manually generate or parse pyc files to grok the new format.

- Support in the interpreter command line code for long options like
  --check-hash-based-pycs.

- Tests and documentation for all of the above.
2017-12-09 10:26:52 -08:00
Barry Warsaw 93952f8815
Fix a grammatical problem and reword for clarity. (#4257)
bpo-31936
2017-11-03 13:45:46 -07:00
Barry Warsaw 191e313820 bpo-31799: Make module.__spec__ more discoverable (#4010)
bpo-31799: Make module.__spec__ more discoverable
2017-10-17 15:52:38 -04:00
Benjamin Peterson 60dbed1850 link to legacy doc on the non-legacy website (#3362) 2017-09-05 16:24:39 -07:00
kms70847 9c972b5780 Improve grammar in The Import System documentation (GH-1862)
Replace `an ModuleNotFoundError` with `a ModuleNotFoundError`.
Replace `an path` with `a path`.
2017-05-30 09:12:33 -07:00
Dominik Miedziński af34e0a07b Fix ModuleNotFoundError typo in import reference (#1606) 2017-05-16 19:40:17 +03:00
Mariatta 1f5639c77f bpo-26184: import.rst: Improve versionchanged note (GH-325) 2017-02-26 13:23:38 -08:00
Mariatta 6b4a5f45e2 bpo-26184: import.rst: Improve versionchanged note (GH-277)
Mention that an ImportError is raised when exec_module() is defined, but
create_module() is not.
2017-02-26 07:36:57 -08:00
Marco Buttu 46ce7599af bpo-29648: import.rst: Add reference to create_module() (GH-290)
Add a reference to create_module(), in the first versionadded of section Loaders.
2017-02-26 07:14:45 -08:00
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