[issue17505] [doc] email.header.Header.__unicode__ does not decode header

2022-03-08 Thread Vidhya


Vidhya  added the comment:

The PR for the email parser doc update is: 
https://github.com/python/cpython/pull/31765

Can someone review it pls.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17505] [doc] email.header.Header.__unicode__ does not decode header

2022-03-08 Thread Vidhya


Change by Vidhya :


--
keywords: +patch
pull_requests: +29874
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/31765

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17505] [doc] email.header.Header.__unicode__ does not decode header

2022-03-04 Thread Vidhya


Vidhya  added the comment:

@hniksic: Thanks for your suggestions. I will look into BytesFeedParser 
documents.
@david.murray: I can help you for the switch over to the default in the default 
policy and update the deprecation as well. It will be good if someone can guide 
me on this. Being a beginner, I am not sure if we are allowed to change the 
python code.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17505] [doc] email.header.Header.__unicode__ does not decode header

2022-03-04 Thread R. David Murray


R. David Murray  added the comment:

The policy is named 'default' because it was intended to become the default two 
feature releases after the new email code became non-provisional (first: 
deprecate not specifying an explicit policy, next release make default the 
default policy and make the deprecation only cover compat32).  However, for 
various reasons that switchover did not happen (one big factor being my reduced 
time spent doing python development).  It can happen any time someone steps 
forward to guide it through the release process.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17505] [doc] email.header.Header.__unicode__ does not decode header

2022-03-04 Thread Hrvoje Nikšić

Hrvoje Nikšić  added the comment:

> Any suggestions on what needs to be done for current revisions?

Hi! I'm the person who submitted this issue back in 2013. Let's take a look at 
how things are in Python 3.10:

Python 3.10.2 (main, Jan 13 2022, 19:06:22) [GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import email
>>> msg = email.message_from_string('Subject: 
>>> =?gb2312?b?1eLKx9bQzsSy4srUo6E=?=\n\nfoo\n')
>>> msg['Subject']
'=?gb2312?b?1eLKx9bQzsSy4srUo6E=?='

So the headers are still not decoded by default. The `unicode()` invocation in 
the original description was just an attempt to get a Unicode string out of a 
byte string (assuming it was correctly decoded from MIME, which it wasn't). 
Since Python 3 strings are Unicode already, I'd expect to just get the decoded 
subject - but that still doesn't happen.

The correct way to make it happen is to specify `policy=email.policy.default`:

>>> msg = email.message_from_string('Subject: 
>>> =?gb2312?b?1eLKx9bQzsSy4srUo6E=?=\n\nfoo\n', policy=email.policy.default)
>>> msg['Subject']
'这是中文测试!'

The docs should point out that you really _want_ to specify the "default" 
policy (strangely named, since it's not in fact the default). The current docs 
only say that `message_from_string()` is "equivalent to Parser().parsestr(s)." 
and that `policy` is interpreted "as with the Parser class constructor". The 
docs of the Parser constructor don't document `policy` at all, except for the 
version when it was added.

So, if you want to work for this, my suggestion would be to improve the docs in 
the following ways:

* in message_from_string() docs, explain that `policy=email.policy.default` is 
what you want to send to get the headers decoded.

* in Parser docs, explain what _class and policy arguments do in the 
constructor, which policies are possible, etc. (These things seem to be 
explained in the BytesFeedParser, so you might want to just link to that, or 
include a shortened version.)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17505] [doc] email.header.Header.__unicode__ does not decode header

2022-03-01 Thread Vidhya


Vidhya  added the comment:

The latest versions 3.9, 3.10 and 3.11 are updated in the issue. So I thought 
like it still applies.

@irit: Any suggestions on what needs to be done for current revisions?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17505] [doc] email.header.Header.__unicode__ does not decode header

2022-02-28 Thread Jelle Zijlstra


Jelle Zijlstra  added the comment:

The messages above are very old and seem to be discussing Python 2. There is no 
`__unicode__` method any more, for example, though there is a `__str__` method 
which presumably does what `__unicode__` used to do. It is documented now at 
https://docs.python.org/3.10/library/email.header.html#email.header.Header.__str__
 . You'll have to do some more digging to figure out whether the OP's complaint 
still applies.

--
nosy: +Jelle Zijlstra

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17505] [doc] email.header.Header.__unicode__ does not decode header

2022-02-28 Thread Vidhya


Vidhya  added the comment:

[Entry level contributor seeking guidance] If this is still open, I like to 
work on this.

Also, planning to add the following(if no PR yet created) at make_header API at 
https://docs.python.org/3/library/email.header.html :

To get unicode strings use the API as shown below:
 unicode(make_header(decode_header('=?gb2312?b?1eLKx9bQzsSy4srUo6E=?=')))

If email policy parameter is set as 'policy.default' then the default policy, 
for that Python version, is used for header encoding and decoding. 

Please correct me if anything wrong.

--
nosy: +vidhya

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17505] [doc] email.header.Header.__unicode__ does not decode header

2021-12-13 Thread Irit Katriel


Change by Irit Katriel :


--
keywords: +easy
title: email.header.Header.__unicode__ does not decode header -> [doc] 
email.header.Header.__unicode__ does not decode header
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 2.7, Python 3.2, Python 
3.3, Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com