Explorar o código

HUE-9112 [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.
Romain %!s(int64=5) %!d(string=hai) anos
pai
achega
56b05cc00a
Modificáronse 1 ficheiros con 2 adicións e 3 borrados
  1. 2 3
      desktop/libs/hadoop/src/hadoop/fs/webhdfs.py

+ 2 - 3
desktop/libs/hadoop/src/hadoop/fs/webhdfs.py

@@ -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"""