Skip to content

Commit

Permalink
gyp: replace basestring with str, but only on Python 3.
Browse files Browse the repository at this point in the history
On Python 2, basestring is (unicode, str).
On Python 3, basestring and unicode are gone, and there is only str.
  • Loading branch information
rodrigc authored and rvagg committed Apr 24, 2019
1 parent 7535e44 commit 98226d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
10 changes: 6 additions & 4 deletions gyp/pylib/gyp/MSVSSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

from __future__ import print_function

from gyp import string_types

import sys
import re

Expand Down Expand Up @@ -108,11 +110,11 @@ class _String(_Type):
"""A setting that's just a string."""

def ValidateMSVS(self, value):
if not isinstance(value, basestring):
if not isinstance(value, string_types):
raise ValueError('expected string; got %r' % value)

def ValidateMSBuild(self, value):
if not isinstance(value, basestring):
if not isinstance(value, string_types):
raise ValueError('expected string; got %r' % value)

def ConvertToMSBuild(self, value):
Expand All @@ -124,11 +126,11 @@ class _StringList(_Type):
"""A settings that's a list of strings."""

def ValidateMSVS(self, value):
if not isinstance(value, basestring) and not isinstance(value, list):
if not isinstance(value, string_types) and not isinstance(value, list):
raise ValueError('expected string list; got %r' % value)

def ValidateMSBuild(self, value):
if not isinstance(value, basestring) and not isinstance(value, list):
if not isinstance(value, string_types) and not isinstance(value, list):
raise ValueError('expected string list; got %r' % value)

def ConvertToMSBuild(self, value):
Expand Down
9 changes: 8 additions & 1 deletion gyp/pylib/gyp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
import traceback
from gyp.common import GypError

try:
# Python 2
string_types = basestring
except NameError:
# Python 3
string_types = str

# Default debug modes for GYP
debug = {}

Expand Down Expand Up @@ -412,7 +419,7 @@ def gyp_main(args):
for option, value in sorted(options.__dict__.items()):
if option[0] == '_':
continue
if isinstance(value, basestring):
if isinstance(value, string_types):
DebugOutput(DEBUG_GENERAL, " %s: '%s'", option, value)
else:
DebugOutput(DEBUG_GENERAL, " %s: %s", option, value)
Expand Down

0 comments on commit 98226d1

Please sign in to comment.