Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment: You can validate the input before using it.
if '_' in s: raise ValueError or if not re.fullmatch('[0-9]+', s): raise ValueError Do you want to accept "۱۲۳۴" or " 12 "? If not then validate the input before using int(). Also, do not use ast.literal_eval() with untrusted input without validation. It is not a "safe eval" and may even crash the interpreter. ---------- nosy: +serhiy.storchaka _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue39956> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com