Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d2078db

Browse filesBrowse files
committed
Belt and suspenders -- use sym_matches_type before assert
1 parent d7280d2 commit d2078db
Copy full SHA for d2078db

File tree

Expand file treeCollapse file tree

2 files changed

+36
-12
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+36
-12
lines changed

‎Python/optimizer_bytecodes.c

Copy file name to clipboardExpand all lines: Python/optimizer_bytecodes.c
+18-6Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ dummy_func(void) {
108108
}
109109

110110
op(_BINARY_OP_ADD_INT, (left, right -- res)) {
111-
if (sym_is_const(left) && sym_is_const(right)) {
111+
if (sym_is_const(left) && sym_is_const(right) &&
112+
sym_matches_type(left, &PyLong_Type) && sym_matches_type(right, &PyLong_Type))
113+
{
112114
assert(PyLong_CheckExact(sym_get_const(left)));
113115
assert(PyLong_CheckExact(sym_get_const(right)));
114116
PyObject *temp = _PyLong_Add((PyLongObject *)sym_get_const(left),
@@ -127,7 +129,9 @@ dummy_func(void) {
127129
}
128130

129131
op(_BINARY_OP_SUBTRACT_INT, (left, right -- res)) {
130-
if (sym_is_const(left) && sym_is_const(right)) {
132+
if (sym_is_const(left) && sym_is_const(right) &&
133+
sym_matches_type(left, &PyLong_Type) && sym_matches_type(right, &PyLong_Type))
134+
{
131135
assert(PyLong_CheckExact(sym_get_const(left)));
132136
assert(PyLong_CheckExact(sym_get_const(right)));
133137
PyObject *temp = _PyLong_Subtract((PyLongObject *)sym_get_const(left),
@@ -146,7 +150,9 @@ dummy_func(void) {
146150
}
147151

148152
op(_BINARY_OP_MULTIPLY_INT, (left, right -- res)) {
149-
if (sym_is_const(left) && sym_is_const(right)) {
153+
if (sym_is_const(left) && sym_is_const(right) &&
154+
sym_matches_type(left, &PyLong_Type) && sym_matches_type(right, &PyLong_Type))
155+
{
150156
assert(PyLong_CheckExact(sym_get_const(left)));
151157
assert(PyLong_CheckExact(sym_get_const(right)));
152158
PyObject *temp = _PyLong_Multiply((PyLongObject *)sym_get_const(left),
@@ -165,7 +171,9 @@ dummy_func(void) {
165171
}
166172

167173
op(_BINARY_OP_ADD_FLOAT, (left, right -- res)) {
168-
if (sym_is_const(left) && sym_is_const(right)) {
174+
if (sym_is_const(left) && sym_is_const(right) &&
175+
sym_matches_type(left, &PyFloat_Type) && sym_matches_type(right, &PyFloat_Type))
176+
{
169177
assert(PyFloat_CheckExact(sym_get_const(left)));
170178
assert(PyFloat_CheckExact(sym_get_const(right)));
171179
PyObject *temp = PyFloat_FromDouble(
@@ -185,7 +193,9 @@ dummy_func(void) {
185193
}
186194

187195
op(_BINARY_OP_SUBTRACT_FLOAT, (left, right -- res)) {
188-
if (sym_is_const(left) && sym_is_const(right)) {
196+
if (sym_is_const(left) && sym_is_const(right) &&
197+
sym_matches_type(left, &PyFloat_Type) && sym_matches_type(right, &PyFloat_Type))
198+
{
189199
assert(PyFloat_CheckExact(sym_get_const(left)));
190200
assert(PyFloat_CheckExact(sym_get_const(right)));
191201
PyObject *temp = PyFloat_FromDouble(
@@ -205,7 +215,9 @@ dummy_func(void) {
205215
}
206216

207217
op(_BINARY_OP_MULTIPLY_FLOAT, (left, right -- res)) {
208-
if (sym_is_const(left) && sym_is_const(right)) {
218+
if (sym_is_const(left) && sym_is_const(right) &&
219+
sym_matches_type(left, &PyFloat_Type) && sym_matches_type(right, &PyFloat_Type))
220+
{
209221
assert(PyFloat_CheckExact(sym_get_const(left)));
210222
assert(PyFloat_CheckExact(sym_get_const(right)));
211223
PyObject *temp = PyFloat_FromDouble(

‎Python/optimizer_cases.c.h

Copy file name to clipboardExpand all lines: Python/optimizer_cases.c.h
+18-6Lines changed: 18 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.