py3: use setattr() to assign new class attribute
authorPulkit Goyal <7895pulkit@gmail.com>
Tue, 17 May 2016 05:32:36 +0530
changeset 29192 bac14dbbbfab
parent 29191 ad1ce3c7af72
child 29193 cd3c6f3ee5e9
py3: use setattr() to assign new class attribute The old method produces error 'object does not supports item assignment'. So setattr() is used to assign a new class attribute via __dict__ .
mercurial/mail.py
--- a/mercurial/mail.py	Wed May 11 14:18:52 2016 -0700
+++ b/mercurial/mail.py	Tue May 17 05:32:36 2016 +0530
@@ -41,7 +41,7 @@
     kw['continuation_ws'] = ' '
     _oldheaderinit(self, *args, **kw)
 
-email.Header.Header.__dict__['__init__'] = _unifiedheaderinit
+setattr(email.header.Header, '__init__', _unifiedheaderinit)
 
 class STARTTLS(smtplib.SMTP):
     '''Derived class to verify the peer certificate for STARTTLS.