# HG changeset patch # User Benoit Boissinot # Date 2010-02-17 10:00:48 # 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 --git a/mercurial/httprepo.py b/mercurial/httprepo.py --- a/mercurial/httprepo.py +++ b/mercurial/httprepo.py @@ -74,10 +74,15 @@ class httprepository(repo.repository): 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'))