mirror of
https://github.com/python/cpython.git
synced 2025-09-05 00:11:10 +00:00
gh-102567: Add -X importtime=2 for logging an importtime message for already-loaded modules (#118655)
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
This commit is contained in:
parent
e6f8e0a035
commit
c4bcc6a778
15 changed files with 166 additions and 44 deletions
|
@ -29,6 +29,7 @@ import signal
|
|||
import struct
|
||||
import termios
|
||||
import time
|
||||
import types
|
||||
import platform
|
||||
from fcntl import ioctl
|
||||
|
||||
|
@ -39,6 +40,12 @@ from .trace import trace
|
|||
from .unix_eventqueue import EventQueue
|
||||
from .utils import wlen
|
||||
|
||||
# declare posix optional to allow None assignment on other platforms
|
||||
posix: types.ModuleType | None
|
||||
try:
|
||||
import posix
|
||||
except ImportError:
|
||||
posix = None
|
||||
|
||||
TYPE_CHECKING = False
|
||||
|
||||
|
@ -556,11 +563,9 @@ class UnixConsole(Console):
|
|||
|
||||
@property
|
||||
def input_hook(self):
|
||||
try:
|
||||
import posix
|
||||
except ImportError:
|
||||
return None
|
||||
if posix._is_inputhook_installed():
|
||||
# avoid inline imports here so the repl doesn't get flooded
|
||||
# with import logging from -X importtime=2
|
||||
if posix is not None and posix._is_inputhook_installed():
|
||||
return posix._inputhook
|
||||
|
||||
def __enable_bracketed_paste(self) -> None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue