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: bug#23750: 25.0.95; bug in url-retrieve or json.el Date: Tue, 29 Nov 2016 23:09:57 +0000 Message-ID: References: <6d0c8c2e-8428-2fdb-0d6e-899f7b9d7ffd@nifty.com> <8053af81-80e1-a24a-f649-8ffc86963ed5@nifty.com> <0cc7fab4-9a2c-6a8d-def7-36bd50317ca3@yandex.ru> <7f9a799f-de88-fd78-0cdc-dac0928f1503@nifty.com> <308bb78f-8be3-092d-d877-e129d340242b@nifty.com> <4dc615e7-ec73-60a5-426e-0d6986f15d76@yandex.ru> <0cb406fb-ffc4-a4ad-557a-2cacc99b8e75@nifty.com> <86ccb4af-5719-c017-26bb-fc06b4c904d2@yandex.ru> <83r35uxkr5.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=089e0118454c7c707f054278b04f X-Trace: blaine.gmane.org 1480461115 14578 195.159.176.226 (29 Nov 2016 23:11:55 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 29 Nov 2016 23:11:55 +0000 (UTC) Cc: larsi@gnus.org, kentaro.nakazawa@nifty.com, emacs-devel@gnu.org To: Eli Zaretskii , Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Nov 30 00:11:50 2016 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 1cBrZ0-00039I-H9 for ged-emacs-devel@m.gmane.org; Wed, 30 Nov 2016 00:11:50 +0100 Original-Received: from localhost ([::1]:39676 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBrZ4-0008U6-5w for ged-emacs-devel@m.gmane.org; Tue, 29 Nov 2016 18:11:54 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49817) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBrYQ-0008SR-9d for emacs-devel@gnu.org; Tue, 29 Nov 2016 18:11:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cBrYP-000651-1b for emacs-devel@gnu.org; Tue, 29 Nov 2016 18:11:14 -0500 Original-Received: from mail-wj0-f169.google.com ([209.85.210.169]:32786) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cBrYK-00062G-WC; Tue, 29 Nov 2016 18:11:09 -0500 Original-Received: by mail-wj0-f169.google.com with SMTP id xy5so158774012wjc.0; Tue, 29 Nov 2016 15:11:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Ejf/SWJXxM12tlaZGBqxzMOQscpjQadrvjQJU0jvnJE=; b=r1/WiUQbkXDU7sCbiVsrPmsPmatrPc5zrGi+CGwgbep+eEUj4soC/NaqbA3I4xLPTt ZvrBzkSHzeRJrZlA72DCZkkMqYIJa1AD+Y7YmaJF7GW/WmQ5ASz+5ol+VOKERFRxScWz W4r6XJYWsmc5RHCnfDHQ4EYFAuJblcritH6nqzQpp0rZ3zk/GyNe5IMoe9QLIasNtGbR +D5+6uymlTJ6YHPYe7mKmiXggSDZlS+oN9cV0N+F1UL4swQn0rNcMlN9tbgzFiTJYL7D BhdzT5NJIXHoxv9ls0OH0TMgKIM6u2Jr/Upk5L5VUgIMk0F6Nq4VdBmn5wGfTs9TMp32 SunA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Ejf/SWJXxM12tlaZGBqxzMOQscpjQadrvjQJU0jvnJE=; b=jtY5hlMaiqSyAUUZNzxq+BdWnt43yQsK8og+6TyhtmVBvbgNa7oGpljIOd3v4UVDYV 4/kwHl4LJd02BOHFispZrA0f5VjuCmleVi94LQfa9ivzTDIoo9xzRJo99S6QZOAxe2/e XCw1jMLN1FarFw65vhW6CiJiNNwMod5TEp30nAHG4vmgAMPJeKin+uJLfLXxesBO9ni4 rZ1tlHsuQCgweldzHlE9c+qdqdGKJ9bzwX5DjJZ82JptwCuE++En/bo7wQiccjyKvAYh dWvq5L7E9WredJJY/d+W1scWMZIgbg/KO+qGd6GNTZclSct9PocZAHd0l6d5jNCjKu6x 9SfQ== X-Gm-Message-State: AKaTC01pUGNxfSSSF5JrGKRFto7alTfIoRRcaIYZtrpAR/UP3feBOJJFQz9kz7erbpLHwGW6zn512XkTydKbjw== X-Received: by 10.194.148.4 with SMTP id to4mr25401146wjb.194.1480461008005; Tue, 29 Nov 2016 15:10:08 -0800 (PST) In-Reply-To: <83r35uxkr5.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.210.169 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:209779 Archived-At: --089e0118454c7c707f054278b04f Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Eli Zaretskii schrieb am Di., 29. Nov. 2016 um 18:24 Uhr: > > From: Dmitry Gutov > > Date: Tue, 29 Nov 2016 13:05:39 +0200 > > Cc: emacs-devel@gnu.org > > > > On 29.11.2016 13:03, Kentaro NAKAZAWA wrote: > > > > > (let* ((content (encode-coding-string > > > "=E3=81=BB=E3=81=92 <- VALID utf-8 Japanese multibyt= e text" > > > 'utf-8)) > > > (url "https://api.github.com/gists") > > > (url-request-method "POST") > > > (url-request-data > > > (json-encode > > > `(("description" . "test") > > > ("public" . false) > > > ("files" . (("test.txt" . (("content" . ,content))))))))) > > > (with-current-buffer (url-retrieve-synchronously url) > > > (buffer-string))) > > > > json-encode returns a multibyte string. > > Any idea why? Because (symbol-name 'false) returns a multibyte string. I guess the ultimate reason is that the reader always creates multibyte strings for symbol names. > Is it again that 'concat' misfeature, when one of the > strings is pure-ASCII, but happens to be multibyte? Why is it a misfeature? I'd expect a concatenation of multibyte and unibyte strings to either implicitly upgrade to as multibyte string (as in Python 2) or raise a signal (as in Python 3). That url-retrieve breaks in this case is unfortunate, but I guess we can't do much about it without breaking other stuff. Maybe the behavior regarding unibyte and multibyte strings (e.g. what kinds of strings the reader and `concat' generate) should simply be documented. --089e0118454c7c707f054278b04f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


Eli Za= retskii <eliz@gnu.org> schrieb am= Di., 29. Nov. 2016 um 18:24=C2=A0Uhr:
> From: Dmitry Gutov <dgutov@yandex.ru>
> Date: Tue, 29 Nov 2016 13:05:39 +0200
> Cc: emacs-devel@gnu.org
>
> On 29.11.2016 13:03, Kentaro NAKAZAWA wrote:
>
> > (let* ((content (encode-coding-string
> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &qu= ot;=E3=81=BB=E3=81=92 <- VALID utf-8 Japanese multibyte text"
> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = 9;utf-8))
> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 (url "http= s://api.github.com/gists")
> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 (url-request-method "POST")<= br class=3D"gmail_msg"> > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 (url-request-data
> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(json-encode
> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 `(("description" . &q= uot;test")
> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ("public" . fa= lse)
> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ("files" . ((&= quot;test.txt" . (("content" . ,content)))))))))
> >=C2=A0 =C2=A0(with-current-buffer (url-retrieve-synchronously url)=
> >=C2=A0 =C2=A0 =C2=A0(buffer-string)))
>
> json-encode returns a multibyte string.

Any idea why?=C2=A0

Because (symbol-name &#= 39;false) returns a multibyte string. I guess the ultimate reason is that t= he reader always creates multibyte strings for symbol names.
=C2= =A0
Is it again that 'concat' = misfeature, when one of the
strings is pure-ASCII, but happens to be multibyte?

Why is it a misfeature? I'd expect a concatenation of multibyt= e and unibyte strings to either implicitly upgrade to as multibyte string (= as in Python 2) or raise a signal (as in Python 3).
That url-retr= ieve breaks in this case is unfortunate, but I guess we can't do much a= bout it without breaking other stuff. Maybe the behavior regarding unibyte = and multibyte strings (e.g. what kinds of strings the reader and `concat= 9; generate) should simply be documented.
--089e0118454c7c707f054278b04f--