Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests are failing for storing to two attributes with the same name #68

Closed
15r10nk opened this issue Mar 8, 2023 · 4 comments · Fixed by #69
Closed

tests are failing for storing to two attributes with the same name #68

15r10nk opened this issue Mar 8, 2023 · 4 comments · Fixed by #69

Comments

@15r10nk
Copy link
Collaborator

15r10nk commented Mar 8, 2023

I'm currently working on #64 and have some problems with the tests for 3.7 (reproducible on master)

The pipeline which is failing is the following:
https://github.com/alexmojaki/executing/actions/runs/4362346591/jobs/7627135034

I minimized the problem down to the following line (file was stored in tests/small_samples):

__arg.__deprecated__ = __new__.__deprecated__ = __msg

part of the test output (python 3.7.15):

mapping failed
Expected one value, found 2
search bytecode Instruction(opname='STORE_ATTR', opcode=95, arg=2, argval='__deprecated__', argrepr='__deprecated__', offset=6, starts_line=None, is_jump_target=False)

I don't know if this issue could be fixed in the SentinelNodeFinder or if it should be handled as an known issue and be ignored.

I also don't know why it started to appear now.

@alexmojaki
Copy link
Owner

It's a known issue that should be ignored.

if isinstance(ctx, ast.Store):
# Assignment to attributes and subscripts is less magical
# but can also fail fairly easily, so we can't guarantee
# that every node can be identified with some instruction.
continue

@15r10nk
Copy link
Collaborator Author

15r10nk commented Mar 8, 2023

Interesting. I will try to figure out why it is not. Thank you.

@15r10nk 15r10nk closed this as completed Mar 8, 2023
15r10nk added a commit to 15r10nk/executing that referenced this issue Mar 8, 2023
@15r10nk
Copy link
Collaborator Author

15r10nk commented Mar 8, 2023

the error is already handled here and raised in the last line.

executing/tests/test_main.py

Lines 1246 to 1303 in 0e5096a

print("mapping failed")
print(e)
if isinstance(e, NotOneValueFound):
for value in e.values:
print(
"value:", ast_dump(value, indent=4, include_attributes=True)
)
print("search bytecode", inst)
print("in file", source.filename)
if py11:
print("at position", inst.positions)
with open(source.filename) as sourcefile:
source_code = sourcefile.read()
dump_source(
source_code, start_position(inst), end_position(inst)
)
options = []
for node in ast.walk(ast.parse(source_code)):
if not hasattr(node, "lineno"):
continue
# if {start_position(node), end_position(node)} & {start_position(inst), end_position(inst)}:
if start_position(node) <= end_position(
inst
) and start_position(inst) <= end_position(node):
options.append(node)
for node in sorted(
options,
key=lambda node: (
node.end_lineno - node.lineno,
node.end_col_offset - node.col_offset,
),
):
if (node.end_lineno - node.lineno) > (
inst.positions.end_lineno - inst.positions.lineno
) * 4:
# skip nodes which are way to long
continue
print()
print(
"possible node",
node.lineno,
node.end_lineno,
node.col_offset,
node.end_col_offset,
ast.dump(node),
)
raise

The code that you mentioned is never executed in this case.

@15r10nk 15r10nk reopened this Mar 8, 2023
15r10nk added a commit to 15r10nk/executing that referenced this issue Mar 9, 2023
@15r10nk
Copy link
Collaborator Author

15r10nk commented Mar 11, 2023

I think the problem are the open issues in the SentinelNodeFinder.

skip_sentinel = [
"load_deref",
"4851dc1b626a95e97dbe0c53f96099d165b755dd1bd552c6ca771f7bca6d30f5",
"508ccd0dcac13ecee6f0cea939b73ba5319c780ddbb6c496be96fe5614871d4a",
"fc6eb521024986baa84af2634f638e40af090be4aa70ab3c22f3d022e8068228",
"42a37b8a823eb2e510b967332661afd679c82c60b7177b992a47c16d81117c8a",
]

This issue here is just one more. I skipped test_module_files in #64 for python < 3.8 for now.

This issues should be fixed later or categorized as KnownIssues.

But don't know if I will have time for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants