~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Mark Hammond
  • Date: 2008-08-16 04:00:54 UTC
  • mto: This revision was merged to the branch mainline in revision 3686.
  • Revision ID: mhammond@skippinet.com.au-20080816040054-7ptlmd3zbmxf9yig
Add osutils.get_host_name() to return a unicode hostname to prevent
non-ascii host names from causing Unicode error.  Fixes bzr/+bug/256550

Show diffs side-by-side

added added

removed removed

Lines of Context:
1449
1449
    return user_encoding
1450
1450
 
1451
1451
 
 
1452
def get_host_name():
 
1453
    """Return the current unicode host name"""
 
1454
    if sys.platform == "win32":
 
1455
        import win32utils
 
1456
        return win32utils.get_host_name()
 
1457
    else:
 
1458
        import socket
 
1459
        return socket.gethostname().decode(get_user_encoding())
 
1460
 
 
1461
 
1452
1462
def recv_all(socket, bytes):
1453
1463
    """Receive an exact number of bytes.
1454
1464