@@ -1153,14 +1153,15 @@ def subprocess_shell(self, protocol_factory, cmd, *, stdin=subprocess.PIPE,
11531153 if bufsize != 0 :
11541154 raise ValueError ("bufsize must be 0" )
11551155 protocol = protocol_factory ()
1156+ debug_log = None
11561157 if self ._debug :
11571158 # don't log parameters: they may contain sensitive information
11581159 # (password) and may be too long
11591160 debug_log = 'run shell command %r' % cmd
11601161 self ._log_subprocess (debug_log , stdin , stdout , stderr )
11611162 transport = yield from self ._make_subprocess_transport (
11621163 protocol , cmd , True , stdin , stdout , stderr , bufsize , ** kwargs )
1163- if self ._debug :
1164+ if self ._debug and debug_log is not None :
11641165 logger .info ('%s: %r' , debug_log , transport )
11651166 return transport , protocol
11661167
@@ -1182,6 +1183,7 @@ def subprocess_exec(self, protocol_factory, program, *args,
11821183 "a bytes or text string, not %s"
11831184 % type (arg ).__name__ )
11841185 protocol = protocol_factory ()
1186+ debug_log = None
11851187 if self ._debug :
11861188 # don't log parameters: they may contain sensitive information
11871189 # (password) and may be too long
@@ -1190,7 +1192,7 @@ def subprocess_exec(self, protocol_factory, program, *args,
11901192 transport = yield from self ._make_subprocess_transport (
11911193 protocol , popen_args , False , stdin , stdout , stderr ,
11921194 bufsize , ** kwargs )
1193- if self ._debug :
1195+ if self ._debug and debug_log is not None :
11941196 logger .info ('%s: %r' , debug_log , transport )
11951197 return transport , protocol
11961198
0 commit comments