def visit_Str(self, n: ast27.Str) -> Expression: # Note: typed_ast.ast27 will handled unicode_literals for us. If # n.s is of type 'bytes', we know unicode_literals was not enabled; # otherwise we know it was. # # Note that the following code is NOT run when parsing Python 2.7 stubs: # we always parse stub files (no matter what version) using the Python 3 # parser. This is also why string literals in Python 2.7 stubs are assumed # to be unicode. if isinstance(n.s, bytes): contents = bytes_to_human_readable_repr(n.s) e = StrExpr(contents, from_python_3=False) # type: Union[StrExpr, UnicodeExpr] return self.set_line(e, n) else: e = UnicodeExpr(n.s) return self.set_line(e, n)