mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
gh-117174: Add a new route in linecache to fetch interactive source code (#117500)
This commit is contained in:
parent
ecdf6b15b0
commit
a931a8b324
16 changed files with 142 additions and 93 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue