gh-117174: Add a new route in linecache to fetch interactive source code (#117500)

This commit is contained in:
Pablo Galindo Salgado 2025-03-10 21:54:05 +00:00 committed by GitHub
parent ecdf6b15b0
commit a931a8b324
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 142 additions and 93 deletions

View file

@ -24,6 +24,7 @@ import _colorize # type: ignore[import-not-found]
from abc import ABC, abstractmethod
import ast
import code
import linecache
from dataclasses import dataclass, field
import os.path
import sys
@ -205,6 +206,7 @@ class InteractiveColoredConsole(code.InteractiveConsole):
item = wrapper([stmt])
try:
code = self.compile.compiler(item, filename, the_symbol)
linecache._register_code(code, source, filename)
except SyntaxError as e:
if e.args[0] == "'await' outside function":
python = os.path.basename(sys.executable)