Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
1005c845
Commit
1005c845
authored
Nov 27, 2018
by
Victor Stinner
Committed by
GitHub
Nov 27, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-34100: Partially revert merge_consts_recursive() (GH-10743)
Partically revert commit
c2e1607a
to fix a reference leak.
parent
48083380
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
60 deletions
+0
-60
Lib/test/test_compile.py
Lib/test/test_compile.py
+0
-10
Python/compile.c
Python/compile.c
+0
-50
No files found.
Lib/test/test_compile.py
View file @
1005c845
...
...
@@ -615,16 +615,6 @@ if 1:
self
.
check_constant
(
f1
,
Ellipsis
)
self
.
assertEqual
(
repr
(
f1
()),
repr
(
Ellipsis
))
# Merge constants in tuple or frozenset
# NOTE: frozenset can't reuse previous const, but frozenset
# item can be reused later.
f3
=
lambda
x
:
x
in
{(
"not a name"
,)}
f1
,
f2
=
lambda
:
"not a name"
,
lambda
:
(
"not a name"
,)
self
.
assertIs
(
next
(
iter
(
f3
.
__code__
.
co_consts
[
1
])),
f2
.
__code__
.
co_consts
[
1
])
self
.
assertIs
(
f1
.
__code__
.
co_consts
[
1
],
f2
.
__code__
.
co_consts
[
1
][
0
])
# {0} is converted to a constant frozenset({0}) by the peephole
# optimizer
f1
,
f2
=
lambda
x
:
x
in
{
0
},
lambda
x
:
x
in
{
0
}
...
...
Python/compile.c
View file @
1005c845
...
...
@@ -1240,56 +1240,6 @@ merge_consts_recursive(struct compiler *c, PyObject *o)
Py_DECREF
(
u
);
}
}
else
if
(
PyFrozenSet_CheckExact
(
o
))
{
// We register items in the frozenset, but don't rewrite
// the frozenset when the item is already registered
// because frozenset is rare and difficult.
// *key* is tuple. And it's first item is frozenset of
// constant keys.
// See _PyCode_ConstantKey() for detail.
assert
(
PyTuple_CheckExact
(
key
));
assert
(
PyTuple_GET_SIZE
(
key
)
==
2
);
Py_ssize_t
len
=
PySet_GET_SIZE
(
o
);
if
(
len
==
0
)
{
return
key
;
}
PyObject
*
tuple
=
PyTuple_New
(
len
);
if
(
tuple
==
NULL
)
{
Py_DECREF
(
key
);
return
NULL
;
}
Py_ssize_t
i
=
0
,
pos
=
0
;
PyObject
*
item
;
Py_hash_t
hash
;
while
(
_PySet_NextEntry
(
o
,
&
pos
,
&
item
,
&
hash
))
{
PyObject
*
k
=
merge_consts_recursive
(
c
,
item
);
if
(
k
==
NULL
)
{
Py_DECREF
(
tuple
);
Py_DECREF
(
key
);
return
NULL
;
}
PyObject
*
u
;
if
(
PyTuple_CheckExact
(
k
))
{
u
=
PyTuple_GET_ITEM
(
k
,
1
);
}
else
{
u
=
k
;
}
Py_INCREF
(
u
);
PyTuple_SET_ITEM
(
tuple
,
i
,
u
);
i
++
;
}
PyObject
*
new
=
PyFrozenSet_New
(
tuple
);
Py_DECREF
(
tuple
);
if
(
new
==
NULL
)
{
Py_DECREF
(
key
);
return
NULL
;
}
PyTuple_SET_ITEM
(
key
,
1
,
new
);
}
return
key
;
}
...
...
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