Skip to content
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

python -m pyrepl.completing_reader fails #38

Open
blueyed opened this issue Apr 11, 2021 · 0 comments
Open

python -m pyrepl.completing_reader fails #38

blueyed opened this issue Apr 11, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@blueyed
Copy link
Collaborator

blueyed commented Apr 11, 2021

Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "…/src/pyrepl/pyrepl/completing_reader.py", line 286, in <module>
    test()
  File "…/src/pyrepl/pyrepl/completing_reader.py", line 276, in test
    reader = TestReader()
TypeError: __init__() missing 1 required positional argument: 'console'

The following patch fixes it (based on

def test():
from pyrepl.unix_console import UnixConsole
reader = HistoricalReader(UnixConsole())
):

diff --git i/pyrepl/completing_reader.py w/pyrepl/completing_reader.py
index 6039688..1e456cc 100644
--- i/pyrepl/completing_reader.py
+++ w/pyrepl/completing_reader.py
@@ -265,13 +265,15 @@ def get_completions(self, stem):
 
 
 def test():
+    from pyrepl.unix_console import UnixConsole
+
     class TestReader(CompletingReader):
         def get_completions(self, stem):
             return [s for l in self.history
                     for s in l.split()
                     if s and s.startswith(stem)]
 
-    reader = TestReader()
+    reader = TestReader(UnixConsole())
     reader.ps1 = "c**> "
     reader.ps2 = "c/*> "
     reader.ps3 = "c|*> "

But then using e.g. Up crashes:

% python -m pyrepl.completing_reader
c**> Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "…/src/pyrepl/pyrepl/completing_reader.py", line 286, in <module>
    test()
  File "…/src/pyrepl/pyrepl/completing_reader.py", line 281, in test
    while reader.readline():
  File "…/src/pyrepl/pyrepl/reader.py", line 605, in readline
    self.handle1()
  File "…/src/pyrepl/pyrepl/reader.py", line 588, in handle1
    self.do_cmd(cmd)
  File "…/src/pyrepl/pyrepl/reader.py", line 535, in do_cmd
    cmd.do()
  File "…/src/pyrepl/pyrepl/commands.py", line 210, in do
    if r.historyi > 0:
AttributeError: 'TestReader' object has no attribute 'historyi'

Not sure how useful (the test/__main__ in) completing_reader.py is in the end though..

@blueyed blueyed added the bug Something isn't working label Apr 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant