qdiff: NameError when pygments not installed

Bug #551828 reported by Daniel Clemente
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
QBzr
Fix Released
High
Gary van der Merwe

Bug Description

qdiff crashes at each diff, both calling it from qlog and directly through bzr qdiff.
I'm using latest bzr.dev and qbzr from right now.

 ~/.bazaar/plugins/qbzr $ bzr qdiff
bzr: ERROR: exceptions.NameError: global name 'get_style_by_name' is not defined

Traceback (most recent call last):
  File "/home/dc/.mirp/.bazaar/plugins/qbzr/lib/commands.py", line 165, in run
    ret_code = self._qbzr_run(*args, **kwargs)
  File "/home/dc/.mirp/.bazaar/plugins/qbzr/lib/commands.py", line 466, in _qbzr_run
    ui_mode=ui_mode)
  File "/w/bzr/oficial/bzrlib/lazy_import.py", line 125, in __call__
    return obj(*args, **kwargs)
  File "/home/dc/.mirp/.bazaar/plugins/qbzr/lib/diffwindow.py", line 143, in __init__
    self.diffview = SidebySideDiffView(self)
  File "/home/dc/.mirp/.bazaar/plugins/qbzr/lib/diffview.py", line 213, in __init__
    QtGui.QTextCharFormat(self.monospacedFormat))
  File "/home/dc/.mirp/.bazaar/plugins/qbzr/lib/syntaxhighlighter.py", line 175, in __init__
    self.style = get_style_by_name("default")
NameError: global name 'get_style_by_name' is not defined

bzr 2.2.0dev1 on python 2.5.5 (Linux-2.6.32-3-amd64-x86_64-with-debian-squeeze-sid)
arguments: ['/w/bzr/oficial/bzr', 'qdiff']
encoding: 'UTF-8', fsenc: 'UTF-8', lang: 'ca_ES.UTF-8'
plugins:
  bzrtools /home/dc/.mirp/.bazaar/plugins/bzrtools [2.1.0]
  etckeeper /usr/lib/python2.5/site-packages/bzrlib/plugins/etckeeper [unknown]
  explorer /home/dc/.mirp/.bazaar/plugins/explorer [1.1.0dev]
  fastimport /home/dc/.mirp/.bazaar/plugins/fastimport [0.9.0dev]
  git /home/dc/.mirp/.bazaar/plugins/git [0.5.0]
  gtk /home/dc/.mirp/.bazaar/plugins/gtk [0.99.0dev1]
  launchpad /home/w/bzr/oficial/bzrlib/plugins/launchpad [2.2.0dev1]
  netrc_credential_store /home/w/bzr/oficial/bzrlib/plugins/netrc_credential_store [2.2.0dev1]
  news_merge /home/w/bzr/oficial/bzrlib/plugins/news_merge [2.2.0dev1]
  push_and_update /home/dc/.mirp/.bazaar/plugins/push_and_update [0.2.0dev]
  qbzr /home/dc/.mirp/.bazaar/plugins/qbzr [0.19.0dev1]

*** 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.

Via bisect I tracked down the change at which this crash appeared:

On revision 1227.1.6 (<email address hidden>):
Better custom lazy import for pygments.

And from: bzr diff -c 1227.1.6

         try:
- import pygments
+ from pygments.util import ClassNotFound
+ from pygments.styles import get_style_by_name
+ from pygments import lex
+ from pygments.lexers import get_lexer_for_filename
         except ImportError:
             _have_pygments = False
         else:

Maybe it's necessary to add an "except NameError"?

Related branches

Changed in qbzr:
assignee: nobody → Gary van der Merwe (garyvdm)
importance: Undecided → High
milestone: none → 0.19b2
status: New → Fix Released
summary: - qdiff: NameError: global name 'get_style_by_name' is not defined
+ qdiff: NameError when pygments not installed
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.