From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Philipp Stephani Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Improve error reporting when serializing non-Unicode strings to JSON Date: Sat, 23 Dec 2017 14:29:56 +0000 Message-ID: References: <20171222210031.30811-1-phst@google.com> <83efnllufm.fsf@gnu.org> <83wp1dk18g.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="001a114844d80bf9fa056102c58d" X-Trace: blaine.gmane.org 1514039350 22808 195.159.176.226 (23 Dec 2017 14:29:10 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 23 Dec 2017 14:29:10 +0000 (UTC) Cc: phst@google.com, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Dec 23 15:29:06 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eSknQ-0005Rg-Tu for ged-emacs-devel@m.gmane.org; Sat, 23 Dec 2017 15:29:05 +0100 Original-Received: from localhost ([::1]:42173 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eSkpP-0008QZ-JV for ged-emacs-devel@m.gmane.org; Sat, 23 Dec 2017 09:31:07 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43690) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eSkoU-0008OX-9u for emacs-devel@gnu.org; Sat, 23 Dec 2017 09:30:11 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eSkoT-0000Wz-C3 for emacs-devel@gnu.org; Sat, 23 Dec 2017 09:30:10 -0500 Original-Received: from mail-qt0-x22d.google.com ([2607:f8b0:400d:c0d::22d]:45024) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eSkoS-0000V3-3B; Sat, 23 Dec 2017 09:30:08 -0500 Original-Received: by mail-qt0-x22d.google.com with SMTP id m59so39240876qte.11; Sat, 23 Dec 2017 06:30:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=AM8X1DGQr6kUvsTvXr8DPa+Cx+UgDj3Z+MXW9mHkOAE=; b=LKSjRRv7Q6dPkQpN4neYLTQESnHum++Xc5514Y3cHTpeeMDMaJD2B73ulAUxKrv5Fp 2vLj27BfpytUGphvT+sVIANhTxSBGqPy5zwQ1HIttQORqKMJ962EXoK9XCi/VsDR7441 SVAgRJB+ry+9++bMYJ8F0IumohF4dEhxF4PNQR9HDYdzeDLkv5mqPZ1VdBXTGlJeAXej fYg4wBW2crG6z+kdMcan8JwAvX1qgm2LeVJe/TjsFia/XyeFqD2/A4VwHEnnZHBx8e/1 gL0xwcHO4+9NEIGPB1T/SIKlBXsCXeSqqaKQCCrKMcPpudlIrMTTB+guApKvAdk1d2SG p2uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=AM8X1DGQr6kUvsTvXr8DPa+Cx+UgDj3Z+MXW9mHkOAE=; b=Lc9+ZNrUN8ms6Au7A6OIuY43ReWo/5VvzOpwlTrpbNMVyXpq8F8CKc3wMi2cf7Y+Nz JW9XG3F5BugYP1v1woV99ajnTRaCDeSSmgBhq7XvqECKy940/W8+vCsYsztSLQqkNB+A dPnx0iP04g/L/1nxO67E5Dq1i+qRDIvawPqzcRF8oyQ/tFPAz8JYGM72W27DxjP84aSi s5RmFujBfzZZpcXFJh1bPrQDIulJhpA8A22/I6No5EEi/+kx3xNOzsHeEPItob66o8DI 0kb5X8luprST6z0wrt6bLIHVeh74YRt+3y/ECHlySLYc++qfTbWrbRISFlnvu24+OjmL qRUQ== X-Gm-Message-State: AKGB3mJXQGyZV3uKdf42+K159OeXCpkcd6X+rbZVkylDRrJ65EmU/UwC Htg01+9euiHPI/faYeR8XkUruZGSmvV9fOsxWHiaeQ== X-Google-Smtp-Source: ACJfBovAaZQ/STXErGSHaDm5ZbBeldQBRozRPuGoEh0r1kPNfPUMnkNTEnUXt2UfoxV8t6ReJsKKxgbqsfu03UCukZc= X-Received: by 10.200.28.44 with SMTP id a41mr25571648qtk.340.1514039407277; Sat, 23 Dec 2017 06:30:07 -0800 (PST) In-Reply-To: <83wp1dk18g.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::22d X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:221373 Archived-At: --001a114844d80bf9fa056102c58d Content-Type: text/plain; charset="UTF-8" Eli Zaretskii schrieb am Sa., 23. Dez. 2017 um 14:44 Uhr: > > From: Philipp Stephani > > Date: Sat, 23 Dec 2017 12:33:46 +0000 > > Cc: emacs-devel@gnu.org, phst@google.com > > > > This patch only improves the error symbol when trying to serialize a > non-Unicode string to JSON. Right now > > this raises "out of memory", which is somewhat confusing. This patch > improves this to raise > > "wrong-type-argument". > > OK, but why do we need external functions for doing that? What is > missing in our own code to detect such a situation? > Not much I think, it's just easiest to use Gnulib functions because they are well-documented, have a clean interface, and are probably bug-free. coding.c has check_utf_8, which is quite similar, but has an incompatible interface (it takes struct coding_system objects) and also checks for embedded newlines, which isn't necessary here. --001a114844d80bf9fa056102c58d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


Eli Za= retskii <eliz@gnu.org> schrieb am= Sa., 23. Dez. 2017 um 14:44=C2=A0Uhr:
> From: Philipp Stephani <p.stephani2@gmail.com>
> Date: Sat, 23 Dec 2017 12:33:46 +0000
> Cc: emacs-dev= el@gnu.org, phst@g= oogle.com
>
> This patch only improves the error symbol when trying to serialize a n= on-Unicode string to JSON. Right now
> this raises "out of memory", which is somewhat confusing. Th= is patch improves this to raise
> "wrong-type-argument".

OK, but why do we need external functions for doing that?=C2=A0 What is
missing in our own code to detect such a situation?
Not much I think, it's just easiest to use Gnulib function= s because they are well-documented, have a clean interface, and are probabl= y bug-free.
coding.c has check_utf_8, which is quite similar, but= has an incompatible interface (it takes struct coding_system objects) and = also checks for embedded newlines, which isn't necessary here.=C2=A0
--001a114844d80bf9fa056102c58d--