This is an archive of the discontinued LLVM Phabricator instance.

Python 3.5 compatibility for clang-format.py
ClosedPublic

Authored by jacquelinekay on May 29 2016, 5:58 PM.

Details

Reviewers
djasper
phst
Summary

Some platforms (e.g. Ubuntu 16.04) ship a version of vim which supports Python 3 but not Python 2.7 (the output of vim --version contains -python and +python3 under the list of supported features). This patch updates clang-format.py to be Python 3.5 compatible. vim integration should still work with Python 2.7.

In Python 3, universal_newlines=True is needed for subprocess.communicate to accept a string. Without it, the script errors during runtime with: "TypeError: memoryview: a bytes-like object is required, not 'str'"

Diff Detail

Repository
rL LLVM

Event Timeline

jacquelinekay retitled this revision from to Python 3.5 compatibility for clang-format.py.
jacquelinekay updated this object.
jacquelinekay set the repository for this revision to rL LLVM.

Turns out that there are also Python 3 issues in

  • clang-format-diff.py (legacy-python style print statements)
  • ScanView.py (legacy-python style print statements and old style except statements).
v.g.vassilev added a subscriber: v.g.vassilev.
djasper accepted this revision.Oct 13 2016, 6:09 AM
djasper edited edge metadata.

Looks good.

This revision is now accepted and ready to land.Oct 13 2016, 6:09 AM

The print related changes were added in in r280240 (https://reviews.llvm.org/D23319). Could you rebase the patch?

I tested clang-format in vim with the recent state of trunk and it seems to work without my patch. The bug I ran into initially was fixed in D23319 with added encoding. So I think this can be closed without merging.

v.g.vassilev closed this revision.Oct 13 2016, 12:31 PM

Thanks I am closing it!