# HG changeset patch # User Augie Fackler # Date 2017-09-15 22:37:29 # Node ID ab379eed2e31b523f80eaf316f119a993d99e061 # Parent b59620c52eecb98556d1112a168281f002fdb57c 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(r'Found a non-bytes trying to ' + r'build bundle part header: %r' % header) outdebug(ui, 'header chunk size: %i' % len(headerchunk)) yield _pack(_fpartheadersize, len(headerchunk)) yield headerchunk