This revision was automatically updated to reflect the committed changes.
Closed by commit rHGed96d1116302: tests: help dummysmtpd work on python 3 
(authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2542?vs=6333&id=6355

REVISION DETAIL
  https://phab.mercurial-scm.org/D2542

AFFECTED FILES
  tests/dummysmtpd.py

CHANGE DETAILS

diff --git a/tests/dummysmtpd.py b/tests/dummysmtpd.py
--- a/tests/dummysmtpd.py
+++ b/tests/dummysmtpd.py
@@ -12,6 +12,7 @@
 import traceback
 
 from mercurial import (
+    pycompat,
     server,
     sslutil,
     ui as uimod,
@@ -63,6 +64,19 @@
     except KeyboardInterrupt:
         pass
 
+def _encodestrsonly(v):
+    if isinstance(v, type(u'')):
+        return v.encode('ascii')
+    return v
+
+def bytesvars(obj):
+    unidict = vars(obj)
+    bd = {k.encode('ascii'): _encodestrsonly(v) for k, v in unidict.items()}
+    if bd[b'daemon_postexec'] is not None:
+        bd[b'daemon_postexec'] = [
+            _encodestrsonly(v) for v in bd[b'daemon_postexec']]
+    return bd
+
 def main():
     op = optparse.OptionParser()
     op.add_option('-d', '--daemon', action='store_true')
@@ -85,8 +99,10 @@
             dummysmtpsecureserver(addr, opts.certificate)
         log('listening at %s:%d\n' % addr)
 
-    server.runservice(vars(opts), initfn=init, runfn=run,
-                      runargs=[sys.executable, __file__] + sys.argv[1:])
+    server.runservice(
+        bytesvars(opts), initfn=init, runfn=run,
+        runargs=[pycompat.sysexecutable,
+                 pycompat.fsencode(__file__)] + pycompat.sysargv[1:])
 
 if __name__ == '__main__':
     main()



To: durin42, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to