Fixed an elusive bug in utils.get_variable_from_module() that caused the connection screen to sometimes not load properly, due to the imported modules being erroneously extracted and used.

This commit is contained in:
Griatch 2012-04-15 19:05:50 +02:00
parent 5264dc85bb
commit 6501f30cbc
7 changed files with 80 additions and 78 deletions

View file

@ -6,6 +6,7 @@ be of use when designing your own game.
"""
from inspect import ismodule
import os, sys, imp
import textwrap
import datetime
@ -623,7 +624,7 @@ def variable_from_module(modpath, variable=None, default=None):
return mod.__dict__.get(variable, default)
else:
# random selection
mvars = [val for key, val in mod.__dict__.items() if not key.startswith("_")]
mvars = [val for key, val in mod.__dict__.items() if not (key.startswith("_") or ismodule(val))]
return mvars and random.choice(mvars)
def string_from_module(modpath, variable=None, default=None):