threads / patch / 25485

v2t/gitweb-lib: Don't pass constant to decode_utf8

Subject: [PATCH v2] t/gitweb-lib: Don't pass constant to decode_utf8

## tl;dr

5 messages between Oct 20, 2010 and Oct 20, 2010. Diffs are folded; open one to read it.

replies: 4people: 2as markdown or json

Brian Gernhardt· Oct 20, 2010, 05:57 UTC · lore

Encode.pm started updating the string to decode in-place when a second argument is passed in version 2.40. This causes 'decode_utf8("", Encode::FB_CROAK)' to die with a message like:

Modification of a read-only value attempted at /Library/Perl/Updates/5.10.0/darwin-thread-multi-2level/Encode.pm line 216.

Work around this by passing an empty variable instead of a constant string.

Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>
---
 Changes since v1:
 - Use an explicitly empty variable instead of $_
 - Clearer commit message
 - CC people who worked on t/gitweb-lib.sh
 - based against maint
 t/gitweb-lib.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to t/gitweb-lib.sh +1 −1
diff --git a/t/gitweb-lib.sh b/t/gitweb-lib.sh
index 81ef2a0..1b9523d 100644
--- a/t/gitweb-lib.sh
+++ b/t/gitweb-lib.sh
@@ -80,7 +80,7 @@ if ! test_have_prereq PERL; then
 	test_done
 fi
 
-perl -MEncode -e 'decode_utf8("", Encode::FB_CROAK)' >/dev/null 2>&1 || {
+perl -MEncode -e '$e="";decode_utf8($e, Encode::FB_CROAK)' >/dev/null 2>&1 || {
     skip_all='skipping gitweb tests, perl version is too old'
     test_done
 }
-- 
1.7.3.1.209.g52408
Jakub Narebski· Oct 20, 2010, 19:05 UTC · re: Brian Gernhardt · lore

Re: [PATCH v2] t/gitweb-lib: Don't pass constant to decode_utf8

On Wed, 20 Oct 2010, Brian Gernhardt wrote:
> Encode.pm started updating the string to decode in-place when a second
> argument is passed in version 2.40.  This causes 'decode_utf8("",
> Encode::FB_CROAK)' to die with a message like:
Very minor complaint: line break here makes it less readable.
Perhaps this?
  Encode.pm started updating the string to decode in-place when a second argument
  is passed in version 2.40.  This causes 'decode_utf8("", Encode::FB_CROAK)' to
  die with a message like:
> 
> Modification of a read-only value attempted at
> /Library/Perl/Updates/5.10.0/darwin-thread-multi-2level/Encode.pm line
> 216.

Very minor complaint: It might be better to not include path to installed Encode.pm, which is different on different filesystems.

  Modification of a read-only value attempted at .../Encode.pm line
  216.
Show 5 quoted lines
> 
> Work around this by passing an empty variable instead of a constant
> string.
> 
> Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>
Acked-by: Jakub Narebski <jnareb@gmail.com>
> ---
> 
>  Changes since v1:
>  - Use an explicitly empty variable instead of $_
...which was undefined, not empty, I think.
>  - Clearer commit message
It is very clear (though I don't remember previous one).
>  - CC people who worked on t/gitweb-lib.sh
Thanks a lot.
>  - based against maint
Was there any difference versus being based against 'master'?
Show 17 quoted lines
> 
>  t/gitweb-lib.sh |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/t/gitweb-lib.sh b/t/gitweb-lib.sh
> index 81ef2a0..1b9523d 100644
> --- a/t/gitweb-lib.sh
> +++ b/t/gitweb-lib.sh
> @@ -80,7 +80,7 @@ if ! test_have_prereq PERL; then
>  	test_done
>  fi
>  
> -perl -MEncode -e 'decode_utf8("", Encode::FB_CROAK)' >/dev/null 2>&1 || {
> +perl -MEncode -e '$e="";decode_utf8($e, Encode::FB_CROAK)' >/dev/null 2>&1 || {
>      skip_all='skipping gitweb tests, perl version is too old'
>      test_done
>  }
Nicely done! Thanks!
-- 
Jakub Narebski
Poland
Brian Gernhardt· Oct 20, 2010, 22:13 UTC · re: Jakub Narebski · lore

Re: [PATCH v2] t/gitweb-lib: Don't pass constant to decode_utf8

On Oct 20, 2010, at 3:05 PM, Jakub Narebski wrote:
Show 13 quoted lines
> On Wed, 20 Oct 2010, Brian Gernhardt wrote:
> 
>> Encode.pm started updating the string to decode in-place when a second
>> argument is passed in version 2.40.  This causes 'decode_utf8("",
>> Encode::FB_CROAK)' to die with a message like:
> 
> Very minor complaint: line break here makes it less readable.
> 
> Perhaps this?
> 
>  Encode.pm started updating the string to decode in-place when a second argument
>  is passed in version 2.40.  This causes 'decode_utf8("", Encode::FB_CROAK)' to
>  die with a message like:
The wrapping was automatically done by vim.  I'll try tweaking width/contents to make it flow better.
Show 9 quoted lines
>> Modification of a read-only value attempted at
>> /Library/Perl/Updates/5.10.0/darwin-thread-multi-2level/Encode.pm line
>> 216.
> 
> Very minor complaint: It might be better to not include path to installed
> Encode.pm, which is different on different filesystems.
> 
>  Modification of a read-only value attempted at .../Encode.pm line
>  216.
>> Changes since v1:
>> - Use an explicitly empty variable instead of $_
> 
> ...which was undefined, not empty, I think.
It still served to test the two argument case, but I thought an explicit variable that exactly matched the previous call would be better.
>> - based against maint
> 
> Was there any difference versus being based against 'master'?
Whitespace in context lines.  The skip_all and test_done lines were re-indented at some point.  Minor, but I thought I'd mention it.
~~ Brian
Jakub Narebski· Oct 20, 2010, 22:28 UTC · re: Brian Gernhardt · lore

Re: [PATCH v2] t/gitweb-lib: Don't pass constant to decode_utf8

On Thu, 21 Oct 2010, Brian Gernhardt wrote:
Show 17 quoted lines
> On Oct 20, 2010, at 3:05 PM, Jakub Narebski wrote:
>> On Wed, 20 Oct 2010, Brian Gernhardt wrote:
>> 
>>> Encode.pm started updating the string to decode in-place when a second
>>> argument is passed in version 2.40.  This causes 'decode_utf8("",
>>> Encode::FB_CROAK)' to die with a message like:
>> 
>> Very minor complaint: line break here makes it less readable.
>> 
>> Perhaps this?
>> 
>>  Encode.pm started updating the string to decode in-place when a second argument
>>  is passed in version 2.40.  This causes 'decode_utf8("", Encode::FB_CROAK)' to
>>  die with a message like:
> 
> The wrapping was automatically done by vim.  I'll try tweaking
> width/contents to make it flow better.

Note that it is just nitpicking: the commit message is quite fine as it is.

Show 7 quoted lines
>>> Changes since v1:
>>> - Use an explicitly empty variable instead of $_
>> 
>> ...which was undefined, not empty, I think.
> 
> It still served to test the two argument case, but I thought an explicit
> variable that exactly matched the previous call would be better. 
It is better, IMHO.
Show 6 quoted lines
>>> - based against maint
>> 
>> Was there any difference versus being based against 'master'?
> 
> Whitespace in context lines.  The skip_all and test_done lines were
> re-indented at some point.  Minor, but I thought I'd mention it. 
O.K.
Thanks again.
-- 
Jakub Narebski
Poland
Brian Gernhardt· Oct 20, 2010, 23:07 UTC · re: Jakub Narebski · lore

[PATCH v3 (maint)] t/gitweb-lib: Don't pass constant to decode_utf8

Encode.pm started updating the string to decode in-place when a second argument is passed in version 2.40. This causes 'decode_utf8("", Encode::FB_CROAK)' to die with a message like:

Modification of a read-only value attempted at .../Encode.pm line 216.

Work around this by passing an empty variable instead of a constant string.

Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>
Acked-by: Jakub Narebski <jnareb@gmail.com>
---
 Changes since v2:
 - Re-wrapped first paragraph for easier reading
 - Removed long OS X-specific Perl library path
 - Added Ack
 t/gitweb-lib.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to t/gitweb-lib.sh +1 −1
diff --git a/t/gitweb-lib.sh b/t/gitweb-lib.sh
index 81ef2a0..1b9523d 100644
--- a/t/gitweb-lib.sh
+++ b/t/gitweb-lib.sh
@@ -80,7 +80,7 @@ if ! test_have_prereq PERL; then
 	test_done
 fi
 
-perl -MEncode -e 'decode_utf8("", Encode::FB_CROAK)' >/dev/null 2>&1 || {
+perl -MEncode -e '$e="";decode_utf8($e, Encode::FB_CROAK)' >/dev/null 2>&1 || {
     skip_all='skipping gitweb tests, perl version is too old'
     test_done
 }
-- 
1.7.3.1.209.g52408

← back to recent threads