Index: Doc/library/imaplib.rst =================================================================== --- Doc/library/imaplib.rst (révision 66888) +++ Doc/library/imaplib.rst (copie de travail) @@ -75,7 +75,7 @@ This is a subclass derived from :class:`IMAP4` that connects to the ``stdin/stdout`` file descriptors created by passing *command* to - ``os.popen2()``. + ``subprocess.Popen()``. The following utility functions are defined: Index: Lib/imaplib.py =================================================================== --- Lib/imaplib.py (révision 66888) +++ Lib/imaplib.py (copie de travail) @@ -22,7 +22,7 @@ __version__ = "2.58" -import binascii, os, random, re, socket, sys, time +import binascii, io, random, re, socket, subprocess, sys, time __all__ = ["IMAP4", "IMAP4_stream", "Internaldate2tuple", "Int2AP", "ParseFlags", "Time2Internaldate"] @@ -147,6 +147,7 @@ class abort(error): pass # Service errors - close and retry class readonly(abort): pass # Mailbox status changed to READ-ONLY + encoding = "UTF-8" mustquote = re.compile(r"[^\w!#$%&'*+,.:;<=>?^`|~-]", re.ASCII) def __init__(self, host = '', port = IMAP4_PORT): @@ -1214,7 +1215,7 @@ Instantiate with: IMAP4_stream(command) - where "command" is a string that can be passed to os.popen2() + where "command" is a string that can be passed to subprocess.Popen() for more documentation see the docstring of the parent class IMAP4. """ @@ -1234,8 +1235,11 @@ self.port = None self.sock = None self.file = None - self.writefile, self.readfile = os.popen2(self.command) - + self.process = subprocess.Popen(self.command, + stdin=subprocess.PIPE, stdout=subprocess.PIPE, + shell=True, close_fds=True) + self.writefile = io.TextIOWrapper(self.process.stdin, encoding=self.encoding) + self.readfile = io.TextIOWrapper(self.process.stdout, encoding=self.encoding) def read(self, size): """Read 'size' bytes from remote.""" @@ -1257,6 +1261,7 @@ """Close I/O established in "open".""" self.readfile.close() self.writefile.close() + self.process.wait()