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. .gitignore
  2. .travis.yml
  3. AUTHORS
  4. DEPS
  5. LICENSE
  6. OWNERS
  7. PRESUBMIT.py
  8. README.md
  9. buildbot/
  10. codereview.settings
  11. data/
  12. gyp
  13. gyp.bat
  14. gyp_main.py
  15. gyptest.py
  16. pylib/
  17. samples/
  18. setup.py
  19. test/
  20. tools/
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.