GNU bug report logs - #49082
[PATCH] guix: gexp: Make UTF-8 a default port encoding in mixed-text-file

Previous Next

Package: guix-patches;

Reported by: Andrew Tropin <andrew <at> trop.in>

Date: Fri, 18 Jun 2021 04:33:01 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 49082 in the body.
You can then email your comments to 49082 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#49082; Package guix-patches. (Fri, 18 Jun 2021 04:33:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Andrew Tropin <andrew <at> trop.in>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Fri, 18 Jun 2021 04:33:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Andrew Tropin <andrew <at> trop.in>
To: guix-patches <at> gnu.org
Subject: [PATCH] guix: gexp: Make UTF-8 a default port encoding in
 mixed-text-file
Date: Fri, 18 Jun 2021 07:15:36 +0300
guix/gexp.scm (mixed-text-file): It's necessary because if some UTF-8 symbols
appear in configuration, resulting file in the store will contain ? instead of
it.
---
 guix/gexp.scm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/guix/gexp.scm b/guix/gexp.scm
index afb935761e..187f5c5e85 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -1921,6 +1921,7 @@ This is the declarative counterpart of 'text-file*'."
   (define build
     (gexp (call-with-output-file (ungexp output "out")
             (lambda (port)
+              (set-port-encoding! port "UTF-8")
               (display (string-append (ungexp-splicing text)) port)))))
 
   (computed-file name build))
-- 
2.32.0





Information forwarded to guix-patches <at> gnu.org:
bug#49082; Package guix-patches. (Fri, 18 Jun 2021 07:56:02 GMT) Full text and rfc822 format available.

Message #8 received at 49082 <at> debbugs.gnu.org (full text, mbox):

From: Leo Prikler <leo.prikler <at> student.tugraz.at>
To: 49082 <at> debbugs.gnu.org
Cc: andrew <at> trop.in
Subject: [PATCH] guix: gexp: Make UTF-8 a default port encoding in
 mixed-text-file
Date: Fri, 18 Jun 2021 09:55:06 +0200
I appreciate this change, but how many rebuilds will it cause? It might
need to go to core-updates.
Regards, Leo





Information forwarded to guix-patches <at> gnu.org:
bug#49082; Package guix-patches. (Fri, 18 Jun 2021 16:22:02 GMT) Full text and rfc822 format available.

Message #11 received at 49082 <at> debbugs.gnu.org (full text, mbox):

From: Andrew Tropin <andrew <at> trop.in>
To: Leo Prikler <leo.prikler <at> student.tugraz.at>, 49082 <at> debbugs.gnu.org
Subject: Re: [PATCH] guix: gexp: Make UTF-8 a default port encoding in
 mixed-text-file
Date: Fri, 18 Jun 2021 19:21:36 +0300
Leo Prikler <leo.prikler <at> student.tugraz.at> writes:

> I appreciate this change, but how many rebuilds will it cause? It might
> need to go to core-updates.
> Regards, Leo

Not so many I suppose, AFAIK, it's not used by any packages, so it will
cause rebuild only for users of 2 dozens of system services during
system reconfigure, which should be quite cheap, because it's just
string concatenation.  Let me know if my understanding is wrong here.

Anyway, I don't mind it going to core-updates if you think it's
necessary.







Information forwarded to guix-patches <at> gnu.org:
bug#49082; Package guix-patches. (Fri, 18 Jun 2021 16:40:02 GMT) Full text and rfc822 format available.

Message #14 received at 49082 <at> debbugs.gnu.org (full text, mbox):

From: Leo Prikler <leo.prikler <at> student.tugraz.at>
To: Andrew Tropin <andrew <at> trop.in>, 49082 <at> debbugs.gnu.org
Subject: Re: [PATCH] guix: gexp: Make UTF-8 a default port encoding in
 mixed-text-file
Date: Fri, 18 Jun 2021 18:39:18 +0200
Am Freitag, den 18.06.2021, 19:21 +0300 schrieb Andrew Tropin:
> Leo Prikler <leo.prikler <at> student.tugraz.at> writes:
> 
> > I appreciate this change, but how many rebuilds will it cause? It
> > might
> > need to go to core-updates.
> > Regards, Leo
> 
> Not so many I suppose, AFAIK, it's not used by any packages, so it
> will
> cause rebuild only for users of 2 dozens of system services during
> system reconfigure, which should be quite cheap, because it's just
> string concatenation.  Let me know if my understanding is wrong here.
> 
> Anyway, I don't mind it going to core-updates if you think it's
> necessary.
In that case it's probably good to go to master.
One thing to note however, is that we typically bind %default-port-
encoding throughout Guix.  I suppose this doesn't work for stuff like
mixed-text-file, since it's executed in a different context?





Information forwarded to guix-patches <at> gnu.org:
bug#49082; Package guix-patches. (Fri, 18 Jun 2021 17:22:02 GMT) Full text and rfc822 format available.

Message #17 received at 49082 <at> debbugs.gnu.org (full text, mbox):

From: Andrew Tropin <andrew <at> trop.in>
To: Leo Prikler <leo.prikler <at> student.tugraz.at>, 49082 <at> debbugs.gnu.org
Subject: Re: [PATCH] guix: gexp: Make UTF-8 a default port encoding in
 mixed-text-file
Date: Fri, 18 Jun 2021 20:21:09 +0300
Leo Prikler <leo.prikler <at> student.tugraz.at> writes:

> Am Freitag, den 18.06.2021, 19:21 +0300 schrieb Andrew Tropin:
>> Leo Prikler <leo.prikler <at> student.tugraz.at> writes:
>> 
>> > I appreciate this change, but how many rebuilds will it cause? It
>> > might
>> > need to go to core-updates.
>> > Regards, Leo
>> 
>> Not so many I suppose, AFAIK, it's not used by any packages, so it
>> will
>> cause rebuild only for users of 2 dozens of system services during
>> system reconfigure, which should be quite cheap, because it's just
>> string concatenation.  Let me know if my understanding is wrong here.
>> 
>> Anyway, I don't mind it going to core-updates if you think it's
>> necessary.
> In that case it's probably good to go to master.
Good!
> One thing to note however, is that we typically bind %default-port-
> encoding throughout Guix.  I suppose this doesn't work for stuff like
> mixed-text-file, since it's executed in a different context?
Very probably.

Have a good weekend!




Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Wed, 23 Jun 2021 21:40:02 GMT) Full text and rfc822 format available.

Notification sent to Andrew Tropin <andrew <at> trop.in>:
bug acknowledged by developer. (Wed, 23 Jun 2021 21:40:02 GMT) Full text and rfc822 format available.

Message #22 received at 49082-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Andrew Tropin <andrew <at> trop.in>
Cc: 49082-done <at> debbugs.gnu.org
Subject: Re: bug#49082: [PATCH] guix: gexp: Make UTF-8 a default port
 encoding in mixed-text-file
Date: Wed, 23 Jun 2021 23:39:25 +0200
Hi,

Andrew Tropin <andrew <at> trop.in> skribis:

> guix/gexp.scm (mixed-text-file): It's necessary because if some UTF-8 symbols
> appear in configuration, resulting file in the store will contain ? instead of
> it.

Good catch!  Applied as 1f3d7b45349d43e5cc02594083e0cd44ef730992.

Please look how I modified the commit log, in line with our conventions
and previous entries for this file.

>    (define build
>      (gexp (call-with-output-file (ungexp output "out")
>              (lambda (port)
> +              (set-port-encoding! port "UTF-8")

Leo is right that we’d often write:

  (parameterize ((%default-port-encoding "UTF-8"))
    (call-with-output-file …))

because it’s marginally cleaner (the port is created with the right
encoding from the start).  In this case it doesn’t matter much though.

Thank you!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#49082; Package guix-patches. (Thu, 24 Jun 2021 04:43:01 GMT) Full text and rfc822 format available.

Message #25 received at 49082-done <at> debbugs.gnu.org (full text, mbox):

From: Andrew Tropin <andrew <at> trop.in>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 49082-done <at> debbugs.gnu.org
Subject: Re: bug#49082: [PATCH] guix: gexp: Make UTF-8 a default port
 encoding in mixed-text-file
Date: Thu, 24 Jun 2021 07:41:58 +0300
Ludovic Courtès <ludo <at> gnu.org> writes:

> Hi,
>
> Andrew Tropin <andrew <at> trop.in> skribis:
>
>> guix/gexp.scm (mixed-text-file): It's necessary because if some UTF-8 symbols
>> appear in configuration, resulting file in the store will contain ? instead of
>> it.
>
> Good catch!  Applied as 1f3d7b45349d43e5cc02594083e0cd44ef730992.

Thank you very much!)

> Please look how I modified the commit log, in line with our conventions
> and previous entries for this file.
>
>>    (define build
>>      (gexp (call-with-output-file (ungexp output "out")
>>              (lambda (port)
>> +              (set-port-encoding! port "UTF-8")
>
> Leo is right that we’d often write:
>
>   (parameterize ((%default-port-encoding "UTF-8"))
>     (call-with-output-file …))
>
> because it’s marginally cleaner (the port is created with the right
> encoding from the start).  In this case it doesn’t matter much though.

Got it, I thought Leo meant to wrap (mixed-text-file ...) into
parametrize, which probably won't work, because gexp will be avaluated
in different environment.  Sorry for missunderstanding!)  Leo, Ludo,
thank you for explanation!

> Thank you!
>
> Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 22 Jul 2021 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 279 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.