Changed ImageMath.ops to be static#7721
Merged
radarhere merged 1 commit intopython-pillow:mainfrom Jan 16, 2024
Merged
Conversation
Member
|
Looks good, thanks. I don't expect we'll add new |
Member
|
If some function is not listed in the dict, it wouldn't work in |
Member
|
Ah, that's right, temporarily commenting one one: diff --git a/src/PIL/ImageMath.py b/src/PIL/ImageMath.py
index a7652f237..47e552d3a 100644
--- a/src/PIL/ImageMath.py
+++ b/src/PIL/ImageMath.py
@@ -231,7 +231,7 @@ ops = {
"notequal": imagemath_notequal,
"min": imagemath_min,
"max": imagemath_max,
- "convert": imagemath_convert,
+ # "convert": imagemath_convert,
}Fails like this: Tests/test_imagemath.py ........F.................. [100%]
=============================================================== FAILURES ===============================================================
_____________________________________________________________ test_convert _____________________________________________________________
def test_convert():
> assert pixel(ImageMath.eval("convert(A+B, 'L')", images)) == "L 3"
Tests/test_imagemath.py:84:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/PIL/ImageMath.py:276: in eval
scan(compiled_code)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
code = <code object <module> at 0x107002f70, file "<string>", line 1>
def scan(code: CodeType) -> None:
for const in code.co_consts:
if type(const) is type(compiled_code):
scan(const)
for name in code.co_names:
if name not in args and name != "abs":
msg = f"'{name}' not allowed"
> raise ValueError(msg)
E ValueError: 'convert' not allowed
src/PIL/ImageMath.py:274: ValueError
======================================================= short test summary info ========================================================
FAILED Tests/test_imagemath.py::test_convert - ValueError: 'convert' not allowed
===================================================== 1 failed, 26 passed in 1.80s ===================================================== |
hugovk
approved these changes
Jan 16, 2024
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Resolves #7717