summaryrefslogtreecommitdiffstats
path: root/Lib/sre_constants.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-04-04 08:01:02 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-04-04 08:01:02 (GMT)
commit46ba6c8563922f043cad6423202ee0119614c807 (patch)
tree4523d1a3665af25ef77898f7d2da186fbdca8ce7 /Lib/sre_constants.py
parentae2d667ae83548029fed7244619fadd7f625cb24 (diff)
downloadcpython-46ba6c8563922f043cad6423202ee0119614c807.zip
cpython-46ba6c8563922f043cad6423202ee0119614c807.tar.gz
cpython-46ba6c8563922f043cad6423202ee0119614c807.tar.bz2
Issue #22831: Use "with" to avoid possible fd leaks.
Diffstat (limited to 'Lib/sre_constants.py')
-rw-r--r--Lib/sre_constants.py37
1 files changed, 18 insertions, 19 deletions
diff --git a/Lib/sre_constants.py b/Lib/sre_constants.py
index 8b6bbfa..fc684ae 100644
--- a/Lib/sre_constants.py
+++ b/Lib/sre_constants.py
@@ -182,8 +182,8 @@ if __name__ == "__main__":
items = sorted(d)
for item in items:
f.write("#define %s_%s %d\n" % (prefix, item, item))
- f = open("sre_constants.h", "w")
- f.write("""\
+ with open("sre_constants.h", "w") as f:
+ f.write("""\
/*
* Secret Labs' Regular Expression Engine
*
@@ -199,25 +199,24 @@ if __name__ == "__main__":
""")
- f.write("#define SRE_MAGIC %d\n" % MAGIC)
+ f.write("#define SRE_MAGIC %d\n" % MAGIC)
- dump(f, OPCODES, "SRE_OP")
- dump(f, ATCODES, "SRE")
- dump(f, CHCODES, "SRE")
+ dump(f, OPCODES, "SRE_OP")
+ dump(f, ATCODES, "SRE")
+ dump(f, CHCODES, "SRE")
- f.write("#define SRE_FLAG_TEMPLATE %d\n" % SRE_FLAG_TEMPLATE)
- f.write("#define SRE_FLAG_IGNORECASE %d\n" % SRE_FLAG_IGNORECASE)
- f.write("#define SRE_FLAG_LOCALE %d\n" % SRE_FLAG_LOCALE)
- f.write("#define SRE_FLAG_MULTILINE %d\n" % SRE_FLAG_MULTILINE)
- f.write("#define SRE_FLAG_DOTALL %d\n" % SRE_FLAG_DOTALL)
- f.write("#define SRE_FLAG_UNICODE %d\n" % SRE_FLAG_UNICODE)
- f.write("#define SRE_FLAG_VERBOSE %d\n" % SRE_FLAG_VERBOSE)
- f.write("#define SRE_FLAG_DEBUG %d\n" % SRE_FLAG_DEBUG)
- f.write("#define SRE_FLAG_ASCII %d\n" % SRE_FLAG_ASCII)
+ f.write("#define SRE_FLAG_TEMPLATE %d\n" % SRE_FLAG_TEMPLATE)
+ f.write("#define SRE_FLAG_IGNORECASE %d\n" % SRE_FLAG_IGNORECASE)
+ f.write("#define SRE_FLAG_LOCALE %d\n" % SRE_FLAG_LOCALE)
+ f.write("#define SRE_FLAG_MULTILINE %d\n" % SRE_FLAG_MULTILINE)
+ f.write("#define SRE_FLAG_DOTALL %d\n" % SRE_FLAG_DOTALL)
+ f.write("#define SRE_FLAG_UNICODE %d\n" % SRE_FLAG_UNICODE)
+ f.write("#define SRE_FLAG_VERBOSE %d\n" % SRE_FLAG_VERBOSE)
+ f.write("#define SRE_FLAG_DEBUG %d\n" % SRE_FLAG_DEBUG)
+ f.write("#define SRE_FLAG_ASCII %d\n" % SRE_FLAG_ASCII)
- f.write("#define SRE_INFO_PREFIX %d\n" % SRE_INFO_PREFIX)
- f.write("#define SRE_INFO_LITERAL %d\n" % SRE_INFO_LITERAL)
- f.write("#define SRE_INFO_CHARSET %d\n" % SRE_INFO_CHARSET)
+ f.write("#define SRE_INFO_PREFIX %d\n" % SRE_INFO_PREFIX)
+ f.write("#define SRE_INFO_LITERAL %d\n" % SRE_INFO_LITERAL)
+ f.write("#define SRE_INFO_CHARSET %d\n" % SRE_INFO_CHARSET)
- f.close()
print("done")