From b8473db903cb9114f46c58981c8783ba690ca265 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Sun, 23 Sep 2012 01:02:36 +0200 Subject: [PATCH] Properly idna-encode domains before whoising them --- pythonwhois/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pythonwhois/__init__.py b/pythonwhois/__init__.py index c6d2806..0e8bcff 100644 --- a/pythonwhois/__init__.py +++ b/pythonwhois/__init__.py @@ -137,6 +137,12 @@ grammar = { } } +def unicodedammit(input_string): + if isinstance(input_string, str): + return input_string.decode('utf-8') + else: + return input_string + def whois(domain): global grammar ruleset = None @@ -150,7 +156,7 @@ def whois(domain): data = {} - ping = subprocess.Popen(["jwhois", domain], stdout = subprocess.PIPE, stderr = subprocess.PIPE) + ping = subprocess.Popen(["jwhois", unicodedammit(domain).encode('idna')], stdout = subprocess.PIPE, stderr = subprocess.PIPE) out, error = ping.communicate() for line in out.splitlines():