[downloader/http] Simplify
[youtube-dl] / youtube_dl / jsinterp.py
index 49364786bd17c0d1c55d9094c6d0795d2b2f5224..0e0c7d90d5aa2fbb8039dddf642ac4692f2974a7 100644 (file)
@@ -17,7 +17,7 @@ _OPERATORS = [
     ('-', operator.sub),
     ('+', operator.add),
     ('%', operator.mod),
-    ('/', operator.div),
+    ('/', operator.truediv),
     ('*', operator.mul),
 ]
 _ASSIGN_OPERATORS = [(op + '=', opfunc) for op, opfunc in _OPERATORS]
@@ -30,13 +30,10 @@ class JSInterpreter(object):
     def __init__(self, code, objects=None):
         if objects is None:
             objects = {}
-        self.code = self._remove_comments(code)
+        self.code = code
         self._functions = {}
         self._objects = objects
 
-    def _remove_comments(self, code):
-        return re.sub(r'(?s)/\*.*?\*/', '', code)
-
     def interpret_statement(self, stmt, local_vars, allow_recursion=100):
         if allow_recursion < 0:
             raise ExtractorError('Recursion limit reached')