[PATCH] D36622: [opt-viewer] Use Python 3-compatible `intern()`

Brian Gesiak via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 11 10:15:20 PDT 2017

modocache created this revision.

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.



Index: tools/opt-viewer/optrecord.py
--- tools/opt-viewer/optrecord.py
+++ tools/opt-viewer/optrecord.py
@@ -17,6 +17,12 @@
 from multiprocessing import Lock
 import os, os.path
 import subprocess
+    # The previously builtin function `intern()` was moved
+    # to the `sys` module in Python 3.
+    from sys import intern
+    pass
 import optpmap

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36622.110759.patch
Type: text/x-patch
Size: 438 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170811/6b87dc8c/attachment.bin>

More information about the llvm-commits mailing list