bug 411099: chdir() isn't saving the cwd in a normalized way. added test.
This commit is contained in:
parent
7da1f2c4a3
commit
931f71e627
|
@ -503,7 +503,8 @@ class SFTPClient (BaseSFTP):
|
||||||
doesn't really have the concept of a current working directory, this
|
doesn't really have the concept of a current working directory, this
|
||||||
is emulated by paramiko. Once you use this method to set a working
|
is emulated by paramiko. Once you use this method to set a working
|
||||||
directory, all operations on this SFTPClient object will be relative
|
directory, all operations on this SFTPClient object will be relative
|
||||||
to that path.
|
to that path. You can pass in C{None} to stop using a current working
|
||||||
|
directory.
|
||||||
|
|
||||||
@param path: new current working directory
|
@param path: new current working directory
|
||||||
@type path: str
|
@type path: str
|
||||||
|
@ -512,9 +513,12 @@ class SFTPClient (BaseSFTP):
|
||||||
|
|
||||||
@since: 1.4
|
@since: 1.4
|
||||||
"""
|
"""
|
||||||
|
if path is None:
|
||||||
|
self._cwd = None
|
||||||
|
return
|
||||||
if not stat.S_ISDIR(self.stat(path).st_mode):
|
if not stat.S_ISDIR(self.stat(path).st_mode):
|
||||||
raise SFTPError(errno.ENOTDIR, "%s: %s" % (os.strerror(errno.ENOTDIR), path))
|
raise SFTPError(errno.ENOTDIR, "%s: %s" % (os.strerror(errno.ENOTDIR), path))
|
||||||
self._cwd = self.normalize(path)
|
self._cwd = self.normalize(path).encode('utf-8')
|
||||||
|
|
||||||
def getcwd(self):
|
def getcwd(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -637,7 +637,19 @@ class SFTPTest (unittest.TestCase):
|
||||||
self.fail('exception ' + e)
|
self.fail('exception ' + e)
|
||||||
sftp.unlink(FOLDER + '/\xc3\xbcnic\xc3\xb8\x64\x65')
|
sftp.unlink(FOLDER + '/\xc3\xbcnic\xc3\xb8\x64\x65')
|
||||||
|
|
||||||
def test_L_bad_readv(self):
|
def test_L_utf8_chdir(self):
|
||||||
|
sftp.mkdir(FOLDER + u'\u00fcnic\u00f8de')
|
||||||
|
try:
|
||||||
|
sftp.chdir(FOLDER + u'\u00fcnic\u00f8de')
|
||||||
|
f = sftp.open('something', 'w')
|
||||||
|
f.write('okay')
|
||||||
|
f.close()
|
||||||
|
sftp.unlink('something')
|
||||||
|
finally:
|
||||||
|
sftp.chdir(None)
|
||||||
|
sftp.rmdir(FOLDER + u'\u00fcnic\u00f8de')
|
||||||
|
|
||||||
|
def test_M_bad_readv(self):
|
||||||
"""
|
"""
|
||||||
verify that readv at the end of the file doesn't essplode.
|
verify that readv at the end of the file doesn't essplode.
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue