mirror of
https://github.com/electron/node-gyp.git
synced 2025-09-15 13:43:40 +02:00
gyp: fix the remaining Python 3 issues
PR-URL: https://github.com/nodejs/node-gyp/pull/1793 Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
parent
395f843de0
commit
a991f633d6
6 changed files with 35 additions and 21 deletions
|
@ -4,9 +4,6 @@ cache: pip
|
||||||
python:
|
python:
|
||||||
- 2.7
|
- 2.7
|
||||||
- 3.7
|
- 3.7
|
||||||
matrix:
|
|
||||||
allow_failures:
|
|
||||||
- python: 3.7
|
|
||||||
install:
|
install:
|
||||||
#- pip install -r requirements.txt
|
#- pip install -r requirements.txt
|
||||||
- pip install flake8 # pytest # add another testing frameworks later
|
- pip install flake8 # pytest # add another testing frameworks later
|
||||||
|
|
|
@ -10,6 +10,11 @@ import random
|
||||||
|
|
||||||
import gyp.common
|
import gyp.common
|
||||||
|
|
||||||
|
try:
|
||||||
|
cmp
|
||||||
|
except NameError:
|
||||||
|
def cmp(x, y):
|
||||||
|
return (x > y) - (x < y)
|
||||||
|
|
||||||
# Initialize random number generator
|
# Initialize random number generator
|
||||||
random.seed()
|
random.seed()
|
||||||
|
|
|
@ -28,8 +28,12 @@ _deepcopy_dispatch = d = {}
|
||||||
def _deepcopy_atomic(x):
|
def _deepcopy_atomic(x):
|
||||||
return x
|
return x
|
||||||
|
|
||||||
for x in (type(None), int, long, float,
|
try:
|
||||||
bool, str, unicode, type):
|
types = bool, float, int, str, type, type(None), long, unicode
|
||||||
|
except NameError: # Python 3
|
||||||
|
types = bool, float, int, str, type, type(None)
|
||||||
|
|
||||||
|
for x in types:
|
||||||
d[x] = _deepcopy_atomic
|
d[x] = _deepcopy_atomic
|
||||||
|
|
||||||
def _deepcopy_list(x):
|
def _deepcopy_list(x):
|
||||||
|
|
|
@ -138,21 +138,18 @@ a project file is output.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import gyp.common
|
import gyp.common
|
||||||
|
import hashlib
|
||||||
import posixpath
|
import posixpath
|
||||||
import re
|
import re
|
||||||
import struct
|
import struct
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
# hashlib is supplied as of Python 2.5 as the replacement interface for sha
|
|
||||||
# and other secure hashes. In 2.6, sha is deprecated. Import hashlib if
|
|
||||||
# available, avoiding a deprecation warning under 2.6. Import sha otherwise,
|
|
||||||
# preserving 2.4 compatibility.
|
|
||||||
try:
|
try:
|
||||||
import hashlib
|
basestring, cmp, unicode
|
||||||
_new_sha1 = hashlib.sha1
|
except NameError: # Python 3
|
||||||
except ImportError:
|
basestring = unicode = str
|
||||||
import sha
|
def cmp(x, y):
|
||||||
_new_sha1 = sha.new
|
return (x > y) - (x < y)
|
||||||
|
|
||||||
|
|
||||||
# See XCObject._EncodeString. This pattern is used to determine when a string
|
# See XCObject._EncodeString. This pattern is used to determine when a string
|
||||||
|
@ -324,8 +321,7 @@ class XCObject(object):
|
||||||
that._properties[key] = new_value
|
that._properties[key] = new_value
|
||||||
else:
|
else:
|
||||||
that._properties[key] = value
|
that._properties[key] = value
|
||||||
elif isinstance(value, str) or isinstance(value, unicode) or \
|
elif isinstance(value, (basestring, int)):
|
||||||
isinstance(value, int):
|
|
||||||
that._properties[key] = value
|
that._properties[key] = value
|
||||||
elif isinstance(value, list):
|
elif isinstance(value, list):
|
||||||
if is_strong:
|
if is_strong:
|
||||||
|
@ -422,7 +418,7 @@ class XCObject(object):
|
||||||
hash.update(data)
|
hash.update(data)
|
||||||
|
|
||||||
if seed_hash is None:
|
if seed_hash is None:
|
||||||
seed_hash = _new_sha1()
|
seed_hash = hashlib.sha1()
|
||||||
|
|
||||||
hash = seed_hash.copy()
|
hash = seed_hash.copy()
|
||||||
|
|
||||||
|
@ -788,8 +784,7 @@ class XCObject(object):
|
||||||
self._properties[property] = value.Copy()
|
self._properties[property] = value.Copy()
|
||||||
else:
|
else:
|
||||||
self._properties[property] = value
|
self._properties[property] = value
|
||||||
elif isinstance(value, str) or isinstance(value, unicode) or \
|
elif isinstance(value, (basestring, int)):
|
||||||
isinstance(value, int):
|
|
||||||
self._properties[property] = value
|
self._properties[property] = value
|
||||||
elif isinstance(value, list):
|
elif isinstance(value, list):
|
||||||
if is_strong:
|
if is_strong:
|
||||||
|
|
|
@ -22,6 +22,12 @@ from xml.dom.minidom import Node
|
||||||
|
|
||||||
__author__ = 'nsylvain (Nicolas Sylvain)'
|
__author__ = 'nsylvain (Nicolas Sylvain)'
|
||||||
|
|
||||||
|
try:
|
||||||
|
cmp
|
||||||
|
except NameError:
|
||||||
|
def cmp(x, y):
|
||||||
|
return (x > y) - (x < y)
|
||||||
|
|
||||||
REPLACEMENTS = dict()
|
REPLACEMENTS = dict()
|
||||||
ARGUMENTS = None
|
ARGUMENTS = None
|
||||||
|
|
||||||
|
|
11
test/fixtures/test-charmap.py
vendored
11
test/fixtures/test-charmap.py
vendored
|
@ -2,14 +2,21 @@ from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import locale
|
import locale
|
||||||
|
|
||||||
reload(sys)
|
try:
|
||||||
|
reload(sys)
|
||||||
|
except NameError: # Python 3
|
||||||
|
pass
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
encoding = locale.getdefaultlocale()[1]
|
encoding = locale.getdefaultlocale()[1]
|
||||||
if not encoding:
|
if not encoding:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
sys.setdefaultencoding(encoding)
|
try:
|
||||||
|
sys.setdefaultencoding(encoding)
|
||||||
|
except AttributeError: # Python 3
|
||||||
|
pass
|
||||||
|
|
||||||
textmap = {
|
textmap = {
|
||||||
'cp936': u'\u4e2d\u6587',
|
'cp936': u'\u4e2d\u6587',
|
||||||
'cp1252': u'Lat\u012Bna',
|
'cp1252': u'Lat\u012Bna',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue