This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: httplib: TypeError with file() object in ssl.py
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: erob, r.david.murray
Priority: normal Keywords:

Created on 2014-08-20 13:58 by erob, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (10)
msg225567 - (view) Author: Etienne Robillard (erob) Date: 2014-08-20 13:58
Trying to push to a ssl server but python break in httplib. 



erob@nguns:~/django-hotsauce$ hg push https://tkadm30@bitbucket.org/tkadm30/django-hotsauce
pushing to https://tkadm30@bitbucket.org/tkadm30/django-hotsauce
warning: bitbucket.org certificate with fingerprint 45:ad:ae:1a:cf:0e:73:47:06:07:e0:88:f5:cc:10:e5:fa:1c:f7:99 not verified (check hostfingerprints or web.cacerts config setting)
** unknown exception encountered, please report by visiting
** http://mercurial.selenic.com/wiki/BugTracker
** Python 2.7.3 (default, Aug 20 2014, 09:34:08) [GCC 4.7.2]
** Mercurial Distributed SCM (version 3.1)
** Extensions loaded: color, gpg, strip, mq, notify, patchbomb
Traceback (most recent call last):
  File "/usr/local/bin/hg", line 43, in <module>
    mercurial.dispatch.run()
  File "/usr/local/lib/python2.7/site-packages/mercurial/dispatch.py", line 28, in run
    sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
  File "/usr/local/lib/python2.7/site-packages/mercurial/dispatch.py", line 69, in dispatch
    ret = _runcatch(req)
  File "/usr/local/lib/python2.7/site-packages/mercurial/dispatch.py", line 138, in _runcatch
    return _dispatch(req)
  File "/usr/local/lib/python2.7/site-packages/mercurial/dispatch.py", line 820, in _dispatch
    cmdpats, cmdoptions)
  File "/usr/local/lib/python2.7/site-packages/mercurial/dispatch.py", line 600, in runcommand
    ret = _runcommand(ui, options, cmd, d)
  File "/usr/local/lib/python2.7/site-packages/mercurial/extensions.py", line 196, in wrap
    return wrapper(origfn, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/hgext/color.py", line 433, in colorcmd
    return orig(ui_, opts, cmd, cmdfunc)
  File "/usr/local/lib/python2.7/site-packages/mercurial/dispatch.py", line 911, in _runcommand
    return checkargs()
  File "/usr/local/lib/python2.7/site-packages/mercurial/dispatch.py", line 882, in checkargs
    return cmdfunc()
  File "/usr/local/lib/python2.7/site-packages/mercurial/dispatch.py", line 817, in <lambda>
    d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
  File "/usr/local/lib/python2.7/site-packages/mercurial/util.py", line 550, in check
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/mercurial/extensions.py", line 151, in wrap
    util.checksignature(origfn), *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/mercurial/util.py", line 550, in check
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/hgext/mq.py", line 3393, in mqcommand
    return orig(ui, repo, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/mercurial/util.py", line 550, in check
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/mercurial/commands.py", line 4768, in push
    other = hg.peer(repo, opts, dest)
  File "/usr/local/lib/python2.7/site-packages/mercurial/hg.py", line 129, in peer
    return _peerorrepo(rui, path, create).peer()
  File "/usr/local/lib/python2.7/site-packages/mercurial/hg.py", line 106, in _peerorrepo
    obj = _peerlookup(path).instance(ui, path, create)
  File "/usr/local/lib/python2.7/site-packages/mercurial/httppeer.py", line 261, in instance
    inst._fetchcaps()
  File "/usr/local/lib/python2.7/site-packages/mercurial/httppeer.py", line 58, in _fetchcaps
    self.caps = set(self._call('capabilities').split())
  File "/usr/local/lib/python2.7/site-packages/mercurial/httppeer.py", line 172, in _call
    fp = self._callstream(cmd, **args)
  File "/usr/local/lib/python2.7/site-packages/mercurial/httppeer.py", line 119, in _callstream
    resp = self.urlopener.open(req)
  File "/usr/local/lib/python2.7/urllib2.py", line 400, in open
    response = self._open(req, data)
  File "/usr/local/lib/python2.7/urllib2.py", line 418, in _open
    '_open', req)
  File "/usr/local/lib/python2.7/urllib2.py", line 378, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python2.7/site-packages/mercurial/url.py", line 371, in https_open
    return self.do_open(self._makeconnection, req)
  File "/usr/local/lib/python2.7/site-packages/mercurial/keepalive.py", line 255, in do_open
    r = h.getresponse()
  File "/usr/local/lib/python2.7/site-packages/mercurial/keepalive.py", line 577, in safegetresponse
    return cls.getresponse(self)
  File "/usr/local/lib/python2.7/httplib.py", line 1028, in getresponse
    response = self.response_class(*args, **kwds)
  File "/usr/local/lib/python2.7/site-packages/mercurial/keepalive.py", line 380, in __init__
    httplib.HTTPResponse.__init__(self, sock, debuglevel, method)
  File "/usr/local/lib/python2.7/httplib.py", line 346, in __init__
    self.fp = sock.makefile('rb', 0)
  File "/usr/local/lib/python2.7/ssl.py", line 366, in makefile
    return _fileobject(self, mode, bufsize, close=True)
TypeError: file() takes at most 3 arguments (4 given)
msg225568 - (view) Author: Etienne Robillard (erob) Date: 2014-08-20 14:00
interpreter is Python 2.7.3. 2.7.8 is buggy!
msg225569 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-08-20 14:11
Are you saying that it works with 2.7.2?

If not, you should report this to mercurial first, as recommended by the error message you got.  It will be easier for them to figure out where the problem originates, since there is not really enough information here for us to reproduce the problem.
msg225572 - (view) Author: Etienne Robillard (erob) Date: 2014-08-20 14:39
Thanks. I have forwarded to Mercurial bugtracker the problem.
msg225585 - (view) Author: Etienne Robillard (erob) Date: 2014-08-20 19:57
after reviewing with the Mercurial support it was found the issue may be caused by improper python install. However i have been able to reproduce the problem with a fresh install of python 2.7.3 only.
msg225892 - (view) Author: Etienne Robillard (erob) Date: 2014-08-25 19:58
the bug appear to be reproducible with python 2.7.2 as well. I wonder
if --enable-shared is relevant to this problem.
My configuration options:

./configure --prefix=/usr/local --enable-unicode=ucs4 --with-threads --enable-shared --disable-ipv6 --with-pymalloc

openssl version:
OpenSSL> version
OpenSSL 1.0.1e 11 Feb 2013

perhaps this openssl version breaks specifically python 2.7.x ?
msg235575 - (view) Author: Etienne Robillard (erob) Date: 2015-02-08 23:11
problem is fixed with python 2.7.9. it seem ssl.py module has been greatly improved with this release. Thanks!
msg235577 - (view) Author: Etienne Robillard (erob) Date: 2015-02-09 00:02
hg push worked like a charm... but for some reasons i get another
error trying to install things with setuptools:

erob@nguns:~/Desktop/pyaml-14.12.10$ sudo python setup.py install --prefix=/usr/local

Processing dependencies for pyaml==14.12.10
Searching for PyYAML
Reading http://pypi.python.org/simple/PyYAML/
Download error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581) -- Some packages may not be found!
Couldn't find index page for 'PyYAML' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading http://pypi.python.org/simple/
Download error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581) -- Some packages may not be found!
No local packages or download links found for PyYAML

Is setuptools still working with this ssl.py module ?
msg235605 - (view) Author: Etienne Robillard (erob) Date: 2015-02-09 13:07
sometimes urllib break at different packages, with "SSL: CERTIFICATE_VERIFY_FAILED" message. It seem related to the new ssl.py
backport and pip.


sudo python setup.py install --prefix=/usr/local
Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.10.tar.gz
Traceback (most recent call last):
  File "setup.py", line 31, in <module>
    distribute_setup.use_setuptools()
  File "/home/steiner/Desktop/feedcache-1.4.1/distribute_setup.py", line 145, in use_setuptools
    return _do_download(version, download_base, to_dir, download_delay)
  File "/home/steiner/Desktop/feedcache-1.4.1/distribute_setup.py", line 124, in _do_download
    to_dir, download_delay)
  File "/home/steiner/Desktop/feedcache-1.4.1/distribute_setup.py", line 193, in download_setuptools
    src = urlopen(url)
  File "/usr/local/lib/python2.7/urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/local/lib/python2.7/urllib2.py", line 437, in open
    response = meth(req, response)
  File "/usr/local/lib/python2.7/urllib2.py", line 550, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/local/lib/python2.7/urllib2.py", line 469, in error
    result = self._call_chain(*args)
  File "/usr/local/lib/python2.7/urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python2.7/urllib2.py", line 656, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "/usr/local/lib/python2.7/urllib2.py", line 431, in open
    response = self._open(req, data)
  File "/usr/local/lib/python2.7/urllib2.py", line 449, in _open
    '_open', req)
  File "/usr/local/lib/python2.7/urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python2.7/urllib2.py", line 1240, in https_open
    context=self._context)
  File "/usr/local/lib/python2.7/urllib2.py", line 1197, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)>
msg236174 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-02-18 14:23
Verification errors that used to be ignored (ie: verification was not done by default) are now reported.  That was basically the whole point of 2.7.9.  So this is most likely a problem with the site certificate, not python.

As far as I can see there aren't any CPython bugs being reported in this issue, so I'm closing it as 3rd party.
History
Date User Action Args
2022-04-11 14:58:07adminsetgithub: 66431
2015-02-18 14:23:48r.david.murraysetstatus: open -> closed
resolution: third party
messages: + msg236174

stage: resolved
2015-02-09 13:07:30erobsetmessages: + msg235605
2015-02-09 00:02:28erobsetresolution: fixed -> (no value)
messages: + msg235577
2015-02-08 23:11:17erobsetresolution: fixed
messages: + msg235575
2014-08-25 19:58:09erobsetmessages: + msg225892
2014-08-20 19:57:01erobsetmessages: + msg225585
2014-08-20 14:39:25erobsetmessages: + msg225572
2014-08-20 14:11:45r.david.murraysetnosy: + r.david.murray
messages: + msg225569
2014-08-20 14:00:56erobsetmessages: + msg225568
2014-08-20 13:58:25erobcreate