Skip to content

gh-112730: Use color to highlight error locations #112732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make it work on windows
  • Loading branch information
pablogsal committed Dec 5, 2023
commit 7671e2dcbc4bea0a84c002a2734dbc358b7c8bbb
8 changes: 8 additions & 0 deletions Lib/traceback.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ def print_exception(exc, /, value=_sentinel, tb=_sentinel, limit=None, \
BUILTIN_EXCEPTION_LIMIT = object()

def _can_colorize():
if sys.platform == "win32":
try:
import nt
if not nt._supports_virtual_terminal():
return False
except (ImportError, AttributeError):
return False

if not _COLORIZE:
return False
if os.environ.get("PY_COLORS") == "1":
Expand Down
28 changes: 27 additions & 1 deletion Modules/clinic/posixmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -16073,6 +16073,26 @@ os_waitstatus_to_exitcode_impl(PyObject *module, PyObject *status_obj)
}
#endif

#if defined(MS_WINDOWS)
/*[clinic input]
os._supports_virtual_terminal

Checks if virtual terminal is supported in windows
[clinic start generated code]*/

static PyObject *
os__supports_virtual_terminal_impl(PyObject *module)
/*[clinic end generated code: output=bd0556a6d9d99fe6 input=0752c98e5d321542]*/
{
DWORD mode = 0;
HANDLE handle = GetStdHandle(STD_ERROR_HANDLE);
if (!GetConsoleMode(handle, &mode)) {
Py_RETURN_FALSE;
}
return PyBool_FromLong(mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING);
}
#endif


static PyMethodDef posix_methods[] = {

Expand Down Expand Up @@ -16277,6 +16297,8 @@ static PyMethodDef posix_methods[] = {
OS__PATH_ISFILE_METHODDEF
OS__PATH_ISLINK_METHODDEF
OS__PATH_EXISTS_METHODDEF

OS__SUPPORTS_VIRTUAL_TERMINAL_METHODDEF
{NULL, NULL} /* Sentinel */
};

Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy