New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
poor argument parsing in pragma 'use open' #15848
Comments
From sur98ke@gmail.comThis is a bug report for perl from sur98ke@gmail.com, ?Today I tried to work with UCS-2-LE-BOM encoded data using ARGV and To do so I had to use binmode (STDOUT, ...) What I found out is that format of argument for "use open" pragma is binmode(STDOUT, "raw pop encoding(ucs-2le) crlf utf8"); # works well open (F, '<encoding(ucs-2le) crlf utf8', 'vlc-assoc.reg'); # works well use open ('IN' , 'encoding(ucs-2le) crlf utf8'); # works well And this difference in interpreting arguments IS NOT mentioned at I couldn't even find the example of proper "use open" usage over https://perl5.git.perl.org/perl.git/blob/HEAD:/lib/open.pm#l73 which splits the argument by spaces. Could you please fix this in such a way that examples: Or, at least add explanation of this limitation to perldoc: Thank you. Best regards, Flags: Site configuration information for perl 5.22.3: Configured by ASSI at Sun Jan 15 13:05:43 CET 2017. Summary of my perl5 (revision 5 version 22 subversion 3) configuration: @INC for perl 5.22.3: Environment for perl 5.22.3: PATH=/usr/local/bin:/usr/bin:/win/c/Windows/system32:/win/c/Windows:/win/c/Windows/System32/Wbem:/win/c/Windows/System32/WindowsPowerShell/v1.0:/win/c/bin:/win/c/prog32/SysinternalsSuite:/win/c/Program |
From @jkeenanOn Sun, 29 Jan 2017 13:32:15 GMT, sur98ke@gmail.com wrote:
Would you be able to provide a file attachment with several lines of text in the ucs-2le encoding for which your work-around was necessary? That would enable us to examine the problem on multiple platforms. Thank you very much.
-- |
The RT System itself - Status changed from 'new' to 'open' |
From sur98ke@gmail.comThu, 02 Feb 2017 17:26:34 -0800, jkeenan писал:
OK, I include sample of UCS-2LE file. But I don't think you will really need it - because the problem happens at the stage of module import ('use open' ...) before my script actually start executing and accessing any files.
|
From sur98ke@gmail.comUCS-2LE Content |
From sur98ke@gmail.comFri, 03 Feb 2017 01:44:54 -0800, sur98ke@gmail.com писал:
I'm sorry, but some part of message-delivering software distorted the sample file from previous message (encoding has changed).
|
From @jkeenanOn Fri, 03 Feb 2017 09:48:43 GMT, sur98ke@gmail.com wrote:
Thanks you for supplying the .zip file. As I expected, the file within was useful to me in setting up a diagnostic. I think this is at most a documentation problem. But first let me advise that perldoc.perl.org is a site maintained by people other than the Perl 5 Porters. Occasionally it is out-of-date with respect to recent Perl releases. I don't think that's relevant here, but when seeking information on a Perl pragma, your best bet is to first say: ##### When I did that, I was able to find sufficient documentation to set up the diagnostic program, pragma-handle-ucs-2le.pl, attached. I tried 3 variants of that program by commenting/uncommenting pairs of 'use open' statements. Each variant produced exactly the same output, attached as 130668-output.txt. The only difference was that when I used the first variant: ##### ... the program ran without warnings. When I used the second variant: ##### ... I got these warnings: ##### ... and I got similar warnings with the third variant. The cases where I got warnings were the same cases where you got warnings. IMO there is no reason to assume that 'use open' should be as permissive in its syntax as 'binmode' or the second argument to 'open'. I wouldn't be surprised if the 'open' pragma were implemented at a much later date than 'binmode' or the 'open' built-in function and therefore implemented to throw warnings at imprecisions in the spelling of its arguments. Hence, I think the documentation for 'perldoc open' is satisfactory as is -- but I would be willing to consider/write a one-sentence patch indicating that its syntax will warn where comparable syntax in 'binmode' and the 'open' function does not. Thank you very much. -- |
From @jkeenanUCS-2LE Content |
From @jkeenanOn Sat, 04 Feb 2017 16:34:22 GMT, jkeenan wrote:
As I stated last week, I don't feel any need to change any documentation here. If anyone else feels strongly otherwise, please contribute a patch. Otherwise I will close this ticket within 7 days. Thank you very much. -- |
From sur98ke@gmail.comFri, 10 Feb 2017 18:49:46 -0800, jkeenan писал:
Sorry for late answer. First, sorry once again - when I posted this bug I didn't notice that despite printing warnings all three variants of "use open" still work well. Actually, when I looked at source of open.pm closer, I noticed that it just tries to split argument string by spaces into separate layer and then just checks them and CONCATENATES THEM BACK and puts result into ${^OPEN} special variable. AFAIU PerlIO implementation parses this variable and supports very free way of formatting it. OK, I agree, that valid format for multiple layers is "space separated, each layer name starts from colon". |
From @jkeenanNo patches submitted; therefore, closing this ticket. Thank you very much. -- |
@jkeenan - Status changed from 'open' to 'rejected' |
Migrated from rt.perl.org#130668 (status was 'rejected')
Searchable as RT130668$
The text was updated successfully, but these errors were encountered: