mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-10-31 14:45:14 +00:00 
			
		
		
		
	[jsinterp] Cache undefined variable names (#13639)
Authored by: bashonly
This commit is contained in:
		| @@ -279,6 +279,7 @@ class JSInterpreter: | |||||||
|     def __init__(self, code, objects=None): |     def __init__(self, code, objects=None): | ||||||
|         self.code, self._functions = code, {} |         self.code, self._functions = code, {} | ||||||
|         self._objects = {} if objects is None else objects |         self._objects = {} if objects is None else objects | ||||||
|  |         self._undefined_varnames = set() | ||||||
| 
 | 
 | ||||||
|     class Exception(ExtractorError):  # noqa: A001 |     class Exception(ExtractorError):  # noqa: A001 | ||||||
|         def __init__(self, msg, expr=None, *args, **kwargs): |         def __init__(self, msg, expr=None, *args, **kwargs): | ||||||
| @@ -677,6 +678,8 @@ class JSInterpreter: | |||||||
|                 local_vars.set_local(var, ret) |                 local_vars.set_local(var, ret) | ||||||
|             else: |             else: | ||||||
|                 ret = local_vars.get(var, JS_Undefined) |                 ret = local_vars.get(var, JS_Undefined) | ||||||
|  |                 if ret is JS_Undefined: | ||||||
|  |                     self._undefined_varnames.add(var) | ||||||
|             return ret, should_return |             return ret, should_return | ||||||
| 
 | 
 | ||||||
|         with contextlib.suppress(ValueError): |         with contextlib.suppress(ValueError): | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 bashonly
					bashonly