FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-149879: Fix test_tarfile on Cygwin by vstinner · Pull Request #149897 · python/cpython · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
12 changes: 10 additions & 2 deletions Lib/test/test_tarfile.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -3205,7 +3205,11 @@ def root_is_uid_gid_0():
import pwd, grp
except ImportError:
return False
if pwd.getpwuid(0)[0] != 'root':
try:
if pwd.getpwuid(0)[0] != 'root':
return False
except KeyError:
# On Cygwin, there is no root user (uid 0)
return False
if grp.getgrgid(0)[0] != 'root':
return False
Expand Down Expand Up @@ -3985,6 +3989,9 @@ def test_realpath_limit_attack(self):
check_flag=False)):
if sys.platform == 'win32':
self.expect_exception((FileNotFoundError, FileExistsError))
elif sys.platform == 'cygwin':
exc = self.expect_exception(OSError)
self.assertEqual(exc.errno, errno.ELOOP)
elif self.raised_exception:
# Cannot symlink/hardlink: tarfile falls back to getmember()
self.expect_exception(KeyError)
Expand All @@ -4006,7 +4013,8 @@ def test_realpath_limit_attack(self):
# 206: ERROR_FILENAME_EXCED_RANGE
self.assertIn(exc.winerror, (3, 5, 206))
else:
self.assertEqual(exc.errno, errno.ENAMETOOLONG)
self.assertIn(exc.errno,
(errno.ENAMETOOLONG, errno.ELOOP))

@symlink_test
def test_parent_symlink2(self):
Expand Down
Loading

Back | FazBrowse Home | New Git URL