Bug 237886 - logging/handlers.py doesn't always set unixsocket
Summary: logging/handlers.py doesn't always set unixsocket
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: python
Version: 6
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jeremy Katz
QA Contact: Brock Organ
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2007-04-25 20:59 UTC by Steve Friedman
Modified: 2007-11-30 22:12 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2007-04-30 20:51:45 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Steve Friedman 2007-04-25 20:59:18 UTC
Description of problem:

I am having a problem (for reasons that I don't understand) that line 630 of
handlers.py claims that unixsocket is undefined.  One way that this can happen
is if the socket creation (either _connect_unixsocket() or socket.socket())
throws an uncaught exception as unixsocket is defined after this point. 


Version-Release number of selected component (if applicable):
python-2.4.4-1.fc6

How reproducible:
Always (if you can get the socket creation to fail).

Steps to Reproduce:
1. Turn of syslog / syslog-ng.
2. Run any python command that uses logging (e.g., yum check-update).
3.
  
Actual results:
The code throws an exception in the close().

Expected results:


Additional info:
The simplest solution is to set unixsocket=0 prior to the if and only set it to
1 after the socket is properly created:

From:
       if type(address) == types.StringType:
            self._connect_unixsocket(address)
            self.unixsocket = 1
        else:
            self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
            self.unixsocket = 0

To:
       self.unixsocket = 0
       if type(address) == types.StringType:
            self._connect_unixsocket(address)
            self.unixsocket = 1
        else:
            self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

Comment 1 Jeremy Katz 2007-04-30 20:51:45 UTC
Already fixed in rawhide and I've committed the fix to the FC-6 branch of the
python package for the next time I do an update of it.


Note You need to log in before you can comment on or make changes to this bug.