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

login
register
mail settings
Submitter Yuya Nishihara
Date Feb. 19, 2014, 12:22 p.m.
Message ID <e4a4e4b993ffd4fac6ea.1392812546@gimlet>
Download mbox | patch
Permalink /patch/3695/
State Accepted
Commit ca970d6acedb01af15f6dbabb0d057a6a6643e79
Headers show

Comments

Yuya Nishihara - Feb. 19, 2014, 12:22 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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".
Matt Mackall - Feb. 19, 2014, 10:12 p.m.
On Wed, 2014-02-19 at 21:22 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@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

Queued for stable, thanks.

Patch

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