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.

Author mnewman
Recipients ggenellina, mnewman
Date 2009-01-18.15:51:59
SpamBayes Score 3.9676843e-06
Marked as misclassified No
Message-id <1232293922.48.0.380080404241.issue4973@psf.upfronthosting.co.za>
In-reply-to
Content
It seems to be working consistently (see UTF-16 extreme example below),
but I had expected it to act similarly to Python 2.6, which it does not.
I suppose this is due to the distinction now made between strings and
bytes in Python 3.0.

I was initially concerned that Python 3.0 was always just giving an
ASCII byte stream no matter what encoding was chosen (since you can't
tell between ASCII and UTF-8 for the characters being used in the
example), but the UTF-16 example shows its fine.

I agree that as long as the documentation in Python 3.X notes it will
return "bytes", then its fine. Thanks for the clarification/confirmation.

Python 3.0 (r30:67507, Dec  3 2008, 20:14:27) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import calendar
>>> calendar.HTMLCalendar().formatyearpage(2009, encoding="utf-8")[0:50]
b'<?xml version="1.0" encoding="utf-8"?>\n<!DOCTYPE h'
>>> calendar.HTMLCalendar().formatyearpage(2009, encoding="ascii")[0:50]
b'<?xml version="1.0" encoding="ascii"?>\n<!DOCTYPE h'
>>> calendar.HTMLCalendar().formatyearpage(2009, encoding="utf-16")[0:50]
b'\xff\xfe<\x00?\x00x\x00m\x00l\x00
\x00v\x00e\x00r\x00s\x00i\x00o\x00n\x00=\x00"\x001\x00.\x000\x00"\x00
\x00e\x00n\x00c\x00o\x00'

Python 2.6.1 (r261:67517, Dec  4 2008, 16:51:00) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import calendar
>>> calendar.HTMLCalendar().formatyearpage(2009, encoding="utf-8")[0:50]
'<?xml version="1.0" encoding="utf-8"?>\n<!DOCTYPE h'
>>> calendar.HTMLCalendar().formatyearpage(2009, encoding="ascii")[0:50]
'<?xml version="1.0" encoding="ascii"?>\n<!DOCTYPE h'
>>> calendar.HTMLCalendar().formatyearpage(2009, encoding="utf-16")[0:50]
'\xff\xfe<\x00?\x00x\x00m\x00l\x00
\x00v\x00e\x00r\x00s\x00i\x00o\x00n\x00=\x00"\x001\x00.\x000\x00"\x00
\x00e\x00n\x00c\x00o\x00'
History
Date User Action Args
2009-01-18 15:52:02mnewmansetrecipients: + mnewman, ggenellina
2009-01-18 15:52:02mnewmansetmessageid: <1232293922.48.0.380080404241.issue4973@psf.upfronthosting.co.za>
2009-01-18 15:52:01mnewmanlinkissue4973 messages
2009-01-18 15:51:59mnewmancreate