scripted-diff: force set python source file encoding to utf-8 #14265

pull ken2812221 wants to merge 2 commits into bitcoin:master from ken2812221:2018-09-19-python-utf8 changing 147 files +148 −2
  1. ken2812221 commented at 2:47 AM on September 19, 2018: contributor

    On Windows, the python file have to run with environment variable PYTHONIOENCODING=utf-8. We could not run the test without that environment variable on master.

    The way to force it using utf-8 without that environment variable is to add # -*- coding: utf-8 -*- at the second line of python files.

  2. scripted-diff: force set python source file encoding to utf-8
    -BEGIN VERIFY SCRIPT-
    sed -i 's/#!\/usr\/bin\/env python3/#!\/usr\/bin\/env python3\n# -*- coding: utf-8 -*-/g' $(git ls-files -- '*.py')
    -END VERIFY SCRIPT-
    52623b7bff
  3. lint: use utf-8 to read python source file 42d512bd05
  4. fanquake added the label Tests on Sep 19, 2018
  5. fanquake added the label Scripts and tools on Sep 19, 2018
  6. MarcoFalke commented at 3:04 AM on September 19, 2018: member

    Tend to NACK. It seems easier to export PYTHONIOENCODING=utf-8

  7. ken2812221 commented at 3:22 AM on September 19, 2018: contributor

    It seems easier to export PYTHONIOENCODING=utf-8

    For me, the python file should be locale independent. There is no reason that we should run python script with some specific environment variable. Also, you can't guarantee that everyone run the python script from command line like someone can run it with double-clicking the python file. Furthermore, this would prevent encoding issue forever by using utf-8 explicitly. Shouldn't explicit better than implicit?

  8. MarcoFalke commented at 3:29 AM on September 19, 2018: member

    We require python3, which follows PEP 3120. Explicitly setting the encoding should only be needed when it is not utf-8.

  9. ken2812221 closed this on Sep 19, 2018

  10. ken2812221 deleted the branch on Sep 19, 2018
  11. ken2812221 commented at 4:25 AM on September 19, 2018: contributor

    Oh, it appears to be a mistake running the script with python2. I remember I met this issue before when I was testing #14007, but it seems that the problem is the ouput encoding, I'll try to solve it in another way. Closing this, sorry for annoying.

  12. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-20 09:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me