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
013783c5
Kaydet (Commit)
013783c5
authored
Tem 20, 2010
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
move test_trace.py so as not to conflict with future tests for the trace module
üst
533a167a
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
31 additions
and
11 deletions
+31
-11
opcode.h
Include/opcode.h
+1
-0
symtable.h
Include/symtable.h
+1
-0
test_line_tracing.py
Lib/test/test_line_tracing.py
+0
-0
test_scope.py
Lib/test/test_scope.py
+8
-0
typeobject.c
Objects/typeobject.c
+1
-0
ceval.c
Python/ceval.c
+8
-8
compile.c
Python/compile.c
+3
-1
symtable.c
Python/symtable.c
+9
-2
No files found.
Include/opcode.h
Dosyayı görüntüle @
013783c5
...
@@ -123,6 +123,7 @@ extern "C" {
...
@@ -123,6 +123,7 @@ extern "C" {
#define LOAD_CLOSURE 135
/* Load free variable from closure */
#define LOAD_CLOSURE 135
/* Load free variable from closure */
#define LOAD_DEREF 136
/* Load and dereference from closure cell */
#define LOAD_DEREF 136
/* Load and dereference from closure cell */
#define STORE_DEREF 137
/* Store into cell */
#define STORE_DEREF 137
/* Store into cell */
#define LOAD_NAME_LOCAL_ONLY 138
/* The next 3 opcodes must be contiguous and satisfy
/* The next 3 opcodes must be contiguous and satisfy
(CALL_FUNCTION_VAR - CALL_FUNCTION) & 3 == 1 */
(CALL_FUNCTION_VAR - CALL_FUNCTION) & 3 == 1 */
...
...
Include/symtable.h
Dosyayı görüntüle @
013783c5
...
@@ -88,6 +88,7 @@ PyAPI_FUNC(void) PySymtable_Free(struct symtable *);
...
@@ -88,6 +88,7 @@ PyAPI_FUNC(void) PySymtable_Free(struct symtable *);
#define GLOBAL_IMPLICIT 3
#define GLOBAL_IMPLICIT 3
#define FREE 4
#define FREE 4
#define CELL 5
#define CELL 5
#define LOCAL_ONLY 6
/* The following two names are used for the ste_unoptimized bit field */
/* The following two names are used for the ste_unoptimized bit field */
#define OPT_IMPORT_STAR 1
#define OPT_IMPORT_STAR 1
...
...
Lib/test/test_
trace
.py
→
Lib/test/test_
line_tracing
.py
Dosyayı görüntüle @
013783c5
File moved
Lib/test/test_scope.py
Dosyayı görüntüle @
013783c5
...
@@ -690,6 +690,14 @@ result2 = h()
...
@@ -690,6 +690,14 @@ result2 = h()
h
=
g
()
h
=
g
()
self
.
assertEqual
(
h
(),
3
)
self
.
assertEqual
(
h
(),
3
)
def
testLocalClosureShadowing
(
self
):
exec
(
"""
x = 4
def f(x):
class C:
x = x
raises(NameError, f, 3)"""
,
{
"raises"
:
self
.
assertRaises
})
def
test_main
():
def
test_main
():
run_unittest
(
ScopeTests
)
run_unittest
(
ScopeTests
)
...
...
Objects/typeobject.c
Dosyayı görüntüle @
013783c5
...
@@ -6094,6 +6094,7 @@ supercheck(PyTypeObject *type, PyObject *obj)
...
@@ -6094,6 +6094,7 @@ supercheck(PyTypeObject *type, PyObject *obj)
PyErr_SetString
(
PyExc_TypeError
,
PyErr_SetString
(
PyExc_TypeError
,
"super(type, obj): "
"super(type, obj): "
"obj must be an instance or subtype of type"
);
"obj must be an instance or subtype of type"
);
printf
(
"%s
\n
"
,
type
->
tp_name
);
return
NULL
;
return
NULL
;
}
}
...
...
Python/ceval.c
Dosyayı görüntüle @
013783c5
...
@@ -2052,6 +2052,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
...
@@ -2052,6 +2052,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
break
;
break
;
TARGET
(
LOAD_NAME
)
TARGET
(
LOAD_NAME
)
TARGET
(
LOAD_NAME_LOCAL_ONLY
)
w
=
GETITEM
(
names
,
oparg
);
w
=
GETITEM
(
names
,
oparg
);
if
((
v
=
f
->
f_locals
)
==
NULL
)
{
if
((
v
=
f
->
f_locals
)
==
NULL
)
{
PyErr_Format
(
PyExc_SystemError
,
PyErr_Format
(
PyExc_SystemError
,
...
@@ -2073,15 +2074,14 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
...
@@ -2073,15 +2074,14 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
}
}
}
}
if
(
x
==
NULL
)
{
if
(
x
==
NULL
)
{
x
=
PyDict_GetItem
(
f
->
f_globals
,
w
);
if
(
opcode
!=
LOAD_NAME_LOCAL_ONLY
)
{
x
=
PyDict_GetItem
(
f
->
f_globals
,
w
);
if
(
x
==
NULL
)
x
=
PyDict_GetItem
(
f
->
f_builtins
,
w
);
}
if
(
x
==
NULL
)
{
if
(
x
==
NULL
)
{
x
=
PyDict_GetItem
(
f
->
f_builtins
,
w
);
format_exc_check_arg
(
PyExc_NameError
,
NAME_ERROR_MSG
,
w
);
if
(
x
==
NULL
)
{
break
;
format_exc_check_arg
(
PyExc_NameError
,
NAME_ERROR_MSG
,
w
);
break
;
}
}
}
Py_INCREF
(
x
);
Py_INCREF
(
x
);
}
}
...
...
Python/compile.c
Dosyayı görüntüle @
013783c5
...
@@ -787,6 +787,7 @@ opcode_stack_effect(int opcode, int oparg)
...
@@ -787,6 +787,7 @@ opcode_stack_effect(int opcode, int oparg)
case
LOAD_CONST
:
case
LOAD_CONST
:
return
1
;
return
1
;
case
LOAD_NAME
:
case
LOAD_NAME
:
case
LOAD_NAME_LOCAL_ONLY
:
return
1
;
return
1
;
case
BUILD_TUPLE
:
case
BUILD_TUPLE
:
case
BUILD_LIST
:
case
BUILD_LIST
:
...
@@ -2481,6 +2482,7 @@ compiler_nameop(struct compiler *c, identifier name, expr_context_ty ctx)
...
@@ -2481,6 +2482,7 @@ compiler_nameop(struct compiler *c, identifier name, expr_context_ty ctx)
optype
=
OP_DEREF
;
optype
=
OP_DEREF
;
break
;
break
;
case
LOCAL
:
case
LOCAL
:
case
LOCAL_ONLY
:
if
(
c
->
u
->
u_ste
->
ste_type
==
FunctionBlock
)
if
(
c
->
u
->
u_ste
->
ste_type
==
FunctionBlock
)
optype
=
OP_FAST
;
optype
=
OP_FAST
;
break
;
break
;
...
@@ -2556,7 +2558,7 @@ compiler_nameop(struct compiler *c, identifier name, expr_context_ty ctx)
...
@@ -2556,7 +2558,7 @@ compiler_nameop(struct compiler *c, identifier name, expr_context_ty ctx)
break
;
break
;
case
OP_NAME
:
case
OP_NAME
:
switch
(
ctx
)
{
switch
(
ctx
)
{
case
Load
:
op
=
LOAD_NAME
;
break
;
case
Load
:
op
=
(
scope
==
LOCAL_ONLY
)
?
LOAD_NAME_LOCAL_ONLY
:
LOAD_NAME
;
break
;
case
Store
:
op
=
STORE_NAME
;
break
;
case
Store
:
op
=
STORE_NAME
;
break
;
case
Del
:
op
=
DELETE_NAME
;
break
;
case
Del
:
op
=
DELETE_NAME
;
break
;
case
AugLoad
:
case
AugLoad
:
...
...
Python/symtable.c
Dosyayı görüntüle @
013783c5
...
@@ -432,7 +432,14 @@ analyze_name(PySTEntryObject *ste, PyObject *scopes, PyObject *name, long flags,
...
@@ -432,7 +432,14 @@ analyze_name(PySTEntryObject *ste, PyObject *scopes, PyObject *name, long flags,
return
PySet_Add
(
free
,
name
)
>=
0
;
return
PySet_Add
(
free
,
name
)
>=
0
;
}
}
if
(
flags
&
DEF_BOUND
)
{
if
(
flags
&
DEF_BOUND
)
{
SET_SCOPE
(
scopes
,
name
,
LOCAL
);
if
(
ste
->
ste_type
==
ClassBlock
&&
!
(
flags
&
DEF_PARAM
)
&&
bound
&&
PySet_Contains
(
bound
,
name
))
{
SET_SCOPE
(
scopes
,
name
,
LOCAL_ONLY
);
}
else
{
SET_SCOPE
(
scopes
,
name
,
LOCAL
);
}
if
(
PySet_Add
(
local
,
name
)
<
0
)
if
(
PySet_Add
(
local
,
name
)
<
0
)
return
0
;
return
0
;
if
(
PySet_Discard
(
global
,
name
)
<
0
)
if
(
PySet_Discard
(
global
,
name
)
<
0
)
...
@@ -489,7 +496,7 @@ analyze_cells(PyObject *scopes, PyObject *free, const char *restricted)
...
@@ -489,7 +496,7 @@ analyze_cells(PyObject *scopes, PyObject *free, const char *restricted)
long
scope
;
long
scope
;
assert
(
PyLong_Check
(
v
));
assert
(
PyLong_Check
(
v
));
scope
=
PyLong_AS_LONG
(
v
);
scope
=
PyLong_AS_LONG
(
v
);
if
(
scope
!=
LOCAL
)
if
(
scope
!=
LOCAL
&&
scope
!=
LOCAL_ONLY
)
continue
;
continue
;
if
(
!
PySet_Contains
(
free
,
name
))
if
(
!
PySet_Contains
(
free
,
name
))
continue
;
continue
;
...
...
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