bzr internal error: AttributeError: 'module' object has no attribute 'builtins'

Bug #393694 reported by Samuel Bronson
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Invalid
Critical
Unassigned
1.16
Invalid
Undecided
Unassigned

Bug Description

I get this error from running bzr in any way, except I can't find the flag that turns off plugin loading because it's not listed in the manpage and bzr --help does this too, so I can't try that...

% bzr
bzr: ERROR: exceptions.AttributeError: 'module' object has no attribute 'builtins'

Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 729, in exception_to_return_code
    return the_callable(*args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 872, in run_bzr
    from bzrlib.builtins import cmd_help
  File "/usr/lib/python2.5/site-packages/bzrlib/builtins.py", line 5573, in <module>
    from bzrlib.foreign import cmd_dpush
  File "/usr/lib/python2.5/site-packages/bzrlib/foreign.py", line 21, in <module>
    from bzrlib.branch import (
  File "/usr/lib/python2.5/site-packages/bzrlib/branch.py", line 1977, in <module>
    __format7 = BzrBranchFormat7()
  File "/usr/lib/python2.5/site-packages/bzrlib/branch.py", line 1825, in __init__
    RepositoryFormatKnitPack5RichRoot()
  File "/usr/lib/python2.5/site-packages/bzrlib/lazy_import.py", line 122, in __call__
    obj = _replace()
  File "/usr/lib/python2.5/site-packages/bzrlib/lazy_import.py", line 89, in _replace
    obj = factory(self, scope, name)
  File "/usr/lib/python2.5/site-packages/bzrlib/lazy_import.py", line 192, in _import
    module = __import__(module_python_path, scope, scope, [member])
  File "/usr/lib/python2.5/site-packages/bzrlib/repofmt/pack_repo.py", line 62, in <module>
    from bzrlib.btree_index import (
  File "/usr/lib/python2.5/site-packages/bzrlib/btree_index.py", line 21, in <module>
    import bisect
  File "/home/naesten/.bazaar/plugins/bisect/__init__.py", line 455, in <module>
    register_command(cmd_bisect)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 123, in register_command
    return plugin_cmds.register(cmd, decorate)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 93, in register
    previous = _builtin_commands().get(k_unsquished)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 137, in _builtin_commands
    builtins = bzrlib.builtins.__dict__
AttributeError: 'module' object has no attribute 'builtins'

bzr 1.16.1 on python 2.5.4 (linux2)
arguments: ['/usr/bin/bzr']
encoding: 'UTF-8', fsenc: 'UTF-8', lang: 'en_US.UTF-8'
plugins:
*** Bazaar has encountered an internal error.
    Please report a bug at https://bugs.launchpad.net/bzr/+filebug
    including this traceback, and a description of what you
    were doing when the error occurred.

Revision history for this message
Robert Collins (lifeless) wrote :

Doesn't import needed module.

So, bzr-bisect is using bzrlib.builtins, but doesn't import it itself :). The fix should be quite easy.

As a workaround, bzr --no-plugins ... - this will disable plugin loading.

affects: bzr → bzr-bisect
Changed in bzr-bisect:
importance: Undecided → Critical
status: New → Triaged
Revision history for this message
Robert Collins (lifeless) wrote :

Actually, its something else, bzrlib.builtins is just not loaded by the time register-command is being called. Putting back to bzr and fixing.

affects: bzr-bisect → bzr
Revision history for this message
Robert Collins (lifeless) wrote :

This is fixed in bzr.dev already. I'm not sure why its showing up in 1.16. Looking into that now.

Changed in bzr:
status: Triaged → Fix Released
Revision history for this message
Robert Collins (lifeless) wrote :

Sam, can you check the file
/usr/lib/python2.5/site-packages/bzrlib/commands.py

my 1.16 copy has
def _builtin_commands():
    import bzrlib.builtins
    r = {}
    builtins = bzrlib.builtins.__dict__
...

If yours has that, I don't see how it can be failing!

Perhap change it as follows:
def _builtin_commands():
    import bzrlib.builtins
    import pdb;pdb.set_trace()
    r = {}

and poke around in the debugger.

Revision history for this message
Robert Collins (lifeless) wrote :

"" was in the PYTHONPATH, and bzr was being run from a directory with the 'bisect' plugin in it, leading to a circular import.

Changed in bzr:
status: Fix Released → Invalid
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.