@@ -233,30 +233,33 @@ def __init__(self, filename):
233233 except EnvironmentError as e :
234234 log .warning ('Couldn\' t open %s: %s.' , self .filename , e )
235235 return
236- reader = csv .reader (fd )
237236 try :
238- lineno = 0
239- for t in reader :
240- lineno += 1
241- try :
242- channel = t .pop (0 )
243- id = t .pop (0 )
237+ reader = csv .reader (fd )
238+ try :
239+ lineno = 0
240+ for t in reader :
241+ lineno += 1
244242 try :
245- id = int (id )
246- except ValueError :
247- # We'll skip over this so, say, nicks can be kept here.
248- pass
249- channel = sys .intern (channel )
250- v = self .deserialize (channel , id , t )
251- self [channel , id ] = v
252- except Exception as e :
253- log .warning ('Invalid line #%s in %s.' ,
254- lineno , self .__class__ .__name__ )
255- log .debug ('Exception: %s' , utils .exnToString (e ))
256- except Exception as e : # This catches exceptions from csv.reader.
257- log .warning ('Invalid line #%s in %s.' ,
258- lineno , self .__class__ .__name__ )
259- log .debug ('Exception: %s' , utils .exnToString (e ))
243+ channel = t .pop (0 )
244+ id = t .pop (0 )
245+ try :
246+ id = int (id )
247+ except ValueError :
248+ # We'll skip over this so, say, nicks can be kept here.
249+ pass
250+ channel = sys .intern (channel )
251+ v = self .deserialize (channel , id , t )
252+ self [channel , id ] = v
253+ except Exception as e :
254+ log .warning ('Invalid line #%s in %s.' ,
255+ lineno , self .__class__ .__name__ )
256+ log .debug ('Exception: %s' , utils .exnToString (e ))
257+ except Exception as e : # This catches exceptions from csv.reader.
258+ log .warning ('Invalid line #%s in %s.' ,
259+ lineno , self .__class__ .__name__ )
260+ log .debug ('Exception: %s' , utils .exnToString (e ))
261+ finally :
262+ fd .close ()
260263
261264 def flush (self ):
262265 mode = 'wb' if utils .minisix .PY2 else 'w'
0 commit comments