Check the cookies type

Python2:
- Added type check for cookies param in HomeSFR class

Python3:
- Added type check for cookies param in HomeSFR class
This commit is contained in:
Sasha MOREL 2016-12-01 11:27:01 +01:00
parent 11f59e21ef
commit 4359974efa
2 changed files with 6 additions and 2 deletions

View File

@ -211,8 +211,10 @@ class HomeSFR (Common):
self.autologin = False self.autologin = False
if cookies == None: if cookies == None:
self.cookies = CookieJar () self.cookies = CookieJar ()
else: elif type (cookies) == CookieJar:
self.cookies = cookies self.cookies = cookies
else:
raise TypeError ('Cookies must be CookieJar type.')
self.opener = request.build_opener (request.HTTPCookieProcessor (self.cookies)) self.opener = request.build_opener (request.HTTPCookieProcessor (self.cookies))
def __str__ (self): def __str__ (self):

View File

@ -207,8 +207,10 @@ class HomeSFR (Common):
self.autologin = False self.autologin = False
if cookies == None: if cookies == None:
self.cookies = CookieJar () self.cookies = CookieJar ()
else: elif type (cookies) == CookieJar:
self.cookies = cookies self.cookies = cookies
else:
raise TypeError ('Cookies must be CookieJar type.')
self.opener = request.build_opener (request.HTTPCookieProcessor (self.cookies)) self.opener = request.build_opener (request.HTTPCookieProcessor (self.cookies))
def __str__ (self): def __str__ (self):