Re: [Python-Dev] Pickling objects that return string from reduce

2006-07-19 Thread Martin v. Löwis
Bruce Christensen wrote: >> If obj has no __module__ attribute (or if it is None), pickle >> (didn't check cPickle) also does >> >> for n, module in sys.module.items(): >> if "module-ignored": continue >> if getattr(module, result, None) is obj: >> break # use n as module name > > What i

Re: [Python-Dev] Pickling objects that return string from reduce

2006-07-19 Thread Bruce Christensen
Martin v. Löwis" wrote: > If obj has no __module__ attribute (or if it is None), pickle > (didn't check cPickle) also does > > for n, module in sys.module.items(): > if "module-ignored": continue > if getattr(module, result, None) is obj: > break # use n as module name > > If obj does

Re: [Python-Dev] Pickling objects that return string from reduce

2006-07-17 Thread Martin v. Löwis
Bruce Christensen wrote: > Is something like the following close? Close, yes. > if type(result) == tuple: > ... (do appropriate things here) > elif isinstance(result, basestring): > name = result > module = "" > try: > module = obj.__module__ >

[Python-Dev] Pickling objects that return string from reduce

2006-07-17 Thread Bruce Christensen
I'm still plugging away on IronPython's cPickle, and I've stumbled across another ambiguity in the pickle docs. From http://docs.python.org/lib/node69.html: "If a string is returned, it names a global variable whose contents are pickled as normal. The string returned by __reduce__ should be the ob