[pypy-dev] Problems with modified socket.py

Antonio Cuni anto.cuni at gmail.com
Sun Mar 23 11:01:54 CET 2008

Leandro Lameiro wrote:
> Hi Antonio.
> My name is Leandro Lameiro and I've been a long time observer of PyPy. 
> This weekend I tried to see where I could contribute to PyPy, so I 
> decided to try and run some apps and see what is missing.

Hi Leandro.

Thank you for your interest in PyPy; every contribution is welcome, 
either patches or bug report!

I'm CCing pypy-dev, so that other developers can read it as well.

> The first thing I tried to run was ez_setup.py ( 
> http://peak.telecommunity.com/dist/ez_setup.py ), a simple script that 
> downloads and installs setuptools. It is a really short script but it 
> uses various modules such as md5, socket, urllib, os etc.
> After translating PyPy (with allworkingmodules and socket switches) I 
> found that ez_setup.py will raise and exception in PyPy but not in 
> CPython (tried with 2.4 and 2.5).
> Here is the traceback:
> (virtualenv)lameiro at liria:~/projetos/ez_setup$ python ez_setup.py
> Downloading 
> http://pypi.python.org/packages/2.4/s/setuptools/setuptools-0.6c8-py2.4.egg
> Traceback (most recent call last):
>  File "?", line 34, in run_toplevel
>  File "ez_setup.py", line 267, in <module>
>    main(sys.argv[1:])
>  File "ez_setup.py", line 204, in main
>    os.unlink(egg)
>  File "ez_setup.py", line 198, in main
>    egg = download_setuptools(version, delay=0)
>  File "ez_setup.py", line 152, in download_setuptools
>    if src: src.close()
>  File "/home/lameiro/projetos/pypy-dist/lib-python/2.4.1/urllib.py", 
> line 804, in close
>    if self.fp: self.fp.close()
>  File 
> "/home/lameiro/projetos/pypy-dist/lib-python/modified-2.4.1/socket.py", 
> line 242, in close
>    s._drop()
> AttributeError: 'HTTPResponse' object has no attribute '_drop'
> (virtualenv)lameiro at liria:~/projetos/ez_setup$
> After investigating a little, I found that you modified socket.py and 
> introduced this _drop call and also defined it in socket._closedsocket 
> class (an empty method), but that doesn't seem to be enough since other 
> types are going there (in this case HTTPResponse, but maybe others too).

indeed, you are right; the relevant _drop method is defined in 
pypy-dist/pypy/module/_socket/interp_socket.py (it's called _drop_w), 
but I guess we should take care of cases like this in which the object 
doesn't provide a _drop method.

> The revision in which this modification was introduced is 
> https://codespeak.net/viewvc/pypy/dist/lib-python/modified-2.4.1/socket.py?r1=16842&r2=34429 
> <https://codespeak.net/viewvc/pypy/dist/lib-python/modified-2.4.1/socket.py?r1=16842&r2=34429> 
> , and I suppose it was you because the commiter login is "ac". :)

sorry, your guess is wrong :-).
My login name is "antocuni", "ac" stands for Anders Chrigström.
That's also why I don't know much about this and I'm CCing pypy-dev :-)

> Anyway, thanks for the great work and I hope the next time I can 
> contribute a patch instead of a bug report.

thank to you again for the help!
Feel free to come to #pypy on freenode if you want to talk with us by IRC.


More information about the Pypy-dev mailing list