[PATCH] D42674: Make utils/UpdateTestChecks/common.py Python 2/3 compatible and fix print statements.

Brian Gesiak via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 1 13:03:42 PST 2018


modocache added a comment.

Mostly looks good, but I had one suggestion!



================
Comment at: utils/UpdateTestChecks/common.py:41
+    if sys.version_info[0] > 2:
+      stdout = stdout.decode()
   # Fix line endings to unix CR style.
----------------
I think you can call `decode` regardless. For example, the following code works on both Python 2 and 3:

```
from __future__ import print_function
import subprocess

out = subprocess.check_output(['ls']).decode()
print(out)
```

Here it is in an online [[ https://repl.it/repls/CoolDarkslategreyGermanspaniel | Python 2 ]] and [[ https://repl.it/repls/VitalMediumpurpleSteer | Python 3]] interpreter. (I don't think there's much overhead to doing so on Python 2, but if you're worried about that it might be worth looking into.)


Repository:
  rL LLVM

https://reviews.llvm.org/D42674





More information about the llvm-commits mailing list