]> gitweb @ CieloNegro.org - youtube-dl.git/commitdiff
[utils] Drop trailing comma before closing brace
authorSergey M․ <dstftw@gmail.com>
Sat, 4 Apr 2015 11:48:55 +0000 (17:48 +0600)
committerSergey M․ <dstftw@gmail.com>
Sat, 4 Apr 2015 11:48:55 +0000 (17:48 +0600)
test/test_utils.py
youtube_dl/utils.py

index abaf1ab7331eab044c684b592bd5bfb85f4d39e0..4e524aca3b80ae5359403b7bda8d052be4f8955b 100644 (file)
@@ -470,6 +470,12 @@ class TestUtil(unittest.TestCase):
         self.assertEqual(d['x'], 1)
         self.assertEqual(d['y'], 'a')
 
+        on = js_to_json('["abc", "def",]')
+        self.assertEqual(json.loads(on), ['abc', 'def'])
+
+        on = js_to_json('{"abc": "def",}')
+        self.assertEqual(json.loads(on), {'abc': 'def'})
+
     def test_clean_html(self):
         self.assertEqual(clean_html('a:\nb'), 'a: b')
         self.assertEqual(clean_html('a:\n   "b"'), 'a:    "b"')
index 90e0ed9ab7eb36d4c9f30efffdd2868e9cfe6d47..e1761265c9fe1e02d2ad7989f05aa7f61b2e7832 100644 (file)
@@ -1577,7 +1577,7 @@ def js_to_json(code):
         '(?:[^'\\]*(?:\\\\|\\['"nu]))*[^'\\]*'|
         [a-zA-Z_][.a-zA-Z_0-9]*
         ''', fix_kv, code)
-    res = re.sub(r',(\s*\])', lambda m: m.group(1), res)
+    res = re.sub(r',(\s*[\]}])', lambda m: m.group(1), res)
     return res