[PATCH] D67753: [gn build] Fix Python DeprecationWarning

Marco Antognini via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 24 03:37:57 PDT 2019


mantognini marked an inline comment as done.
mantognini added inline comments.


================
Comment at: llvm/utils/gn/build/write_cmake_config.py:65
 
-    in_lines = open(args.input).readlines()
+    with open(args.input) as f:
+        in_lines = f.readlines()
----------------
thakis wrote:
> What warns about this? Python itself?
> 
> The garbage collector cleans up the file, and this is a very short-lived script anyways, so I'd prefer brevity over linter happyiness if this is to placate some linter.
> 
> If python3 warns about this by default, I suppose it's fine to fix this.
Yep, starting with Python 3.7.4 and PEP565, those warnings are emitted by default:

> To improve this situation, this PEP proposes a single adjustment to the default warnings filter: displaying deprecation warnings attributed to the main module by default.

This is not an extra linter that warns about this, but Python itself.

I'd further recommend fixing this to reduce the noise in our downstream tests.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67753/new/

https://reviews.llvm.org/D67753





More information about the llvm-commits mailing list