bugGNU Octave - Bugs: bug #49695, Invalid FID and fopen(FID)

 
 

bug #49695: Invalid FID and fopen(FID)

Submitted by:  Guillaume <gyom>
Submitted on:  Thu 24 Nov 2016 11:15:27 AM UTC  
 
Category:  Octave Function Severity:  2 - Minor
Priority:  3 - Low Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Guillaume Open/Closed:  Closed
Release:  dev Operating System:  Any

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

( Jump to the original submission)

Tue 29 Nov 2016 10:05:40 AM UTC, comment #6:

Thanks Rik, it now works as expected!

Guillaume <gyom>
Mon 28 Nov 2016 08:21:42 PM UTC, comment #5:

I checked in a change for this on the development branch (http://hg.savannah.gnu.org/hgweb/octave/rev/b125351d4243). Fixed, closing report.

Rik <rik5>
Project Administrator
Sat 26 Nov 2016 04:13:02 AM UTC, comment #4:

My mistake. I thought you were trying to open a file, not query its status. When simply querying there should be no halt in execution of an Octave script.

Rik <rik5>
Project Administrator
Fri 25 Nov 2016 05:40:08 PM UTC, comment #3:

I think this is probably fair to fix in our implementation of fopen. Since Matlab treats this calling form as a "query any open file descriptor", it makes sense that the user may be looking up an invalid file descriptor to see whether it is open or what file it points to if it is open, and not expecting an error to be raised.

Mike Miller <mtmiller>
Project Administrator
Thu 24 Nov 2016 05:09:56 PM UTC, comment #2:

While I agree with you in spirit, this behavior is explicitly described in the Matlab documentation:

[filename,permission,machinefmt,encodingOut] = fopen(fileID)
An invalid fileID returns empty character vectors for all output arguments.

so I wonder if we shouldn't therefore match it nevertheless. I would entirely agree with you if it were for fread or fwrite but this is here a very specific syntax with fopen.

Guillaume <gyom>
Thu 24 Nov 2016 02:42:38 PM UTC, comment #1:

I'm not sure we will implement this. Octave generally tries to validate its inputs much more carefully then Matlab. The idea is to prevent Garbage In/Garbage Out calculations. In this case, by not throwing an error when something has gone wrong Matlab is forcing programmers to spend a lot of time checking return codes. The alternative is not to check return codes, but then the eventual error in the code may be far away from the actual error which was the failure to open the file. This makes things difficult to debug.

Rik <rik5>
Project Administrator
Thu 24 Nov 2016 11:15:27 AM UTC, original submission:

If FID is an invalid handle, fopen(FID) should return an empty string instead of throwing an error, for compatibility with Matlab:

> fopen (-1)
error: invalid stream number = -1

vs

>> fopen(-1)
ans =
0×0 empty char array=

See https://www.mathworks.com/help/matlab/ref/fopen.html#description

Guillaume <gyom>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by gyom (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-11-28 rik5 StatusConfirmed => Fixed
        Open/ClosedOpen => Closed
    2016-11-25 mtmiller StatusWont Fix => Confirmed
    2016-11-24 rik5 Severity3 - Normal => 2 - Minor
        Priority5 - Normal => 3 - Low
        StatusNone => Wont Fix

    Back to the top


    Powered by Savane 3.4