Ugh, the Python confmodule seems a bit broken to me. The shell confmodule fd
redirection hack was there for backward compatibility, and shouldn't have been
introduced into the Python confmodule (because there was no reason to have
backward compatibility there). The Perl confmodule simply does this:
# A truly gross hack. This is only needed if
# /usr/share/debconf/confmodule is loaded, and then this
# perl module is used. In that case, this module needs to write
# to fd #3, rather than stdout. See changelog 0.3.74.
if (exists $ENV{DEBCONF_REDIR} && $ENV{DEBCONF_REDIR}) { open(STDOUT,">&3");
}
That would suggest something more like the following:
- self.write = write or sys.stdout
- sys.stdout = sys.stderr
+ if (os.environ.has_key('DEBCONF_REDIR') and
+ os.environ['DEBCONF_REDIR'] != ''):
+ self.write = write or os.fdopen(3, 'w')
+ else:
+ self.write = write or sys.stdout
It's awkward given that debconf.py has already been deployed with 'sys.stdout =
sys.stderr', though. I'm tempted to add a redirect=True keyword argument to
Debconf.__init__() to allow code that doesn't rely on this misfeature to turn it
off.
Ugh, the Python confmodule seems a bit broken to me. The shell confmodule fd
redirection hack was there for backward compatibility, and shouldn't have been
introduced into the Python confmodule (because there was no reason to have
backward compatibility there). The Perl confmodule simply does this:
# A truly gross hack. This is only needed if debconf/ confmodule is loaded, and then this REDIR}) {
open( STDOUT, ">&3");
# /usr/share/
# perl module is used. In that case, this module needs to write
# to fd #3, rather than stdout. See changelog 0.3.74.
if (exists $ENV{DEBCONF_REDIR} && $ENV{DEBCONF_
}
That would suggest something more like the following:
- self.write = write or sys.stdout has_key( 'DEBCONF_ REDIR') and 'DEBCONF_ REDIR'] != ''):
- sys.stdout = sys.stderr
+ if (os.environ.
+ os.environ[
+ self.write = write or os.fdopen(3, 'w')
+ else:
+ self.write = write or sys.stdout
It's awkward given that debconf.py has already been deployed with 'sys.stdout =
sys.stderr', though. I'm tempted to add a redirect=True keyword argument to
Debconf.__init__() to allow code that doesn't rely on this misfeature to turn it
off.