fix: resolve Windows encoding and package import issues in CRT attestation#4757
fix: resolve Windows encoding and package import issues in CRT attestation#4757Monkey-Sheep wants to merge 1 commit into
Conversation
…ation (Scottcjn#4749) 1. src/__init__.py: Switch absolute imports to relative imports (from crt_x import -> from .crt_x import) so the package can be imported from its parent directory. 2. validate_bounty_2310.py: Replace Unicode emoji (✅❌ℹ️) with ASCII-safe labels ([PASS][FAIL][INFO]) and add explicit encoding='utf-8' to all text file reads. Prevents UnicodeEncodeError/UnicodeDecodeError on Windows CP1252 consoles. Fixes Scottcjn#4749
|
Welcome to RustChain! Thanks for your first pull request. Before we review, please make sure:
Bounty tiers: Micro (1-10 RTC) | Standard (20-50) | Major (75-100) | Critical (100-150) A maintainer will review your PR soon. Thanks for contributing! |
saim256
left a comment
There was a problem hiding this comment.
This is a reasonable subset of the #4749 fix, but I would treat it as incomplete compared with the existing open #4750 patch.
The package import hunk fixes parent-directory import src, and the ASCII/UTF-8 validator changes address the Windows console/default-codec failure. The gap is that this PR only changes src/__init__.py to package-relative imports and does not include the source-path fallback or regression coverage. In this bounty directory, some validation/manual workflows can still execute from inside bounties/issue-2310/src or otherwise put src directly on sys.path; the fallback pattern in #4750 preserves that direct import style while also supporting package imports.
Merge-risk summary:
- duplicates the same #4749 scope as #4750;
- no regression test for parent-path package import or CP1252 validator execution;
- narrower import change may regress direct
srcpath workflows that the compatibility fallback avoids.
Recommendation: either add the compatibility fallback and focused tests, or defer to the already-open #4750 implementation that covers the same behavior with regression coverage.
Summary
Fixes two failures in
bounties/issue-2310/that break local validation on Windows and prevent package-style imports.Problem 1: Package Import Failure
src/__init__.pyuses absolute sibling imports:This fails with
ModuleNotFoundErrorwhen importing from the parent directory (import src).Fix 1: Relative Imports
Changed to package-relative imports:
Problem 2: Windows Encoding Crash
validate_bounty_2310.pyprints Unicode emoji (✅❌ℹ️) and reads UTF-8 files without specifying encoding. On Windows CP1252 consoles this crashes withUnicodeEncodeError/UnicodeDecodeError.Fix 2: ASCII-Safe Output + Explicit Encoding
[PASS],[FAIL],[INFO]encoding='utf-8'to allopen(..., 'r')callsVerification
python -m py_compilepasses for both filesFixes #4749
This fix was generated with AI assistance (WorkBuddy Bounty Hunter).