From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NzVfS-0006yV-Ev for qemu-devel@nongnu.org; Wed, 07 Apr 2010 09:51:42 -0400 Received: from [140.186.70.92] (port=37303 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NzVfQ-0006yJ-9y for qemu-devel@nongnu.org; Wed, 07 Apr 2010 09:51:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NzVfO-0000RY-S2 for qemu-devel@nongnu.org; Wed, 07 Apr 2010 09:51:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33384) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NzVfO-0000RU-Hr for qemu-devel@nongnu.org; Wed, 07 Apr 2010 09:51:38 -0400 Message-ID: <4BBC8DE4.7020509@redhat.com> Date: Wed, 07 Apr 2010 16:51:32 +0300 From: Avi Kivity MIME-Version: 1.0 Subject: Re: [Qemu-devel] Re: [PATCH 1/1] QMP test code - qmp.py References: <20100407103610.4080b945@redhat.com> In-Reply-To: <20100407103610.4080b945@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: Costas Drogos , qemu-devel@nongnu.org On 04/07/2010 04:36 PM, Luiz Capitulino wrote: > > >> diff --git a/QMP/qmp.py b/QMP/qmp.py >> index d9da603..f8581c4 100644 >> --- a/QMP/qmp.py >> +++ b/QMP/qmp.py >> @@ -8,7 +8,15 @@ >> # This work is licensed under the terms of the GNU GPL, version 2. See >> # the COPYING file in the top-level directory. >> >> -import socket, json >> +import socket >> + >> +from sys import version >> +ver = version[:3] >> + >> +if ver == '2.6': >> + import json >> +else: >> + import simplejson as json >> > This won't do what we want for 2.7 and newer, so a better if would be: > > if sys.version_info< (2, 6): > import simplejson as json > else: > import json > > try: import json except: import simplejson as json -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.