[Python-checkins] cpython (2.7): #13163: fix names of _get_socket args

r.david.murray python-checkins at python.org
Tue Apr 2 18:15:44 CEST 2013


http://hg.python.org/cpython/rev/5d99042bd40f
changeset:   83061:5d99042bd40f
branch:      2.7
parent:      83049:240c83902fca
user:        R David Murray <rdmurray at bitdance.com>
date:        Tue Apr 02 12:15:07 2013 -0400
summary:
  #13163: fix names of _get_socket args

This was already done in Python3, but having it wrong leads to
incorrect debug output, so it seems worth fixing in 2.7 as well.

Patch by Victor Terrón.

files:
  Doc/library/email.mime.rst |  9 +++++++++
  Lib/smtplib.py             |  4 ++--
  Misc/ACKS                  |  1 +
  Misc/NEWS                  |  3 +++
  4 files changed, 15 insertions(+), 2 deletions(-)


diff --git a/Doc/library/email.mime.rst b/Doc/library/email.mime.rst
--- a/Doc/library/email.mime.rst
+++ b/Doc/library/email.mime.rst
@@ -199,3 +199,12 @@
       Transfer Encoding now happens implicitly based on the *_charset*
       argument.
 
+   Unless the ``_charset`` parameter is explicitly set to ``None``, the
+   MIMEText object created will have both a :mailheader:`Content-Type` header
+   with a ``charset`` parameter, and a :mailheader:`Content-Transfer-Endcoding`
+   header.  This means that a subsequent ``set_payload`` call will not result
+   in an encoded payload, even if a charset is passed in the ``set_payload``
+   command.  You can "reset" this behavior by deleting the
+   ``Content-Transfer-Encoding`` header, after which a ``set_payload`` call
+   will automatically encode the new payload (and add a new
+   :mailheader:`Content-Transfer-Encoding` header).
diff --git a/Lib/smtplib.py b/Lib/smtplib.py
--- a/Lib/smtplib.py
+++ b/Lib/smtplib.py
@@ -276,12 +276,12 @@
         """
         self.debuglevel = debuglevel
 
-    def _get_socket(self, port, host, timeout):
+    def _get_socket(self, host, port, timeout):
         # This makes it simpler for SMTP_SSL to use the SMTP connect code
         # and just alter the socket connection bit.
         if self.debuglevel > 0:
             print>>stderr, 'connect:', (host, port)
-        return socket.create_connection((port, host), timeout)
+        return socket.create_connection((host, port), timeout)
 
     def connect(self, host='localhost', port=0):
         """Connect to a host on a given port.
diff --git a/Misc/ACKS b/Misc/ACKS
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -992,6 +992,7 @@
 Amy Taylor
 Anatoly Techtonik
 Mikhail Terekhov
+Victor Terrón
 Richard M. Tew
 Tobias Thelen
 Lowe Thiderman
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@
 Library
 -------
 
+- Issue #13163: Rename operands in smtplib.SMTP._get_socket to correct names;
+  fixes otherwise misleading output in tracebacks and when when debug is on.
+
 - Issue #6698: IDLE now opens just an editor window when configured to do so.
 
 - Issue #8900: Using keyboard shortcuts in IDLE to open a file no longer

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list