hg

edgy: hgwebdir.cgi crashes in posixpath.py line 62 with AttributeError: 'NoneType' object has no attribute 'endswith'

Bug #56949 reported by Zingo Andersen
6
Affects Status Importance Assigned to Milestone
hg
Fix Released
Unknown
mercurial (Debian)
Fix Released
Unknown
mercurial (Ubuntu)
Fix Released
Low
Unassigned

Bug Description

Binary package hint: mercurial

Hello
I'm running edgy on AMD64 and mercurial version system (0.9-7)
The "server" hgwebdir.cgi crashes for me whatever I try to browse to on
http://zingo.homeip.net:8000/hg<whatever>
with this output

-------------------------- cgi output on webserver
AttributeError Python 2.4.4c0: /usr/bin/python
Sun Aug 20 01:37:47 2006

A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.
 /home/zingo/projects/src/www/hg/hgwebdir.cgi
   16 # Alternatively you can pass a list of ('virtual/path', '/real/path') tuples
   17 # or use a dictionary with entries like 'virtual/path': '/real/path'
   18
   19 h = hgweb.hgwebdir("hgweb.config")
   20 h.run()
h = <mercurial.hgweb.hgwebdir object>, h.run = <bound method hgwebdir.run of <mercurial.hgweb.hgwebdir object>>
 /var/lib/python-support/python2.4/mercurial/hgweb.py in run(self=<mercurial.hgweb.hgwebdir object>, req=<mercurial.hgweb.hgrequest object>)
 1043 yield tmpl("footer", motd=self.motd, **map)
 1044
 1045 m = os.path.join(templater.templatepath(), "map")
 1046 tmpl = templater.templater(m, templater.common_filters,
 1047 defaults={"header": header,
m undefined, global os = <module 'os' from '/usr/lib/python2.4/os.pyc'>, os.path = <module 'posixpath' from '/usr/lib/python2.4/posixpath.pyc'>, os.path.join = <function join>, global templater = <module 'mercurial.templater' from '/var/lib/python-support/python2.4/mercurial/templater.pyc'>, templater.templatepath = <function templatepath>
 /home/zingo/projects/src/www/hg/posixpath.py in join(a=None, *p=('map',))
   60 if b.startswith('/'):
   61 path = b
   62 elif path == '' or path.endswith('/'):
   63 path += b
   64 else:
path = None, path.endswith undefined

AttributeError: 'NoneType' object has no attribute 'endswith'
      args = ("'NoneType' object has no attribute 'endswith'",)

------------------------------------------------------------ Apace config

# ServerAdmin <email address hidden>
# CustomLog logs/access_log.hg combined
# ErrorLog logs/error_log.hg

  ScriptAlias /hg /home/zingo/projects/src/www/hg/hgwebdir.cgi/

# RewriteEngine on
# RewriteRule (.*) /home/zingo/projects/src/www/hg/hgwebdir.cgi$1

  <Directory "/home/zingo/projects/src/www/hg">
    Order allow,deny
    Allow from all
    AllowOverride All
    Options ExecCGI
    AddHandler cgi-script .cgi
  </Directory>

Tags: edgy
Zingo Andersen (zingo)
description: updated
Revision history for this message
Zingo Andersen (zingo) wrote :

I'm not a python hacker but could it be that
------------- hgweb.py line 1045
        m = os.path.join(templater.templatepath(), "map")
--------------------
that
templater.templatepath() == "NULL" ?
This don't give me any big clues but could it be that it don't find the template dir?

---------------templater.py line 294

def templatepath(name=None):
    '''return location of template file or directory (if no name).
    returns None if not found.'''

    # executable version (py2exe) doesn't support __file__
    if hasattr(sys, 'frozen'):
        module = sys.executable
    else:
        module = __file__
    for f in 'templates', '../templates':
        fl = f.split('/')
        if name: fl.append(name)
        p = os.path.join(os.path.dirname(module), *fl)
        if (name and os.path.exists(p)) or os.path.isdir(p):
            return os.path.normpath(p)

Revision history for this message
Zingo Andersen (zingo) wrote :

If I add a line return "/usr/share/mercurial/templates"
last in the templatepath() function/method it works for me.

def templatepath(name=None):
    '''return location of template file or directory (if no name).
    returns None if not found.'''

    # executable version (py2exe) doesn't support __file__

    if hasattr(sys, 'frozen'):
        module = sys.executable
    else:
        module = __file__
    for f in 'templates', '../templates':
        fl = f.split('/')
        if name: fl.append(name)
        p = os.path.join(os.path.dirname(module), *fl)
        if (name and os.path.exists(p)) or os.path.isdir(p):
            return os.path.normpath(p)
    return "/usr/share/mercurial/templates"

Revision history for this message
Lionel Le Folgoc (mrpouit) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. You reported this bug a while ago and there hasn't been any activity in it recently. We were wondering is this still an issue for you? Thanks in advance.

Changed in mercurial:
importance: Undecided → Low
status: New → Incomplete
Revision history for this message
tonfa (bboissin) wrote :
Revision history for this message
Lionel Le Folgoc (mrpouit) wrote :

Ok, thanks for the feedback.
I'm opening a dapper task in case someone wants to fix it in dapper.

Changed in mercurial:
status: Incomplete → Fix Released
Revision history for this message
Lionel Le Folgoc (mrpouit) wrote :

Sorry, I meant 'edgy'. But it seems to be already fixed in edgy.

Revision history for this message
Zingo Andersen (zingo) wrote :

I have not notice, I did my patch back then, I have not had any problems since then. If that is since I have my patch or not I don't know but since I have newer mercurial versions I assume it has been fixed. Im now on feasty.

Changed in mercurial:
status: Unknown → Fix Released
Changed in hg:
status: Unknown → Fix Released
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.