| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|\
| |
| |
| | |
float.__format__() and complex.__format__().
|
| |
| |
| |
| | |
complex.__format__().
|
| |
| |
| |
| |
| | |
Don't create a temporary buffer of zeroy byte nor call r_string() if the length
is zero, create directly the empty string.
|
| | |
|
|\ \
| |/ |
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
UnicodeDecodeError as ImportError. That was over-reaching the point of
raising ImportError in get_source() (which is to signal the source
code was not found when it should have). Conflating the two exceptions
with ImportError could lead to masking errors with the source which
should be known outside of whether there was an error simply getting
the source to begin with.
|
| |
| |
| |
| | |
loaders where C code provides the loaded module.
|
| |
| |
| |
| |
| | |
conform the the InspectLoader ABC. Perk of this is that runpy/-m can
now work with namespace packages.
|
| | |
|
| |
| |
| |
| | |
deprecation of imp.get_magic().
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
|\ \
| |/ |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| | |
EOF is hit while trying to read the header of a bytecode file.
|
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| | |
explains better what the context manager is providing.
|
| |
| |
| |
| |
| | |
and __package__ unconditionally in order to do the right thing for
reloading.
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| | |
handle providing (and cleaning up if needed) the module to be loaded.
A future commit will use the context manager in
Lib/importlib/_bootstrap.py and thus why the code is placed there
instead of in Lib/importlib/util.py.
|
| |
| |
| |
| | |
when applicable.
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| | |
idx variable is used for a tuple indexn so use Py_ssize_t (not int).
|
| | |
|
| |
| |
| |
| | |
the proper environment
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| | |
stderr remains usable.
(should fix Windows buildbot failures on test_gc)
|
| |
| |
| |
| | |
compare two Unicode kinds
|
| |
| |
| |
| | |
HAVE_MBRTOWC is not defined
|
| |
| |
| |
| | |
garbage-collected at shutdown.
|
| |
| |
| |
| |
| |
| |
| | |
Note that this is a potentially disruptive change since it may
release some system resources which would otherwise remain
perpetually alive (e.g. database connections kept in thread-local
storage).
|
|\ \
| |/
| |
| | |
(thanks Arfrever for reporting).
|
| |
| |
| |
| | |
(thanks Arfrever for reporting).
|