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.
Created on 2012年09月12日 00:37 by Arfrever, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| parsedate_invalid.patch | r.david.murray, 2012年09月16日 14:16 | review | ||
| Messages (9) | |||
|---|---|---|---|
| msg170347 - (view) | Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) * (Python triager) | Date: 2012年09月12日 00:37 | |
Documentation (in Python 3.3) says that None is returned when date cannot be parsed.
In Python 3.2:
>>> email.utils.parsedate("0")
>>> email.utils.parsedate_tz("0")
>>>
In Python 3.3:
>>> email.utils.parsedate("0")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python3.3/email/utils.py", line 232, in parsedate
return _parsedate(data)
File "/usr/lib64/python3.3/email/_parseaddr.py", line 172, in parsedate
t = parsedate_tz(data)
File "/usr/lib64/python3.3/email/_parseaddr.py", line 51, in parsedate_tz
if res[9] is None:
TypeError: 'NoneType' object is not subscriptable
>>> email.utils.parsedate_tz("0")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python3.3/email/utils.py", line 238, in parsedate_tz
return _parsedate_tz(data)
File "/usr/lib64/python3.3/email/_parseaddr.py", line 51, in parsedate_tz
if res[9] is None:
TypeError: 'NoneType' object is not subscriptable
>>> email.utils.parsedate_to_datetime("0")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python3.3/email/utils.py", line 243, in parsedate_to_datetime
*dtuple, tz = __parsedate_tz(data)
TypeError: 'NoneType' object is not iterable
>>>
|
|||
| msg170556 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2012年09月16日 14:16 | |
Here is a patch. Georg, this unfortunately represents a regression from 3.2 and should be fixed. |
|||
| msg170557 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2012年09月16日 14:18 | |
Hmm. Not sure why Georg didn't get auto-added. |
|||
| msg170558 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2012年09月16日 14:20 | |
Oh, and I'm purposely allowing parsedate_to_datetime throw exceptions. I suppose that should be documented, but that's a separate issue. |
|||
| msg170626 - (view) | Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) * (Python triager) | Date: 2012年09月17日 20:47 | |
I think that email.utils.parsedate_to_datetime("0") should raise ValueError instead of TypeError.
|
|||
| msg170996 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年09月22日 14:02 | |
New changeset 3b03d31f6a79 by R David Murray in branch 'default': #15925: fix regression: return None for null and non-date strings. http://hg.python.org/cpython/rev/3b03d31f6a79 |
|||
| msg170997 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2012年09月22日 14:04 | |
I don't think it is worth the extra code to convert the TypeError into a ValueError. We aren't very strict about the distinction between those two. Leaving this open for Georg to transplant it to 3.3.0. |
|||
| msg171002 - (view) | Author: Georg Brandl (georg.brandl) * (Python committer) | Date: 2012年09月22日 15:35 | |
This was committed to the release clone as c1e9a1fc6931. |
|||
| msg171096 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年09月24日 05:46 | |
New changeset c1e9a1fc6931 by Georg Brandl in branch 'default': Closes #15925: fix regression in parsedate() and parsedate_tz() that should return None if unable to parse the argument. http://hg.python.org/cpython/rev/c1e9a1fc6931 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:35 | admin | set | github: 60129 |
| 2012年09月24日 05:46:47 | python-dev | set | messages:
+ msg171096 stage: commit review -> resolved |
| 2012年09月22日 15:35:54 | georg.brandl | set | status: open -> closed |
| 2012年09月22日 15:35:38 | georg.brandl | set | messages: + msg171002 |
| 2012年09月22日 14:04:58 | r.david.murray | set | assignee: georg.brandl messages: + msg170997 resolution: fixed type: behavior |
| 2012年09月22日 14:02:27 | python-dev | set | nosy:
+ python-dev messages: + msg170996 |
| 2012年09月17日 20:47:15 | Arfrever | set | messages: + msg170626 |
| 2012年09月16日 14:20:59 | r.david.murray | set | messages:
+ msg170558 title: email.utils.parsedate(), email.utils.parsedate_tz() and email.utils.parsedate_to_datetime() should return None when date cannot be parsed -> email.utils.parsedate() and email.utils.parsedate_tz() should return None when date cannot be parsed |
| 2012年09月16日 14:18:08 | r.david.murray | set | nosy:
+ georg.brandl messages: + msg170557 |
| 2012年09月16日 14:16:09 | r.david.murray | set | files:
+ parsedate_invalid.patch keywords: + patch messages: + msg170556 stage: commit review |
| 2012年09月12日 03:12:34 | Arfrever | set | keywords: + 3.3regression |
| 2012年09月12日 00:38:51 | Arfrever | set | nosy:
+ barry, r.david.murray components: + email |
| 2012年09月12日 00:37:45 | Arfrever | create | |