Commit Graph

1380 Commits

Author SHA1 Message Date
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 b1611e2772 Issue #15767: Introduce ModuleNotFoundError, a subclass of
ImportError.

The exception is raised by import when a module could not be found.
Technically this is defined as no viable loader could be found for the
specified module. This includes ``from ... import`` statements so that
the module usage is consistent for all situations where import
couldn't find what was requested.

This should allow for the common idiom of::

  try:
    import something
  except ImportError:
    pass

to be updated to using ModuleNotFoundError and not accidentally mask
ImportError messages that should propagate (e.g. issues with a
loader).

This work was driven by the fact that the ``from ... import``
statement needed to be able to tell the difference between an
ImportError that simply couldn't find a module (and thus silence the
exception so that ceval can raise it) and an ImportError that
represented an actual problem.
2013-06-12 16:59:46 -04:00
Brett Cannon 3e0651b5fa Issue #18065: For frozen packages set __path__ to [].
Previously __path__ was set to [__name__], but that could lead to bad
results if someone managed to circumvent the frozen importer and
somehow ended up with a finder that thought __name__ was a legit
directory/location.
2013-05-31 23:18:39 -04:00
Brett Cannon 0dbb4c7f13 Issues #18088, 18089: Introduce
importlib.abc.Loader.init_module_attrs() and implement
importlib.abc.InspectLoader.load_module().

The importlib.abc.Loader.init_module_attrs() method sets the various
attributes on the module being loaded. It is done unconditionally to
support reloading. Typically people used
importlib.util.module_for_loader, but since that's a decorator there
was no way to override it's actions, so init_module_attrs() came into
existence to allow for overriding. This is also why module_for_loader
is now pending deprecation (having its other use replaced by
importlib.util.module_to_load).

All of this allowed for importlib.abc.InspectLoader.load_module() to
be implemented. At this point you can now implement a loader with
nothing more than get_code() (which only requires get_source();
package support requires is_package()). Thanks to init_module_attrs()
the implementation of load_module() is basically a context manager
containing 2 methods calls, a call to exec(), and a return statement.
2013-05-31 18:56:47 -04:00
Brett Cannon 028d51236a Update What's New for importlib.util.module_to_load name change 2013-05-31 18:02:11 -04:00
Brett Cannon 3dc48d6f69 Issue #18070: importlib.util.module_for_loader() now sets __loader__
and __package__ unconditionally in order to do the right thing for
reloading.
2013-05-28 18:35:54 -04:00
Nick Coghlan b39fd0c9b8 Issue #11816: multiple improvements to the dis module
* get_instructions generator
* ability to redirect output to a file
* Bytecode and Instruction abstractions

Patch by Nick Coghlan, Ryan Kelly and Thomas Kluyver.
2013-05-06 23:59:20 +10: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
R David Murray 8a34596bbe #2118: IOError is deprecated, use OSError. 2013-04-14 06:46:35 -04:00
R David Murray 8e37d5df95 #2118: Make SMTPException a subclass of IOError.
Initial patch by Ned Jackson Lovely.
2013-04-13 14:49:48 -04:00
R David Murray 671cd3290b #17487: wave.getparams now returns a namedtuple.
Patch by Claudiu Popa.
2013-04-10 12:31:43 -04:00
Brett Cannon 777622b6ca What's new entry for issue #17093 2013-04-09 17:03:10 -04:00
R David Murray 9c7dfbf720 Merge #17623: fix whatsnew typo
Patch by Thomas Heller.
2013-04-03 06:17:30 -04:00
R David Murray 03b2a1ce51 #17623: fix whatsnew typo
Patch by Thomas Heller.
2013-04-03 06:16:14 -04:00
Antoine Pitrou 2463e5fee4 Issue #16692: The ssl module now supports TLS 1.1 and TLS 1.2. Initial patch by Michele Orrù. 2013-03-28 22:24:43 +01: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
Kristjan Valur Jonsson a1e8244afa Issue #16475: Add a whatsnew entry for 3.4 2013-03-26 13:56:14 +00:00
Terry Jan Reedy 2b6c26ebe3 Issue #13248: NEWS and What's New items 2013-03-21 19:36:26 -04:00
doko@ubuntu.com 6d3d0fe0b2 - Issue #16754: Fix the incorrect shared library extension on linux. Introduce
two makefile macros SHLIB_SUFFIX and EXT_SUFFIX. SO now has the value of
  SHLIB_SUFFIX again (as in 2.x and 3.1). The SO macro is removed in 3.4.
2013-03-21 13:39:52 -07:00
doko@ubuntu.com 1621d77fc8 - Issue #16754: Fix the incorrect shared library extension on linux. Introduce
two makefile macros SHLIB_SUFFIX and EXT_SUFFIX. SO now has the value of
  SHLIB_SUFFIX again (as in 2.x and 3.1). The SO macro is removed in 3.4.
2013-03-21 13:31:41 -07:00
doko@ubuntu.com d5537d071c - Issue #16754: Fix the incorrect shared library extension on linux. Introduce
two makefile macros SHLIB_SUFFIX and EXT_SUFFIX. SO now has the value of
  SHLIB_SUFFIX again (as in 2.x and 3.1). The SO macro is removed in 3.4.
2013-03-21 13:21:49 -07:00
Chris Jerdonek 7d2fad1be2 Merge from 3.3: link to "yield from" examples in yield documentation. 2012-12-23 15:35:23 -08:00
Chris Jerdonek 2654b86e88 Link to "yield from" examples in yield documentation.
This commit also simplifies the more advanced "yield from" example and removes
unused function parameters.
2012-12-23 15:31:57 -08:00
R David Murray 5a9d706123 #16522: Add FAIL_FAST flag to doctest.
Patch by me, most of the work (doc and tests) by Daniel Urban.
2012-11-21 15:09:21 -05:00
Ezio Melotti 25bbe5e0bc #16157: merge with 3.3. 2012-11-17 19:30:48 +02:00
Ezio Melotti fa7aeecbca #16157: fix links in the whatsnew files. 2012-11-17 19:29:12 +02:00
Victor Stinner e64322e034 Close #14625: Rewrite the UTF-32 decoder. It is now 3x to 4x faster
Patch written by Serhiy Storchaka.
2012-10-30 23:12:47 +01:00
Georg Brandl 3b80d34c55 Remove confusing "Release" and "Date" markers from whatsnews. Merge with 3.3. 2012-10-28 13:37:54 +01:00
Georg Brandl ff65a10418 Remove confusing "Release" and "Date" markers from whatsnews. Merge with 3.2. 2012-10-28 13:37:18 +01:00
Georg Brandl 75f0020d29 Remove confusing "Release" and "Date" markers from whatsnews. 2012-10-28 13:35:56 +01:00
Ezio Melotti 777d0c5c21 Merge PEP name fix with 3.3. 2012-10-21 07:37:25 +03:00
Ezio Melotti 8cd45bd48d Fix PEP name. 2012-10-21 07:36:58 +03:00
Ezio Melotti 13b1547e1b Merge punctuation fixes with 3.3. 2012-10-20 22:54:12 +03:00
Ezio Melotti 76e7ea5b4c Fix punctuation. 2012-10-20 22:53:47 +03:00
Ezio Melotti 022b6d2fa5 Merge "seealso" change with 3.3. 2012-10-20 16:27:51 +03:00
Ezio Melotti 36e01df18e Move note about the implementation in the "seealso". 2012-10-20 16:26:18 +03:00
R David Murray 4d289a2a4d Merge: A couple more whatsnew updates. 2012-10-16 21:54:12 -04:00
R David Murray e54c718572 A couple more whatsnew updates. 2012-10-16 21:52:24 -04:00
Ezio Melotti 6ca07a221a Merge typo fix. 2012-10-16 21:51:06 +03:00
Ezio Melotti ad626807a6 Fix typo. 2012-10-16 21:50:33 +03:00
Benjamin Peterson 143d034ecd merge 3.2 2012-10-12 12:04:32 -04:00
Ezio Melotti 5c3283e43a Merge __next__ method link fixes with 3.3. 2012-10-12 13:46:37 +03:00
Ezio Melotti 1dd7c30419 Merge __next__ method link fixes with 3.2. 2012-10-12 13:45:38 +03:00
Ezio Melotti 7fa822275b Fix links to the __next__ method. 2012-10-12 13:42:08 +03:00
R David Murray 96e936712f Merge: More whatsnew updates, move some doc NEWS items into the doc section. 2012-10-06 23:21:01 -04:00
R David Murray f4c2757d78 More whatsnew updates, move some doc NEWS items into the doc section. 2012-10-06 23:19:17 -04:00
R David Murray fb4dc080eb Merge: starmap/starmap_async for whatsnew, and fix multiprocessing Pool markup. 2012-10-06 22:27:31 -04:00
R David Murray ace5162294 starmap/starmap_async for whatsnew, and fix multiprocessing Pool markup. 2012-10-06 22:26:52 -04:00
R David Murray 7ecc5ba7be Merge: More whatsnew updates. Also move a C-API NEWS item out of library section. 2012-10-06 22:10:42 -04:00