Skip to content

Commit

Permalink
Scope the libedit hack to PEX scies.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirois committed Aug 11, 2024
1 parent 0249f99 commit cf1bef3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
9 changes: 5 additions & 4 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

## 2.16.1

This release fixes the PEX repl for Pythons that use some versions of
libedit to support readline functionality. For those versions, ansi
terminal escape sequences for prompt colorization were not working.
This release fixes the PEX repl for [Python Standalone Builds][PBS]
CPython PEX scies. These PEXes ship using a version of libedit for
readline support that does not support naive use of ansi terminal
escape sequences for prompt colorization.

* Fix PEX repl prompt for libedit. (#2503)
* Fix PEX repl prompt for PBS libedit. (#2503)

## 2.16.0

Expand Down
3 changes: 2 additions & 1 deletion pex/repl/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def repl_loop(
custom_commands=None, # type: Optional[Mapping[str, Tuple[Callable, str]]]
history=False, # type: bool
history_file=None, # type: Optional[str]
use_libedit_color_prompt_workaround=False, # type: bool
):
# type: (...) -> Callable[[], Dict[str, Any]]

Expand Down Expand Up @@ -123,7 +124,7 @@ def fixup_ansi(

if not sys.stdout.isatty():
text = _ANSI_RE.sub("", text)
elif prompt and libedit:
elif prompt and libedit and use_libedit_color_prompt_workaround:
# Most versions of libedit do not support ansi terminal escape sequences, but they do
# support a readline back door where you can bracket characters that should be ignored
# for prompt width calculation but otherwise passed through unaltered to the terminal.
Expand Down
3 changes: 3 additions & 0 deletions pex/repl/pex_repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ def pex(json=False):
},
history=history,
history_file=history_file,
# The PBS CPythons used by PEX scies use a version of libedit that needs workarounds to
# support color prompts.
use_libedit_color_prompt_workaround=os.environ.get("SCIE") is not None,
)


Expand Down

0 comments on commit cf1bef3

Please sign in to comment.