the current package cannot be used at all here' the issue livetext from prior example in his section 'content-typemultipart/mixedboundary="=============== =="\nmime-ver btext text encode(btext 'content-typemultipart/mixedboundary="=============== =="\nmime-ve msg parser(parsestr(textemail parser expects unicode str msg parser(parsestr(btextbut poplib fetches email as bytestraceback (most recent call last)file ""line in file " :\python \lib\email\parser py"line in parsestr return self parse(stringio(text)headersonly=headersonlytypeerrorinitial_value must be str or nonenot bytes msg parser(parsestr(btext decode()msg parser(parsestr(btext decode('utf ')msg parser(parsestr(btext decode('latin ')msg parser(parsestr(btext decode('ascii')okay per default ascii encoded (defaultascii is same in all this is less than idealas bytes-based email would be able to handle message encodings more directly as mentionedthoughthe email package is not really fully functional in python because of its legacy str focusand the sharp distinction that python makes between unicode text and byte strings in this caseits parser should accept bytes and not expect clients to know how to decode because of thatthis book' email clients take simplistic approaches to decoding fetched message bytes to be parsed by email specificallyfull-text decoding will try userconfigurable encoding namethen fall back on trying common types as heuristicand finally attempt to decode just message headers this will suffice for the examples shown but may need to be enhanced for broader applicability in some casesencoding may have to be determined by other schemes such as inspecting email headers (if present at all)guessing from bytes structure analysisor dynamic user feedback adding such enhancements in robust fashion is likely too complex to attempt in book' example codeand it is better performed in common standard library tools in any event reallyrobust decoding of mail text may not be possible today at allif it requires headers inspections--we can' inspect message' encoding information headers unless we parse the messagebut we can' parse message with ' email package unless we already know the encoding that isscripts may need to parse in order to decodebut they need to decode in order to parsethe byte strings of poplib and unicode strings of email in are fundamentally at odds even within its own librariespython ' changes have created chicken-and-egg dependency problem that still exists nearly two years after ' release client-side scripting