Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

urllib.request.thishost() fails on OSX 10.7 #59339

Closed
ronaldoussoren opened this issue Jun 22, 2012 · 3 comments
Closed

urllib.request.thishost() fails on OSX 10.7 #59339

ronaldoussoren opened this issue Jun 22, 2012 · 3 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@ronaldoussoren
Copy link
Contributor

BPO 15134
Nosy @ronaldoussoren, @orsenthil

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2012-06-22.09:34:44.976>
labels = ['type-bug', 'library']
title = 'urllib.request.thishost() fails on OSX 10.7'
updated_at = <Date 2014-07-02.21:37:07.287>
user = 'https://github.com/ronaldoussoren'

bugs.python.org fields:

activity = <Date 2014-07-02.21:37:07.287>
actor = 'BreamoreBoy'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2012-06-22.09:34:44.976>
creator = 'ronaldoussoren'
dependencies = []
files = []
hgrepos = []
issue_num = 15134
keywords = []
message_count = 1.0
messages = ['163389']
nosy_count = 2.0
nosy_names = ['ronaldoussoren', 'orsenthil']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue15134'
versions = ['Python 3.4', 'Python 3.5']

@ronaldoussoren
Copy link
Contributor Author

I just noticed that test_urllib fails for me because urllib.request.thishost() fails:

======================================================================
ERROR: test_thishost (test.test_urllib.Utility_Tests)
Test the urllib.request.thishost utility function returns a tuple
----------------------------------------------------------------------

Traceback (most recent call last):
  File "/Users/ronald/Projects/python/rw/default/Lib/test/test_urllib.py", line 1155, in test_thishost
    self.assertIsInstance(urllib.request.thishost(), tuple)
  File "/Users/ronald/Projects/python/rw/default/Lib/urllib/request.py", line 2236, in thishost
    _thishost = tuple(socket.gethostbyname_ex(socket.gethostname())[2])
socket.gaierror: [Errno 8] nodename nor servname provided, or not known

This is because this host's hostname (Gondolin.local) is not in DNS because my mDNSReponder detected a conflict and picked a different name to advertise in the .local zone without updating the hostname.

The reason I report this anyway is that URLopener.open_local_file seems to assume that thishost() cannot fail, and the error condition on my machine could easily happen on other systems as well.

BTW. The use of this host() in URLopener.open_local_file is wrong for other reasons as well: it assumes that the local machine has exactly 1 IP address, and won't correctly detect that a file is local when the IP address is one of the other IP addresses on a multi homed system.

@ronaldoussoren ronaldoussoren added the stdlib Python modules in the Lib dir label Jun 22, 2012
@BreamoreBoy BreamoreBoy mannequin added the type-bug An unexpected behavior, bug, or error label Jul 2, 2014
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@kumaraditya303
Copy link
Contributor

@ronaldoussoren Is this still relevant or can this be closed?

@ronaldoussoren
Copy link
Contributor Author

I don't think this is still relevant, the implementation of thishost() now guards against errors during resolving.

@ronaldoussoren ronaldoussoren closed this as not planned Won't fix, can't repro, duplicate, stale Sep 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants