[PATCH STABLE] hgweb: make sure sys module is loaded prior to reload hack

Yuya Nishihara yuya at tcha.org
Wed Feb 19 06:22:26 CST 2014


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1392812203 -32400
#      Wed Feb 19 21:16:43 2014 +0900
# Branch stable
# Node ID e4a4e4b993ffd4fac6ea53b3928bbc91fc9e8613
# Parent  4e41b2fe46ccfb9722e51e23902f7019d286b15d
hgweb: make sure sys module is loaded prior to reload hack

If sys is still a demandmod, reload(sys) fails with "TypeError: reload()
argument must be module".

diff --git a/mercurial/hgweb/server.py b/mercurial/hgweb/server.py
--- a/mercurial/hgweb/server.py
+++ b/mercurial/hgweb/server.py
@@ -331,6 +331,7 @@ def create_server(ui, app):
         # as ascii (clown fail), because the default Python Unicode
         # codec is hardcoded as ascii.
 
+        sys.argv # unwrap demand-loader so that reload() works
         reload(sys) # resurrect sys.setdefaultencoding()
         oldenc = sys.getdefaultencoding()
         sys.setdefaultencoding("latin1") # or any full 8-bit encoding


More information about the Mercurial-devel mailing list