~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Aaron Bentley
  • Date: 2006-10-25 15:07:21 UTC
  • mfrom: (2095 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2098.
  • Revision ID: abentley@panoramicfeedback.com-20061025150721-71290b10eff4e691
Merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
228
228
# choke on a Unicode string containing a relative path if
229
229
# os.getcwd() returns a non-sys.getdefaultencoding()-encoded
230
230
# string.
231
 
_fs_enc = sys.getfilesystemencoding()
 
231
_fs_enc = sys.getfilesystemencoding() or 'utf-8'
232
232
def _posix_abspath(path):
233
233
    # jam 20060426 rather than encoding to fsencoding
234
234
    # copy posixpath.abspath, but use os.getcwdu instead
1090
1090
    if _cached_user_encoding is None:
1091
1091
        _cached_user_encoding = 'ascii'
1092
1092
    return _cached_user_encoding
 
1093
 
 
1094
 
 
1095
def recv_all(socket, bytes):
 
1096
    """Receive an exact number of bytes.
 
1097
 
 
1098
    Regular Socket.recv() may return less than the requested number of bytes,
 
1099
    dependning on what's in the OS buffer.  MSG_WAITALL is not available
 
1100
    on all platforms, but this should work everywhere.  This will return
 
1101
    less than the requested amount if the remote end closes.
 
1102
 
 
1103
    This isn't optimized and is intended mostly for use in testing.
 
1104
    """
 
1105
    b = ''
 
1106
    while len(b) < bytes:
 
1107
        new = socket.recv(bytes - len(b))
 
1108
        if new == '':
 
1109
            break # eof
 
1110
        b += new
 
1111
    return b
 
1112