Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Unified Diff: pylib/gyp/simple_copy.py

Issue 1454433002: Python 3 compatibility Base URL: https://chromium.googlesource.com/external/gyp.git@master
Patch Set: Rebase with master (4ec6c4e3a94bd04a6da2858163d40b2429b8aad1) Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pylib/gyp/simple_copy.py
diff --git a/pylib/gyp/simple_copy.py b/pylib/gyp/simple_copy.py
index 74c98c5a79594b81eda9dfaaefa743cb9765be30..58a61c34231f81e7a49d1606d42bfd773551e80d 100644
--- a/pylib/gyp/simple_copy.py
+++ b/pylib/gyp/simple_copy.py
@@ -28,8 +28,19 @@ _deepcopy_dispatch = d = {}
def _deepcopy_atomic(x):
return x
-for x in (type(None), int, long, float,
- bool, str, unicode, type):
+try:
+ _string_types = (str, unicode)
+# There's no unicode in python3
+except NameError:
+ _string_types = (str, )
+
+try:
+ _integer_types = (int, long)
+# There's no long in python3
+except NameError:
+ _integer_types = (int, )
+
+for x in (type(None), float, bool, type) + _integer_types + _string_types:
d[x] = _deepcopy_atomic
def _deepcopy_list(x):
@@ -38,7 +49,7 @@ d[list] = _deepcopy_list
def _deepcopy_dict(x):
y = {}
- for key, value in x.iteritems():
+ for key, value in x.items():
y[deepcopy(key)] = deepcopy(value)
return y
d[dict] = _deepcopy_dict

Powered by Google App Engine
This is Rietveld 408576698