summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-02-11 18:32:47 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-02-11 18:32:47 (GMT)
commit55e2238272daf0a6b585cf6314abb9fdf768bbde (patch)
tree8d543e3fe04ce4b25ed75839c19449ed5db3ae86 /Lib
parent66383b2e0a47cebf31586a1038e85d37c9aefadc (diff)
downloadcpython-55e2238272daf0a6b585cf6314abb9fdf768bbde.zip
cpython-55e2238272daf0a6b585cf6314abb9fdf768bbde.tar.gz
cpython-55e2238272daf0a6b585cf6314abb9fdf768bbde.tar.bz2
Raise KeyError instead of OverflowError when getpwuid's argument is out of
uid_t range.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_pwd.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_pwd.py b/Lib/test/test_pwd.py
index ae1c8fe..aa8f69f 100644
--- a/Lib/test/test_pwd.py
+++ b/Lib/test/test_pwd.py
@@ -49,7 +49,9 @@ class PwdTest(unittest.TestCase):
def test_errors(self):
self.assertRaises(TypeError, pwd.getpwuid)
+ self.assertRaises(TypeError, pwd.getpwuid, 3.14)
self.assertRaises(TypeError, pwd.getpwnam)
+ self.assertRaises(TypeError, pwd.getpwnam, 42)
self.assertRaises(TypeError, pwd.getpwall, 42)
# try to get some errors
@@ -93,6 +95,13 @@ class PwdTest(unittest.TestCase):
self.assertNotIn(fakeuid, byuids)
self.assertRaises(KeyError, pwd.getpwuid, fakeuid)
+ # -1 shouldn't be a valid uid because it has a special meaning in many
+ # uid-related functions
+ self.assertRaises(KeyError, pwd.getpwuid, -1)
+ # should be out of uid_t range
+ self.assertRaises(KeyError, pwd.getpwuid, 2**128)
+ self.assertRaises(KeyError, pwd.getpwuid, -2**128)
+
def test_main():
support.run_unittest(PwdTest)