[New-bugs-announce] [issue4973] calendar formatyearpage returns bytes, not str

Michael Newman report at bugs.python.org
Sat Jan 17 18:57:54 CET 2009

New submission from Michael Newman <michael.b.newman at gmail.com>:

formatyearpage is returning "bytes", not "str"

Python 3.0 (r30:67507, Dec  3 2008, 20:14:27) [MSC v.1500 32 bit
(Intel)] on win
Type "help", "copyright", "credits" or "license" for more information.
>>> import calendar
>>> calendar.HTMLCalendar().formatyearpage(2009)[0:50]
b'<?xml version="1.0" encoding="utf-8"?>\n<!DOCTYPE h'
>>> type(calendar.HTMLCalendar().formatyearpage(2009)[0:50])
<class 'bytes'>

# For the time being, to fix it I can use "decode"...
>>> calendar.HTMLCalendar().formatyearpage(2009).decode("utf-8")[0:50]
'<?xml version="1.0" encoding="utf-8"?>\n<!DOCTYPE h'
>>> type(calendar.HTMLCalendar().formatyearpage(2009).decode("utf-8")[0:50])
<class 'str'>

components: Extension Modules
messages: 80030
nosy: mnewman
severity: normal
status: open
title: calendar formatyearpage returns bytes, not str
versions: Python 3.0

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list