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
338ef7d2
Kaydet (Commit)
338ef7d2
authored
Mar 31, 2006
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Bug #1445068: getpass.getpass() can now be given an explicit stream
argument to specify where to write the prompt.
üst
22ec80bc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
12 deletions
+24
-12
libgetpass.tex
Doc/lib/libgetpass.tex
+6
-2
getpass.py
Lib/getpass.py
+15
-10
NEWS
Misc/NEWS
+3
-0
No files found.
Doc/lib/libgetpass.tex
Dosyayı görüntüle @
338ef7d2
...
...
@@ -11,11 +11,15 @@
The
\module
{
getpass
}
module provides two functions:
\begin{funcdesc}
{
getpass
}{
\optional
{
prompt
}}
\begin{funcdesc}
{
getpass
}{
\optional
{
prompt
\optional
{
, stream
}
}}
Prompt the user for a password without echoing. The user is
prompted using the string
\var
{
prompt
}
, which defaults to
\code
{
'Password: '
}
.
\code
{
'Password: '
}
. On
\UNIX
, the prompt is written to the
file-like object
\var
{
stream
}
, which defaults to
\code
{
sys.stdout
}
(this argument is ignored on Windows).
Availability: Macintosh,
\UNIX
, Windows.
\versionadded
[The \var{stream} parameter]
{
2.5
}
\end{funcdesc}
...
...
Lib/getpass.py
Dosyayı görüntüle @
338ef7d2
...
...
@@ -15,11 +15,14 @@ import sys
__all__
=
[
"getpass"
,
"getuser"
]
def
unix_getpass
(
prompt
=
'Password: '
):
def
unix_getpass
(
prompt
=
'Password: '
,
stream
=
None
):
"""Prompt for a password, with echo turned off.
The prompt is written on stream, by default stdout.
Restore terminal settings at end.
"""
if
stream
is
None
:
stream
=
sys
.
stdout
try
:
fd
=
sys
.
stdin
.
fileno
()
...
...
@@ -32,18 +35,18 @@ def unix_getpass(prompt='Password: '):
new
[
3
]
=
new
[
3
]
&
~
termios
.
ECHO
# 3 == 'lflags'
try
:
termios
.
tcsetattr
(
fd
,
termios
.
TCSADRAIN
,
new
)
passwd
=
_raw_input
(
prompt
)
passwd
=
_raw_input
(
prompt
,
stream
)
finally
:
termios
.
tcsetattr
(
fd
,
termios
.
TCSADRAIN
,
old
)
s
ys
.
stdout
.
write
(
'
\n
'
)
s
tream
.
write
(
'
\n
'
)
return
passwd
def
win_getpass
(
prompt
=
'Password: '
):
def
win_getpass
(
prompt
=
'Password: '
,
stream
=
None
):
"""Prompt for password with echo off, using Windows getch()."""
if
sys
.
stdin
is
not
sys
.
__stdin__
:
return
default_getpass
(
prompt
)
return
default_getpass
(
prompt
,
stream
)
import
msvcrt
for
c
in
prompt
:
msvcrt
.
putch
(
c
)
...
...
@@ -63,17 +66,19 @@ def win_getpass(prompt='Password: '):
return
pw
def
default_getpass
(
prompt
=
'Password: '
):
print
"Warning: Problem with getpass. Passwords may be echoed."
return
_raw_input
(
prompt
)
def
default_getpass
(
prompt
=
'Password: '
,
stream
=
None
):
print
>>
sys
.
stderr
,
"Warning: Problem with getpass. Passwords may be echoed."
return
_raw_input
(
prompt
,
stream
)
def
_raw_input
(
prompt
=
""
):
def
_raw_input
(
prompt
=
""
,
stream
=
None
):
# A raw_input() replacement that doesn't save the string in the
# GNU readline history.
if
stream
is
None
:
stream
=
sys
.
stdout
prompt
=
str
(
prompt
)
if
prompt
:
s
ys
.
stdout
.
write
(
prompt
)
s
tream
.
write
(
prompt
)
line
=
sys
.
stdin
.
readline
()
if
not
line
:
raise
EOFError
...
...
Misc/NEWS
Dosyayı görüntüle @
338ef7d2
...
...
@@ -487,6 +487,9 @@ Extension Modules
Library
-------
- Bug #1445068: getpass.getpass() can now be given an explicit stream
argument to specify where to write the prompt.
- Patch #1462313, bug #1443328: the pickle modules now can handle classes
that have __private names in their __slots__.
...
...
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