[hdfs] Avoid potential log trace failure similarly to Resource
If one of the path truly can't be printed as is, better to sanitize it
so that the exception is properly raised instead of creating a different
failure.
@@ -47,8 +47,7 @@ from hadoop.fs.webhdfs_types import WebHdfsStat, WebHdfsContentSummary
from hadoop.hdfs_site import get_nn_sentry_prefixes, get_umask_mode, get_supergroup, get_webhdfs_ssl
if sys.version_info[0] > 2:
- from urllib.parse import unquote as urllib_quote
- from urllib.parse import urlparse
+ from urllib.parse import unquote as urllib_quote, urlparse
else:
from urllib import unquote as urllib_quote
from urlparse import urlparse
@@ -472,7 +471,7 @@ class WebHdfs(Hdfs):
headers = self._getheaders()
result = self._root.put(old, params, headers=headers)
if not result['boolean']:
- raise IOError(_("Rename failed: %s -> %s") % (smart_str(old), smart_str(new)))
+ raise IOError(_("Rename failed: %s -> %s") % (smart_str(old, errors='replace'), smart_str(new, errors='replace')))
def rename_star(self, old_dir, new_dir):
"""Equivalent to `mv old_dir/* new"""
