Patchwork [4,of,4] mail: do not print(), use ui.debug() instead

login
register
mail settings
Submitter Yuya Nishihara
Date Nov. 8, 2016, 2:47 p.m.
Message ID <05cd251962e3220fff7e.1478616448@mimosa>
Download mbox | patch
Permalink /patch/17405/
State Accepted
Headers show

Comments

Yuya Nishihara - Nov. 8, 2016, 2:47 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1476969631 -32400
#      Thu Oct 20 22:20:31 2016 +0900
# Node ID 05cd251962e3220fff7ef22ad745b346a052a924
# Parent  2d4f257e45ea19cc71912f285a090036deeacb40
mail: do not print(), use ui.debug() instead

Since print() can't take a bytes output, it's pretty useless in Mercurial
on Python 3. As this is a debug message, switching to ui.debug() seems fine.

Patch

diff --git a/mercurial/mail.py b/mercurial/mail.py
--- a/mercurial/mail.py
+++ b/mercurial/mail.py
@@ -5,7 +5,7 @@ 
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
-from __future__ import absolute_import, print_function
+from __future__ import absolute_import
 
 import email
 import email.charset
@@ -14,7 +14,6 @@  import os
 import quopri
 import smtplib
 import socket
-import sys
 import time
 
 from .i18n import _
@@ -87,7 +86,7 @@  class SMTPS(smtplib.SMTP):
 
     def _get_socket(self, host, port, timeout):
         if self.debuglevel > 0:
-            print('connect:', (host, port), file=sys.stderr)
+            self._ui.debug('connect: %r\n' % (host, port))
         new_socket = socket.create_connection((host, port), timeout)
         new_socket = sslutil.wrapsocket(new_socket,
                                         self.keyfile, self.certfile,