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
2d6acd2a
Kaydet (Commit)
2d6acd2a
authored
Mar 16, 2013
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
reject non-docs strings between future imports (closes #17434)
üst
694bafa0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
11 deletions
+28
-11
badsyntax_future10.py
Lib/test/badsyntax_future10.py
+3
-0
test_future.py
Lib/test/test_future.py
+8
-0
NEWS
Misc/NEWS
+3
-0
future.c
Python/future.c
+14
-11
No files found.
Lib/test/badsyntax_future10.py
0 → 100644
Dosyayı görüntüle @
2d6acd2a
from
__future__
import
absolute_import
"spam, bar, blah"
from
__future__
import
print_function
Lib/test/test_future.py
Dosyayı görüntüle @
2d6acd2a
...
...
@@ -82,6 +82,14 @@ class FutureTest(unittest.TestCase):
else
:
self
.
fail
(
"expected exception didn't occur"
)
def
test_badfuture10
(
self
):
try
:
from
test
import
badsyntax_future10
except
SyntaxError
as
msg
:
self
.
assertEqual
(
get_error_location
(
msg
),
(
"badsyntax_future10"
,
'3'
))
else
:
self
.
fail
(
"expected exception didn't occur"
)
def
test_parserhack
(
self
):
# test that the parser.c::future_hack function works as expected
# Note: although this test must pass, it's not testing the original
...
...
Misc/NEWS
Dosyayı görüntüle @
2d6acd2a
...
...
@@ -10,6 +10,9 @@ What's New in Python 3.4.0 Alpha 1?
Core and Builtins
-----------------
- Issue #17434: Properly raise a SyntaxError when a string occurs between future
imports.
- Issue #17117: Import and @importlib.util.set_loader now set __loader__ when
it has a value of None or the attribute doesn'
t
exist
.
...
...
Python/future.c
Dosyayı görüntüle @
2d6acd2a
...
...
@@ -58,11 +58,14 @@ future_check_features(PyFutureFeatures *ff, stmt_ty s, const char *filename)
static
int
future_parse
(
PyFutureFeatures
*
ff
,
mod_ty
mod
,
const
char
*
filename
)
{
int
i
,
found_docstring
=
0
,
done
=
0
,
prev_line
=
0
;
int
i
,
done
=
0
,
prev_line
=
0
;
if
(
!
(
mod
->
kind
==
Module_kind
||
mod
->
kind
==
Interactive_kind
))
return
1
;
if
(
asdl_seq_LEN
(
mod
->
v
.
Module
.
body
)
==
0
)
return
1
;
/* A subsequent pass will detect future imports that don't
appear at the beginning of the file. There's one case,
however, that is easier to handle here: A series of imports
...
...
@@ -71,8 +74,13 @@ future_parse(PyFutureFeatures *ff, mod_ty mod, const char *filename)
but is preceded by a regular import.
*/
i
=
0
;
stmt_ty
first
=
(
stmt_ty
)
asdl_seq_GET
(
mod
->
v
.
Module
.
body
,
i
);
if
(
first
->
kind
==
Expr_kind
&&
first
->
v
.
Expr
.
value
->
kind
==
Str_kind
)
i
++
;
for
(
i
=
0
;
i
<
asdl_seq_LEN
(
mod
->
v
.
Module
.
body
);
i
++
)
{
for
(;
i
<
asdl_seq_LEN
(
mod
->
v
.
Module
.
body
);
i
++
)
{
stmt_ty
s
=
(
stmt_ty
)
asdl_seq_GET
(
mod
->
v
.
Module
.
body
,
i
);
if
(
done
&&
s
->
lineno
>
prev_line
)
...
...
@@ -99,18 +107,13 @@ future_parse(PyFutureFeatures *ff, mod_ty mod, const char *filename)
return
0
;
ff
->
ff_lineno
=
s
->
lineno
;
}
else
else
{
done
=
1
;
}
}
else
if
(
s
->
kind
==
Expr_kind
&&
!
found_docstring
)
{
expr_ty
e
=
s
->
v
.
Expr
.
value
;
if
(
e
->
kind
!=
Str_kind
)
done
=
1
;
else
found_docstring
=
1
;
}
else
else
{
done
=
1
;
}
}
return
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