Skip to content

Commit 92a536d

Browse files
committed
f
1 parent 2f285a2 commit 92a536d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/runtime/long.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,15 @@ extern "C" PyObject* PyLong_FromString(const char* str, char** pend, int base) n
220220
if (i >= 0 && i <= 9)
221221
valid_chars.push_back('0' + i);
222222
if (i >= 10) {
223-
valid_chars.push_back('a' + i);
224-
valid_chars.push_back('A' + i);
223+
valid_chars.push_back('a' + i - 10);
224+
valid_chars.push_back('A' + i - 10);
225225
}
226226
}
227227

228-
auto last = llvm::StringRef(str).find_first_not_of(valid_chars);
229-
std::string without_invalid(str);
230-
without_invalid.erase(last, without_invalid.npos);
228+
llvm::StringRef str_ref = str;
229+
str_ref = str_ref.substr(0, str_ref.find_first_not_of(valid_chars));
230+
231+
std::string without_invalid = str_ref.str();
231232

232233
r = mpz_init_set_str(rtn->n, without_invalid.c_str(), base);
233234

0 commit comments

Comments
 (0)