GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Inconsistent behaviour when stripping bytestrings via CliRunner · Issue #334 · pallets/click

Inconsistent behaviour when stripping bytestrings via CliRunner #334

New issue
Copy link
New issue
Copy link
Closed
Closed
Inconsistent behaviour when stripping bytestrings via CliRunner#334
Copy link
Assignees
mitsuhiko
Labels
docsUpdates to documentation, readme, docstrings, typos
Milestone
7.0

Description

@WhyNotHugo
WhyNotHugo
opened on May 2, 2015
Issue body actions

CliRunner seems to strip bold ansi escape sequences from .output on python2, but they're present on python3.

The doc says color escape codes are removes, but does not mention bold codes. I'm not sure if they're meant to be kept or not, but the behaviour should be consistent across python versions.

Activity

  1. untitaker commented on May 2, 2015

    @untitaker
    untitaker
    on May 2, 2015
    Contributor
    More actions

    Hmm, this works on both Python versions though:

    assert strip_ansi(style('lol', bold=True)) == 'lol'
    
  2. untitaker commented on May 2, 2015

    @untitaker
    untitaker
    on May 2, 2015
    Contributor
    More actions

    The bug seems to be that Click doesn't do any colorcode stripping with echo(b'...') on Python 3.

  3. untitaker commented on May 2, 2015

    @untitaker
    untitaker
    on May 2, 2015
    Contributor
    More actions

    Reading through the code, it seems that Click intentionally does not do any code-stripping when the input is bytes.

  4. untitaker
    added
    docsUpdates to documentation, readme, docstrings, typos
    on May 2, 2015
  5. WhyNotHugo commented on May 2, 2015

    @WhyNotHugo
    WhyNotHugo
    on May 2, 2015
    Author
    More actions

    Why does this example use echo() instead of the regular print() function? The answer to this question is that Click attempts to support both Python 2 and Python 3 the same way and to be very robust even when the environment is misconfigured.

    source

    Looks it's a bug, since the doc states that this sort of discrepancy is exactly what they intend to fix.

  6. untitaker commented on May 2, 2015

    @untitaker
    untitaker
    on May 2, 2015
    Contributor
    More actions

    Which is why I'm tagging it as a documentation issue. The code comments describe that particular exception: https://github.com/mitsuhiko/click/blob/master/click/utils.py#L278

  7. WhyNotHugo commented on May 2, 2015

    @WhyNotHugo
    WhyNotHugo
    on May 2, 2015
    Author
    More actions

    This isn't the issue in my case anyway. The content I'm printing is unicode on python2 and str on python3.

    What you describe may be true, but it's still a separate issue.

  8. untitaker commented on May 2, 2015

    @untitaker
    untitaker
    on May 2, 2015
    Contributor
    More actions

    You're right.

  9. untitaker commented on May 2, 2015

    @untitaker
    untitaker
    on May 2, 2015
    Contributor
    More actions

    No, actually you're not. This fixes all your tests: https://gist.github.com/untitaker/65042a4c1fd9436ab71d

  10. WhyNotHugo commented on May 2, 2015

    @WhyNotHugo
    WhyNotHugo
    on May 2, 2015
    Author
    More actions

    Oh. My check was in the wrong place, I failed to notice that.
    Ok, my issue seems to have been a non-issue and bad testing (twice) on my behalf.

    I'll leave this open for the documentation fix you mentioned.

  11. untitaker commented on May 2, 2015

    @untitaker
    untitaker
    on May 2, 2015
    Contributor
    More actions

    I'm definetly not sure if Click's current behavior is desirable at all though (since it's hard to debug why click didn't rip out escape sequences in this particular case), even though I apprechiate Click's careful approach to encodings.

  12. untitaker
    assigned
    mitsuhiko
    on May 2, 2015
  13. untitaker
    changed the title [-]Inconsistent behaviour when stripping bold via CliRunner[/-] [+]Inconsistent behaviour when stripping bytestrings via CliRunner[/+] on Jun 18, 2015
  14. untitaker
    added a commit that references this issue on Jun 18, 2015

    Remove encodings

    18a6a35
  15. mitsuhiko commented on Jul 19, 2015

    @mitsuhiko
    mitsuhiko
    on Jul 19, 2015
    Contributor
    More actions

    Click does not strip colors from bytes, buffer or bytearray on any platform. On Python 2 because we cannot differ str and unicode stripping might happen with quasi bytes there. I do not want to break this behavior because otherwise you cannot echo binary data safely to the terminal.

    Why do you need to strip ansi codes on byte data?

  16. untitaker commented on Jul 19, 2015

    @untitaker
    untitaker
    on Jul 19, 2015
    Contributor
    More actions

    IIRC we're echoing bytes (when it should be unicode) in some rather old software that was recently ported to be a 2-and-3 polyglot. I think that string type was the wrong choice, but changing our string model will take a lot of time.

  17. jcrotts commented on May 15, 2018

    @jcrotts
    jcrotts
    on May 15, 2018
    Contributor
    More actions

    Proposing that we add some documentation to http://click.pocoo.org/5/quickstart/#echoing highlighting the different handling of color codes in bytes, buffer and bytearray in Python 2 and 3.

  18. dsully
    added a commit that references this issue on May 15, 2018

    Merge pull request #1010 from rpgraham84/master

    692cb32
  19. dsully
    closed this as completedon May 15, 2018
  20. davidism
    added this to the 7.0 milestone on Sep 10, 2018
  21. bors
    added 2 commits that reference this issue on Oct 8, 2018

    Merge #1576

    b204cec

    Merge #37

    d8ffc17
  22. kornicameister
    added a commit that references this issue on Oct 29, 2018

    Update click to 7.0 (#97)

    62891b6
  23. github-actions
    locked as resolved and limited conversation to collaborators on Nov 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @mitsuhiko
    mitsuhiko

Labels

docsUpdates to documentation, readme, docstrings, typos

Type

No type

Projects

No projects

    Milestone

    • 7.0

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.