Author: Amaury Forgeot d'Arc <amaur...@gmail.com> Branch: py3.5 Changeset: r88153:a221fb64f9a2 Date: 2016-11-06 17:35 +0100 http://bitbucket.org/pypy/pypy/changeset/a221fb64f9a2/
Log: Fix pickling of SimpleNamespace objects. diff --git a/pypy/module/sys/app.py b/pypy/module/sys/app.py --- a/pypy/module/sys/app.py +++ b/pypy/module/sys/app.py @@ -126,6 +126,9 @@ finally: recurse.remove(ident) +# This class is not exposed in sys, but by the types module. +SimpleNamespace.__module__ = 'types' + implementation = SimpleNamespace( name='pypy', diff --git a/pypy/module/sys/test/test_sysmodule.py b/pypy/module/sys/test/test_sysmodule.py --- a/pypy/module/sys/test/test_sysmodule.py +++ b/pypy/module/sys/test/test_sysmodule.py @@ -226,6 +226,10 @@ class AppTestSysModulePortedFromCPython: + spaceconfig = { + "usemodules": ["struct"], + } + def setup_class(cls): cls.w_appdirect = cls.space.wrap(cls.runappdirect) @@ -586,6 +590,13 @@ raises(AttributeError, "del ns.spam") del ns.y + def test_pickle_simplenamespace(self): + import pickle, sys + SimpleNamespace = type(sys.implementation) + ns = SimpleNamespace(x=1, y=2, w=3) + copy = pickle.loads(pickle.dumps(ns)) + copy.__dict__ == dict(x=1, y=2, w=3, z=4) + def test_reload_doesnt_override_sys_executable(self): import sys from imp import reload _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit