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
b46edf35
Kaydet (Commit)
b46edf35
authored
Ara 19, 2016
tarafından
Martin Panter
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #25677: Merge SyntaxError caret positioning from 3.6
üst
932ee731
619555d7
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
5 deletions
+39
-5
test_cmd_line_script.py
Lib/test/test_cmd_line_script.py
+33
-0
ACKS
Misc/ACKS
+1
-0
NEWS
Misc/NEWS
+3
-0
errors.c
Python/errors.c
+1
-4
pythonrun.c
Python/pythonrun.c
+1
-1
No files found.
Lib/test/test_cmd_line_script.py
Dosyayı görüntüle @
b46edf35
...
...
@@ -10,6 +10,7 @@ import os
import
os.path
import
py_compile
import
subprocess
import
io
import
textwrap
from
test
import
support
...
...
@@ -539,6 +540,38 @@ class CmdLineTest(unittest.TestCase):
text
=
stderr
.
decode
(
'ascii'
)
self
.
assertEqual
(
text
,
"some text"
)
def
test_syntaxerror_unindented_caret_position
(
self
):
script
=
"1 + 1 = 2
\n
"
with
support
.
temp_dir
()
as
script_dir
:
script_name
=
_make_test_script
(
script_dir
,
'script'
,
script
)
exitcode
,
stdout
,
stderr
=
assert_python_failure
(
script_name
)
text
=
io
.
TextIOWrapper
(
io
.
BytesIO
(
stderr
),
'ascii'
)
.
read
()
# Confirm that the caret is located under the first 1 character
self
.
assertIn
(
"
\n
1 + 1 = 2
\n
^"
,
text
)
def
test_syntaxerror_indented_caret_position
(
self
):
script
=
textwrap
.
dedent
(
"""
\
if True:
1 + 1 = 2
"""
)
with
support
.
temp_dir
()
as
script_dir
:
script_name
=
_make_test_script
(
script_dir
,
'script'
,
script
)
exitcode
,
stdout
,
stderr
=
assert_python_failure
(
script_name
)
text
=
io
.
TextIOWrapper
(
io
.
BytesIO
(
stderr
),
'ascii'
)
.
read
()
# Confirm that the caret is located under the first 1 character
self
.
assertIn
(
"
\n
1 + 1 = 2
\n
^"
,
text
)
# Try the same with a form feed at the start of the indented line
script
=
(
"if True:
\n
"
"
\f
1 + 1 = 2
\n
"
)
script_name
=
_make_test_script
(
script_dir
,
"script"
,
script
)
exitcode
,
stdout
,
stderr
=
assert_python_failure
(
script_name
)
text
=
io
.
TextIOWrapper
(
io
.
BytesIO
(
stderr
),
"ascii"
)
.
read
()
self
.
assertNotIn
(
"
\f
"
,
text
)
self
.
assertIn
(
"
\n
1 + 1 = 2
\n
^"
,
text
)
def
test_main
():
support
.
run_unittest
(
CmdLineTest
)
...
...
Misc/ACKS
Dosyayı görüntüle @
b46edf35
...
...
@@ -852,6 +852,7 @@ Julia Lawall
Chris Lawrence
Mark Lawrence
Chris Laws
Michael Layzell
Michael Lazar
Brian Leair
Mathieu Leduc-Hamel
...
...
Misc/NEWS
Dosyayı görüntüle @
b46edf35
...
...
@@ -10,6 +10,9 @@ What's New in Python 3.7.0 alpha 1
Core and Builtins
-----------------
- Issue #25677: Correct the positioning of the syntax error caret for
indented blocks. Based on patch by Michael Layzell.
- Issue #29000: Fixed bytes formatting of octals with zero padding in alternate
form.
...
...
Python/errors.c
Dosyayı görüntüle @
b46edf35
...
...
@@ -1138,11 +1138,8 @@ err_programtext(FILE *fp, int lineno)
}
fclose
(
fp
);
if
(
i
==
lineno
)
{
char
*
p
=
linebuf
;
PyObject
*
res
;
while
(
*
p
==
' '
||
*
p
==
'\t'
||
*
p
==
'\014'
)
p
++
;
res
=
PyUnicode_FromString
(
p
);
res
=
PyUnicode_FromString
(
linebuf
);
if
(
res
==
NULL
)
PyErr_Clear
();
return
res
;
...
...
Python/pythonrun.c
Dosyayı görüntüle @
b46edf35
...
...
@@ -528,7 +528,7 @@ print_error_text(PyObject *f, int offset, PyObject *text_obj)
offset
-=
(
int
)(
nl
+
1
-
text
);
text
=
nl
+
1
;
}
while
(
*
text
==
' '
||
*
text
==
'\t'
)
{
while
(
*
text
==
' '
||
*
text
==
'\t'
||
*
text
==
'\f'
)
{
text
++
;
offset
--
;
}
...
...
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