question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

curses.has_key._capability_names missing on systems without native _curses.has_key

See original GitHub issue

I’ve downloaded Blessed 1.15.0 on the HP-UX-B.11.31-ia64-32bit build of Python 2.7.13. The following code generates the following traceback:

>>> from blessed import Terminal
>>> term = Terminal()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/self/.local/lib/python2.7/site-packages/blessed/terminal.py", line 229, in __init__
    self.__init__keycodes()
  File "/home/self/.local/lib/python2.7/site-packages/blessed/terminal.py", line 277, in __init__keycodes
    self._keymap = get_keyboard_sequences(self)
  File "/home/self/.local/lib/python2.7/site-packages/blessed/keyboard.py", line 174, in get_keyboard_sequences
    capability_names = curses.has_key._capability_names
AttributeError: 'function' object has no attribute '_capability_names'

The object curses.has_key is a function with only the usual attributes; no single-underscore attributes are present.

I believe the problem is caused by my _curses module not exporting the has_key function, and therefore exports the curses.has_key.has_key function instead. Because the module and function have the same name, the has_key module is not accessible. The following is from my curses/__init__.py:

# Import Python has_key() implementation if _curses doesn't contain has_key()

try:
    has_key
except NameError:
    from has_key import has_key

Because has_key.has_key is a function, this makes has_key._capability_names inaccessible.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
avylovecommented, Sep 26, 2019

@jquast Sounds like we can use the logic in #110 blessed/keyboard.py (minus the platform test) and blessed/tests/test_keyboard.py to fix this universally. It’s basically moving the import to the top of the file and fixing up a monkeypatch in the tests.

0reactions
jquastcommented, Jan 12, 2020

we use the code pattern you suggest, so i suggest this is resolved

Read more comments on GitHub >

github_iconTop Results From Across the Web

blessed.keyboard — Blessed 1.19.0 documentation
A small gem from curses.has_key that makes this all possible, # _capability_names: a lookup table of terminal capability names for # keyboard sequences...
Read more >
Error no module named curses - python - Stack Overflow
It allows python's native curses to be used on Windows, so all your standard python curses code can be used. Share.
Read more >
ncurses/NEWS at gittup · gittup/ncurses - GitHub
This is a log of changes that ncurses has gone through since Zeyd started ... + suppress a warning message (which is ignored)...
Read more >
NEWS - platform/external/ncurses - android Git repositories
> fix several errata in tic (reports/testcases by "zjuchenyuan"): + check for invalid hashcode in _nc_find_entry. + check for missing character after ...
Read more >
Change-Log for NCURSES - Thomas E. Dickey
+ update ncurses-howto, more documentation fixes along with corrections to ... + use NQ to flag entries where the terminal does not support...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found