From e95e8bc66287892401ee4ade161511ea544c431a Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Sun, 23 Sep 2012 01:59:12 +0200 Subject: [PATCH] Properly handle issues in idna encoding --- pythonwhois/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pythonwhois/__init__.py b/pythonwhois/__init__.py index 40fe898..97c653e 100644 --- a/pythonwhois/__init__.py +++ b/pythonwhois/__init__.py @@ -158,7 +158,12 @@ def whois(domain): data = {} - ping = subprocess.Popen(["jwhois", unicodedammit(domain).encode('idna')], stdout = subprocess.PIPE, stderr = subprocess.PIPE) + try: + encoded_domain = unicodedammit(domain).encode('idna') + except UnicodeError, e: + encoded_domain = domain + + ping = subprocess.Popen(["jwhois", encoded_domain], stdout = subprocess.PIPE, stderr = subprocess.PIPE) out, error = ping.communicate() for line in out.splitlines():