jjlee / mechanize

Stateful programmatic web browsing in Python, after Andy Lester's Perl module WWW::Mechanize .
http://wwwsearch.sourceforge.net/mechanize/
618 stars 123 forks source link

Does this mechanize poke private implementation of socket.py? #108

Open thinksource opened 9 years ago

thinksource commented 9 years ago

I use pypy 2.5.1 and mechanize. The erorr:

Traceback (most recent call last):
  File "app_main.py", line 75, in run_toplevel
  File "mmtmain.py", line 8, in <module>
    from converter.mmtconverter import MMTConverter
  File "C:\Dataload\Dataload Executables\AO3Dataload\src\converter\mmtconverter.
py", line 17, in <module>
    import mechanize
  File "C:\pypy\site-packages\mechanize\__init__.py", line 122, in <module>
    from _mechanize import \
  File "C:\pypy\site-packages\mechanize\_mechanize.py", line 14, in <module>
    from _html import DefaultFactory
  File "C:\pypy\site-packages\mechanize\_html.py", line 19, in <module>
    import _form
  File "C:\pypy\site-packages\mechanize\_form.py", line 74, in <module>
    import _request
  File "C:\pypy\site-packages\mechanize\_request.py", line 15, in <module>
    import _urllib2_fork
  File "C:\pypy\site-packages\mechanize\_urllib2_fork.py", line 70, in <module>
    socket._fileobject("fake socket", close=True)
  File "C:\pypy\lib-python\2.7\socket.py", line 301, in __init__
    sock._reuse()
AttributeError: 'str' object has no attribute '_reuse'

When I go to the 301 of the socket.py:

        # Note that a few libraries (like eventlet) poke at the
        # private implementation of socket.py, passing custom
        # objects to _fileobject().  These libraries need the
        # following fix for use on PyPy: the custom objects need
        # methods _reuse() and _drop() that maintains an explicit
        # reference counter, starting at 0.  When it drops back to
        # zero, close() must be called.
        sock._reuse()

For me, I think mechanize should implement their socket.py. I just want to konw how to explicit call the counter method _reuser() and _drop() what is the explicit function's variable here.