def isprintable(instring):
    #http://stackoverflow.com/a/3637294
    import string
    printset = set(string.printable)
    isprintable = set(instring).issubset(printset)
    return isprintable

def count_newlines_from_end(str):
    i = len(str)
    while i > 0:
        if str[i-1] != '\n':
            break
        i -= 1
    return len(str) - i


def isprintable(instring):
    if isinstance(instring, str):
        #http://stackoverflow.com/a/3637294
        import string
        printset = set(string.printable)
        isprintable = set(instring).issubset(printset)
        return isprintable
    else:
        return True

def count_newlines_from_end(str):
    i = len(str)
    while i > 0:
        if str[i-1] != '\n':
            break
        i -= 1
    return len(str) - i


Allow isprintable() util function to work with unicode
Allow isprintable() util function to work with unicode

Fixes #6842

  def isprintable(instring):
+     if isinstance(instring, str):
-     #http://stackoverflow.com/a/3637294
+         #http://stackoverflow.com/a/3637294
-     import string
+         import string
-     printset = set(string.printable)
+         printset = set(string.printable)
-     isprintable = set(instring).issubset(printset)
+         isprintable = set(instring).issubset(printset)
-     return isprintable
+         return isprintable
+     else:
+         return True
  
  def count_newlines_from_end(str):
      i = len(str)
      while i > 0:
          if str[i-1] != '\n':
              break
          i -= 1
      return len(str) - i
  
  
Allow isprintable() util function to work with unicode
## Code Before:
def isprintable(instring):
    #http://stackoverflow.com/a/3637294
    import string
    printset = set(string.printable)
    isprintable = set(instring).issubset(printset)
    return isprintable

def count_newlines_from_end(str):
    i = len(str)
    while i > 0:
        if str[i-1] != '\n':
            break
        i -= 1
    return len(str) - i


## Instruction:
Allow isprintable() util function to work with unicode
## Code After:
def isprintable(instring):
    if isinstance(instring, str):
        #http://stackoverflow.com/a/3637294
        import string
        printset = set(string.printable)
        isprintable = set(instring).issubset(printset)
        return isprintable
    else:
        return True

def count_newlines_from_end(str):
    i = len(str)
    while i > 0:
        if str[i-1] != '\n':
            break
        i -= 1
    return len(str) - i

