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
77736710
Kaydet (Commit)
77736710
authored
May 04, 2006
tarafından
Martin v. Löwis
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Patch #1475845: Raise IndentationError for unexpected indent.
üst
61d168a5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
3 deletions
+23
-3
test_syntax.py
Lib/test/test_syntax.py
+18
-2
NEWS
Misc/NEWS
+2
-0
parsetok.c
Parser/parsetok.c
+3
-1
No files found.
Lib/test/test_syntax.py
Dosyayı görüntüle @
77736710
...
@@ -243,15 +243,18 @@ from test import test_support
...
@@ -243,15 +243,18 @@ from test import test_support
class
SyntaxTestCase
(
unittest
.
TestCase
):
class
SyntaxTestCase
(
unittest
.
TestCase
):
def
_check_error
(
self
,
code
,
errtext
,
def
_check_error
(
self
,
code
,
errtext
,
filename
=
"<testcase>"
,
mode
=
"exec"
):
filename
=
"<testcase>"
,
mode
=
"exec"
,
subclass
=
None
):
"""Check that compiling code raises SyntaxError with errtext.
"""Check that compiling code raises SyntaxError with errtext.
errtest is a regular expression that must be present in the
errtest is a regular expression that must be present in the
test of the exception raised.
test of the exception raised. If subclass is specified it
is the expected subclass of SyntaxError (e.g. IndentationError).
"""
"""
try
:
try
:
compile
(
code
,
filename
,
mode
)
compile
(
code
,
filename
,
mode
)
except
SyntaxError
,
err
:
except
SyntaxError
,
err
:
if
subclass
and
not
isinstance
(
err
,
subclass
):
self
.
fail
(
"SyntaxError is not a
%
s"
%
subclass
.
__name__
)
mo
=
re
.
search
(
errtext
,
str
(
err
))
mo
=
re
.
search
(
errtext
,
str
(
err
))
if
mo
is
None
:
if
mo
is
None
:
self
.
fail
(
"SyntaxError did not contain '
%
r'"
%
(
errtext
,))
self
.
fail
(
"SyntaxError did not contain '
%
r'"
%
(
errtext
,))
...
@@ -290,6 +293,19 @@ class SyntaxTestCase(unittest.TestCase):
...
@@ -290,6 +293,19 @@ class SyntaxTestCase(unittest.TestCase):
:"""
)
:"""
)
self
.
_check_error
(
source
,
"nested scope"
)
self
.
_check_error
(
source
,
"nested scope"
)
def
test_unexpected_indent
(
self
):
self
.
_check_error
(
"foo()
\n
bar()
\n
"
,
"unexpected indent"
,
subclass
=
IndentationError
)
def
test_no_indent
(
self
):
self
.
_check_error
(
"if 1:
\n
foo()"
,
"expected an indented block"
,
subclass
=
IndentationError
)
def
test_bad_outdent
(
self
):
self
.
_check_error
(
"if 1:
\n
foo()
\n
bar()"
,
"unindent does not match .* level"
,
subclass
=
IndentationError
)
def
test_main
():
def
test_main
():
test_support
.
run_unittest
(
SyntaxTestCase
)
test_support
.
run_unittest
(
SyntaxTestCase
)
from
test
import
test_syntax
from
test
import
test_syntax
...
...
Misc/NEWS
Dosyayı görüntüle @
77736710
...
@@ -12,6 +12,8 @@ What's New in Python 2.5 alpha 2?
...
@@ -12,6 +12,8 @@ What's New in Python 2.5 alpha 2?
Core and builtins
Core and builtins
-----------------
-----------------
- Patch #1475845: Raise IndentationError for unexpected indent.
- Patch #1479181: split open() and file() from being aliases for each other.
- Patch #1479181: split open() and file() from being aliases for each other.
- Bug #1465834: '
bdist_wininst
preinstall
script
support
' was fixed
- Bug #1465834: '
bdist_wininst
preinstall
script
support
' was fixed
...
...
Parser/parsetok.c
Dosyayı görüntüle @
77736710
...
@@ -194,8 +194,10 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret,
...
@@ -194,8 +194,10 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret,
if
((
err_ret
->
error
=
if
((
err_ret
->
error
=
PyParser_AddToken
(
ps
,
(
int
)
type
,
str
,
tok
->
lineno
,
col_offset
,
PyParser_AddToken
(
ps
,
(
int
)
type
,
str
,
tok
->
lineno
,
col_offset
,
&
(
err_ret
->
expected
)))
!=
E_OK
)
{
&
(
err_ret
->
expected
)))
!=
E_OK
)
{
if
(
err_ret
->
error
!=
E_DONE
)
if
(
err_ret
->
error
!=
E_DONE
)
{
PyObject_FREE
(
str
);
PyObject_FREE
(
str
);
err_ret
->
token
=
type
;
}
break
;
break
;
}
}
}
}
...
...
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