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
e323e0e9
Kaydet (Commit)
e323e0e9
authored
Haz 29, 2009
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix error handling in PyCode_Optimize, by Alexander Schremmer at EuroPython sprint.
üst
99ebc63f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
peephole.c
Python/peephole.c
+9
-6
No files found.
Python/peephole.c
Dosyayı görüntüle @
e323e0e9
...
@@ -305,7 +305,7 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
...
@@ -305,7 +305,7 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
/* Bail out if an exception is set */
/* Bail out if an exception is set */
if
(
PyErr_Occurred
())
if
(
PyErr_Occurred
())
goto
exit
Unchanged
;
goto
exit
Error
;
/* Bypass optimization when the lineno table is too complex */
/* Bypass optimization when the lineno table is too complex */
assert
(
PyString_Check
(
lineno_obj
));
assert
(
PyString_Check
(
lineno_obj
));
...
@@ -323,7 +323,7 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
...
@@ -323,7 +323,7 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
/* Make a modifiable copy of the code string */
/* Make a modifiable copy of the code string */
codestr
=
(
unsigned
char
*
)
PyMem_Malloc
(
codelen
);
codestr
=
(
unsigned
char
*
)
PyMem_Malloc
(
codelen
);
if
(
codestr
==
NULL
)
if
(
codestr
==
NULL
)
goto
exit
Unchanged
;
goto
exit
Error
;
codestr
=
(
unsigned
char
*
)
memcpy
(
codestr
,
codestr
=
(
unsigned
char
*
)
memcpy
(
codestr
,
PyString_AS_STRING
(
code
),
codelen
);
PyString_AS_STRING
(
code
),
codelen
);
...
@@ -338,11 +338,11 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
...
@@ -338,11 +338,11 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
/* Mapping to new jump targets after NOPs are removed */
/* Mapping to new jump targets after NOPs are removed */
addrmap
=
(
int
*
)
PyMem_Malloc
(
codelen
*
sizeof
(
int
));
addrmap
=
(
int
*
)
PyMem_Malloc
(
codelen
*
sizeof
(
int
));
if
(
addrmap
==
NULL
)
if
(
addrmap
==
NULL
)
goto
exit
Unchanged
;
goto
exit
Error
;
blocks
=
markblocks
(
codestr
,
codelen
);
blocks
=
markblocks
(
codestr
,
codelen
);
if
(
blocks
==
NULL
)
if
(
blocks
==
NULL
)
goto
exit
Unchanged
;
goto
exit
Error
;
assert
(
PyList_Check
(
consts
));
assert
(
PyList_Check
(
consts
));
for
(
i
=
0
;
i
<
codelen
;
i
+=
CODESIZE
(
codestr
[
i
]))
{
for
(
i
=
0
;
i
<
codelen
;
i
+=
CODESIZE
(
codestr
[
i
]))
{
...
@@ -394,7 +394,7 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
...
@@ -394,7 +394,7 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
}
}
if
(
j
==
PyList_GET_SIZE
(
consts
))
{
if
(
j
==
PyList_GET_SIZE
(
consts
))
{
if
(
PyList_Append
(
consts
,
Py_None
)
==
-
1
)
if
(
PyList_Append
(
consts
,
Py_None
)
==
-
1
)
goto
exit
Unchanged
;
goto
exit
Error
;
}
}
assert
(
PyList_GET_ITEM
(
consts
,
j
)
==
Py_None
);
assert
(
PyList_GET_ITEM
(
consts
,
j
)
==
Py_None
);
codestr
[
i
]
=
LOAD_CONST
;
codestr
[
i
]
=
LOAD_CONST
;
...
@@ -647,6 +647,9 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
...
@@ -647,6 +647,9 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
PyMem_Free
(
blocks
);
PyMem_Free
(
blocks
);
return
code
;
return
code
;
exitError:
code
=
NULL
;
exitUnchanged:
exitUnchanged:
if
(
blocks
!=
NULL
)
if
(
blocks
!=
NULL
)
PyMem_Free
(
blocks
);
PyMem_Free
(
blocks
);
...
@@ -654,6 +657,6 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
...
@@ -654,6 +657,6 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
PyMem_Free
(
addrmap
);
PyMem_Free
(
addrmap
);
if
(
codestr
!=
NULL
)
if
(
codestr
!=
NULL
)
PyMem_Free
(
codestr
);
PyMem_Free
(
codestr
);
Py_INCREF
(
code
);
Py_
X
INCREF
(
code
);
return
code
;
return
code
;
}
}
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