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
6baded49
Kaydet (Commit)
6baded49
authored
May 17, 2010
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #6697: Fix a crash if code of "python -c code" contains surrogates
üst
f155f1f4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
4 deletions
+26
-4
test_sys.py
Lib/test/test_sys.py
+18
-0
main.c
Modules/main.c
+8
-4
No files found.
Lib/test/test_sys.py
Dosyayı görüntüle @
6baded49
...
...
@@ -449,6 +449,24 @@ class SysModuleTest(unittest.TestCase):
self
.
assertRaises
(
TypeError
,
sys
.
intern
,
S
(
"abc"
))
def
test_main_invalid_unicode
(
self
):
import
locale
non_decodable
=
b
"
\xff
"
encoding
=
locale
.
getpreferredencoding
()
try
:
non_decodable
.
decode
(
encoding
)
except
UnicodeDecodeError
:
pass
else
:
self
.
skipTest
(
'
%
r is decodable with encoding
%
s'
%
(
non_decodable
,
encoding
))
code
=
b
'print("'
+
non_decodable
+
b
'")'
p
=
subprocess
.
Popen
([
sys
.
executable
,
"-c"
,
code
],
stderr
=
subprocess
.
PIPE
)
stdout
,
stderr
=
p
.
communicate
()
self
.
assertEqual
(
p
.
returncode
,
1
)
self
.
assert_
(
stderr
.
startswith
(
b
"UnicodeEncodeError: "
b
"'utf-8' codec can't encode character '
\\
udcff' in "
b
"position 7: surrogates not allowed"
),
stderr
)
def
test_sys_flags
(
self
):
self
.
assertTrue
(
sys
.
flags
)
...
...
Modules/main.c
Dosyayı görüntüle @
6baded49
...
...
@@ -563,18 +563,22 @@ Py_Main(int argc, wchar_t **argv)
}
if
(
command
)
{
char
*
commandStr
;
PyObject
*
commandObj
=
PyUnicode_FromWideChar
(
command
,
wcslen
(
command
));
free
(
command
);
if
(
commandObj
!=
NULL
)
{
sts
=
PyRun_SimpleStringFlags
(
_PyUnicode_AsString
(
commandObj
),
&
cf
)
!=
0
;
if
(
commandObj
!=
NULL
)
commandStr
=
_PyUnicode_AsString
(
commandObj
);
else
commandStr
=
NULL
;
if
(
commandStr
!=
NULL
)
{
sts
=
PyRun_SimpleStringFlags
(
commandStr
,
&
cf
)
!=
0
;
Py_DECREF
(
commandObj
);
}
else
{
PyErr_Print
();
sts
=
1
;
}
Py_DECREF
(
commandObj
);
}
else
if
(
module
)
{
sts
=
RunModule
(
module
,
1
);
}
...
...
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