Skip to content

Handle ASCII help output streams#1852

Open
puneetdixit200 wants to merge 11 commits into
httpie:masterfrom
puneetdixit200:fix-ascii-help-output
Open

Handle ASCII help output streams#1852
puneetdixit200 wants to merge 11 commits into
httpie:masterfrom
puneetdixit200:fix-ascii-help-output

Conversation

@puneetdixit200
Copy link
Copy Markdown

Fixes #1411.

Summary:

  • Fall back to ASCII-safe escape sequences when argparse help text is written to a strict ASCII stream.
  • Add a regression test for http --help with ASCII-only stdout.

Tests:

  • python -m pytest tests/test_httpie.py::test_help tests/test_httpie.py::test_help_with_ascii_stdout -q
  • python -m pytest tests/test_httpie.py -q
  • python -m pytest tests/test_cli.py -q
  • python -m pytest tests/test_cli_utils.py -q
  • python -m flake8 httpie/cli/argparser.py tests/test_httpie.py
  • git diff --check

@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 85.71429% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.10%. Comparing base (4d7d6b6) to head (e3ac637).
⚠️ Report is 383 commits behind head on master.

Files with missing lines Patch % Lines
httpie/cli/argparser.py 70.00% 3 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1852      +/-   ##
==========================================
- Coverage   97.28%   94.10%   -3.19%     
==========================================
  Files          67      113      +46     
  Lines        4235     7712    +3477     
==========================================
+ Hits         4120     7257    +3137     
- Misses        115      455     +340     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@puneetdixit200 puneetdixit200 force-pushed the fix-ascii-help-output branch from f85211a to 7b8d933 Compare May 21, 2026 10:29
@puneetdixit200
Copy link
Copy Markdown
Author

Added coverage for the remaining ASCII help output branches in BaseHTTPieArgumentParser._print_message.

Local checks run:

UV_CACHE_DIR=/tmp/httpie-1852-uv-cache PIP_CACHE_DIR=/tmp/httpie-1852-pip-cache uv run --python 3.12 --with '.[dev,test]' python -m pytest tests/test_httpie.py::test_help_with_ascii_stdout tests/test_httpie.py::test_help_message_encodes_binary_stream_without_buffer tests/test_httpie.py::test_help_message_reraises_non_text_unicode_errors tests/test_cli_ui.py::test_naked_invocation --cov=httpie.cli.argparser --cov-report=term-missing -q\nUV_CACHE_DIR=/tmp/httpie-1852-uv-cache PIP_CACHE_DIR=/tmp/httpie-1852-pip-cache uv run --python 3.12 --with '.[dev,test]' python -m pytest tests/test_httpie.py tests/test_cli_ui.py tests/test_encoding.py -q\nUV_CACHE_DIR=/tmp/httpie-1852-uv-cache PIP_CACHE_DIR=/tmp/httpie-1852-pip-cache uv run --python 3.12 --with '.[dev,test]' python -m flake8 tests/test_httpie.py\ngit diff --check\n```\n\nThe focused coverage run no longer reports the changed `_print_message` fallback lines as missing.

@puneetdixit200
Copy link
Copy Markdown
Author

Follow-up for the red macOS matrix: the jobs were still targeting the retired macos-13 runner and were canceling after 24 hours without logs or steps. I moved the matrix to macos-15-intel, which keeps the Intel macOS environment while using a supported runner label.\n\nLocal validation for this CI-only change:\n\n\ngit diff --check\nruby -e "require 'yaml'; YAML.load_file('.github/workflows/tests.yml')"\n\n\nNew CI is running on head 2f300ec: https://github.com/httpie/cli/actions/runs/26440024081

@puneetdixit200
Copy link
Copy Markdown
Author

Follow-up on the macOS dependency setup failure from the first replacement run: test (macos-15-intel, 3.9, 1) reached install and failed while brotlicffi was being built through setuptools' legacy fetch_build_eggs path. I pushed 4122d86 to make the dev dependency install use pip's PEP 517 build path.\n\nValidation run locally in a temp Python 3.9 venv:\n\n\npython -m pip install --upgrade "pip<25.3; python_version<'3.10'" "pip; python_version>='3.10'" setuptools wheel build\npython -m pip install --use-pep517 --no-binary=brotlicffi brotlicffi\n\n\nThat forced source build completed successfully with brotlicffi-1.2.0.1, cffi-2.0.0, and pycparser. Latest CI is running on head 4122d86: https://github.com/httpie/cli/actions/runs/26440591693

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.

Help option crash

2 participants