Skip to content

Commit

Permalink
Fix TypeError: object of type 'NoneType' has no len() on telegram eve…
Browse files Browse the repository at this point in the history
…nt handler initialization (#5252)
  • Loading branch information
rbusquet authored and solderzzc committed Sep 6, 2016
1 parent 1e62ec4 commit 3d65681
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pokemongo_bot/event_handlers/telegram_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,10 @@ def initDBstructure(self):
def initDBobject(self, name, sql):
res = self.conn.execute("select sql,type from sqlite_master where name = ?", [name]).fetchone() # grab objects definition

if len(res) > 0 and res[0] != sql: # object exists and sql not matching
if res and len(res) > 0 and res[0] != sql: # object exists and sql not matching
self.conn.execute("drop {} {}".format(res[1], name)) # drop it

if len(res) == 0 or res[0] != sql: # object missing or sql not matching
if res is None or len(res) == 0 or res[0] != sql: # object missing or sql not matching
self.conn.execute(sql)
return

Expand Down

0 comments on commit 3d65681

Please sign in to comment.