Patch: When demandimport is disabled the 'test-profile' test fails.
Alejandro Santos
alejolp at alejolp.com
Wed Jul 29 03:53:12 UTC 2009
On crew and hg-stable repos, 'test-profile' test fails when
demandimport is disabled. This is caused by the email package wich
uses it's own LazyImporter.
Accessing the '__file__' attr of the module raises the full import of
the module, affecting the sys.modules dict.
$ diff -u test-profile.out test-profile.err
--- test-profile.out 2009-06-16 00:23:56.000000000 -0300
+++ test-profile.err 2009-07-28 13:00:27.000000000 -0300
@@ -1,2 +1,29 @@
% test --time
% test --profile
+--profile failed
+** unknown exception encountered, details follow
+** report bug details to http://mercurial.selenic.com/bts/
+** or mercurial at selenic.com
+** Mercurial Distributed SCM (version 0d04d42fbab4)
+** Extensions loaded:
+Traceback (most recent call last):
+ File "/tmp/hgtests.xStzl7/install/bin/hg", line 30, in <module>
+ mercurial.dispatch.run()
+ File "/tmp/hgtests.xStzl7/install/lib/python/mercurial/dispatch.py",
line 16, in run
+ sys.exit(dispatch(sys.argv[1:]))
+ File "/tmp/hgtests.xStzl7/install/lib/python/mercurial/dispatch.py",
line 27, in dispatch
+ return _runcatch(u, args)
+ File "/tmp/hgtests.xStzl7/install/lib/python/mercurial/dispatch.py",
line 43, in _runcatch
+ return _dispatch(ui, args)
+ File "/tmp/hgtests.xStzl7/install/lib/python/mercurial/dispatch.py",
line 449, in _dispatch
+ return runcommand(lui, repo, cmd, fullargs, ui, options, d)
+ File "/tmp/hgtests.xStzl7/install/lib/python/mercurial/dispatch.py",
line 317, in runcommand
+ ret = _runcommand(ui, options, cmd, d)
+ File "/tmp/hgtests.xStzl7/install/lib/python/mercurial/dispatch.py",
line 496, in _runcommand
+ stats.pprint(top=10, file=ostream, climit=5)
+ File "/tmp/hgtests.xStzl7/install/lib/python/mercurial/lsprof.py",
line 48, in pprint
+ e.inlinetime, label(e.code)))
+ File "/tmp/hgtests.xStzl7/install/lib/python/mercurial/lsprof.py",
line 88, in label
+ for k, v in sys.modules.iteritems():
+RuntimeError: dictionary changed size during iteration
+--profile + output to file failed
Patch:
# HG changeset patch
# User Alejandro Santos <alejolp at alejolp.com>
# Date 1248839201 10800
# Node ID bc5ef32eced1a80874e535492d747c418bcf5bac
# Parent 1eed391889f4e4a4dc441194fafe0e7165abf49d
When demandimport is disabled the 'test-profile' test fails.
diff -r 1eed391889f4 -r bc5ef32eced1 mercurial/lsprof.py
--- a/mercurial/lsprof.py Wed Jul 29 00:20:28 2009 -0300
+++ b/mercurial/lsprof.py Wed Jul 29 00:46:41 2009 -0300
@@ -85,7 +85,11 @@
try:
mname = _fn2mod[code.co_filename]
except KeyError:
- for k, v in sys.modules.iteritems():
+ # Force the complete load of all the lazy and on demand modules.
+ for k, v in sys.modules.items():
+ hasattr(v, 'somemissingattr')
+
+ for k, v in sys.modules.items():
if v is None:
continue
if not hasattr(v, '__file__'):
More information about the Mercurial-devel
mailing list