[PATCH STABLE V2] demandimport: avoid infinite recursion at actual module importing (issue5304)
Yuya Nishihara
yuya at tcha.org
Sun Jul 31 00:18:39 EDT 2016
On Sun, 31 Jul 2016 05:46:34 +0900, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
> # Date 1469911199 -32400
> # Sun Jul 31 05:39:59 2016 +0900
> # Branch stable
> # Node ID 3ee78885a361e06d1729101c5b1bd68b782bf08e
> # Parent 491ee264b9f6e32b6e4dfe34180fb48226fc1641
> demandimport: avoid infinite recursion at actual module importing (issue5304)
> diff --git a/mercurial/demandimport.py b/mercurial/demandimport.py
> --- a/mercurial/demandimport.py
> +++ b/mercurial/demandimport.py
> @@ -94,6 +94,23 @@ class _demandmod(object):
> if not self._module:
> head, globals, locals, after, level, modrefs = self._data
> mod = _hgextimport(_import, head, globals, locals, None, level)
> + if mod is self:
> + # In this case, _hgextimport() above should imply
> + # _demandimport(). Otherwise, _hgextimport() never
> + # returns _demandmod. This isn't intentional behavior,
> + # in fact. (see also issue5304 for detail)
> + #
> + # If self._module is already bound at this point, self
> + # should be already _load()-ed while _hgextimport().
> + # Otherwise, there is no way to import actual module
> + # as expected, because (re-)invoking _hgextimport()
> + # should cause same result.
> + # This is reason why _load() returns without any more
> + # setup but assumes self to be already bound.
> + mod = self._module
> + assert mod and mod is not self, "%s, %s" % (self, mod)
> + return
Nice. Queued this, thanks!
More information about the Mercurial-devel
mailing list