Revision 8ad0da1e lib/netutils.py

b/lib/netutils.py
1 1
#
2 2
#
3 3

  
4
# Copyright (C) 2010 Google Inc.
4
# Copyright (C) 2010, 2011, 2012 Google Inc.
5 5
#
6 6
# This program is free software; you can redistribute it and/or modify
7 7
# it under the terms of the GNU General Public License as published by
......
280 280
  if source is not None:
281 281
    try:
282 282
      sock.bind((source, 0))
283
    except socket.error, (errcode, _):
284
      if errcode == errno.EADDRNOTAVAIL:
283
    except socket.error, err:
284
      if err[0] == errno.EADDRNOTAVAIL:
285 285
        success = False
286 286

  
287 287
  sock.settimeout(timeout)
......
292 292
    success = True
293 293
  except socket.timeout:
294 294
    success = False
295
  except socket.error, (errcode, _):
296
    success = (not live_port_needed) and (errcode == errno.ECONNREFUSED)
295
  except socket.error, err:
296
    success = (not live_port_needed) and (err[0] == errno.ECONNREFUSED)
297 297

  
298 298
  return success
299 299

  

Also available in: Unified diff