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: test_zipfile failure when run by unprivileged user with installed Python
Type: behavior Stage: resolved
Components: Tests, Windows Versions: Python 3.6, Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: paul.moore, python-dev, serhiy.storchaka, steve.dower, tim.golden, zach.ware
Priority: normal Keywords: patch

Created on 2015-09-14 04:54 by zach.ware, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test_zipfile_check_write_access.patch serhiy.storchaka, 2015-09-14 06:11 review
test_zipfile_check_write_access_2.patch serhiy.storchaka, 2015-09-18 09:43 review
Messages (5)
msg250624 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2015-09-14 04:54
======================================================================
ERROR: test_write_with_optimization (test.test_zipfile.PyZipFileTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Program Files\Python 3.5\lib\test\test_zipfile.py", line 771, in test_write_with_optimization
    zipfp.writepy(packagedir)
  File "C:\Program Files\Python 3.5\lib\zipfile.py", line 1756, in writepy
    fname, arcname = self._get_codename(initname[0:-3], basename)
  File "C:\Program Files\Python 3.5\lib\zipfile.py", line 1882, in _get_codename
    if not _compile(file_py, optimize=self._optimize):
  File "C:\Program Files\Python 3.5\lib\zipfile.py", line 1819, in _compile
    py_compile.compile(file, doraise=True, optimize=optimize)
  File "C:\Program Files\Python 3.5\lib\py_compile.py", line 143, in compile
    importlib._bootstrap_external._write_atomic(cfile, bytecode, mode)
  File "<frozen importlib._bootstrap_external>", line 106, in _write_atomic
PermissionError: [Errno 13] Permission denied: 'C:\\Program Files\\Python 3.5\\lib\\email\\__pycache__\\__init__.cpython-35.opt-1.pyc.755404532528'
msg250627 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-09-14 05:16
Ah, os.access() doesn't work on Windows.
msg250632 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-09-14 06:11
Here is a patch that check write access by just trying to create a file.
msg250960 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-09-18 09:43
Oh, using TemporaryFile for testing write access is not good on Windows, because there is an issue with TemporaryFile that it repeats attempts to create a file in read-only directory.

Updated patch used constant file name.
msg251061 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-09-19 08:00
New changeset 80d002edc9c1 by Serhiy Storchaka in branch '3.4':
Issue #25101: Try to create a file to test write access in test_zipfile.
https://hg.python.org/cpython/rev/80d002edc9c1

New changeset fe84898fbe98 by Serhiy Storchaka in branch '2.7':
Issue #25101: Try to create a file to test write access in test_zipfile.
https://hg.python.org/cpython/rev/fe84898fbe98

New changeset 6899bf8d21c3 by Serhiy Storchaka in branch '3.5':
Issue #25101: Try to create a file to test write access in test_zipfile.
https://hg.python.org/cpython/rev/6899bf8d21c3

New changeset 399746fde4f8 by Serhiy Storchaka in branch 'default':
Issue #25101: Try to create a file to test write access in test_zipfile.
https://hg.python.org/cpython/rev/399746fde4f8
History
Date User Action Args
2022-04-11 14:58:20adminsetgithub: 69288
2015-09-19 08:05:16serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2015-09-19 08:00:56python-devsetnosy: + python-dev
messages: + msg251061
2015-09-19 07:55:46serhiy.storchakasetassignee: serhiy.storchaka
2015-09-18 09:43:58serhiy.storchakasetfiles: + test_zipfile_check_write_access_2.patch

messages: + msg250960
2015-09-14 12:18:55serhiy.storchakalinkissue17750 dependencies
2015-09-14 06:11:48serhiy.storchakasetfiles: + test_zipfile_check_write_access.patch
versions: + Python 2.7, Python 3.4, Python 3.6
messages: + msg250632

keywords: + patch
stage: needs patch -> patch review
2015-09-14 05:16:21serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg250627
2015-09-14 04:54:05zach.warecreate