This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: os.open() exception doesn't contain file name on Windows
Type: behavior Stage: resolved
Components: IO, Windows Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, brian.curtin, georg.brandl, hynek, larry, pitrou, python-dev, serhiy.storchaka, stutzbach, tim.golden
Priority: normal Keywords:

Created on 2014-01-24 19:34 by serhiy.storchaka, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (15)
msg209109 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-01-24 19:34
On Linux for 2.7, 3.3 and 3.4 the open of non-existing file raises an exception which contains file name.

Python 2.7:

>>> open('non-existing', 'rb')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IOError: [Errno 2] No such file or directory: 'non-existing'
>>> import io
>>> io.open('non-existing', 'rb')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IOError: [Errno 2] No such file or directory: 'non-existing'

Python 3.3 and 3.4:

>>> open('non-existing', 'rb')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'non-existing'

On Windows for 2.7 and 3.4 raised exception also contains file name. But on 3.3 error message is only "[Errno 2] No such file or directory" and doesn't contains file name.

This change affects tests. test_tarfile failed on all Windows buildbots for 3.3.

http://buildbot.python.org/all/builders/x86%20Windows7%203.3/builds/1252/steps/test/logs/stdio

I suppose this is 3.3 bug.
msg209110 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-01-24 19:39
Not on my system, so what's changed?

Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:18:40) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> open('non-existing', 'rb')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'non-existing'
msg209111 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-01-24 19:45
Mark, could you please try following commands?

import tarfile; tarfile.open('non-existing', 'r|')
msg209113 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-01-24 19:51
Two attempts, one with the pipe "|" symbol in the mode, one without.

>>> import tarfile; tarfile.open('non-existing', 'r|')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python33\lib\tarfile.py", line 1594, in open
    stream = _Stream(name, filemode, comptype, fileobj, bufsize)
  File "C:\Python33\lib\tarfile.py", line 362, in __init__
    fileobj = _LowLevelFile(name, mode)
  File "C:\Python33\lib\tarfile.py", line 335, in __init__
    self.fd = os.open(name, mode, 0o666)
FileNotFoundError: [Errno 2] No such file or directory

>>> import tarfile; tarfile.open('non-existing', 'r')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python33\lib\tarfile.py", line 1566, in open
    return func(name, "r", fileobj, **kwargs)
  File "C:\Python33\lib\tarfile.py", line 1614, in taropen
    return cls(name, mode, fileobj, **kwargs)
  File "C:\Python33\lib\tarfile.py", line 1442, in __init__
    fileobj = bltn_open(name, self._mode)
FileNotFoundError: [Errno 2] No such file or directory: 'non-existing'
msg209115 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-01-24 20:05
Ah, here is os.open() raises an exception. Thank you Mark.

On Linux it raises an exception with file name.

>>> import os; os.open('non-existing', os.O_RDONLY | getattr(os, 'O_BINARY', 0), 0x666)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'non-existing'
msg209116 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-01-24 20:20
New changeset 69d885ac042d by Serhiy Storchaka in branch '3.3':
Issue #20384: Fix the test_tarfile test on Windows.
http://hg.python.org/cpython/rev/69d885ac042d
msg209117 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-01-24 20:32
I think there's a typo in the patch, test = 'xxx' but after the check for platform and mode, text = ''.
msg209118 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-01-24 20:41
Yes, thank you. It is alredy fixed in 38a50d8102be (thanks Arfrever).
msg210015 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-02-02 20:47
Larry, what would you say about os.open() error?
msg210132 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2014-02-03 14:46
If it's fixed in 3.4, then the first step would be to ask Georg if he will accept a fix for 3.3.  If he will not, then we don't need to go any further.
msg210134 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-02-03 14:56
Good afternoon,

Would you please be kind enough to have my name removed from all nosy lists as I've no interest in being constantly reminded that I've been called a liar.

Kindest regards. 

Mark Lawrence.

On Monday, 3 February 2014, 14:46, Larry Hastings <report@bugs.python.org> wrote:

>Larry Hastings added the comment:
>
>If it's fixed in 3.4, then the first step would be to ask Georg if he will accept a fix for 3.3.  If he will not, then we don't need to go any further.
>
>----------
>
>_______________________________________
>Python tracker <report@bugs.python.org>
><http://bugs.python.org/issue20384>
>_______________________________________
>
>
msg210135 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-02-03 14:56
Good afternoon,

Would you please be kind enough to have my name removed from all nosy lists as I've no interest in being constantly reminded that I've been called a liar.

Kindest regards. 

Mark Lawrence.

On Monday, 3 February 2014, 14:46, Larry Hastings <report@bugs.python.org> wrote:

>Larry Hastings added the comment:
>
>If it's fixed in 3.4, then the first step would be to ask Georg if he will accept a fix for 3.3.  If he will not, then we don't need to go any further.
>
>----------
>
>_______________________________________
>Python tracker <report@bugs.python.org>
><http://bugs.python.org/issue20384>
>_______________________________________
>
>
msg210138 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2014-02-03 15:17
Mark Lawrence: you can remove it yourself, by directly editing the "nosy" list on the page for the bug.  If you want to remove yourself from all issues on the tracker, click on the "Followed by you" link on the left side and work your way down the list.
msg210140 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-02-03 15:32
@Larry - thank you for the heads up.
msg218005 - (view) Author: Tim Golden (tim.golden) * (Python committer) Date: 2014-05-06 19:09
Fixed in 3.4 and later; 3.3 is no longer accepting patches
History
Date User Action Args
2022-04-11 14:57:57adminsetgithub: 64583
2014-05-06 19:09:47tim.goldensetstatus: open -> closed
versions: + Python 3.4, - Python 3.3
messages: + msg218005

resolution: fixed
stage: resolved
2014-02-03 19:58:30serhiy.storchakasetnosy: + georg.brandl
2014-02-03 15:33:02BreamoreBoysetnosy: - BreamoreBoy
2014-02-03 15:32:07BreamoreBoysetmessages: + msg210140
2014-02-03 15:17:56larrysetmessages: + msg210138
2014-02-03 14:56:23BreamoreBoysetmessages: + msg210135
2014-02-03 14:56:22BreamoreBoysetmessages: + msg210134
2014-02-03 14:46:28larrysetmessages: + msg210132
2014-02-02 20:47:20serhiy.storchakasetnosy: + larry
messages: + msg210015
2014-01-24 20:49:47serhiy.storchakasettitle: open() exception doesn't contain file name on Windows -> os.open() exception doesn't contain file name on Windows
2014-01-24 20:41:48serhiy.storchakasetmessages: + msg209118
2014-01-24 20:32:37BreamoreBoysetmessages: + msg209117
2014-01-24 20:20:27python-devsetnosy: + python-dev
messages: + msg209116
2014-01-24 20:05:32serhiy.storchakasetmessages: + msg209115
2014-01-24 19:51:43BreamoreBoysetmessages: + msg209113
2014-01-24 19:47:45serhiy.storchakasetnosy: + tim.golden, brian.curtin
2014-01-24 19:47:30serhiy.storchakasetcomponents: + Windows
2014-01-24 19:45:57serhiy.storchakasetmessages: + msg209111
2014-01-24 19:39:27BreamoreBoysetnosy: + BreamoreBoy
messages: + msg209110
2014-01-24 19:34:39serhiy.storchakacreate