This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: doctest fails to display bytes type
Type: behavior Stage:
Components: Extension Modules Versions: Python 3.0
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, msyang
Priority: normal Keywords:

Created on 2008-12-07 21:44 by msyang, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg77264 - (view) Author: Michael Yang (msyang) Date: 2008-12-07 21:44
doctest.testmod() fails when attempting to echo back a bytes type with
ord() > 128.


def ok():
   """
>>> bytes([255,])
b'\xff'

"""
    pass

def notOK():
    """
>>> b'\xff'

"""
    pass

import doctest
doctest.testmod()

Traceback (most recent call last):
...
UnicodeEncodeError: 'ascii' codec can't encode character '\xff' in
position 141: ordinal not in range(128)
msg77268 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-12-07 22:01
You've included a chr(255) character in your docstring.  You need to
escape the backslash in order to include the bytes representation like
it will be generated.
History
Date User Action Args
2022-04-11 14:56:42adminsetgithub: 48834
2008-12-07 22:01:06georg.brandlsetstatus: open -> closed
resolution: not a bug
messages: + msg77268
nosy: + georg.brandl
2008-12-07 21:44:06msyangcreate