[New-bugs-announce] [issue34056] checked hash-based pyc files not working with imp module

Patrick McCarty report at bugs.python.org
Thu Jul 5 18:31:12 EDT 2018


New submission from Patrick McCarty <patrick.mccarty at intel.com>:

OS: Clear Linux build 23460
Python version: 3.7.0

Description:
I am seeing an uncaught exception in Python 3.7.0 when using the "imp" module to import a module that has a checked hash-based pyc file. See the attached source files.

Steps to reproduce:
1) Copy attached source files to a directory
2) In that directory, run
    $ python3.7 -m compileall --invalidation-mode checked-hash imp-test-mod.py
    $ python3.7 imp-test.py
3) See the resulting output (omitting the imp deprecation notice):

Traceback (most recent call last):
  File "imp-test.py", line 6, in <module>
    mod = imp.load_module(modname, f, p, d)
  File "/usr/lib/python3.7/imp.py", line 235, in load_module
    return load_source(name, filename, file)
  File "/usr/lib/python3.7/imp.py", line 172, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 696, in _load
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 724, in exec_module
  File "<frozen importlib._bootstrap_external>", line 838, in get_code
TypeError: a bytes-like object is required, not 'str'

----------
components: Interpreter Core
files: imp-test.py
messages: 321139
nosy: phmccarty
priority: normal
severity: normal
status: open
title: checked hash-based pyc files not working with imp module
type: behavior
versions: Python 3.7
Added file: https://bugs.python.org/file47671/imp-test.py

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34056>
_______________________________________


More information about the New-bugs-announce mailing list