Andreas Sandberg has uploaded this change for review. (
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]>
---
M src/python/m5/stats/__init__.py
M src/python/m5/util/code_formatter.py
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/src/python/m5/stats/__init__.py
b/src/python/m5/stats/__init__.py
index ba91f22..10184c2 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 6769adc..9870430 100644
--- a/src/python/m5/util/code_formatter.py
+++ b/src/python/m5/util/code_formatter.py
@@ -27,7 +27,11 @@
from __future__ import print_function
from six import add_metaclass
-import __builtin__
+try:
+ import builtins
+except ImportError:
+ # Python 2 fallback
+ import __builtin__ as builtins
import inspect
import os
import re
@@ -67,8 +71,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: 1
Gerrit-Owner: Andreas Sandberg <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev