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
9670543a
Kaydet (Commit)
9670543a
authored
Haz 09, 2013
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #18038: SyntaxError raised during compilation sources with illegal
encoding now always contains an encoding name.
üst
7dc4c033
3af14aab
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
7 deletions
+28
-7
test_pep263.py
Lib/test/test_pep263.py
+18
-0
NEWS
Misc/NEWS
+3
-0
tokenizer.c
Parser/tokenizer.c
+7
-7
No files found.
Lib/test/test_pep263.py
Dosyayı görüntüle @
9670543a
...
@@ -55,6 +55,24 @@ class PEP263Test(unittest.TestCase):
...
@@ -55,6 +55,24 @@ class PEP263Test(unittest.TestCase):
# two bytes in common with the UTF-8 BOM
# two bytes in common with the UTF-8 BOM
self
.
assertRaises
(
SyntaxError
,
eval
,
b
'
\xef\xbb\x20
'
)
self
.
assertRaises
(
SyntaxError
,
eval
,
b
'
\xef\xbb\x20
'
)
def
test_error_message
(
self
):
compile
(
b
'# -*- coding: iso-8859-15 -*-
\n
'
,
'dummy'
,
'exec'
)
compile
(
b
'
\xef\xbb\xbf\n
'
,
'dummy'
,
'exec'
)
compile
(
b
'
\xef\xbb\xbf
# -*- coding: utf-8 -*-
\n
'
,
'dummy'
,
'exec'
)
with
self
.
assertRaisesRegexp
(
SyntaxError
,
'fake'
):
compile
(
b
'# -*- coding: fake -*-
\n
'
,
'dummy'
,
'exec'
)
with
self
.
assertRaisesRegexp
(
SyntaxError
,
'iso-8859-15'
):
compile
(
b
'
\xef\xbb\xbf
# -*- coding: iso-8859-15 -*-
\n
'
,
'dummy'
,
'exec'
)
with
self
.
assertRaisesRegexp
(
SyntaxError
,
'BOM'
):
compile
(
b
'
\xef\xbb\xbf
# -*- coding: iso-8859-15 -*-
\n
'
,
'dummy'
,
'exec'
)
with
self
.
assertRaisesRegexp
(
SyntaxError
,
'fake'
):
compile
(
b
'
\xef\xbb\xbf
# -*- coding: fake -*-
\n
'
,
'dummy'
,
'exec'
)
with
self
.
assertRaisesRegexp
(
SyntaxError
,
'BOM'
):
compile
(
b
'
\xef\xbb\xbf
# -*- coding: fake -*-
\n
'
,
'dummy'
,
'exec'
)
def
test_main
():
def
test_main
():
support
.
run_unittest
(
PEP263Test
)
support
.
run_unittest
(
PEP263Test
)
...
...
Misc/NEWS
Dosyayı görüntüle @
9670543a
...
@@ -10,6 +10,9 @@ What's New in Python 3.4.0 Alpha 1?
...
@@ -10,6 +10,9 @@ What's New in Python 3.4.0 Alpha 1?
Core and Builtins
Core and Builtins
-----------------
-----------------
- Issue #18038: SyntaxError raised during compilation sources with illegal
encoding now always contains an encoding name.
- Issue #17931: Resolve confusion on Windows between pids and process
- Issue #17931: Resolve confusion on Windows between pids and process
handles.
handles.
...
...
Parser/tokenizer.c
Dosyayı görüntüle @
9670543a
...
@@ -291,20 +291,20 @@ check_coding_spec(const char* line, Py_ssize_t size, struct tok_state *tok,
...
@@ -291,20 +291,20 @@ check_coding_spec(const char* line, Py_ssize_t size, struct tok_state *tok,
tok
->
encoding
=
cs
;
tok
->
encoding
=
cs
;
tok
->
decoding_state
=
STATE_NORMAL
;
tok
->
decoding_state
=
STATE_NORMAL
;
}
}
else
else
{
PyErr_Format
(
PyExc_SyntaxError
,
"encoding problem: %s"
,
cs
);
PyMem_FREE
(
cs
);
PyMem_FREE
(
cs
);
}
}
}
}
else
{
/* then, compare cs with BOM */
}
else
{
/* then, compare cs with BOM */
r
=
(
strcmp
(
tok
->
encoding
,
cs
)
==
0
);
r
=
(
strcmp
(
tok
->
encoding
,
cs
)
==
0
);
if
(
!
r
)
PyErr_Format
(
PyExc_SyntaxError
,
"encoding problem: %s with BOM"
,
cs
);
PyMem_FREE
(
cs
);
PyMem_FREE
(
cs
);
}
}
}
}
if
(
!
r
)
{
cs
=
tok
->
encoding
;
if
(
!
cs
)
cs
=
"with BOM"
;
PyErr_Format
(
PyExc_SyntaxError
,
"encoding problem: %s"
,
cs
);
}
return
r
;
return
r
;
}
}
...
...
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