fix: handle emoji/special-character PDF paths in ASCII terminals#52
Open
ambicuity wants to merge 1 commit intoSUPAIDEAS:mainfrom
Open
fix: handle emoji/special-character PDF paths in ASCII terminals#52ambicuity wants to merge 1 commit intoSUPAIDEAS:mainfrom
ambicuity wants to merge 1 commit intoSUPAIDEAS:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a CLI exit-code regression where printing success/error messages could raise UnicodeEncodeError in ASCII-only output environments when file paths include emoji/special characters, causing a false failure despite successful encryption.
Changes:
- Add
_stream_safe_text/_safe_printhelpers and route CLI messaging through them to avoid encoding exceptions. - Add unit + integration coverage to validate ASCII-only stdout behavior with emoji paths.
- Update README “Known Issues” to reflect current behavior (emoji paths supported; PDF-object warnings may still appear).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
passifypdf/encryptpdf.py |
Introduces encoding-safe printing for CLI success/error output to prevent UnicodeEncodeError from impacting exit codes. |
tests/unittests/test_encryptpdf.py |
Adds a unit test that runs main() with ASCII-only stdout/stderr and verifies escaped output + success exit code. |
tests/integrationtests/test_encryptpdf_integration.py |
Adds a subprocess integration test with PYTHONIOENCODING=ascii to ensure the CLI succeeds and produces an escaped path. |
README.md |
Updates “Known Issues” to remove outdated emoji-path warning and document current behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PYTHONIOENCODING=asciiwith emoji file pathsWhy
Issue #23 reports that special characters/emojis in file paths cause a minor complaint during execution.
Root cause: success logging attempted to print non-ASCII paths directly, which can raise
UnicodeEncodeErrorin ASCII output environments and incorrectly return a failure exit code.Validation
poetry run coverage run -m unittest discover testsPYTHONIOENCODING=asciinow returns exit code0and writes output successfullyCloses #23