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
b6a748b8
Kaydet (Commit)
b6a748b8
authored
May 29, 2009
tarafından
Martin v. Löwis
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #4859: Implement PEP 383 for pwd, spwd, and grp.
üst
c15bdef8
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
26 deletions
+61
-26
ACKS
Misc/ACKS
+1
-0
NEWS
Misc/NEWS
+2
-0
grpmodule.c
Modules/grpmodule.c
+21
-15
pwdmodule.c
Modules/pwdmodule.c
+17
-5
spwdmodule.c
Modules/spwdmodule.c
+20
-6
No files found.
Misc/ACKS
Dosyayı görüntüle @
b6a748b8
...
...
@@ -766,6 +766,7 @@ Greg Ward
Barry Warsaw
Steve Waterbury
Bob Watson
David Watson
Aaron Watters
Henrik Weber
Corran Webster
...
...
Misc/NEWS
Dosyayı görüntüle @
b6a748b8
...
...
@@ -40,6 +40,8 @@ Core and Builtins
Library
-------
- Issue #4859: Implement PEP 383 for pwd, spwd, and grp.
- smtplib 'login' and 'cram-md5' login are also fixed (see Issue #5259).
- Issue #6121: pydoc now ignores leading and trailing spaces in the
...
...
Modules/grpmodule.c
Dosyayı görüntüle @
b6a748b8
...
...
@@ -46,8 +46,11 @@ mkgrent(struct group *p)
Py_DECREF
(
v
);
return
NULL
;
}
#define FSDECODE(val) PyUnicode_Decode(val, strlen(val),\
Py_FileSystemDefaultEncoding,\
"surrogateescape")
for
(
member
=
p
->
gr_mem
;
*
member
!=
NULL
;
member
++
)
{
PyObject
*
x
=
PyUnicode_FromString
(
*
member
);
PyObject
*
x
=
FSDECODE
(
*
member
);
if
(
x
==
NULL
||
PyList_Append
(
w
,
x
)
!=
0
)
{
Py_XDECREF
(
x
);
Py_DECREF
(
w
);
...
...
@@ -58,13 +61,13 @@ mkgrent(struct group *p)
}
#define SET(i,val) PyStructSequence_SET_ITEM(v, i, val)
SET
(
setIndex
++
,
PyUnicode_FromString
(
p
->
gr_name
));
SET
(
setIndex
++
,
FSDECODE
(
p
->
gr_name
));
#ifdef __VMS
SET
(
setIndex
++
,
Py_None
);
Py_INCREF
(
Py_None
);
#else
if
(
p
->
gr_passwd
)
SET
(
setIndex
++
,
PyUnicode_FromString
(
p
->
gr_passwd
));
SET
(
setIndex
++
,
FSDECODE
(
p
->
gr_passwd
));
else
{
SET
(
setIndex
++
,
Py_None
);
Py_INCREF
(
Py_None
);
...
...
@@ -104,25 +107,28 @@ grp_getgrgid(PyObject *self, PyObject *pyo_id)
}
static
PyObject
*
grp_getgrnam
(
PyObject
*
self
,
PyObject
*
pyo_name
)
grp_getgrnam
(
PyObject
*
self
,
PyObject
*
args
)
{
PyObject
*
py_str_name
;
char
*
name
;
struct
group
*
p
;
PyObject
*
arg
,
*
bytes
,
*
retval
=
NULL
;
py_str_name
=
PyObject_Str
(
pyo_name
);
if
(
!
py_str_name
)
return
NULL
;
name
=
_PyUnicode_AsString
(
py_str_name
);
if
(
!
PyArg_ParseTuple
(
args
,
"U:getgrnam"
,
&
arg
))
return
NULL
;
if
((
bytes
=
PyUnicode_AsEncodedString
(
arg
,
Py_FileSystemDefaultEncoding
,
"surrogateescape"
))
==
NULL
)
return
NULL
;
if
(
PyBytes_AsStringAndSize
(
bytes
,
&
name
,
NULL
)
==
-
1
)
goto
out
;
if
((
p
=
getgrnam
(
name
))
==
NULL
)
{
PyErr_Format
(
PyExc_KeyError
,
"getgrnam(): name not found: %s"
,
name
);
Py_DECREF
(
py_str_name
);
return
NULL
;
goto
out
;
}
Py_DECREF
(
py_str_name
);
return
mkgrent
(
p
);
retval
=
mkgrent
(
p
);
out:
Py_DECREF
(
bytes
);
return
retval
;
}
static
PyObject
*
...
...
@@ -152,7 +158,7 @@ static PyMethodDef grp_methods[] = {
"getgrgid(id) -> tuple
\n
\
Return the group database entry for the given numeric group ID. If
\n
\
id is not valid, raise KeyError."
},
{
"getgrnam"
,
grp_getgrnam
,
METH_
O
,
{
"getgrnam"
,
grp_getgrnam
,
METH_
VARARGS
,
"getgrnam(name) -> tuple
\n
\
Return the group database entry for the given group name. If
\n
\
name is not valid, raise KeyError."
},
...
...
Modules/pwdmodule.c
Dosyayı görüntüle @
b6a748b8
...
...
@@ -49,8 +49,9 @@ static void
sets
(
PyObject
*
v
,
int
i
,
const
char
*
val
)
{
if
(
val
)
{
PyObject
*
o
=
PyUnicode_DecodeUnicodeEscape
(
val
,
strlen
(
val
),
"strict"
);
PyObject
*
o
=
PyUnicode_Decode
(
val
,
strlen
(
val
),
Py_FileSystemDefaultEncoding
,
"surrogateescape"
);
PyStructSequence_SET_ITEM
(
v
,
i
,
o
);
}
else
{
...
...
@@ -129,14 +130,25 @@ pwd_getpwnam(PyObject *self, PyObject *args)
{
char
*
name
;
struct
passwd
*
p
;
if
(
!
PyArg_ParseTuple
(
args
,
"s:getpwnam"
,
&
name
))
PyObject
*
arg
,
*
bytes
,
*
retval
=
NULL
;
if
(
!
PyArg_ParseTuple
(
args
,
"U:getpwnam"
,
&
arg
))
return
NULL
;
if
((
bytes
=
PyUnicode_AsEncodedString
(
arg
,
Py_FileSystemDefaultEncoding
,
"surrogateescape"
))
==
NULL
)
return
NULL
;
if
(
PyBytes_AsStringAndSize
(
bytes
,
&
name
,
NULL
)
==
-
1
)
goto
out
;
if
((
p
=
getpwnam
(
name
))
==
NULL
)
{
PyErr_Format
(
PyExc_KeyError
,
"getpwnam(): name not found: %s"
,
name
);
return
NULL
;
goto
out
;
}
return
mkpwent
(
p
);
retval
=
mkpwent
(
p
);
out:
Py_DECREF
(
bytes
);
return
retval
;
}
#ifdef HAVE_GETPWENT
...
...
Modules/spwdmodule.c
Dosyayı görüntüle @
b6a748b8
...
...
@@ -59,9 +59,12 @@ static PyTypeObject StructSpwdType;
static
void
sets
(
PyObject
*
v
,
int
i
,
const
char
*
val
)
{
if
(
val
)
PyStructSequence_SET_ITEM
(
v
,
i
,
PyUnicode_FromString
(
val
));
else
{
if
(
val
)
{
PyObject
*
o
=
PyUnicode_Decode
(
val
,
strlen
(
val
),
Py_FileSystemDefaultEncoding
,
"surrogateescape"
);
PyStructSequence_SET_ITEM
(
v
,
i
,
o
);
}
else
{
PyStructSequence_SET_ITEM
(
v
,
i
,
Py_None
);
Py_INCREF
(
Py_None
);
}
...
...
@@ -113,13 +116,24 @@ static PyObject* spwd_getspnam(PyObject *self, PyObject *args)
{
char
*
name
;
struct
spwd
*
p
;
if
(
!
PyArg_ParseTuple
(
args
,
"s:getspnam"
,
&
name
))
PyObject
*
arg
,
*
bytes
,
*
retval
=
NULL
;
if
(
!
PyArg_ParseTuple
(
args
,
"U:getspnam"
,
&
arg
))
return
NULL
;
if
((
bytes
=
PyUnicode_AsEncodedString
(
arg
,
Py_FileSystemDefaultEncoding
,
"surrogateescape"
))
==
NULL
)
return
NULL
;
if
(
PyBytes_AsStringAndSize
(
bytes
,
&
name
,
NULL
)
==
-
1
)
goto
out
;
if
((
p
=
getspnam
(
name
))
==
NULL
)
{
PyErr_SetString
(
PyExc_KeyError
,
"getspnam(): name not found"
);
return
NULL
;
goto
out
;
}
return
mkspent
(
p
);
retval
=
mkspent
(
p
);
out:
Py_DECREF
(
bytes
);
return
retval
;
}
#endif
/* HAVE_GETSPNAM */
...
...
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