diff -r 8dcd49938611 Lib/subprocess.py --- a/Lib/subprocess.py Fri Jun 12 01:14:53 2009 +0200 +++ b/Lib/subprocess.py Sat Jun 13 18:11:30 2009 +0000 @@ -369,6 +369,7 @@ import traceback import gc import signal +import codecs # Exception classes used by this module. class CalledProcessError(Exception): @@ -584,10 +585,15 @@ stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=False, shell=False, cwd=None, env=None, universal_newlines=False, - startupinfo=None, creationflags=0): + startupinfo=None, creationflags=0, encoding=None, + errors='strict'): """Create new Popen instance.""" _cleanup() + if encoding is not None: + reader = codecs.getreader(encoding) + writer = codecs.getwriter(encoding) + self._child_created = False if not isinstance(bufsize, (int, long)): raise TypeError("bufsize must be an integer") @@ -652,16 +658,22 @@ if p2cwrite is not None: self.stdin = os.fdopen(p2cwrite, 'wb', bufsize) + if encoding is not None: + self.stdin = writer(self.stdin, errors) if c2pread is not None: if universal_newlines: self.stdout = os.fdopen(c2pread, 'rU', bufsize) else: self.stdout = os.fdopen(c2pread, 'rb', bufsize) + if encoding is not None: + self.stdout = reader(self.stdout, errors) if errread is not None: if universal_newlines: self.stderr = os.fdopen(errread, 'rU', bufsize) else: self.stderr = os.fdopen(errread, 'rb', bufsize) + if encoding is not None: + self.stderr = reader(self.stderr, errors) def _translate_newlines(self, data):