From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on starla X-Spam-Level: X-Spam-Status: No, score=-1.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 Received: from nue.mailmanlists.eu (nue.mailmanlists.eu [IPv6:2a01:4f8:1c0c:6b10::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 99F191F4B8 for ; Sun, 5 May 2024 15:20:24 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; secure) header.d=ml.ruby-lang.org header.i=@ml.ruby-lang.org header.a=rsa-sha256 header.s=mail header.b=cEY6rYt8; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=W3dTOuoM; dkim-atps=neutral Received: from nue.mailmanlists.eu (localhost [127.0.0.1]) by nue.mailmanlists.eu (Postfix) with ESMTP id C2FBB847EC; Sun, 5 May 2024 15:20:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ml.ruby-lang.org; s=mail; t=1714922410; bh=JOaw7aBLOuvwcIQfjrg9g6XvGmibomRdSiobcJCyEaw=; h=Date:References:To:Reply-To:Subject:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From:Cc:From; b=cEY6rYt86E+4V37eH+cgBzkNy+XJ03Hr7bJrPwhFqF16JFvz2mz7FmxQskcAVM1DP JP2HgDhEhX7l34ZmK/gcfQWpAgsRbQjHDqJ1Dga8Kq8XGIhsd0JCnRRgE0TUGw2D3O 8hTjhvilJCRbkhbPXfgbqGAz3OLgt4LwRJokZ0d4= Received: from s.wrqvtzvf.outbound-mail.sendgrid.net (s.wrqvtzvf.outbound-mail.sendgrid.net [149.72.126.143]) by nue.mailmanlists.eu (Postfix) with ESMTPS id 603648473F for ; Sun, 5 May 2024 15:20:07 +0000 (UTC) Authentication-Results: nue.mailmanlists.eu; dkim=pass (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=W3dTOuoM; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ruby-lang.org; h=from:references:subject:mime-version:content-type: content-transfer-encoding:list-id:to:cc:content-type:from:subject:to; s=s1; bh=LddLOcdxw3NQN4i8BmGjDB88jbI3Fph9Wz96NXQGCuY=; b=W3dTOuoMsBdO1+P7qYzy7oNKIyGu/0Q5wyzKaUq6m3Ako61jKCviaQvm2DNS7OybdQOb 3g2kA/ElQmq4YwotZrVOdq5BxSle+QwkJMxDBKatbSEDWJmwQUjy7qtpc27TA5iA1bawLd VjqGNV/An10t+uWNwHdOdg6T0VDqov4c1HDW6pyrp8H84dkY5j7N6TwPLon/lRHIZc9tMd ZkcR9A0NuZwjUnAqXpvB7CfIKdyEBTXydfVGKkSm0j2nACMWJ5kTGOsF+mTgkU5bpNTMmp pNGW0zD41VFpSj+LcLki2W/hUhI9tVWtCLRJ1RzJ9tHHKssgNRlQyadZDxzgWR5A== Received: by recvd-6c74bc6469-bwgm6 with SMTP id recvd-6c74bc6469-bwgm6-1-6637A3A6-3 2024-05-05 15:20:06.146379401 +0000 UTC m=+401283.342152650 Received: from herokuapp.com (unknown) by geopod-ismtpd-canary-0 (SG) with ESMTP id vJvzZD-yR_q4shl7jUFUHw for ; Sun, 05 May 2024 15:20:06.040 +0000 (UTC) Date: Sun, 05 May 2024 15:20:06 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 18995 X-Redmine-Issue-Author: javanthropus X-Redmine-Issue-Priority: Normal X-Redmine-Sender: javanthropus X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-Redmine-MailingListIntegration-Message-Ids: 94374 X-SG-EID: =?us-ascii?Q?u001=2ErGSxngKD6oGl9tWadX4XoV3etLquOoKg0CfRIgtn0=2F=2F51X16iSgr7Y8Wy?= =?us-ascii?Q?1fjCWEM5G6QT6lpC2QanJ2tFrap9W5zaCqDWGhY?= =?us-ascii?Q?=2F96ZJYC5KNTSd84ekThf4bs8lZOjbUAJpDpW9Nx?= =?us-ascii?Q?v8Q5Jyjn+dBKeStJY0Y=2FyXDKoDSpr5dkcew3POa?= =?us-ascii?Q?VCCmS7zDCW0n73Y1+5x1Az4DvIue38KhijZphEc?= =?us-ascii?Q?4nEOtmSv+a4iiec3FDLxKcQ3z=2FXcl8Jb3P7v+fS?= =?us-ascii?Q?wXy9CChwM4Q1a044o5wrv0UnZQ=3D=3D?= To: ruby-core@ml.ruby-lang.org X-Entity-ID: u001.I8uzylDtAfgbeCOeLBYDww== Message-ID-Hash: VETUCK4UL7WGYZLZ5VKV7BRXTKIPHHTL X-Message-ID-Hash: VETUCK4UL7WGYZLZ5VKV7BRXTKIPHHTL X-MailFrom: bounces+313651-b711-ruby-core=ml.ruby-lang.org@em5188.ruby-lang.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list Reply-To: Ruby developers Subject: [ruby-core:117778] [Ruby master Bug#18995] IO#set_encoding sometimes set an IO's internal encoding to the default external encoding List-Id: Ruby developers Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: "javanthropus (Jeremy Bopp) via ruby-core" Cc: "javanthropus (Jeremy Bopp)" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Issue #18995 has been updated by javanthropus (Jeremy Bopp). @jeremyevans, did you ever take a look at this issue when I referenced it in #18899? The behavior is unchanged in Ruby 3.3. The script above prints the following: ``` external encoding: # internal encoding: # external encoding: # internal encoding: # external encoding: # internal encoding: # ``` I expected it to print this: ``` external encoding: # internal encoding: # external encoding: # internal encoding: # external encoding: # internal encoding: # ``` ---------------------------------------- Bug #18995: IO#set_encoding sometimes set an IO's internal encoding to the default external encoding https://bugs.ruby-lang.org/issues/18995#change-108185 * Author: javanthropus (Jeremy Bopp) * Status: Open * ruby -v: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux] * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- This script demonstrates the behavior: ```ruby def show(io) printf( "external encoding: %-25p internal encoding: %-25p\n", io.external_encoding, io.internal_encoding ) end Encoding.default_external = 'iso-8859-1' Encoding.default_internal = 'iso-8859-2' File.open('/dev/null') do |f| f.set_encoding('utf-8', nil) show(f) # f.internal_encoding is iso-8859-2, as expected f.set_encoding('utf-8', 'invalid') show(f) # f.internal_encoding is now iso-8859-1! Encoding.default_external = 'iso-8859-3' Encoding.default_internal = 'iso-8859-4' show(f) # f.internal_encoding is now iso-8859-3! end ``` In the 1st case, we see that the IO's internal encoding is set to the current setting of Encoding.default_internal. In the 2nd case, the IO's internal encoding is set to Encoding.default_external instead. The 3rd case is more interesting because it shows that the IO's internal encoding is actually following the current setting of Encoding.default_external. It didn't just copy it when #set_encoding was called. It changes whenever Encoding.default_external changes. What should the correct behavior be? -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/