#NEWLINE# def _matchingString( constantString , inputString ) : #NEWLINE# #INDENT# '\n    Some functions, such as C{os.path.join}, operate on string arguments which\n    may be bytes or text, and wish to return a value of the same type.  In\n    those cases you may wish to have a string constant (in the case of\n    C{os.path.join}, that constant would be C{os.path.sep}) involved in the\n    parsing or processing, that must be of a matching type in order to use\n    string operations on it.  L{_matchingString} will take a constant string\n    (either L{bytes} or L{unicode}) and convert it to the same type as the\n    input string.  C{constantString} should contain only characters from ASCII;\n    to ensure this, it will be encoded or decoded regardless.\n\n    @param constantString: A string literal used in processing.\n    @type constantString: L{unicode} or L{bytes}\n\n    @param inputString: A byte string or text string provided by the user.\n    @type inputString: L{unicode} or L{bytes}\n\n    @return: C{constantString} converted into the same type as C{inputString}\n    @rtype: the type of C{inputString}\n    ' #NEWLINE# if isinstance ( constantString , bytes ) : #NEWLINE# #INDENT# otherType = constantString . decode ( 'ascii' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# otherType = constantString . encode ( 'ascii' ) #NEWLINE# #UNINDENT# if ( type ( constantString ) == type ( inputString ) ) : #NEWLINE# #INDENT# return constantString #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return otherType