Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix printing of emoji on Windows when stdout is redirected #3374

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Commits on Nov 15, 2022

  1. Fix printing of emoji on Windows when stdout is redirected

    This is most apparent when black is run via pre-commit which does
    `subprocess.Popen(stdout=PIPE)`.
    
    One option around this would be to instruct users to set `PYTHONUTF8=1`,
    but that is not a very good approach, as basically everything supports
    UTF-8 these days.
    
    This fix was inspired by pycln and hadialqattan/pycln#54
    ashb committed Nov 15, 2022
    Configuration menu
    Copy the full SHA
    405c2e0 View commit details
    Browse the repository at this point in the history
  2. Only force utf-8 stdout/err on Windows 10+

    On older versions of Windows the cmd.exe can't display UTF-8, so this
    would likely result in mojibake. By limiting it to Windows10 we _know_
    that displaying UTF-8 will work
    ashb committed Nov 15, 2022
    Configuration menu
    Copy the full SHA
    08cc65d View commit details
    Browse the repository at this point in the history
  3. Ensure we have the Windows 10 Creators Update before forcing UTF-8

    It _might_ work on earlier versions, but this is where
    `CreatePseudoConsole` and the ConHost overhaul was released which
    definitely has universal utf-8 support.
    
    See https://learn.microsoft.com/en-us/windows/console/createpseudoconsole
    ashb committed Nov 15, 2022
    Configuration menu
    Copy the full SHA
    5e52770 View commit details
    Browse the repository at this point in the history
  4. Apply suggestions from code review

    Co-authored-by: Łukasz Langa <lukasz@langa.pl>
    ashb and ambv committed Nov 15, 2022
    Configuration menu
    Copy the full SHA
    bd81114 View commit details
    Browse the repository at this point in the history

Commits on Nov 19, 2022

  1. Update CHANGES.md

    ashb committed Nov 19, 2022
    Configuration menu
    Copy the full SHA
    3cf2c67 View commit details
    Browse the repository at this point in the history

Commits on Dec 30, 2022

  1. Configuration menu
    Copy the full SHA
    de02031 View commit details
    Browse the repository at this point in the history