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
c078f929
Kaydet (Commit)
c078f929
authored
Kas 21, 2008
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
don't segfault when \N escapes are used and unicodedata fails to load
Fixes #4367
üst
d4294175
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
3 deletions
+30
-3
test_unicodedata.py
Lib/test/test_unicodedata.py
+25
-2
NEWS
Misc/NEWS
+3
-0
ast.c
Python/ast.c
+2
-1
No files found.
Lib/test/test_unicodedata.py
Dosyayı görüntüle @
c078f929
...
@@ -4,9 +4,13 @@
...
@@ -4,9 +4,13 @@
(c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
(c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
"""
#"
"""
import
unittest
,
test
.
test_support
import
sys
import
unittest
import
hashlib
import
hashlib
import
subprocess
import
test.test_support
encoding
=
'utf-8'
encoding
=
'utf-8'
...
@@ -196,6 +200,25 @@ class UnicodeFunctionsTest(UnicodeDatabaseTest):
...
@@ -196,6 +200,25 @@ class UnicodeFunctionsTest(UnicodeDatabaseTest):
class
UnicodeMiscTest
(
UnicodeDatabaseTest
):
class
UnicodeMiscTest
(
UnicodeDatabaseTest
):
def
test_failed_import_during_compiling
(
self
):
# Issue 4367
# Decoding \N escapes requires the unicodedata module. If it can't be
# imported, we shouldn't segfault.
# This program should raise a SyntaxError in the eval.
code
=
"import sys;"
\
"sys.modules['unicodedata'] = None;"
\
"""eval("u'
\N{SOFT HYPHEN}
'")"""
args
=
[
sys
.
executable
,
"-c"
,
code
]
# We use a subprocess because the unicodedata module may already have
# been loaded in this process.
popen
=
subprocess
.
Popen
(
args
,
stderr
=
subprocess
.
PIPE
)
popen
.
wait
()
self
.
assertEqual
(
popen
.
returncode
,
1
)
error
=
"SyntaxError: (unicode error)
\
N escapes not supported "
\
"(can't load unicodedata module)"
self
.
assertTrue
(
error
in
popen
.
stderr
.
read
())
def
test_decimal_numeric_consistent
(
self
):
def
test_decimal_numeric_consistent
(
self
):
# Test that decimal and numeric are consistent,
# Test that decimal and numeric are consistent,
# i.e. if a character has a decimal value,
# i.e. if a character has a decimal value,
...
...
Misc/NEWS
Dosyayı görüntüle @
c078f929
...
@@ -12,6 +12,9 @@ What's New in Python 2.7 alpha 1
...
@@ -12,6 +12,9 @@ What's New in Python 2.7 alpha 1
Core and Builtins
Core and Builtins
-----------------
-----------------
- Issue #4367: Python would segfault during compiling when the unicodedata
module couldn't be imported and \N escapes were present.
- Issue #4233: Changed semantic of ``_fileio.FileIO``'s ``close()``
- Issue #4233: Changed semantic of ``_fileio.FileIO``'s ``close()``
method on file objects with closefd=False. The file descriptor is still
method on file objects with closefd=False. The file descriptor is still
kept open but the file object behaves like a closed file. The ``FileIO``
kept open but the file object behaves like a closed file. The ``FileIO``
...
...
Python/ast.c
Dosyayı görüntüle @
c078f929
...
@@ -1294,13 +1294,14 @@ ast_for_atom(struct compiling *c, const node *n)
...
@@ -1294,13 +1294,14 @@ ast_for_atom(struct compiling *c, const node *n)
if
(
PyErr_ExceptionMatches
(
PyExc_UnicodeError
)){
if
(
PyErr_ExceptionMatches
(
PyExc_UnicodeError
)){
PyObject
*
type
,
*
value
,
*
tback
,
*
errstr
;
PyObject
*
type
,
*
value
,
*
tback
,
*
errstr
;
PyErr_Fetch
(
&
type
,
&
value
,
&
tback
);
PyErr_Fetch
(
&
type
,
&
value
,
&
tback
);
errstr
=
((
PyUnicodeErrorObject
*
)
value
)
->
reason
;
errstr
=
PyObject_Str
(
value
)
;
if
(
errstr
)
{
if
(
errstr
)
{
char
*
s
=
""
;
char
*
s
=
""
;
char
buf
[
128
];
char
buf
[
128
];
s
=
PyString_AsString
(
errstr
);
s
=
PyString_AsString
(
errstr
);
PyOS_snprintf
(
buf
,
sizeof
(
buf
),
"(unicode error) %s"
,
s
);
PyOS_snprintf
(
buf
,
sizeof
(
buf
),
"(unicode error) %s"
,
s
);
ast_error
(
n
,
buf
);
ast_error
(
n
,
buf
);
Py_DECREF
(
errstr
);
}
else
{
}
else
{
ast_error
(
n
,
"(unicode error) unknown error"
);
ast_error
(
n
,
"(unicode error) unknown error"
);
}
}
...
...
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