sha2 module still referenced even if not built (3.12.11)

Open Beginner friendly
#17 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
python, zig
Domain
build-system

Research direction

Start in build.zig, where the .sha2 module is disabled by default, then inspect the Python 3.12 hashlib.py and random.py references shown in the traceback. Rebuild and use the REPL's modules check to verify that disabled sha2 support no longer causes exceptions or references to unavailable _sha2 code.

Written by the indexing model from the issue text.

Description

The module .sha2 is explicitly disabled in build.zig by default. The build completes fine, but when checking for modules in the REPL, throws exceptions:

help> modules

Please wait a moment while I gather a list of all available modules...

ERROR:root:code for hash sha224 was not found.
Traceback (most recent call last):
  File "/mnt/mimic/pkg/python/lib/python3.12/random.py", line 68, in <module>
    from _sha2 import sha512 as _sha512
ModuleNotFoundError: No module named '_sha2'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/mnt/mimic/pkg/python/lib/python3.12/hashlib.py", line 245, in <module>
    globals()[__func_name] = __get_hash(__func_name)
                             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/mimic/pkg/python/lib/python3.12/hashlib.py", line 123, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha224
ERROR:root:code for hash sha256 was not found.
Traceback (most recent call last):
  File "/mnt/mimic/pkg/python/lib/python3.12/random.py", line 68, in <module>
    from _sha2 import sha512 as _sha512
ModuleNotFoundError: No module named '_sha2'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/mnt/mimic/pkg/python/lib/python3.12/hashlib.py", line 245, in <module>
    globals()[__func_name] = __get_hash(__func_name)
                             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/mimic/pkg/python/lib/python3.12/hashlib.py", line 123, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha256
ERROR:root:code for hash sha384 was not found.
Traceback (most recent call last):
  File "/mnt/mimic/pkg/python/lib/python3.12/random.py", line 68, in <module>
    from _sha2 import sha512 as _sha512
ModuleNotFoundError: No module named '_sha2'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/mnt/mimic/pkg/python/lib/python3.12/hashlib.py", line 245, in <module>
    globals()[__func_name] = __get_hash(__func_name)
                             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/mimic/pkg/python/lib/python3.12/hashlib.py", line 123, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha384
ERROR:root:code for hash sha512 was not found.
Traceback (most recent call last):
  File "/mnt/mimic/pkg/python/lib/python3.12/random.py", line 68, in <module>
    from _sha2 import sha512 as _sha512
ModuleNotFoundError: No module named '_sha2'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/mnt/mimic/pkg/python/lib/python3.12/hashlib.py", line 245, in <module>
    globals()[__func_name] = __get_hash(__func_name)
                             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/mimic/pkg/python/lib/python3.12/hashlib.py", line 123, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha512
Dominant language
Zig
Stars
19
Forks
7
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from allyourcodebase/cpython

All issues in allyourcodebase/cpython

Similar issues

More Build System issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.