fix encoding issues with inputs for better Python 3 support

When running subprocesses like '!<(which foo)', we return subprocess's
stdout contents as bytes, not as a string.  Make sure we decode it into
UTF-8 first.

When reading gyp files, we don't specify an encoding, so the default
might be ASCII which breaks when the gyp files contain UTF-8.  Change
it to always read it as a binary stream before decoding to UTF-8.

With those fixes in place, we need to rework all the type checks for
strings & numbers.  Introduce some aliases to the right set of types
for the active version of Python, and then change all the type checks
to use isinstance.

Bug: 926296
Test: building CrOS gyp packages with python3 works again
Test: `./gyptest.py -a` mostly passes (4 failures look toolchain related)
Change-Id: I416acf140d01948748f5cc09e966b52f166b82d0
Reviewed-on: https://chromium-review.googlesource.com/c/external/gyp/+/1697943
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
1 file changed
tree: 5854b9b9b493426b00c0eec02a6e764ca77fac53
  1. buildbot/
  2. data/
  3. pylib/
  4. samples/
  5. test/
  6. tools/
  7. .gitignore
  8. .travis.yml
  9. AUTHORS
  10. codereview.settings
  11. DEPS
  12. gyp
  13. gyp.bat
  14. gyp_main.py
  15. gyptest.py
  16. LICENSE
  17. OWNERS
  18. PRESUBMIT.py
  19. README.md
  20. setup.py
README.md

GYP can Generate Your Projects.

Documents are available at gyp.gsrc.io, or you can check out md-pages branch to read those documents offline.