This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Make add_new_check.py Python 3 compatible
AbandonedPublic

Authored by omtcyfz on Sep 28 2016, 7:19 AM.

Details

Reviewers
None
Summary

add_new_check.py didn't support Python 3.X for some reason, even though it used print in Python 3.X-compatible way. With just a few tweaks add_new_check.py supports both Python 2.7.X and Python 3.X.

Tested: Python 2.7.6, Python 2.7.12, Python 3.5.2.

Currently stalled, not updated for a while.

Diff Detail

Event Timeline

omtcyfz updated this revision to Diff 72820.Sep 28 2016, 7:19 AM
omtcyfz retitled this revision from to [clang-tidy] Make add_new_check.py Python 3 compatible.
omtcyfz updated this object.
omtcyfz added reviewers: alexfh, ioeric, bkramer.
omtcyfz added subscribers: cfe-commits, aaron.ballman.
bkramer added inline comments.Sep 30 2016, 4:09 AM
clang-tidy/add_new_check.py
16

Can we rely on six being available? It's not part of the default python installation afaik.

omtcyfz added inline comments.Sep 30 2016, 5:22 AM
clang-tidy/add_new_check.py
16

Yes, I am pretty sure about that. Absolute majority of Python projects relies on having six available and Python installation without six seems really weird to me.

This is THE standard library for Python 2.7.X/3.X compatibility issues.

bkramer accepted this revision.Sep 30 2016, 5:25 AM
bkramer edited edge metadata.

Okay. If six is installed by default on Ubuntu and macOS we should be fine. The script isn't in the critical path for anyone.

This revision is now accepted and ready to land.Sep 30 2016, 5:25 AM

UPD: This patch is eventually causing some problems in Python 3. Working on that.

alexfh requested changes to this revision.Oct 5 2016, 10:53 PM
alexfh edited edge metadata.
alexfh added inline comments.
clang-tidy/add_new_check.py
58

Too many parentheses.

97–100

Is it better to encode the result of the formatting operator instead?

(""" ..... """ % {'header_guard': header_guard, ... }).encode()
This revision now requires changes to proceed.Oct 5 2016, 10:53 PM
omtcyfz edited the summary of this revision. (Show Details)
omtcyfz abandoned this revision.Jul 20 2018, 1:47 AM

No longer relevant.