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
09fff7a8
Kaydet (Commit)
09fff7a8
authored
Kas 05, 2010
tarafından
Hirokazu Yamamoto
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed socket_gethostname() on windows.
üst
9696088b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
socketmodule.c
Modules/socketmodule.c
+8
-5
No files found.
Modules/socketmodule.c
Dosyayı görüntüle @
09fff7a8
...
@@ -3097,17 +3097,20 @@ socket_gethostname(PyObject *self, PyObject *unused)
...
@@ -3097,17 +3097,20 @@ socket_gethostname(PyObject *self, PyObject *unused)
/* Don't use winsock's gethostname, as this returns the ANSI
/* Don't use winsock's gethostname, as this returns the ANSI
version of the hostname, whereas we need a Unicode string.
version of the hostname, whereas we need a Unicode string.
Otherwise, gethostname apparently also returns the DNS name. */
Otherwise, gethostname apparently also returns the DNS name. */
wchar_t
buf
[
MAX_COMPUTERNAME_LENGTH
];
wchar_t
buf
[
MAX_COMPUTERNAME_LENGTH
+
1
];
DWORD
size
=
sizeof
(
buf
);
DWORD
size
=
sizeof
(
buf
)
/
sizeof
(
wchar_t
);
PyObject
*
result
;
if
(
!
GetComputerNameExW
(
ComputerNamePhysicalDnsHostname
,
buf
,
&
size
))
{
if
(
!
GetComputerNameExW
(
ComputerNamePhysicalDnsHostname
,
buf
,
&
size
))
{
if
(
GetLastError
()
==
ERROR_MORE_DATA
)
{
if
(
GetLastError
()
==
ERROR_MORE_DATA
)
{
/* MSDN says this may occur "because DNS allows longer names */
/* MSDN says this may occur "because DNS allows longer names */
PyObject
*
result
=
PyUnicode_FromUnicode
(
NULL
,
size
);
if
(
size
==
0
)
/* XXX: I'm not sure how to handle this */
return
PyUnicode_FromUnicode
(
NULL
,
0
);
result
=
PyUnicode_FromUnicode
(
NULL
,
size
-
1
);
if
(
!
result
)
if
(
!
result
)
return
NULL
;
return
NULL
;
if
(
GetComputerName
(
ComputerNamePhysicalDnsHostname
,
if
(
GetComputerName
ExW
(
ComputerNamePhysicalDnsHostname
,
PyUnicode_AS_UNICODE
(
result
),
PyUnicode_AS_UNICODE
(
result
),
size
+
1
))
&
size
))
return
result
;
return
result
;
Py_DECREF
(
result
);
Py_DECREF
(
result
);
}
}
...
...
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