0

I'm trying to fix the following exception I get while running Trac 0.11 with mod_fcgid on Apache2:

Unhandled exception in thread started by <bound method Connection.run of <trac.web._fcgi.Connection object at 0x88b5fec>>
Traceback (most recent call last):
  File "/usr/lib/python2.6/dist-packages/trac/web/_fcgi.py", line 661, in run
    except socket.error, e:
AttributeError: 'NoneType' object has no attribute 'error'

I modified the relevant block in _fcgi.py to lock like this:

def run(self):
    """Begin processing data from the socket."""
    self._keepGoing = True
    while self._keepGoing:
        try:
            self.process_input()
        except EOFError:
            break
        except socket.error, e:
            if e[0] == errno.EBADF:
                break
            raise
        except select.error, e:
            if e[0] == errno.EBADF: # Socket was closed by Request.
                break
            raise

    self._cleanupSocket()

The line causing the exception is except socket.error, e:. Reading the Pydocs I see 'socket' is a class and there should be a member named 'error', so why this exception?

I'm usually coding C or Java and never did something in Python, can someone enlighten me? :)

Thanks,

lynix

lynix
  • 145
  • 8

1 Answers1

0

Are you sure, you don't have a socket variable that has a value of None? This sample:

import socket
socket = None
print socket.error

produces exactly the same error. As a quick hack, you can try to add import socket as socketLib at the beginning of your file and replacing your line with except socketLib.error, e... but just to identify the problem!

tomasz
  • 12,574
  • 4
  • 43
  • 54
  • I did as you say, changing the import to 'socketLib'. The error now occurs with socketLib: except socketLib.error, e: AttributeError: 'NoneType' object has no attribute 'error' – lynix May 06 '12 at 14:52