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
a48f3ab8
Kaydet (Commit)
a48f3ab8
authored
Mar 30, 2008
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Patch #2511: Give the "excepthandler" AST item proper attributes by making it a Sum.
üst
c15317ef
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
25 deletions
+29
-25
Python-ast.h
Include/Python-ast.h
+12
-5
Python.asdl
Parser/Python.asdl
+2
-5
Python-ast.c
Python/Python-ast.c
+0
-0
ast.c
Python/ast.c
+3
-3
compile.c
Python/compile.c
+7
-7
symtable.c
Python/symtable.c
+5
-5
No files found.
Include/Python-ast.h
Dosyayı görüntüle @
a48f3ab8
...
...
@@ -324,10 +324,17 @@ struct _comprehension {
asdl_seq
*
ifs
;
};
enum
_excepthandler_kind
{
ExceptHandler_kind
=
1
};
struct
_excepthandler
{
expr_ty
type
;
expr_ty
name
;
asdl_seq
*
body
;
enum
_excepthandler_kind
kind
;
union
{
struct
{
expr_ty
type
;
expr_ty
name
;
asdl_seq
*
body
;
}
ExceptHandler
;
}
v
;
int
lineno
;
int
col_offset
;
};
...
...
@@ -489,8 +496,8 @@ slice_ty _Py_Index(expr_ty value, PyArena *arena);
#define comprehension(a0, a1, a2, a3) _Py_comprehension(a0, a1, a2, a3)
comprehension_ty
_Py_comprehension
(
expr_ty
target
,
expr_ty
iter
,
asdl_seq
*
ifs
,
PyArena
*
arena
);
#define
excepthandler(a0, a1, a2, a3, a4, a5) _Py_excepth
andler(a0, a1, a2, a3, a4, a5)
excepthandler_ty
_Py_
excepth
andler
(
expr_ty
type
,
expr_ty
name
,
asdl_seq
*
body
,
#define
ExceptHandler(a0, a1, a2, a3, a4, a5) _Py_ExceptH
andler(a0, a1, a2, a3, a4, a5)
excepthandler_ty
_Py_
ExceptH
andler
(
expr_ty
type
,
expr_ty
name
,
asdl_seq
*
body
,
int
lineno
,
int
col_offset
,
PyArena
*
arena
);
#define arguments(a0, a1, a2, a3, a4) _Py_arguments(a0, a1, a2, a3, a4)
arguments_ty
_Py_arguments
(
asdl_seq
*
args
,
identifier
vararg
,
identifier
...
...
Parser/Python.asdl
Dosyayı görüntüle @
a48f3ab8
...
...
@@ -98,11 +98,8 @@ module Python version "$Revision$"
comprehension = (expr target, expr iter, expr* ifs)
-- not sure what to call the first argument for raise and except
-- TODO(jhylton): Figure out if there is a better way to handle
-- lineno and col_offset fields, particularly when
-- ast is exposed to Python.
excepthandler = (expr? type, expr? name, stmt* body, int lineno,
int col_offset)
excepthandler = ExceptHandler(expr? type, expr? name, stmt* body)
attributes (int lineno, int col_offset)
arguments = (expr* args, identifier? vararg,
identifier? kwarg, expr* defaults)
...
...
Python/Python-ast.c
Dosyayı görüntüle @
a48f3ab8
This diff is collapsed.
Click to expand it.
Python/ast.c
Dosyayı görüntüle @
a48f3ab8
...
...
@@ -2830,7 +2830,7 @@ ast_for_except_clause(struct compiling *c, const node *exc, node *body)
if
(
!
suite_seq
)
return
NULL
;
return
excepth
andler
(
NULL
,
NULL
,
suite_seq
,
LINENO
(
exc
),
return
ExceptH
andler
(
NULL
,
NULL
,
suite_seq
,
LINENO
(
exc
),
exc
->
n_col_offset
,
c
->
c_arena
);
}
else
if
(
NCH
(
exc
)
==
2
)
{
...
...
@@ -2844,7 +2844,7 @@ ast_for_except_clause(struct compiling *c, const node *exc, node *body)
if
(
!
suite_seq
)
return
NULL
;
return
excepth
andler
(
expression
,
NULL
,
suite_seq
,
LINENO
(
exc
),
return
ExceptH
andler
(
expression
,
NULL
,
suite_seq
,
LINENO
(
exc
),
exc
->
n_col_offset
,
c
->
c_arena
);
}
else
if
(
NCH
(
exc
)
==
4
)
{
...
...
@@ -2862,7 +2862,7 @@ ast_for_except_clause(struct compiling *c, const node *exc, node *body)
if
(
!
suite_seq
)
return
NULL
;
return
excepth
andler
(
expression
,
e
,
suite_seq
,
LINENO
(
exc
),
return
ExceptH
andler
(
expression
,
e
,
suite_seq
,
LINENO
(
exc
),
exc
->
n_col_offset
,
c
->
c_arena
);
}
...
...
Python/compile.c
Dosyayı görüntüle @
a48f3ab8
...
...
@@ -1855,32 +1855,32 @@ compiler_try_except(struct compiler *c, stmt_ty s)
for
(
i
=
0
;
i
<
n
;
i
++
)
{
excepthandler_ty
handler
=
(
excepthandler_ty
)
asdl_seq_GET
(
s
->
v
.
TryExcept
.
handlers
,
i
);
if
(
!
handler
->
type
&&
i
<
n
-
1
)
if
(
!
handler
->
v
.
ExceptHandler
.
type
&&
i
<
n
-
1
)
return
compiler_error
(
c
,
"default 'except:' must be last"
);
c
->
u
->
u_lineno_set
=
false
;
c
->
u
->
u_lineno
=
handler
->
lineno
;
except
=
compiler_new_block
(
c
);
if
(
except
==
NULL
)
return
0
;
if
(
handler
->
type
)
{
if
(
handler
->
v
.
ExceptHandler
.
type
)
{
ADDOP
(
c
,
DUP_TOP
);
VISIT
(
c
,
expr
,
handler
->
type
);
VISIT
(
c
,
expr
,
handler
->
v
.
ExceptHandler
.
type
);
ADDOP_I
(
c
,
COMPARE_OP
,
PyCmp_EXC_MATCH
);
ADDOP_JREL
(
c
,
JUMP_IF_FALSE
,
except
);
ADDOP
(
c
,
POP_TOP
);
}
ADDOP
(
c
,
POP_TOP
);
if
(
handler
->
name
)
{
VISIT
(
c
,
expr
,
handler
->
name
);
if
(
handler
->
v
.
ExceptHandler
.
name
)
{
VISIT
(
c
,
expr
,
handler
->
v
.
ExceptHandler
.
name
);
}
else
{
ADDOP
(
c
,
POP_TOP
);
}
ADDOP
(
c
,
POP_TOP
);
VISIT_SEQ
(
c
,
stmt
,
handler
->
body
);
VISIT_SEQ
(
c
,
stmt
,
handler
->
v
.
ExceptHandler
.
body
);
ADDOP_JREL
(
c
,
JUMP_FORWARD
,
end
);
compiler_use_next_block
(
c
,
except
);
if
(
handler
->
type
)
if
(
handler
->
v
.
ExceptHandler
.
type
)
ADDOP
(
c
,
POP_TOP
);
}
ADDOP
(
c
,
END_FINALLY
);
...
...
Python/symtable.c
Dosyayı görüntüle @
a48f3ab8
...
...
@@ -1308,11 +1308,11 @@ symtable_visit_arguments(struct symtable *st, arguments_ty a)
static
int
symtable_visit_excepthandler
(
struct
symtable
*
st
,
excepthandler_ty
eh
)
{
if
(
eh
->
type
)
VISIT
(
st
,
expr
,
eh
->
type
);
if
(
eh
->
name
)
VISIT
(
st
,
expr
,
eh
->
name
);
VISIT_SEQ
(
st
,
stmt
,
eh
->
body
);
if
(
eh
->
v
.
ExceptHandler
.
type
)
VISIT
(
st
,
expr
,
eh
->
v
.
ExceptHandler
.
type
);
if
(
eh
->
v
.
ExceptHandler
.
name
)
VISIT
(
st
,
expr
,
eh
->
v
.
ExceptHandler
.
name
);
VISIT_SEQ
(
st
,
stmt
,
eh
->
v
.
ExceptHandler
.
body
);
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