Skip to content

Commit 72b85c4

Browse files
committed
Fix Python 3 "TypeError: decoding str is not supported" in FtpUrl.cwd
1 parent 68550f6 commit 72b85c4

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

linkcheck/checker/ftpurl.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
# Python 3
2626
from io import StringIO
2727

28+
from builtins import bytes
29+
2830
from .. import log, LOG_CHECK, LinkCheckerError, mimeutil
2931
from . import proxysupport, httpurl, internpaturl, get_index_html
3032
from .const import WARN_FTP_MISSING_SLASH
@@ -116,7 +118,9 @@ def cwd (self):
116118
Change to URL parent directory. Return filename of last path
117119
component.
118120
"""
119-
path = self.urlparts[2].encode(self.filename_encoding, 'replace')
121+
path = self.urlparts[2]
122+
if isinstance(path, bytes):
123+
path = path.decode(self.filename_encoding, 'replace')
120124
dirname = path.strip('/')
121125
dirs = dirname.split('/')
122126
filename = dirs.pop()

0 commit comments

Comments
 (0)