From 840af1fa7bb0342db2ec2362bc203c188127789d Mon Sep 17 00:00:00 2001 From: stamparm Date: Wed, 29 May 2013 10:20:43 +0200 Subject: [PATCH] Fix for missing global name __file__ --- sqlmap.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sqlmap.py b/sqlmap.py index faa91369e..4fdcabc53 100755 --- a/sqlmap.py +++ b/sqlmap.py @@ -6,6 +6,7 @@ See the file 'doc/COPYING' for copying permission """ import bdb +import inspect import logging import os import sys @@ -50,7 +51,12 @@ def modulePath(): using py2exe """ - return os.path.dirname(os.path.realpath(getUnicode(sys.executable if weAreFrozen() else __file__, sys.getfilesystemencoding()))) + try: + _ = sys.executable if weAreFrozen() else __file__ + except NameError: + _ = inspect.getsourcefile(modulePath) + + return os.path.dirname(os.path.realpath(getUnicode(_, sys.getfilesystemencoding()))) def main(): """