Skip to content

Fix genkatdict.py bug and add tests for scripts (#1408)#2466

Open
vikasmulaje wants to merge 2 commits into
open-quantum-safe:mainfrom
vikasmulaje:test-scripts-1408
Open

Fix genkatdict.py bug and add tests for scripts (#1408)#2466
vikasmulaje wants to merge 2 commits into
open-quantum-safe:mainfrom
vikasmulaje:test-scripts-1408

Conversation

@vikasmulaje

Copy link
Copy Markdown

Purpose

Fix a bug in scripts/genkatdict.py and add test coverage for 6 previously
untested scripts, addressing #1408.

Bug fix

scripts/genkatdict.py line 16 used json.dumps(d, f, ...) instead of
json.dump(d, f, ...). Since Python 3.6, all optional parameters to
json.dumps() are keyword-only, so passing a file handle as a second
positional argument raises TypeError. The fix is a one-character change:
dumps -> dump.

New tests

tests/test_scripts.py adds 22 tests covering:

  • scripts/doxyfy.py (7 tests)
  • scripts/format_docs_yaml.py (2 tests)
  • scripts/git_commit.sh (2 tests)
  • scripts/genkatsha256.sh (3 tests)
  • scripts/update_docs_from_yaml.py (3 tests)
  • scripts/update_cbom.py (3 tests)
  • scripts/genkatdict.py (2 tests)

All 22 tests pass locally.

Use of generative AI

This contribution was produced with the assistance of an AI coding agent
(Cursor with Claude). The AI was used to:

  • Explore the repository structure and identify untested scripts
  • Draft the test file tests/test_scripts.py
  • Identify the json.dumps/json.dump bug in genkatdict.py

All code has been reviewed and verified by the contributor before submission.
The contributor has read the OpenSSF Security-Focused Guide for AI Code
Assistant Instructions
.

Made with Cursor

Fix json.dumps -> json.dump in genkatdict.py: the script used
json.dumps(d, f, ...) which raises TypeError on all Python 3.6+
versions since the file handle cannot be a positional argument to
dumps(). The correct function is json.dump() which writes to a file.

Add tests/test_scripts.py covering 6 previously untested scripts:
- scripts/doxyfy.py (anchor reformatting for doxygen)
- scripts/format_docs_yaml.py (YAML normalization)
- scripts/git_commit.sh (git hash retrieval)
- scripts/genkatsha256.sh (SHA-256 generation from KAT files)
- scripts/update_docs_from_yaml.py (markdown generation from YAML)
- scripts/update_cbom.py (Cryptography BOM generation)
- scripts/genkatdict.py (KAT dictionary builder)

Addresses open-quantum-safe#1408

Co-authored-by: Cursor <cursoragent@cursor.com>
@xuganyu96 xuganyu96 added this to the 0.17.0 milestone Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants