Bzr qdiff crashes

Bug #1529659 reported by SirVer
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
QBzr
Invalid
Undecided
Unassigned

Bug Description

Running bzr qdiff crashes immediately after showing a window:

$ bzr qdiff
bzr: ERROR: exceptions.TypeError: first argument must be string or compiled pattern

Traceback (most recent call last):
  File "/Users/sirver/.bazaar/plugins/qbzr/lib/trace.py", line 381, in reports_exception_decorate
    return f(*args, **kargs)
  File "/Users/sirver/.bazaar/plugins/qbzr/lib/diffwindow.py", line 367, in initial_load
    op.run()
  File "/usr/local/lib/python2.7/site-packages/bzrlib/cleanup.py", line 132, in run
    self.cleanups, self.func, self, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/cleanup.py", line 166, in _do_with_cleanups
    result = func(*args, **kwargs)
  File "/Users/sirver/.bazaar/plugins/qbzr/lib/diffwindow.py", line 381, in _initial_load
    self.load_diff()
  File "/Users/sirver/.bazaar/plugins/qbzr/lib/diffwindow.py", line 448, in load_diff
    data, di.properties_changed)
  File "/Users/sirver/.bazaar/plugins/qbzr/lib/diffview.py", line 566, in append_diff
    paths)]
  File "/Users/sirver/.bazaar/plugins/qbzr/lib/diffview.py", line 555, in getTokens
    lexer = get_lexer_for_filename(path, stripnl=False)
  File "/usr/local/lib/python2.7/site-packages/pygments/lexers/__init__.py", line 147, in get_lexer_for_filename
    res = find_lexer_class_for_filename(_fn, code)
  File "/usr/local/lib/python2.7/site-packages/pygments/lexers/__init__.py", line 112, in find_lexer_class_for_filename
    for cls in find_plugin_lexers():
  File "/usr/local/lib/python2.7/site-packages/pygments/plugin.py", line 53, in find_plugin_lexers
    yield entrypoint.load()
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2379, in load
    self.require(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2395, in require
    reqs = self.dist.requires(self.extras)
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2640, in requires
    dm = self._dep_map
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2861, in _dep_map
    self.__dep_map = self._compute_dependencies()
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2884, in _compute_dependencies
    distvers, mark = self._preparse_requirement(req)
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2872, in _preparse_requirement
    distvers = re.sub(self.EQEQ, r"\1==\2\3", distvers)
  File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py", line 155, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py", line 247, in _compile
    raise TypeError, "first argument must be string or compiled pattern"
TypeError: first argument must be string or compiled pattern

bzr 2.6.0 on python 2.7.11 (Darwin-15.2.0-x86_64-i386-64bit)
arguments: ['/usr/local/bin/bzr', 'qdiff']
plugins: bash_completion[2.6.0], bisect[1.1.0dev], changelog_merge[2.6.0],
    grep[2.6.0], launchpad[2.6.0], netrc_credential_store[2.6.0],
    news_merge[2.6.0], po_merge[2.6.0], qbzr[0.23.2dev], rewrite[0.6.4dev],
    weave_fmt[2.6.0]
encoding: 'utf-8', fsenc: 'utf-8', lang: 'C'

*** Bazaar has encountered an internal error. This probably indicates a
    bug in Bazaar. You can help us fix it by filing a bug report at
        https://bugs.launchpad.net/bzr/+filebug
    including this traceback and a description of the problem.

$ bzr --version
Bazaar (bzr) 2.6.0
  Python interpreter: /usr/local/opt/python/bin/python2.7 2.7.11
  Python standard library: /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7
  Platform: Darwin-15.2.0-x86_64-i386-64bit
  bzrlib: /usr/local/lib/python2.7/site-packages/bzrlib
  Bazaar configuration: /Users/sirver/.bazaar
  Bazaar log file: /Users/sirver/.bzr.log

Copyright 2005-2012 Canonical Ltd.
http://bazaar.canonical.com/

bzr comes with ABSOLUTELY NO WARRANTY. bzr is free software, and
you may use, modify and redistribute it under the terms of the GNU
General Public License version 2 or later.

Bazaar is part of the GNU Project to produce a free operating system.

---

qbzr is latest revision:
$ cd ~/.bazaar/plugins/qbzr
$ bzr revno
1515

Revision history for this message
Alexander Belchenko (bialix) wrote :

Hi, it seems either your version of setuptools is outdated or you need to upgrade your pygments library.

It started to break here:

File "/usr/local/lib/python2.7/site-packages/pygments/lexers/__init__.py", line 147, in get_lexer_for_filename

i.e. this is separate pygments library - maybe try `sudo pip install --upgrade pygments`

or try to get fresh version of setuptools: `sudo pip install --upgrade setuptools`.

Error you got is not strictly related to qbzr code itself. If you won't be able to fix this problem, try to uninstall pygments library, and check whether qdiff will work.

Changed in qbzr:
status: New → Invalid
Revision history for this message
SirVer (sirver) wrote :

Removing pygments indeed does the trick.

Reinstalling pygments-2.0.2 (the latest stable) brings the bug back.

Revision history for this message
Alexander Belchenko (bialix) wrote :

Can you tell me what type of files you try to diff there? I.e. file extensions, e.g. ".txt" or ".png" etc, please?

Revision history for this message
Alexander Belchenko (bialix) wrote :

I've filed a bug report against pygments https://bitbucket.org/birkenfeld/pygments-main/issues/1185/get_lexer_for_filename-ends-wih-traceback maybe their authors can help.

My best guess so far is: you have some plugins for pygments installed and setuptools can't load such plugins, or those plugins are outdated or something like that. That said problem is not in pygments per se, but in some other python library you have installed on your machine.

Probably QBzr could catch such tracebacks and just ignore pygments at all, but right now nobody's actively working on qbzr codebase, so it should be easier for you to sort out somehow what is installed on your machine. Try to examine content of the folder /usr/local/lib/python2.7/site-packages/ or check the output of `pip list`

Revision history for this message
hareesh (hareesh-gurukul) wrote :

I have also faced same issue, Installed bzr, qbzr, PyQt4, SIP in virtualenv to compare and it worked fine. As said above removing pygments will solve the issue.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.