MCPcopy Index your code
hub / github.com/python/cpython / _is_local_authority

Function _is_local_authority

Lib/urllib/request.py:1487–1505  ·  view source on GitHub ↗
(authority, resolve)

Source from the content-addressed store, hash-verified

1485 file_open = open_local_file
1486
1487def _is_local_authority(authority, resolve):
1488 # Compare hostnames
1489 if not authority or authority == 'localhost':
1490 return True
1491 try:
1492 hostname = socket.gethostname()
1493 except (socket.gaierror, AttributeError):
1494 pass
1495 else:
1496 if authority == hostname:
1497 return True
1498 # Compare IP addresses
1499 if not resolve:
1500 return False
1501 try:
1502 address = socket.gethostbyname(authority)
1503 except (socket.gaierror, AttributeError, UnicodeEncodeError):
1504 return False
1505 return address in FileHandler().get_names()
1506
1507class FTPHandler(BaseHandler):
1508 def ftp_open(self, req):

Callers 1

url2pathnameFunction · 0.85

Calls 2

FileHandlerClass · 0.70
get_namesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…