From patchwork Fri Sep 15 23:14:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1, of, 8, py3] bundle2: raise a more helpful error if building a bundle part header fails From: Augie Fackler X-Patchwork-Id: 23924 Message-Id: <662bbd6d96952985eff8.1505517244@augie-macbookpro2.roam.corp.google.com> To: mercurial-devel@mercurial-scm.org Date: Fri, 15 Sep 2017 19:14:04 -0400 # HG changeset patch # User Augie Fackler # Date 1505515049 14400 # Fri Sep 15 18:37:29 2017 -0400 # Node ID 662bbd6d96952985eff807f424dd128663724672 # Parent 209120041d12b524648fa856732aa404dfedd91d bundle2: raise a more helpful error if building a bundle part header fails I've tripped on this several times now, and am tired of debugging. Now the header parts are part of the error message when the ''.join() fails, which makes debugging obvious. diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py --- a/mercurial/bundle2.py +++ b/mercurial/bundle2.py @@ -1050,7 +1050,11 @@ class bundlepart(object): header.append(key) header.append(value) ## finalize header - headerchunk = ''.join(header) + try: + headerchunk = ''.join(header) + except TypeError: + raise TypeError(u'Found a non-bytes trying to ' + u'build bundle part header: %r' % header) outdebug(ui, 'header chunk size: %i' % len(headerchunk)) yield _pack(_fpartheadersize, len(headerchunk)) yield headerchunk