Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'non-ascii': 0.09; 'typeerror:': 0.09; 'bug': 0.10; 'aug': 0.13; '(name,': 0.16; '__new__': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'iterable': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'string:': 0.16; 'value))': 0.16; 'wrote:': 0.17; 'skip:u 30': 0.17; '>>>': 0.18; 'skip:" 30': 0.20; 'skip:" 40': 0.20; 'trying': 0.21; 'parse': 0.22; 'skip:_ 20': 0.22; 'this:': 0.23; "i've": 0.23; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'looks': 0.26; 'skip:" 20': 0.26; '(most': 0.27; '>>>>': 0.29; 'received:192.168.1.3': 0.29; 'value)': 0.29; 'helpful': 0.30; 'file': 0.32; 'received:84': 0.32; 'comments': 0.33; 'him.': 0.33; 'traceback': 0.33; 'to:addr :python-list': 0.33; '(with': 0.33; 'hi,': 0.33; 'skip:d 20': 0.34; "can't": 0.34; 'thanks': 0.34; 'add': 0.36; 'but': 0.36; 'skip:p 20': 0.36; 'subject:: ': 0.38; 'object': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'email,': 0.66; 'header:Reply-To:1': 0.68; 'reply-to:no real name:2**0': 0.72; 'reply- to:addr:python.org': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.0 cv=IekFqBWa c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=DKcI9XZsuF4A:10 a=AhbMgIzJzKIA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=IkcTkHD0fZMA:10 a=uoFtZhjTERsA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=8mp7MIsyEm68DpBjMAIA:9 a=QEXdDO2ut3YA:10 a=0nF1XD0wxitMEM03M9B4ZQ==:117 X-AUTH: mrabarnett:2500 Date: Thu, 23 Aug 2012 12:36:01 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Python3.3 email policy date field References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: python-list@python.org List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 49 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1345721756 news.xs4all.nl 6846 [2001:888:2000:d::a6]:46292 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:27727 On 23/08/2012 09:30, Helmut Jarausch wrote: > Hi, > > in response to a bug report I got the follow helpful comments from R. David Murray. > Many thanks to him. (Unfortunately, I don't know his email, so I can write him directly) > > To generate an email (with non-ascii letters) > > R. David Murray wrote: > >>>> But even better, so will this: > >>>> m = Message(policy=policy.SMTP) >>>> m['From'] = "Günter Weiße " > > > > > This works, but now I cannot add a date field > > Trying > > m['Date'] = datetime.datetime.utcnow().strftime('%m/%d/%Y %I:%M:%S %p') > > I get > > Traceback (most recent call last): > File "Test_EMail_Py3_4.py", line 23, in > msg['Date'] = datetime.datetime.utcnow().strftime('%m/%d/%Y %I:%M:%S %p') > File "/usr/lib64/python3.3/email/message.py", line 359, in __setitem__ > self._headers.append(self.policy.header_store_parse(name, val)) > File "/usr/lib64/python3.3/email/policy.py", line 119, in header_store_parse > return (name, self.header_factory(name, value)) > File "/usr/lib64/python3.3/email/headerregistry.py", line 583, in __call__ > return self[name](name, value) > File "/usr/lib64/python3.3/email/headerregistry.py", line 194, in __new__ > cls.parse(value, kwds) > File "/usr/lib64/python3.3/email/headerregistry.py", line 300, in parse > value = utils.parsedate_to_datetime(value) > 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 > From what I've tried, it looks like the date can't be a string: >>> m['Date'] = datetime.datetime.utcnow() >>> m['Date'] 'Thu, 23 Aug 2012 11:33:20 -0000'