Received: from eggs.gnu.org ([2001:4830:134:3::10]:43210) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUz1m-0006dH-Sl for qemu-devel@nongnu.org; Tue, 01 Apr 2014 09:47:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WUz1e-0007lr-Kn for qemu-devel@nongnu.org; Tue, 01 Apr 2014 09:46:58 -0400 Received: from roura.ac.upc.es ([147.83.33.10]:34351) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUz1d-0007kL-Oj for qemu-devel@nongnu.org; Tue, 01 Apr 2014 09:46:50 -0400 From: =?utf-8?Q?Llu=C3=ADs_Vilanova?= References: <20140331191631.21034.25433.stgit@fimbulvetr.bsc.es> <20140331191648.21034.9744.stgit@fimbulvetr.bsc.es> <5339C950.8060308@redhat.com> Date: Tue, 01 Apr 2014 15:46:44 +0200 In-Reply-To: <5339C950.8060308@redhat.com> (Eric Blake's message of "Mon, 31 Mar 2014 14:00:16 -0600") Message-ID: <87ob0lrwl7.fsf@fimbulvetr.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v6 3/4] qapi: Add a primitive to include other files from a QAPI schema file List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: =?utf-8?Q?Beno=C3=AEt?= Canet , Markus Armbruster , qemu-devel@nongnu.org, Luiz Capitulino Eric Blake writes: > On 03/31/2014 01:16 PM, Llu=C3=ADs Vilanova wrote: [...] >> + if not os.path.isabs(include_path): >> + include_path =3D os.path.join(self.input_dir, inclu= de_path) >> + if not os.path.isfile(include_path): >> + raise QAPIExprError( >> + expr_info, >> + 'Non-existing included file "%s"' % >> + include_path) > Is this error necessary, or would you get a sane error message by just > trying to open the file? Not catching it would throw a Python exception, with no context of how the = user got there. [...] >> + if include_path in self.included: >> + raise QAPIExprError(expr_info, "Infinite inclusion = loop: %s" >> + % " -> ".join(self.included + >> + [include_path])) > Good, include-self-cycle.err covers a one-file loop, and > include-cycle.err covers a 3-file loop. > Not so good: your error message is an extremely long line: > +tests/qapi-schema/include-cycle-c.json:1: Infinite inclusion loop: > tests/qapi-schema/include-cycle.json -> > tests/qapi-schema/include-cycle-b.json -> > tests/qapi-schema/include-cycle-c.json -> > tests/qapi-schema/include-cycle.json > The formatting in Beno=C3=AEt's series was a little nicer aesthetically: > +Inclusion loop detected with file: multi_file_loop_include.json > +Path to the broken include is: > + multi_file_loop_include.json > + multi_loop.json > Furthermore, it had the benefit of using the spelling provided by the > user, rather than the absolute path to the files. You want to track > canonical paths for detecting the loop, but do NOT want to report > absolute paths back to the user - instead, it's nicer to report back the > names as they spelled it. I think it's better reporting absolute paths, otherwise the user has to men= tally keep track of the relative paths to get to the file. Thanks, Lluis --=20 "And it's much the same thing with knowledge, for whenever you learn something new, the whole world becomes that much richer." -- The Princess of Pure Reason, as told by Norton Juster in The Phantom Tollbooth