[Python-Dev] Strange memo behavior from cPickle

2006-08-01 Thread Bruce Christensen
We seem to have stumbled upon some strange behavior in cPickle's memo use when pickling instances. Here's the repro: [mymodule.py] class C: def __getstate__(self): return ('s1', 's2', 's3') [interactive interpreter] Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on win

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

[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

Re: [Python-Dev] Pickle implementation questions

2006-06-30 Thread Bruce Christensen
Tim Peters wrote: > I hope you've read PEP 307: I have. Thanks to you and Guido for writing it! It's been a huge help. > The implementation is more like: [snip] Thanks! That helps a lot. PEP 307 and the pickle module docs describe the end result pretty well, but they don't always make it clear

Re: [Python-Dev] Pickle implementation questions

2006-06-30 Thread Bruce Christensen
Fredrik Lundh wrote: > on the other hand, it would be nice if someone actually used Bruce's questions > and the clarifications to update the documentation; the ideas behind the > internal pickle interfaces aren't exactly obvious, even if you have the > source. I've found a few other places where t

Re: [Python-Dev] Pickle implementation questions

2006-06-30 Thread Bruce Christensen
Thanks for your responses, Martin! Martin v. Löwis wrote: > Bruce Christensen wrote: > > - Where are object.__reduce__ and object.__reduce_ex__ defined, and how > > does copy_reg._reduce_ex fit into the picture? > > See > > http://docs.python.org/lib/node69.html

[Python-Dev] Pickle implementation questions

2006-06-29 Thread Bruce Christensen
In developing a cPickle module for IronPython that's as compatible as possible with CPython, these questions have come up: - Where are object.__reduce__ and object.__reduce_ex__ defined, and how does copy_reg._reduce_ex fit into the picture? PEP 307 states that the default __reduce__ implementat

[Python-Dev] socket._socketobject.close() doesn't really close sockets

2006-06-12 Thread Bruce Christensen
In implementing the IronPython _socket module, I've discovered some puzzling behavior in the standard Python socket wrapper module: socket._socketobject.close() doesn't actually close sockets; rather, it just sets _sock to an instance of _closedsocket and lets the GC clean up the real socket. (See

Re: [Python-Dev] Socket module corner cases

2006-05-30 Thread Bruce Christensen
> > * getfqdn(): The function seems to not always return the FQDN. For > >example, if I run the following code from 'mybox.mydomain.com', I get > >strange output. Does getfqdn() remove the common domain between my > >hostname and the one that I'm looking up? > socket.getfqdn('otherbox') > >

[Python-Dev] Socket module corner cases

2006-05-30 Thread Bruce Christensen
Hello, I'm working on implementing a socket module for IronPython that aims to be compatible with the standard CPython module documented at http://docs.python.org/lib/module-socket.html. I have a few questions about some corner cases that I've found. CPython results below are from Python 2.4.3 (#6