From 40a06d65271309331239098f90572261093ce853 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Tue, 2 Aug 2016 10:31:27 +0200 Subject: [PATCH] =?UTF-8?q?Deprecate=20IrcMsg.=5F=5Fgetattr=5F=5F=20and=20?= =?UTF-8?q?fix=20compatibility=20with=20Python=20=E2=89=A5=203.6.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ircmsgs.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/ircmsgs.py b/src/ircmsgs.py index 2b9a48df0..d52aa0892 100644 --- a/src/ircmsgs.py +++ b/src/ircmsgs.py @@ -39,6 +39,7 @@ import re import time import base64 import datetime +import warnings import functools from . import conf, ircutils, utils @@ -262,7 +263,17 @@ class IrcMsg(object): return self.tags.get(tag) # Returns None if it's not there. def __getattr__(self, attr): - return self.tagged(attr) + if attr.startswith('__'): # Since PEP 487, Python calls __set_name__ + raise AttributeError("'%s' object has no attribute '%s'" % + (self.__class__.__name__, attr)) + if attr in self.tags: + warnings.warn("msg. is deprecated. Use " + "msg.tagged('') or msg.tags['']" + "instead.", DeprecationWarning) + return self.tags[attr] + else: + # TODO: make this raise AttributeError + return None def isCtcp(msg):