Uploaded image for project: 'mod_python'
  1. mod_python
  2. MODPYTHON-101

If target handler found but evaluates false, there should still be an error if not silent.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.1.4, 3.2.7
    • 3.3.1
    • core
    • None

    Description

      If one specifies PythonHandler directive and the target is mistakenly set to be something like:

      handler = 0
      handler = None
      handler = False
      handler = []
      handler = {}

      no error is raised.

      As comparison, if one has:

      handler = 1

      you get an error:

      Traceback (most recent call last):

      File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/mod_python/apache.py", line 309, in HandlerDispatch
      result = object(req)

      TypeError: 'int' object is not callable

      This is because if the target in any way evaluates to false, no attempt is made to execute it, but at the same time if the silent flag is not set no error is raised either.

      In the case of HandlerDispatch in apache.py, the code currently is:

      1. find the object
        object = resolve_object(module, object_str,
        arg=req, silent=hlist.silent)

      if object:

      1. call the object

      ....

      elif hlist.silent:
      result = DECLINED

      It would make more sense that if hlist.silent is not set, that the object, whatever it may be should be called. This would ensure that any error response is always generated when it can be.

      Thus, instead of just:

      if object:

      it should really be:

      if not hlist.silent or object:

      In the case of ConnectionDispatch() and FilterDispatch(), because silent is fixed to "0" in those cases, there should not even be a check of whether object evaluates true, it should just be called regardless.

      Thus instead of:

      if object:

      1. call the object
        if config.has_key("PythonEnablePdb"):
        result = pdb.runcall(object, conn)
        else:
        result = object(conn)

      it should just be:

      1. call the object:
        if config.has_key("PythonEnablePdb"):
        result = pdb.runcall(object, conn)
        else:
        result = object(conn)

      Indent level of following assertion clause in case of ConnectionDispatch() and call to filter.flush() in FilterDispatcher() should also be shifted out as well as appropriate.

      Attachments

        Activity

          People

            grahamd Graham Phillip Dumpleton
            grahamd Graham Phillip Dumpleton
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: