[issue15031] Split .pyc parsing from module loading

Brett Cannon report at bugs.python.org
Sun Nov 18 11:33:41 CET 2012


Brett Cannon added the comment:

The rationale is that was the way it already was prior to importlib.

As for the approach you are suggesting, I am understand it, it will just
not give the public method the same functionality which might not be that
important.
On Nov 18, 2012 5:18 AM, "Nick Coghlan" <report at bugs.python.org> wrote:

>
> Nick Coghlan added the comment:
>
> The suppression flag rings alarm bells for me, as does the fact that all
> the arguments are optional. Do you remember the rationale for allowing the
> marshalling errors to propagate rather than falling back to loading from
> source? It seems weird that a truncated read in the first 12 bytes means to
> fall back to compiling from source, but truncation after that is a user
> visible error. Allowing those exceptions to be suppressed as well would
> simplify things a fair bit.
>
> Regardless, looking at the full patch in context on a real computer
> (rather than through my phone), suggests to me there needs to be *two*
> private static methods on _LoaderBasics._parse_bytecode_file:
>
>     _validate_bytecode_header
>     _unmarshal_code
>
> SourcelessLoader.get_code would just call these directly, while
> SourceLoader.parse_cache_contents would suppress exceptions from the first
> one.
>
> I'll put together a patch illustrating this approach.
>
> ----------
>
> _______________________________________
> Python tracker <report at bugs.python.org>
> <http://bugs.python.org/issue15031>
> _______________________________________
>

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15031>
_______________________________________


More information about the Python-bugs-list mailing list