This repository has been archived by the owner on Jan 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
[opcode][3.11] support MAKE_FUNCTION in py311 #356
Merged
zrr1999
merged 1 commit into
PaddlePaddle:develop
from
gouzil:support_MAKE_FUNCTION_py311
Aug 30, 2023
Merged
[opcode][3.11] support MAKE_FUNCTION in py311 #356
zrr1999
merged 1 commit into
PaddlePaddle:develop
from
gouzil:support_MAKE_FUNCTION_py311
Aug 30, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Thanks for your contribution! |
gouzil
commented
Aug 30, 2023
Comment on lines
+1268
to
+1278
if sys.version_info < (3, 11): | ||
fn_name = self.stack.pop() | ||
codeobj = self.stack.pop() | ||
if sys.version_info >= (3, 11): | ||
# MAKE_FUNCTION behavior actually changed in 3.11, see | ||
# https://github.com/python/cpython/pull/93189/ | ||
assert hasattr(codeobj.value, "co_qualname") | ||
fn_name = ConstantVariable( | ||
codeobj.value.co_qualname, self._graph, DummyTracker([codeobj]) | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里其实也可以写成
if sys.version_info < (3, 11):
self.stack.pop()
codeobj = self.stack.pop()
assert hasattr(codeobj.value, "co_qualname")
fn_name = ConstantVariable(
codeobj.value.co_qualname, self._graph, DummyTracker([codeobj])
)
少一次判断
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果能保证 3.10 stack[-1] == stack[-2].co_qualname
倒是没问题,这点能保证么?如果不能保证就维持现有逻辑吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不太行emmm,我回滚了
gouzil
requested review from
SigureMo and
zrr1999
and removed request for
SigureMo
August 30, 2023 08:49
SigureMo
previously approved these changes
Aug 30, 2023
Comment on lines
+1268
to
+1278
if sys.version_info < (3, 11): | ||
fn_name = self.stack.pop() | ||
codeobj = self.stack.pop() | ||
if sys.version_info >= (3, 11): | ||
# MAKE_FUNCTION behavior actually changed in 3.11, see | ||
# https://github.com/python/cpython/pull/93189/ | ||
assert hasattr(codeobj.value, "co_qualname") | ||
fn_name = ConstantVariable( | ||
codeobj.value.co_qualname, self._graph, DummyTracker([codeobj]) | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果能保证 3.10 stack[-1] == stack[-2].co_qualname
倒是没问题,这点能保证么?如果不能保证就维持现有逻辑吧
gouzil
force-pushed
the
support_MAKE_FUNCTION_py311
branch
from
August 30, 2023 13:10
d43a0e1
to
e940500
Compare
SigureMo
approved these changes
Aug 30, 2023
SigureMo
changed the title
[opcode] support MAKE_FUNCTION in py311
[opcode][3.11] support MAKE_FUNCTION in py311
Aug 30, 2023
zrr1999
approved these changes
Aug 30, 2023
Closed
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
支持
python3.11
的MAKE_FUNCTION
python3.11
:python3.8
:相关任务:任务 5
单测状态变化:
test_13_make_function.py
❌ -> ✅