classification
Title: Pathlib crashes when os module is missing 'link' method
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.9, Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: brett.cannon, miss-islington, serhiy.storchaka, tohojo, vstinner
Priority: normal Keywords: patch

Created on 2019-11-15 12:04 by tohojo, last changed 2019-12-16 12:42 by vstinner. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 17170 merged tohojo, 2019-11-15 12:10
PR 17204 closed miss-islington, 2019-11-17 17:07
PR 17219 merged vstinner, 2019-11-18 11:05
PR 17225 merged tohojo, 2019-11-18 12:32
PR 17626 merged miss-islington, 2019-12-16 12:24
Messages (10)
msg356670 - (view) Author: Toke Høiland-Jørgensen (tohojo) * Date: 2019-11-15 12:04
Commit 6b5b013bcc22 ("bpo-26978: Implement pathlib.Path.link_to (Using os.link) (GH-12990)") introduced a new link_to method in pathlib. However, this makes pathlib crash when the 'os' module is missing a 'link' method, as can be seen in the report in this CI test:

https://travis-ci.org/tohojo/flent/jobs/611950252
msg356696 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2019-11-15 17:24
Just an FYI a raised exception isn't considered a crash. For us a crash is a C-level crash like a segfault.
msg356703 - (view) Author: Toke Høiland-Jørgensen (tohojo) * Date: 2019-11-15 17:53
Right, sure, that makes sense; thanks for clarifying :)
msg356818 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-11-17 17:06
New changeset 111772fc27cfe388bc060f019d68a3e33481ec65 by Serhiy Storchaka (Toke Høiland-Jørgensen) in branch 'master':
bpo-38811: Check for presence of os.link method in pathlib. (GH-17170)
https://github.com/python/cpython/commit/111772fc27cfe388bc060f019d68a3e33481ec65
msg356858 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-11-18 11:07
The change failed on x86 Windows7 3.x buildbot:
https://buildbot.python.org/all/#/builders/58/builds/3257

Moreover, PR 17170 was merged whereas the CLA was not signed. So I created PR 17219 to revert the change to fix the Windows 7 failure and to wait until the CLA is signed.

======================================================================
ERROR: test_symlink_to_not_implemented (test.test_pathlib.PathTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\cygwin\home\db3l\buildarea\3.x.bolen-windows7\build\lib\test\test_pathlib.py", line 2031, in test_symlink_to_not_implemented
    link.symlink_to(target)
  File "D:\cygwin\home\db3l\buildarea\3.x.bolen-windows7\build\lib\pathlib.py", line 1395, in symlink_to
    self._accessor.symlink(target, self, target_is_directory)
OSError: [WinError 1314] A required privilege is not held by the client: 'D:\\cygwin\\home\\db3l\\buildarea\\3.x.bolen-windows7\\build\\build\\test_python_848\\test_python_worker_2032\\@test_2032_tmp\\fileA' -> 'D:\\cygwin\\home\\db3l\\buildarea\\3.x.bolen-windows7\\build\\build\\test_python_848\\test_python_worker_2032\\@test_2032_tmp\\dirA\\linkAA'

======================================================================
ERROR: test_symlink_to_not_implemented (test.test_pathlib.WindowsPathTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\cygwin\home\db3l\buildarea\3.x.bolen-windows7\build\lib\test\test_pathlib.py", line 2031, in test_symlink_to_not_implemented
    link.symlink_to(target)
  File "D:\cygwin\home\db3l\buildarea\3.x.bolen-windows7\build\lib\pathlib.py", line 1395, in symlink_to
    self._accessor.symlink(target, self, target_is_directory)
OSError: [WinError 1314] A required privilege is not held by the client: 'D:\\cygwin\\home\\db3l\\buildarea\\3.x.bolen-windows7\\build\\build\\test_python_848\\test_python_worker_2032\\@test_2032_tmp\\fileA' -> 'D:\\cygwin\\home\\db3l\\buildarea\\3.x.bolen-windows7\\build\\build\\test_python_848\\test_python_worker_2032\\@test_2032_tmp\\dirA\\linkAA'
msg356860 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-11-18 11:26
New changeset 59c80889ff3f74230a613732aacf93d4de1e0e04 by Victor Stinner in branch 'master':
Revert "bpo-38811: Check for presence of os.link method in pathlib. (GH-17170)" (#17219)
https://github.com/python/cpython/commit/59c80889ff3f74230a613732aacf93d4de1e0e04
msg358477 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-12-16 12:24
New changeset 092435e932dee1802784ec28f39454f50fdd879a by Victor Stinner (Toke Høiland-Jørgensen) in branch 'master':
bpo-38811: Check for presence of os.link method in pathlib (GH-17225)
https://github.com/python/cpython/commit/092435e932dee1802784ec28f39454f50fdd879a
msg358480 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-12-16 12:28
Thanks Toke Høiland-Jørgensen! I merged your fix.

I don't really get why the Debian/Ubuntu image on Travis CI didn't get os.link() function, but I'm not really intersted to dig into this question. It's fine to simply skip the feature if it's not available, we do that in many places in Python.

I asked Toke Høiland-Jørgensen to revert his changes about os.symlink(): the pathlib code to handle missing os.symlink() seems to be broken, but it also seems like Python no longer support platforms without os.symlink(). Only old Windows version didn't support os.symlink(), but Python don't support these versions anymore.

I merged the os.link() change into master and made a 3.8 backport which will be merged automatically soon.

I close the issue.
msg358482 - (view) Author: miss-islington (miss-islington) Date: 2019-12-16 12:42
New changeset 8d0f36940e728989822c3789025b0813a8fe249a by Miss Islington (bot) in branch '3.8':
bpo-38811: Check for presence of os.link method in pathlib (GH-17225)
https://github.com/python/cpython/commit/8d0f36940e728989822c3789025b0813a8fe249a
msg358483 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-12-16 12:42
If someone cares about the missing os.symlink code path: please open a separated issue.
History
Date User Action Args
2019-12-16 12:42:56vstinnersetmessages: + msg358483
2019-12-16 12:42:24miss-islingtonsetnosy: + miss-islington
messages: + msg358482
2019-12-16 12:28:38vstinnersetstatus: open -> closed
versions: + Python 3.9
messages: + msg358480

resolution: fixed
stage: patch review -> resolved
2019-12-16 12:24:41miss-islingtonsetpull_requests: + pull_request17094
2019-12-16 12:24:00vstinnersetmessages: + msg358477
2019-11-18 12:32:06tohojosetpull_requests: + pull_request16726
2019-11-18 11:26:40vstinnersetmessages: + msg356860
2019-11-18 11:07:50vstinnersetnosy: + vstinner
messages: + msg356858
2019-11-18 11:05:36vstinnersetpull_requests: + pull_request16720
2019-11-17 17:07:14miss-islingtonsetpull_requests: + pull_request16710
2019-11-17 17:06:54serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg356818
2019-11-15 17:53:27tohojosetmessages: + msg356703
2019-11-15 17:24:33brett.cannonsetnosy: + brett.cannon
type: crash -> behavior
messages: + msg356696
2019-11-15 12:10:12tohojosetkeywords: + patch
stage: patch review
pull_requests: + pull_request16678
2019-11-15 12:04:34tohojocreate