Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions gyp/pylib/gyp/MSVSNew.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
import md5
_new_md5 = md5.new

try:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move these to init.py, then import them (cmp, type_list, basestring, etc..)

cmp # Python 2
except NameError:
def cmp(x, y): # Python 3
return (x > y) - (x < y)

# Initialize random number generator
random.seed()
Expand Down
7 changes: 3 additions & 4 deletions gyp/pylib/gyp/MSVSVersion.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import re
import subprocess
import sys
import gyp
import glob


Expand Down Expand Up @@ -178,15 +177,15 @@ def _RegistryGetValueUsingWinReg(key, value):
"""
try:
# Python 2
from _winreg import OpenKey, QueryValueEx
from _winreg import HKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
except ImportError:
# Python 3
from winreg import OpenKey, QueryValueEx
from winreg import HKEY_LOCAL_MACHINE, OpenKey, QueryValueEx

try:
root, subkey = key.split('\\', 1)
assert root == 'HKLM' # Only need HKLM for now.
with OpenKey(_winreg.HKEY_LOCAL_MACHINE, subkey) as hkey:
with OpenKey(HKEY_LOCAL_MACHINE, subkey) as hkey:
return QueryValueEx(hkey, value)[0]
except WindowsError:
return None
Expand Down
7 changes: 5 additions & 2 deletions gyp/pylib/gyp/simple_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ def deepcopy(x):
def _deepcopy_atomic(x):
return x

for x in (type(None), int, long, float,
bool, str, unicode, type):
try:
type_list = (type(None), int, long, float, bool, str, unicode, type)
except NameError:
type_list = (type(None), int, float, bool, str, type)
for x in type_list:
d[x] = _deepcopy_atomic

def _deepcopy_list(x):
Expand Down
2 changes: 1 addition & 1 deletion gyp/pylib/gyp/xcode_emulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ def GetLdflags(self, configname, product_dir, gyp_to_build_path, arch=None):
if self._IsXCTest():
platform_root = self._XcodePlatformPath(configname)
if platform_root:
cflags.append('-F' + platform_root + '/Developer/Library/Frameworks/')
ldflags.append('-F' + platform_root + '/Developer/Library/Frameworks/')

is_extension = self._IsIosAppExtension() or self._IsIosWatchKitExtension()
if sdk_root and is_extension:
Expand Down
25 changes: 19 additions & 6 deletions gyp/pylib/gyp/xcodeproj_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,21 @@
import sha
_new_sha1 = sha.new

try:
basestring # Python 2
except NameError:
basestring = (str, ) # Python 3

try:
cmp # Python 2
except NameError:
def cmp(x, y): # Python 3
return (x > y) - (x < y)

try:
unicode # Python 2
except NameError:
unicode = str # Python 3

# See XCObject._EncodeString. This pattern is used to determine when a string
# can be printed unquoted. Strings that match this pattern may be printed
Expand Down Expand Up @@ -324,8 +339,7 @@ def Copy(self):
that._properties[key] = new_value
else:
that._properties[key] = value
elif isinstance(value, str) or isinstance(value, unicode) or \
isinstance(value, int):
elif isinstance(value, (basestring, int)):
that._properties[key] = value
elif isinstance(value, list):
if is_strong:
Expand Down Expand Up @@ -766,15 +780,15 @@ def UpdateProperties(self, properties, do_copy=False):
' must be list, not ' + value.__class__.__name__)
for item in value:
if not isinstance(item, property_type) and \
not (item.__class__ == unicode and property_type == str):
item.__class__ not in (str, unicode):
# Accept unicode where str is specified. str is treated as
# UTF-8-encoded.
raise TypeError(
'item of ' + property + ' of ' + self.__class__.__name__ + \
' must be ' + property_type.__name__ + ', not ' + \
item.__class__.__name__)
elif not isinstance(value, property_type) and \
not (value.__class__ == unicode and property_type == str):
value.__class__ not in (str, unicode):
# Accept unicode where str is specified. str is treated as
# UTF-8-encoded.
raise TypeError(
Expand All @@ -788,8 +802,7 @@ def UpdateProperties(self, properties, do_copy=False):
self._properties[property] = value.Copy()
else:
self._properties[property] = value
elif isinstance(value, str) or isinstance(value, unicode) or \
isinstance(value, int):
elif isinstance(value, (basestring, int)):
self._properties[property] = value
elif isinstance(value, list):
if is_strong:
Expand Down
Loading