[Jython-checkins] jython: FS-encode host names reported from os.uname() and platform.uname().

Alan Kennedy jython-dev at xhaus.com
Thu Jul 20 06:24:15 EDT 2017


[jeff.allen]
 @raises_java_exception
 def gethostname():
-    return str(InetAddress.getLocalHost().getHostName())
+    """Return FS-encoded local host name."""
+    return _fsencode(InetAddress.getLocalHost().getHostName())

[Alan]
This looks correct: cpython also returns the fsdecoded name.

https://github.com/python/cpython/blob/master/Modules/socketmodule.c#L4855

[jeff.allen]
 @raises_java_exception
 def gethostbyname(name):
-    return str(InetAddress.getByName(name).getHostAddress())
+    """Return IP address as string from FS-decoded host name."""
+    return str(InetAddress.getByName(_fsdecode(name)).getHostAddress())

[Alan]
I think that this should be decoded as IDNA (not file system encoding),
which is what cpython does.

https://github.com/python/cpython/blob/master/Modules/socketmodule.c#L4905

Alan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/jython-checkins/attachments/20170720/7afdf88d/attachment.html>


More information about the Jython-checkins mailing list