code: def get_errno(exc):
      
      try:
          return exc.errno
      except AttributeError:
          try:
              # e.args = (errno, reason)
              if isinstance(exc.args, tuple) and len(exc.args) == 2:
                  return exc.args[0]
          except AttributeError:
              pass
      return 0
docs: :exc:`socket.error` and :exc:`IOError` first got
      the ``.errno`` attribute in Py2.7