Skip to content

Commit

Permalink
Merge pull request #55472 from s0undt3ch/features/pytest-staged-9
Browse files Browse the repository at this point in the history
[PyTest #9] Py2/Py3 Unicode Fixes
  • Loading branch information
dwoz authored Dec 1, 2019
2 parents a74bcc3 + a79b624 commit f988077
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 3 additions & 1 deletion salt/modules/cp.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,8 @@ def get_url(path, dest='', saltenv='base', makedirs=False, source_hash=None):
log.error('Unable to fetch file %s from saltenv %s.',
salt.utils.url.redact_http_basic_auth(path),
saltenv)
if result:
return salt.utils.stringutils.to_unicode(result)
return result


Expand All @@ -443,7 +445,7 @@ def get_file_str(path, saltenv='base'):
if isinstance(fn_, six.string_types):
try:
with salt.utils.files.fopen(fn_, 'r') as fp_:
return fp_.read()
return salt.utils.stringutils.to_unicode(fp_.read())
except IOError:
return False
return fn_
Expand Down
12 changes: 7 additions & 5 deletions salt/transport/ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import sys
import errno
import logging
import socket
Expand Down Expand Up @@ -341,10 +342,6 @@ def _connect(self, timeout=None):
def __del__(self):
try:
self.close()
except socket.error as exc:
if exc.errno != errno.EBADF:
# If its not a bad file descriptor error, raise
raise
except TypeError:
# This is raised when Python's GC has collected objects which
# would be needed when calling self.close()
Expand All @@ -364,7 +361,12 @@ def close(self):
log.debug('Closing %s instance', self.__class__.__name__)

if self.stream is not None and not self.stream.closed():
self.stream.close()
try:
self.stream.close()
except socket.error as exc:
if exc.errno != errno.EBADF:
# If its not a bad file descriptor error, raise
six.reraise(*sys.exc_info())


class IPCMessageClient(IPCClient):
Expand Down

0 comments on commit f988077

Please sign in to comment.