From: Brian Gesiak Date: Fri, 11 Aug 2017 17:56:57 +0000 (+0000) Subject: [opt-viewer] Use Python 3-compatible `intern()` X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=51d5be37337a4e6089435f49d62ef69ee91541ce;p=llvm [opt-viewer] Use Python 3-compatible `intern()` Summary: In Python 2, `intern()` is a builtin function available to all programs. In Python 3, it was moved into the `sys` module, available as `sys.intern`. Import it such that, within `optrecord.py`, `intern()` is available whether run using Python 2 or 3. Test Plan: Run `opt-viewer.py` using Python 3, confirm it no longer encounters a runtime error when `intern()` is called. Reviewers: anemet Reviewed By: anemet Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D36622 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310739 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/opt-viewer/optrecord.py b/tools/opt-viewer/optrecord.py index 3744c68af60..2bf0f356d85 100644 --- a/tools/opt-viewer/optrecord.py +++ b/tools/opt-viewer/optrecord.py @@ -17,6 +17,12 @@ import functools from multiprocessing import Lock import os, os.path import subprocess +try: + # The previously builtin function `intern()` was moved + # to the `sys` module in Python 3. + from sys import intern +except: + pass import optpmap