#๐Ÿ”’ pyreadline3 `module 'readline' has no attribute 'backend'`

9 messages ยท Page 1 of 1 (latest)

shut umbra
#

I'm trying to build a basic cmd-based command interpreter, and to that end I'm trying to get something to the effect of readline on windows (for autocomplete reasons), which is apparently difficult. Fair enough. I did some research and everyone seems to say to pip install pyreadline3, so I did that. And then proceeded to find out that doing so causes the readline.backend attribute to not exist, which causes Cmd.cmdloop to raise an error.

I'm mostly confused as to why pyreadline3 seems to not have this attribute. The builtin repl complains about readline.backend being missing, this can't have been an issue nobody noticed. Why is this problem a thing? And also, why does utterly nobody online seem to mention that it exists?

I'm currently monkeypatching the attribute in via

import readline
readline.backend = "readline"
```which _works_, but it also seems extremely evil and doesn't make me feel I understand why this is an issue in the first place
willow valleyBOT
#

@shut umbra

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

languid walrus
#
GitHub

This may be a bug with cpython, rather than pyreadline3. See a related issue for cpython here: python/cpython#125154 Python 3.13 introduced a new REPL, so it may not be surprising that pyreadline3 ...

GitHub

Using this library introduces an error into anything that tries to access the "backend" attribute of Readline. This is included here in the standard library version of Readline, but not i...

shut umbra
#

So basically, they forgot to add it and right now I just have to monkeypatch it in?

languid walrus
#

maybe fork and make a PR instead
or just don't use 3.13

red pivot
shut umbra
willow valleyBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.