Skip to content

Conversation

@radarhere
Copy link
Member

My attempt to deprecate Image._showxv, without raising a DeprecationWarning when calling Image.show or Image._show.

Inspired by #4693 (comment)

@hugovk
Copy link
Member

hugovk commented Jun 21, 2020

Would something like this be simpler?

 def _show(image, **options):
-    _showxv(image, **options)
+    from . import ImageShow
+
+    ImageShow.show(image, **options)


 def _showxv(image, title=None, **options):
     from . import ImageShow

+    warnings.warn(
+        "_showxv is deprecated and will be removed in a future release. "
+        "Use Image.show instead.",
+        DeprecationWarning,
+        stacklevel=2,
+    )
     ImageShow.show(image, title, **options)

Also adds stacklevel=2 for the warning to show the line of the user's own script calling _showxv (where action is required), instead of the line in Image.py.

@radarhere
Copy link
Member Author

I'm just thinking that if a user has overridden _showxv and expects their custom function to be called by im.show, changing the code as you have suggested would break their code, instead of showing a deprecation warning.

@hugovk hugovk merged commit f6cb5ef into python-pillow:master Jun 25, 2020
@hugovk
Copy link
Member

hugovk commented Jun 25, 2020

Thanks!

@radarhere radarhere deleted the show branch June 25, 2020 21:51
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 this pull request may close these issues.

2 participants