Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
fd6e6cfa
Kaydet (Commit)
fd6e6cfa
authored
Şub 11, 2013
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Raise KeyError instead of OverflowError when getpwuid's argument is out of
uid_t range.
üst
64634eb3
55e22382
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
test_pwd.py
Lib/test/test_pwd.py
+9
-0
pwdmodule.c
Modules/pwdmodule.c
+5
-1
No files found.
Lib/test/test_pwd.py
Dosyayı görüntüle @
fd6e6cfa
...
...
@@ -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
)
...
...
Modules/pwdmodule.c
Dosyayı görüntüle @
fd6e6cfa
...
...
@@ -106,8 +106,12 @@ pwd_getpwuid(PyObject *self, PyObject *args)
{
uid_t
uid
;
struct
passwd
*
p
;
if
(
!
PyArg_ParseTuple
(
args
,
"O&:getpwuid"
,
_Py_Uid_Converter
,
&
uid
))
if
(
!
PyArg_ParseTuple
(
args
,
"O&:getpwuid"
,
_Py_Uid_Converter
,
&
uid
))
{
if
(
PyErr_ExceptionMatches
(
PyExc_OverflowError
))
PyErr_Format
(
PyExc_KeyError
,
"getpwuid(): uid not found"
);
return
NULL
;
}
if
((
p
=
getpwuid
(
uid
))
==
NULL
)
{
PyObject
*
uid_obj
=
_PyLong_FromUid
(
uid
);
if
(
uid_obj
==
NULL
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment