[New-bugs-announce] [issue17244] py_compile.compile() fails to raise exceptions when writing of target file fails

Arfrever Frehtes Taifersar Arahesis report at bugs.python.org
Tue Feb 19 21:47:16 CET 2013


New submission from Arfrever Frehtes Taifersar Arahesis:

Since d4eb02b6aac9 py_compile.compile() fails to raise exceptions when writing of target file fails.

$ cd /tmp
$ touch test.py
$ mkdir dir
$ chmod a-w dir
mode of ‘dir’ changed from 0755 (rwxr-xr-x) to 0555 (r-xr-xr-x)
$ python3.3 -c 'import py_compile; py_compile.compile("test.py", cfile="/tmp/dir/test.pyc")'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib64/python3.3/py_compile.py", line 141, in compile
    with open(cfile, 'wb') as fc:
PermissionError: [Errno 13] Permission denied: '/tmp/dir/test.pyc'
$ python3.4 -c 'import py_compile; py_compile.compile("test.py", cfile="/tmp/dir/test.pyc")'
$ python3.3 -c 'import py_compile; py_compile.compile("test.py", cfile="/tmp/dir")'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib64/python3.3/py_compile.py", line 141, in compile
    with open(cfile, 'wb') as fc:
IsADirectoryError: [Errno 21] Is a directory: '/tmp/dir'
$ python3.4 -c 'import py_compile; py_compile.compile("test.py", cfile="/tmp/dir")'
$ ls -l dir
total 0
$

----------
components: Library (Lib)
messages: 182426
nosy: Arfrever, brett.cannon, eric.snow, ncoghlan, pitrou
priority: normal
severity: normal
status: open
title: py_compile.compile() fails to raise exceptions when writing of target file fails
type: behavior
versions: Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17244>
_______________________________________


More information about the New-bugs-announce mailing list