digitalmars.D.bugs - [Issue 6993] New: File.byLine runs on an empty file, fails enforcement
- d-bugmail puremagic.com (31/31) Nov 22 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6993
- d-bugmail puremagic.com (16/16) Nov 22 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6993
- d-bugmail puremagic.com (9/16) Nov 23 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6993
- d-bugmail puremagic.com (11/11) Nov 23 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6993
http://d.puremagic.com/issues/show_bug.cgi?id=6993 Summary: File.byLine runs on an empty file, fails enforcement Product: D Version: D2 Platform: Other OS/Version: Windows Status: NEW Severity: major Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: andrej.mitrovich gmail.com --- Comment #0 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2011-11-22 21:04:53 PST --- Create a new file "empty.d" and run this: import std.stdio; void main() { auto file = File("empty.d", "r"); foreach (aLine; file.byLine) { } } object.Exception D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\stdio.d(943): Enforcement failed Line 943: enforce(file.isOpen); So the file was not successfully opened, but why wasn't an exception thrown in the File constructor then? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 22 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6993 Jonathan M Davis <jmdavisProg gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |jmdavisProg gmx.com Resolution| |DUPLICATE --- Comment #1 from Jonathan M Davis <jmdavisProg gmx.com> 2011-11-22 21:49:06 PST --- I don't see any reason why an exception would be thrown from File's constructor for an empty file. It certainly doesn't say that it does. The problem is that ByLine clearly isn't set up to handle empty files correctly. Duplicate of Bug# 6944 *** This issue has been marked as a duplicate of issue 6944 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 22 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6993 --- Comment #2 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2011-11-23 09:15:25 PST --- (In reply to comment #1)I don't see any reason why an exception would be thrown from File's constructor for an empty file. It certainly doesn't say that it does. The problem is that ByLine clearly isn't set up to handle empty files correctly. Duplicate of Bug# 6944 *** This issue has been marked as a duplicate of issue 6944 ***I agree, but the file handle was closed so I *assumed* that meant the file was not opened. I would rather have byLine not iterate than throw just because a file is empty. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 23 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6993 --- Comment #3 from Jonathan M Davis <jmdavisProg gmx.com> 2011-11-23 09:26:47 PST --- Oh. I agree completely. I think that byLine should just be empty when the file is empty, so no iteration occurs. I don't know what the exact details of opening the file are, but I don't see why an empty file should throw when you try and open it. Certainly, File's docs don't say anything of the sort. In Linux however, I ended up hitting an assertion rather than the exception that you hit, so there may be system-dependent behavior going on. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 23 2011