[New-bugs-announce] [issue2811] doctest doesn't treat unicode literals as specified by the file declared encoding

Paulo Eduardo Neves report at bugs.python.org
Sat May 10 20:47:11 CEST 2008


New submission from Paulo Eduardo Neves <pauloneves at gmail.com>:

Doctest doesn't obey the specified file encoding for unicode literals.

I've put the minimum test case that demonstrate the error in the
attached file. 

The program has the # -*- coding: utf-8 -*- as the first line and is
saved in this encoding. My computer  environment is configured as
iso8859-1. Doctest ignores the file encoding specification and
interprets the u'á' as u'á' (the utf-8 text decoded as iso8859-1 )

I've reproduced this error in python 2.5 in linux and windows.


This is the output of the program below that runs the function normalize
from inside doctest and directly from python. They show different results.

**********************************************************************
File "doctesteerror.py", line 7, in __main__.normalize
Failed example:
    normalize(u'á')
Expected:
    u'b'
Got:
    u'\xc3\xa1'
**********************************************************************
1 items had failures:
   1 of   1 in __main__.normalize
***Test Failed*** 1 failures.
without doctest ===>>> b

----------
components: Library (Lib)
files: doctesteerror.py
messages: 66559
nosy: neves
severity: normal
status: open
title: doctest doesn't treat unicode literals as specified by the file declared encoding
type: behavior
versions: Python 2.5
Added file: http://bugs.python.org/file10265/doctesteerror.py

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2811>
__________________________________


More information about the New-bugs-announce mailing list