Skip to content

fix: resolve Windows encoding and package import issues in CRT attestation#4757

Closed
Monkey-Sheep wants to merge 1 commit into
Scottcjn:mainfrom
Monkey-Sheep:fix/crt-attestation-windows-encoding-4749
Closed

fix: resolve Windows encoding and package import issues in CRT attestation#4757
Monkey-Sheep wants to merge 1 commit into
Scottcjn:mainfrom
Monkey-Sheep:fix/crt-attestation-windows-encoding-4749

Conversation

@Monkey-Sheep
Copy link
Copy Markdown

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__.py uses absolute sibling imports:

from crt_pattern_generator import CRTPatternGenerator

This fails with ModuleNotFoundError when importing from the parent directory (import src).

Fix 1: Relative Imports

Changed to package-relative imports:

from .crt_pattern_generator import CRTPatternGenerator

Problem 2: Windows Encoding Crash

validate_bounty_2310.py prints Unicode emoji (✅❌ℹ️) and reads UTF-8 files without specifying encoding. On Windows CP1252 consoles this crashes with UnicodeEncodeError / UnicodeDecodeError.

Fix 2: ASCII-Safe Output + Explicit Encoding

  • Replaced emoji with ASCII labels: [PASS], [FAIL], [INFO]
  • Added encoding='utf-8' to all open(..., 'r') calls

Verification

  • python -m py_compile passes for both files
  • ✅ No Unicode emoji remaining in output functions
  • ✅ All text reads use explicit UTF-8 encoding
  • ✅ Relative imports allow package-style import from parent dir

Fixes #4749


This fix was generated with AI assistance (WorkBuddy Bounty Hunter).

…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
@github-actions
Copy link
Copy Markdown
Contributor

Welcome to RustChain! Thanks for your first pull request.

Before we review, please make sure:

  • Your PR has a BCOS-L1 or BCOS-L2 label
  • New code files include an SPDX license header
  • You've tested your changes against the live node

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!

@github-actions github-actions Bot added BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) size/S PR: 11-50 lines labels May 12, 2026
Copy link
Copy Markdown

@saim256 saim256 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 src path 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.

@Monkey-Sheep
Copy link
Copy Markdown
Author

Closing per @saim256's review — this PR duplicates the scope of #4750 which covers the same #4749 fix with compatibility fallbacks and regression coverage. Deferring to the more complete implementation. Appreciate the thorough review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) size/S PR: 11-50 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CRT attestation validation fails on Windows encodings and package import

2 participants