Download tasks/swe-next-53c4002d7c95f0dc4bbd/instruction.md from FineEnvs/repo2rlenv-swe-next: direct link, hf CLI and curl.
- Browser
- Download file 1.75 kB
-
https://huggingface.co/datasets/FineEnvs/repo2rlenv-swe-next/resolve/main/tasks/swe-next-53c4002d7c95f0dc4bbd/instruction.md
- Command line
-
hf download hf://datasets/FineEnvs/repo2rlenv-swe-next/tasks/swe-next-53c4002d7c95f0dc4bbd/instruction.md
-
curl -L -o instruction.md https://huggingface.co/datasets/FineEnvs/repo2rlenv-swe-next/resolve/main/tasks/swe-next-53c4002d7c95f0dc4bbd/instruction.md
iequals incorrectly returns True when comparing iterables of different lengths with equality-wildcard objects
Description
When using iequals to compare two iterables of different lengths, it can incorrectly return True if one of the iterables contains an object that compares equal to everything (such as unittest.mock.ANY).
Here's a minimal reproduction:
from unittest import mock
import more_itertools as mi
# An empty list vs a list containing mock.ANY
result = mi.iequals([], [mock.ANY])
print(result) # prints True, but should be False
The two iterables clearly have different lengths (0 vs 1), so iequals should return False. But it returns True.
Root cause
The current implementation uses zip_longest with a private sentinel fillvalue=object() to detect length mismatches:
return all(map(all_equal, zip_longest(*iterables, fillvalue=object())))
The idea is that the sentinel won't compare equal to real values. However, mock.ANY (and any object that overrides __eq__ to always return True) compares equal to the sentinel too, so the length mismatch goes undetected and iequals returns True instead of False.
Expected behavior
mi.iequals([], [mock.ANY]) should return False, since the two iterables have different lengths and cannot be considered equal regardless of the values they contain.
Actual behavior
mi.iequals([], [mock.ANY]) returns True.
Work in /workspace. Submit your fix in the existing Python source files under more_itertools. Preserve the other public behavior. The environment is offline; dependencies are preinstalled. Grading runs the repository's test suite in a fresh environment, using your submitted source files.