diff --git a/mwclient/ex.py b/mwclient/ex.py
index db4006c25dd7e4076090e8955fe96a74c2d33ff7..c0b1eaebcef32f453f06732a584ac08e4805660f 100644
--- a/mwclient/ex.py
+++ b/mwclient/ex.py
@@ -12,7 +12,7 @@ def read_config(config_files, **predata):
 
 def _read_config_file(_config_file, predata):
     _file = open(_config_file)
-    exec _file in globals(), predata
+    exec(_file, globals(), predata)
     _file.close()
 
     for _k, _v in predata.iteritems():