Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions Doc/library/curses.ascii.rst
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,12 @@ C library:

Checks for a non-ASCII character (ordinal values 0x80 and above).

These functions accept either integers or strings; when the argument is a
These functions accept either integers or single-character strings; when the argument is a

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be changed? It accept multi-character strings, too. Alought it will raise TypeError by ord.

Also, after this paragraph, it has written this Note that all these functions check ordinal bit values derived from the first character of the string you pass in.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does single-character string as same as you mention in note? (it can be specified as a Unicode string or a byte string.). If yes, but these function can't accept byte string:

>>> curses.ascii.ascii(b'1')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.6/curses/ascii.py", line 75, in ascii
    return _ctoi(c) & 0x7f
TypeError: unsupported operand type(s) for &: 'bytes' and 'int'
>>> curses.ascii.ctrl(b'1')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.6/curses/ascii.py", line 81, in ctrl
    return _ctoi(c) & 0x1f
TypeError: unsupported operand type(s) for &: 'bytes' and 'int'

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raising TypeError doesn't mean that the function accepts multi-character strings.

"string" means just string here. Although I think it is worth to add the support of bytes here, this PR changes only the documentation.

string, it is first converted using the built-in function :func:`ord`.

Note that all these functions check ordinal bit values derived from the first
Note that all these functions check ordinal bit values derived from the
character of the string you pass in; they do not actually know anything about
the host machine's character encoding. For functions that know about the
character encoding (and handle internationalization properly) see the
:mod:`string` module.
the host machine's character encoding.

The following two functions take either a single-character string or integer
byte value; they return a value of the same type.
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/curses.panel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Panel objects have the following methods:

.. method:: Panel.hidden()

Returns true if the panel is hidden (not visible), false otherwise.
Returns ``True`` if the panel is hidden (not visible), ``False`` otherwise.


.. method:: Panel.hide()
Expand Down
Loading