Bazaar Version Control System

Branch.get_config_file smart verb breaks get_bzr_remote_path

Reported by Matt Nordhoff on 2009-04-02
16
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Critical
Matt Nordhoff

Bug Description

With a client & server running bzr.dev >= r4234, attempting to call get_bzr_remote_path() causes a traceback:

>>> import bzrlib.branch
>>> bzrlib.branch.Branch.open('bzr+ssh://...').get_config().get_bzr_remote_path()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/mnordhoff/co/bzr/bazaar/bzr/bzr.dev/bzrlib/config.py", line 293, in get_bzr_remote_path
    path = self.get_user_option("bzr_remote_path")
  File "/home/mnordhoff/co/bzr/bazaar/bzr/bzr.dev/bzrlib/config.py", line 175, in get_user_option
    return self._get_user_option(option_name)
  File "/home/mnordhoff/co/bzr/bazaar/bzr/bzr.dev/bzrlib/config.py", line 684, in _get_user_option
    value = source()._get_user_option(option_name)
  File "/home/mnordhoff/co/bzr/bazaar/bzr/bzr.dev/bzrlib/config.py", line 355, in _get_user_option
    value = self._get_parser().get_value(section, option_name)
  File "/home/mnordhoff/co/bzr/bazaar/bzr/bzr.dev/bzrlib/config.py", line 925, in _get_parser
    return self._config._get_configobj()
  File "/home/mnordhoff/co/bzr/bazaar/bzr/bzr.dev/bzrlib/remote.py", line 2399, in _get_configobj
    return config.ConfigObj([bytes], encoding='utf-8')
  File "/home/mnordhoff/co/bzr/bazaar/bzr/bzr.dev/bzrlib/config.py", line 143, in ConfigObj
    return _ConfigObj(*args, **kwargs)
  File "/home/mnordhoff/co/bzr/bazaar/bzr/bzr.dev/bzrlib/util/configobj/configobj.py", line 1276, in __init__
    self._load(infile, configspec)
  File "/home/mnordhoff/co/bzr/bazaar/bzr/bzr.dev/bzrlib/util/configobj/configobj.py", line 1359, in _load
    raise error
bzrlib.util.configobj.configobj.ParseError: Invalid line at line "1".

Related branches

Matt Nordhoff (mnordhoff) wrote :
description: updated
Robert Collins (lifeless) wrote :

Looks like 'bytes' is bogus, can you print it out?

Robert Collins (lifeless) wrote :

Works for me:

>>> import bzrlib.branch
>>> b = bzrlib.branch.Branch.open(':push')
>>> b.get_config().get_bzr_remote_path()
u'/home/robertc/bzr.dev/bzr'
>>>

Matt Nordhoff (mnordhoff) wrote :

Oh. I changed it to print repr(bytes), and it's the contents of branch.conf:

'parent_location = http://bazaar-vcs.org/bzr/bzr.dev/\nstacked_on_location = ""\n'

Gary van der Merwe (garyvdm) wrote :

I get a similar error in qlog:

bzr: ERROR: bzrlib.util.configobj.configobj.ParseError: Invalid line at line "1".

Traceback (most recent call last):
  File "/home/garyvdm/qbzr/wd/qbzr/lib/util.py", line 934, in decorate
    run_in_loading_queue(f, *args, **kargs)
  File "/home/garyvdm/qbzr/wd/qbzr/lib/util.py", line 946, in run_in_loading_queue
    f(*args, **kargs)
  File "/home/garyvdm/qbzr/wd/qbzr/lib/uifactory.py", line 31, in decorate
    r = f(*args, **kargs)
  File "/home/garyvdm/qbzr/wd/qbzr/lib/log.py", line 370, in update_selection
    replace = self.replace_config(rev.branch)
  File "/home/garyvdm/qbzr/wd/qbzr/lib/log.py", line 281, in replace_config
    replace = config.get_user_option("qlog_replace")
  File "/home/garyvdm/bzr.dev/bzrlib/config.py", line 175, in get_user_option
    return self._get_user_option(option_name)
  File "/home/garyvdm/bzr.dev/bzrlib/config.py", line 684, in _get_user_option
    value = source()._get_user_option(option_name)
  File "/home/garyvdm/bzr.dev/bzrlib/config.py", line 355, in _get_user_option
    value = self._get_parser().get_value(section, option_name)
  File "/home/garyvdm/bzr.dev/bzrlib/config.py", line 925, in _get_parser
    return self._config._get_configobj()
  File "/home/garyvdm/bzr.dev/bzrlib/remote.py", line 2399, in _get_configobj
    return config.ConfigObj([bytes], encoding='utf-8')
  File "/home/garyvdm/bzr.dev/bzrlib/config.py", line 143, in ConfigObj
    return _ConfigObj(*args, **kwargs)
  File "/home/garyvdm/bzr.dev/bzrlib/util/configobj/configobj.py", line 1276, in __init__
    self._load(infile, configspec)
  File "/home/garyvdm/bzr.dev/bzrlib/util/configobj/configobj.py", line 1359, in _load
    raise error
ParseError: Invalid line at line "1".

bzr 1.14dev on python 2.5.2 (linux2)
arguments: ['/home/garyvdm/bzr.dev/bzr', 'qlog', 'lp:qbzr']
encoding: 'UTF-8', fsenc: 'UTF-8', lang: 'en_ZA.UTF-8'
plugins:
  avahi /usr/lib/python2.5/site-packages/bzrlib/plugins/avahi [0.3dev]
  bzrtools /usr/lib/python2.5/site-packages/bzrlib/plugins/bzrtools [1.13]
  dbus /usr/lib/python2.5/site-packages/bzrlib/plugins/dbus [unknown]
  launchpad /home/garyvdm/bzr.dev/bzrlib/plugins/launchpad [unknown]
  netrc_credential_store /home/garyvdm/bzr.dev/bzrlib/plugins/netrc_credential_store [unknown]
  qbzr /home/garyvdm/qbzr/wd/qbzr [0.10dev]
  svn /usr/lib/python2.5/site-packages/bzrlib/plugins/svn [0.5.3]

Matt Nordhoff (mnordhoff) wrote :

So it looks like ConfigObj wants a list of lines, but bzr is passing a list containing the entire file. lifeless, the reason it worked for you is probably that your branch.conf is 0 or 1 lines long.

>>> from bzrlib.util.configobj.configobj import ConfigObj
>>> s = 'parent_location = http://bazaar-vcs.org/bzr/bzr.dev/\nstacked_on_location = ""\n'
>>> ConfigObj([s], encoding='utf-8')
Traceback (most recent call last):
    [snip]
bzrlib.util.configobj.configobj.ParseError: Invalid line at line "1".
>>> ConfigObj(s.splitlines(), encoding='utf-8')
ConfigObj({u'parent_location': u'http://bazaar-vcs.org/bzr/bzr.dev/', u'stacked_on_location': u''})

Changed in bzr:
assignee: nobody → mnordhoff
importance: Undecided → Critical
status: New → Confirmed
Matt Nordhoff (mnordhoff) wrote :

Fix merged in bzr.dev r4251.

Changed in bzr:
status: Confirmed → 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