[pypy-commit] pypy default: don't init() the builtin modules at space.startup() if they have already been initialized before
antocuni
noreply at buildbot.pypy.org
Fri Feb 24 09:59:41 CET 2012
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch:
Changeset: r52833:a82f18539bbb
Date: 2012-02-24 09:55 +0100
http://bitbucket.org/pypy/pypy/changeset/a82f18539bbb/
Log: don't init() the builtin modules at space.startup() if they have
already been initialized before
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -328,7 +328,7 @@
raise
modname = self.str_w(w_modname)
mod = self.interpclass_w(w_mod)
- if isinstance(mod, Module):
+ if isinstance(mod, Module) and not mod.startup_called:
self.timer.start("startup " + modname)
mod.init(self)
self.timer.stop("startup " + modname)
diff --git a/pypy/interpreter/test/test_objspace.py b/pypy/interpreter/test/test_objspace.py
--- a/pypy/interpreter/test/test_objspace.py
+++ b/pypy/interpreter/test/test_objspace.py
@@ -322,3 +322,14 @@
space.ALL_BUILTIN_MODULES.pop()
del space._builtinmodule_list
mods = space.get_builtinmodule_to_install()
+
+ def test_dont_reload_builtin_mods_on_startup(self):
+ from pypy.tool.option import make_config, make_objspace
+ config = make_config(None)
+ space = make_objspace(config)
+ w_executable = space.wrap('executable')
+ assert space.str_w(space.getattr(space.sys, w_executable)) == 'py.py'
+ space.setattr(space.sys, w_executable, space.wrap('foobar'))
+ assert space.str_w(space.getattr(space.sys, w_executable)) == 'foobar'
+ space.startup()
+ assert space.str_w(space.getattr(space.sys, w_executable)) == 'foobar'
More information about the pypy-commit
mailing list