Comments (10)
Maybe add a site._CAN_USE_PYREPL
constant and modify _pyrepl/__main__.py
to set site._CAN_USE_PYREPL
?
from cpython.
I can do this if it's ok
from cpython.
@danielhollas I worked with @lysnikolaou during PyCon sprints on this one, we came to the same conclusion but he said this is not the best practice to export the env variable to the system. He said he will take a deeper look as to why this might be happening
from cpython.
I proposed PR gh-119269 to fix this issue.
from cpython.
Looks like the write_history
callback is registered in site.py
here:
Line 525 in 65de194
def write_history():
try:
if os.getenv("PYTHON_BASIC_REPL"):
readline.write_history_file(history)
else:
_pyrepl.readline.write_history_file(history)
except (FileNotFoundError, PermissionError):
# home directory does not exist or is not writable
# https://bugs.python.org/issue19891
pass
It clearly needs to get more clever to detect whether pyrepl is actually in use.
Maybe it can just look at the _pyrepl.__main__.CAN_USE_PYREPL
global.
from cpython.
@danielhollas CAN_USE_PYREPL
just checks whether we're on a Windows system, so I wouldn't think checking that would help in this case.
Maybe: We set PYTHON_BASIC_REPL to true if TERM is set to "dumb"?
from cpython.
@eugenetriguba if you look at the _pyrepl/__main__.py
, CAN_USE_PYREPL
is indeed checking for windows at import, but then later it is set to False if for any reason the new repl cannot be used, on line 41.
I tried to fix this by checking CAN_USE_PYREPL in the write_history
callback function but couldn't make it work -- accessing CAN_USE_PYREPL from __main__
module seems to be cursed, and moving it to __init__
did not help.
from cpython.
Maybe: We set PYTHON_BASIC_REPL to true if TERM is set to "dumb"?
The following patch indeed fixes the issue, happy to make a PR if this seems like a right approach
diff --git a/Lib/_pyrepl/__main__.py b/Lib/_pyrepl/__main__.py
index c598019e7c..40cdd6d9fe 100644
--- a/Lib/_pyrepl/__main__.py
+++ b/Lib/_pyrepl/__main__.py
@@ -39,6 +39,7 @@ def interactive_console(mainmodule=None, quiet=False, pythonstartup=False):
trace(msg)
print(msg, file=sys.stderr)
CAN_USE_PYREPL = False
+ os.environ["PYTHON_BASIC_REPL"] = "true"
if run_interactive is None:
return sys._baserepl()
return run_interactive(mainmodule)
from cpython.
Leaving this open since #119269 did not fix the problem.
from cpython.
Please check my second fix: PR gh-119332.
from cpython.
Related Issues (20)
- PySequence_Fast needs new macros to be safe in a nogil world HOT 3
- Import `_ios_support` raises RuntimeError on Windows
- pyrepl: Cursor behaviour during tab-completion HOT 1
- Tier 2 Optimizer Eliminate Type Version Guards
- is_dataclass() returns True for non-dataclass subclass of dataclass HOT 5
- test_ioctl is skipped because of setsid()
- Update type checking conditions in new repl module
- `contextlib.suppress` converts instances of a subtype of `ExceptionGroup` to an instance of the `ExceptionGroup` class HOT 2
- Add job to `jit.yml` to build and test with `--disable-gil`
- Incompatibility between _decimal and _pydecimal: tp_name for Decimal
- Python float calculation error HOT 2
- IDLE: Menu fonts too small HOT 1
- `get_origin(str|None) != get_origin(Union[str,None])` HOT 4
- Break up _pyrepl tests HOT 1
- '\040' instead of space in repl history on macOS with 3.13 or main branch HOT 2
- Unexpected name mangling behavior with generics HOT 1
- Resolve deprecation warnings in Docs/tools HOT 1
- REPL cursor is rendered offset in VSCode on WSL HOT 1
- Add c-api to set callback function on enter and exit of PyContext
- '_PyLong_NumBits': identifier not found in 3.13 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cpython.