Skip to content

Commit

Permalink
[utils] handle int values passed to str_to_int
Browse files Browse the repository at this point in the history
  • Loading branch information
remitamine committed Nov 29, 2019
1 parent b568561 commit 348c6bf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ def test_int_or_none(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(523), 523)

def test_url_basename(self):
self.assertEqual(url_basename('http://foo.de/'), '')
Expand Down
4 changes: 2 additions & 2 deletions youtube_dl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3519,8 +3519,8 @@ def str_or_none(v, default=None):

def str_to_int(int_str):
""" A more relaxed version of int_or_none """
if int_str is None:
return None
if not isinstance(int_str, compat_str):
return int_str
int_str = re.sub(r'[,\.\+]', '', int_str)
return int(int_str)

Expand Down

0 comments on commit 348c6bf

Please sign in to comment.