Commit 5ab1e199 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge branch 'strRepr' of https://github.com/xiafan68/pyston into github

Merges #88

Conflicts:
	src/core/threading.cpp
parents 71c310dd 1af19b2a
......@@ -237,10 +237,14 @@ extern "C" Box* strRepr(BoxedString* self) {
std::ostringstream os("");
const std::string& s = self->s;
os << '\'';
char quote = '\'';
if (s.find('\'', 0) != std::string::npos && s.find('\"', 0) == std::string::npos) {
quote = '\"';
}
os << quote;
for (int i = 0; i < s.size(); i++) {
char c = s[i];
if (!_needs_escaping[c & 0xff]) {
if ((c == '\'' && quote == '\"') || !_needs_escaping[c & 0xff]) {
os << c;
} else {
char special = 0;
......@@ -275,7 +279,7 @@ extern "C" Box* strRepr(BoxedString* self) {
}
}
}
os << '\'';
os << quote;
return boxString(os.str());
}
......
a=1
try:
a.b
except AttributeError, e:
print repr(e)
print repr("both\'\"quotes")
print repr("single\'quote")
print repr("double\"quote")
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment