hedronvision / bazel-compile-commands-extractor

Goal: Enable awesome tooling for Bazel users of the C language family.
Other
696 stars 112 forks source link

Fix: Use os.readlink instead of Path.readlink before Python 3.9. #172

Closed jinchengJL closed 9 months ago

jinchengJL commented 9 months ago

Path.readlink is not available before Python 3.9, which is causing the tool to complain in a project I'm working on. This code was implemented as os.readlink() before rules_python was introduced (per https://github.com/hedronvision/bazel-compile-commands-extractor/commit/0e5b1aa26d87a431d2a52676d0b9ce469448ee54), but didn't seem to be reverted when rules_python was reverted.

Verified locally that this fixes the issue for me.

cpsauer commented 9 months ago

Thanks for flagging and for contributing a fix, Jincheng! Sorry about that. Merging!

(I also added a conversion to a pathlib path to avoid a spurious error about the prior link pointing to the wrong place. Otherwise os.readlink returns a string which fails comparison with a later path.)

Thanks and happy coding! Chris