Packaging cleanup: remove conditionals for < 2.6 support.
PEP 370 features and sys.dont_write_bytecode are always available
in 3.3; the distutils2 backport still has the conditionals.
I also renamed an internal misnamed method and fixed a few things
(“packaging2” name, stray print, unused import, fd leak).
diff --git a/Lib/packaging/util.py b/Lib/packaging/util.py
index 49c5991..89f5389 100644
--- a/Lib/packaging/util.py
+++ b/Lib/packaging/util.py
@@ -326,7 +326,7 @@
"""
# nothing is done if sys.dont_write_bytecode is True
# FIXME this should not raise an error
- if hasattr(sys, 'dont_write_bytecode') and sys.dont_write_bytecode:
+ if sys.dont_write_bytecode:
raise PackagingByteCompileError('byte-compiling is disabled.')
# First, if the caller didn't force us into direct or indirect mode,
@@ -346,8 +346,10 @@
# run it with the appropriate flags.
if not direct:
from tempfile import mkstemp
- # XXX script_fd may leak, use something better than mkstemp
+ # XXX use something better than mkstemp
script_fd, script_name = mkstemp(".py")
+ os.close(script_fd)
+ script_fd = None
logger.info("writing byte-compilation script '%s'", script_name)
if not dry_run:
if script_fd is not None: