TypeError in git repository

Bug #1795681 reported by Neil Martinsen-Burrell on 2018-10-02
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Breezy
Critical
Jelmer Vernooij

Bug Description

I was excited to try brz 3.0a1. I installed with `pip install brz`. When I first ran `brz --version` it required that I install `dulwich` for `brz-git` and I did a `pip install dulwich`. Then I went to a git repository and ran `brz log`. I got the following error:

$ brz log
brz: ERROR: TypeError: startswith first arg must be bytes or a tuple of bytes, not str

Traceback (most recent call last):
  File "/home/neil/.asdf/installs/python/3.6.5/lib/python3.6/site-packages/breezy/commands.py", line 1009, in exception_to_return_code
    return the_callable(*args, **kwargs)
  File "/home/neil/.asdf/installs/python/3.6.5/lib/python3.6/site-packages/breezy/commands.py", line 1194, in run_bzr
    ret = run(*run_argv)
  File "/home/neil/.asdf/installs/python/3.6.5/lib/python3.6/site-packages/breezy/commands.py", line 760, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/home/neil/.asdf/installs/python/3.6.5/lib/python3.6/site-packages/breezy/commands.py", line 784, in run
    return self._operation.run_simple(*args, **kwargs)
  File "/home/neil/.asdf/installs/python/3.6.5/lib/python3.6/site-packages/breezy/cleanup.py", line 136, in run_simple
    self.cleanups, self.func, *args, **kwargs)
  File "/home/neil/.asdf/installs/python/3.6.5/lib/python3.6/site-packages/breezy/cleanup.py", line 165, in _do_with_cleanups
    result = func(*args, **kwargs)
  File "/home/neil/.asdf/installs/python/3.6.5/lib/python3.6/site-packages/breezy/commands.py", line 1211, in ignore_pipe
    result = func(*args, **kwargs)
  File "/home/neil/.asdf/installs/python/3.6.5/lib/python3.6/site-packages/breezy/builtins.py", line 2874, in run
    Logger(b, rqst).show(lf)
  File "/home/neil/.asdf/installs/python/3.6.5/lib/python3.6/site-packages/breezy/log.py", line 393, in show
    self._show_body(lf)
  File "/home/neil/.asdf/installs/python/3.6.5/lib/python3.6/site-packages/breezy/log.py", line 419, in _show_body
    generator = self._generator_factory(self.branch, rqst)
  File "/home/neil/.asdf/installs/python/3.6.5/lib/python3.6/site-packages/breezy/log.py", line 433, in _generator_factory
    return _DefaultLogGenerator(branch, rqst)
  File "/home/neil/.asdf/installs/python/3.6.5/lib/python3.6/site-packages/breezy/log.py", line 447, in __init__
    self.rev_tag_dict = branch.tags.get_reverse_tag_dict()
  File "/home/neil/.asdf/installs/python/3.6.5/lib/python3.6/site-packages/breezy/tag.py", line 186, in get_reverse_tag_dict
    d = self.get_tag_dict()
  File "/home/neil/.asdf/installs/python/3.6.5/lib/python3.6/site-packages/breezy/git/branch.py", line 223, in get_tag_dict
    for (ref_name, tag_name, peeled, unpeeled) in self.branch.get_tag_refs():
  File "/home/neil/.asdf/installs/python/3.6.5/lib/python3.6/site-packages/breezy/git/branch.py", line 575, in get_tag_refs
    self._tag_refs = list(self._iter_tag_refs())
  File "/home/neil/.asdf/installs/python/3.6.5/lib/python3.6/site-packages/breezy/git/branch.py", line 694, in _iter_tag_refs
    for ref_name, unpeeled in viewitems(refs.as_dict()):
  File "/home/neil/.asdf/installs/python/3.6.5/lib/python3.6/site-packages/dulwich/refs.py", line 181, in as_dict
    keys = self.keys(base)
  File "/home/neil/.asdf/installs/python/3.6.5/lib/python3.6/site-packages/dulwich/refs.py", line 160, in keys
    return self.allkeys()
  File "/home/neil/.asdf/installs/python/3.6.5/lib/python3.6/site-packages/breezy/git/transportgit.py", line 144, in allkeys
    keys.update(self.get_packed_refs())
  File "/home/neil/.asdf/installs/python/3.6.5/lib/python3.6/site-packages/breezy/git/transportgit.py", line 167, in get_packed_refs
    if (first_line.startswith("# pack-refs") and " peeled" in
TypeError: startswith first arg must be bytes or a tuple of bytes, not str

brz 3.0a1 on python 3.6.5 (Linux-4.15.0-34-generic-x86_64-with-debian-buster-
    sid)
arguments: ['/home/neil/.asdf/installs/python/3.6.5/bin/brz', 'log']
plugins: bash_completion[3.0a1], changelog_merge[3.0a1],
    commitfromnews[unknown], cvs[3.0a1], darcs[unknown], email[unknown],
    fastimport[unknown], grep[3.0a1], launchpad[3.0a1], mtn[3.0a1],
    netrc_credential_store[3.0a1], news_merge[3.0a1], po_merge[3.0a1],
    repodebug[unknown], stats[3.0a1], upload[3.0a1], weave_fmt[3.0a1]
encoding: 'utf-8', fsenc: 'utf-8', lang: 'en_US.UTF-8'

It looks like a Python3 issue with strings/bytes and it's possible that I have old plugins or old BZR setup that is interfering.

Tags: git Edit Tag help

Related branches

Jelmer Vernooij (jelmer) wrote :

Looks like a lack of test coverage.

Changed in brz:
status: New → In Progress
importance: Undecided → Medium
assignee: nobody → Jelmer Vernooij (jelmer)
tags: added: git
Changed in brz:
importance: Medium → Critical
milestone: none → 3.0.0
Jelmer Vernooij (jelmer) on 2018-10-03
Changed in brz:
status: In Progress → Fix Committed
Neil Martinsen-Burrell (nmb) wrote :
Download full text (4.3 KiB)

I wanted to test the fix and I got the following error around the additional `name.decode(...)` change:

$ brz log
brz: ERROR: AttributeError: 'str' object has no attribute 'decode'

Traceback (most recent call last):
  File "/home/neil/proj/brz/brz.dev/breezy/commands.py", line 1009, in exception_to_return_code
    return the_callable(*args, **kwargs)
  File "/home/neil/proj/brz/brz.dev/breezy/commands.py", line 1194, in run_bzr
    ret = run(*run_argv)
  File "/home/neil/proj/brz/brz.dev/breezy/commands.py", line 760, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/home/neil/proj/brz/brz.dev/breezy/commands.py", line 784, in run
    return self._operation.run_simple(*args, **kwargs)
  File "/home/neil/proj/brz/brz.dev/breezy/cleanup.py", line 136, in run_simple
    self.cleanups, self.func, *args, **kwargs)
  File "/home/neil/proj/brz/brz.dev/breezy/cleanup.py", line 165, in _do_with_cleanups
    result = func(*args, **kwargs)
  File "/home/neil/proj/brz/brz.dev/breezy/commands.py", line 1211, in ignore_pipe
    result = func(*args, **kwargs)
  File "/home/neil/proj/brz/brz.dev/breezy/builtins.py", line 2874, in run
    Logger(b, rqst).show(lf)
  File "/home/neil/proj/brz/brz.dev/breezy/log.py", line 393, in show
    self._show_body(lf)
  File "/home/neil/proj/brz/brz.dev/breezy/log.py", line 421, in _show_body
    for lr in generator.iter_log_revisions():
  File "/home/neil/proj/brz/brz.dev/breezy/log.py", line 463, in iter_log_revisions
    revision_iterator = self._create_log_revision_iterator()
  File "/home/neil/proj/brz/brz.dev/breezy/log.py", line 515, in _create_log_revision_iterator
    self.rqst.get('end_revision'))
  File "/home/neil/proj/brz/brz.dev/breezy/log.py", line 1100, in _get_revision_limits
    end_revno = branch.revno()
  File "/home/neil/proj/brz/brz.dev/breezy/branch.py", line 969, in revno
    return self.last_revision_info()[0]
  File "/home/neil/proj/brz/brz.dev/breezy/branch.py", line 986, in last_revision_info
    self._last_revision_info_cache = self._read_last_revision_info()
  File "/home/neil/proj/brz/brz.dev/breezy/git/branch.py", line 638, in _read_last_revision_info
    last_revid = self.last_revision()
  File "/home/neil/proj/brz/brz.dev/breezy/git/branch.py", line 539, in last_revision
    return self.lookup_foreign_revision_id(self.head)
  File "/home/neil/proj/brz/brz.dev/breezy/git/branch.py", line 548, in lookup_foreign_revision_id
    self.mapping)
  File "/home/neil/proj/brz/brz.dev/breezy/git/repository.py", line 475, in lookup_foreign_revision_id
    commit = self._git.object_store.peel_sha(foreign_revid)
  File "/home/neil/.asdf/installs/python/3.6.5/lib/python3.6/site-packages/dulwich/object_store.py", line 256, in peel_sha
    obj = self[sha]
  File "/home/neil/.asdf/installs/python/3.6.5/lib/python3.6/site-packages/dulwich/object_store.py", line 119, in __getitem__
    type_num, uncomp = self.get_raw(sha)
  File "/home/neil/.asdf/installs/python/3.6.5/lib/python3.6/site-packages/dulwich/object_store.py", line 446, in get_raw
    for pack in self.packs:
  File "/home/neil/proj/brz/brz.dev/breezy/git/transportgit.py", line 594, in packs
    self._update_pack_cache()
  File "/h...

Read more...

Jelmer Vernooij (jelmer) on 2018-10-14
Changed in brz:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers