# HG changeset patch # User Benoit Boissinot # Date 1266400848 -3600 # Node ID d7e582cab6b6b3004df25b2b5766fb3e639059d9 # Parent f2618cacb485e7b3f4e96fc656460e1d0e647088 http: len(x) fails if it doesn't fit into an int, use __len__() instead len(x) raises OverflowError if it's bigger than 2**31-1, we need to call __len__() ourself instead. diff -r f2618cacb485 -r d7e582cab6b6 mercurial/httprepo.py --- a/mercurial/httprepo.py Tue Feb 16 21:04:04 2010 +0100 +++ b/mercurial/httprepo.py Wed Feb 17 11:00:48 2010 +0100 @@ -74,10 +74,15 @@ q.update(args) qs = '?%s' % urllib.urlencode(q) cu = "%s%s" % (self._url, qs) + req = urllib2.Request(cu, data, headers) + if data is not None: + # len(data) is broken if data doesn't fit into Py_ssize_t + # add the header ourself to avoid OverflowError + size = data.__len__() + self.ui.debug("sending %s bytes\n" % size) + req.add_unredirected_header('Content-Length', '%d' % size) try: - if data: - self.ui.debug("sending %s bytes\n" % len(data)) - resp = self.urlopener.open(urllib2.Request(cu, data, headers)) + resp = self.urlopener.open(req) except urllib2.HTTPError, inst: if inst.code == 401: raise util.Abort(_('authorization failed'))