mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-12-22 16:57:40 +00:00
[utils] handle int values passed to str_to_int
This commit is contained in:
parent
b568561eba
commit
348c6bf1c1
2 changed files with 3 additions and 2 deletions
|
@ -499,6 +499,7 @@ class TestUtil(unittest.TestCase):
|
||||||
def test_str_to_int(self):
|
def test_str_to_int(self):
|
||||||
self.assertEqual(str_to_int('123,456'), 123456)
|
self.assertEqual(str_to_int('123,456'), 123456)
|
||||||
self.assertEqual(str_to_int('123.456'), 123456)
|
self.assertEqual(str_to_int('123.456'), 123456)
|
||||||
|
self.assertEqual(str_to_int(523), 523)
|
||||||
|
|
||||||
def test_url_basename(self):
|
def test_url_basename(self):
|
||||||
self.assertEqual(url_basename('http://foo.de/'), '')
|
self.assertEqual(url_basename('http://foo.de/'), '')
|
||||||
|
|
|
@ -3519,8 +3519,8 @@ def str_or_none(v, default=None):
|
||||||
|
|
||||||
def str_to_int(int_str):
|
def str_to_int(int_str):
|
||||||
""" A more relaxed version of int_or_none """
|
""" A more relaxed version of int_or_none """
|
||||||
if int_str is None:
|
if not isinstance(int_str, compat_str):
|
||||||
return None
|
return int_str
|
||||||
int_str = re.sub(r'[,\.\+]', '', int_str)
|
int_str = re.sub(r'[,\.\+]', '', int_str)
|
||||||
return int(int_str)
|
return int(int_str)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue