Andreas Sandberg has submitted this change and it was merged. (
https://gem5-review.googlesource.com/c/public/gem5/+/15994 )
Change subject: python: Add fallbacks for packages that have been renamed
......................................................................
python: Add fallbacks for packages that have been renamed
Python 3 has restructured some packages. Specifically, __builtin__ has
been renamed to builtins and urlparse has been included in urllib.
Change-Id: I81f8f3942471db1043006a36abbad6e5a49e0a43
Signed-off-by: Andreas Sandberg <[email protected]>
Reviewed-on: https://gem5-review.googlesource.com/c/15994
Reviewed-by: Juha Jäykkä <[email protected]>
---
M src/python/m5/stats/__init__.py
M src/python/m5/util/code_formatter.py
2 files changed, 17 insertions(+), 5 deletions(-)
Approvals:
Juha Jäykkä: Looks good to me, approved
Andreas Sandberg: Looks good to me, approved
diff --git a/src/python/m5/stats/__init__.py
b/src/python/m5/stats/__init__.py
index acb62f1..019c7eb 100644
--- a/src/python/m5/stats/__init__.py
+++ b/src/python/m5/stats/__init__.py
@@ -71,7 +71,11 @@
@wraps(func)
def wrapper(url):
- from urlparse import parse_qs
+ try:
+ from urllib.parse import parse_qs
+ except ImportError:
+ # Python 2 fallback
+ from urlparse import parse_qs
from ast import literal_eval
qs = parse_qs(url.query, keep_blank_values=True)
@@ -135,7 +139,11 @@
"""
- from urlparse import urlsplit
+ try:
+ from urllib.parse import urlsplit
+ except ImportError:
+ # Python 2 fallback
+ from urlparse import urlsplit
parsed = urlsplit(url)
diff --git a/src/python/m5/util/code_formatter.py
b/src/python/m5/util/code_formatter.py
index c845c90..21bbcd7 100644
--- a/src/python/m5/util/code_formatter.py
+++ b/src/python/m5/util/code_formatter.py
@@ -26,7 +26,11 @@
from __future__ import print_function
-import __builtin__
+try:
+ import builtins
+except ImportError:
+ # Python 2 fallback
+ import __builtin__ as builtins
import inspect
import os
import re
@@ -66,8 +70,8 @@
if self.formatter.globals and item in self.frame.f_globals:
return self.frame.f_globals[item]
- if item in __builtin__.__dict__:
- return __builtin__.__dict__[item]
+ if item in builtins.__dict__:
+ return builtins.__dict__[item]
try:
item = int(item)
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/15994
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I81f8f3942471db1043006a36abbad6e5a49e0a43
Gerrit-Change-Number: 15994
Gerrit-PatchSet: 8
Gerrit-Owner: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Juha Jäykkä <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev