
def safe_unicode(obj, *args):
    """ return the unicode representation of obj """
    try:
        return unicode(obj, *args)  # pylint:disable=undefined-variable
    except UnicodeDecodeError:
        # obj is byte string
        ascii_text = str(obj).encode('string_escape')
        return unicode(ascii_text)  # pylint:disable=undefined-variable

def safe_str(obj):
    """ return the byte string representation of obj """
    try:
        return str(obj)
    except UnicodeEncodeError:
        # obj is unicode
        return unicode(obj).encode('unicode_escape')  # pylint:disable=undefined-variable


def safe_unicode(obj, *args):
    """ return the unicode representation of obj """
    try:
        return unicode(obj, *args)  # noqa for undefined-variable
    except UnicodeDecodeError:
        # obj is byte string
        ascii_text = str(obj).encode('string_escape')
        return unicode(ascii_text)  # noqa for undefined-variable

def safe_str(obj):
    """ return the byte string representation of obj """
    try:
        return str(obj)
    except UnicodeEncodeError:
        # obj is unicode
        return unicode(obj).encode('unicode_escape')  # noqa for undefined-variable

Disable error-checking that assumes Python 3 for these Python 2 helpers, landscape.io style
Disable error-checking that assumes Python 3 for these Python 2 helpers,
landscape.io style

  
  def safe_unicode(obj, *args):
      """ return the unicode representation of obj """
      try:
-         return unicode(obj, *args)  # pylint:disable=undefined-variable
+         return unicode(obj, *args)  # noqa for undefined-variable
      except UnicodeDecodeError:
          # obj is byte string
          ascii_text = str(obj).encode('string_escape')
-         return unicode(ascii_text)  # pylint:disable=undefined-variable
+         return unicode(ascii_text)  # noqa for undefined-variable
  
  def safe_str(obj):
      """ return the byte string representation of obj """
      try:
          return str(obj)
      except UnicodeEncodeError:
          # obj is unicode
-         return unicode(obj).encode('unicode_escape')  # pylint:disable=undefined-variable
+         return unicode(obj).encode('unicode_escape')  # noqa for undefined-variable
  
Disable error-checking that assumes Python 3 for these Python 2 helpers, landscape.io style
## Code Before:

def safe_unicode(obj, *args):
    """ return the unicode representation of obj """
    try:
        return unicode(obj, *args)  # pylint:disable=undefined-variable
    except UnicodeDecodeError:
        # obj is byte string
        ascii_text = str(obj).encode('string_escape')
        return unicode(ascii_text)  # pylint:disable=undefined-variable

def safe_str(obj):
    """ return the byte string representation of obj """
    try:
        return str(obj)
    except UnicodeEncodeError:
        # obj is unicode
        return unicode(obj).encode('unicode_escape')  # pylint:disable=undefined-variable

## Instruction:
Disable error-checking that assumes Python 3 for these Python 2 helpers, landscape.io style
## Code After:

def safe_unicode(obj, *args):
    """ return the unicode representation of obj """
    try:
        return unicode(obj, *args)  # noqa for undefined-variable
    except UnicodeDecodeError:
        # obj is byte string
        ascii_text = str(obj).encode('string_escape')
        return unicode(ascii_text)  # noqa for undefined-variable

def safe_str(obj):
    """ return the byte string representation of obj """
    try:
        return str(obj)
    except UnicodeEncodeError:
        # obj is unicode
        return unicode(obj).encode('unicode_escape')  # noqa for undefined-variable
