#599·pygame

surface.convert_alpha(surf) (with an argument) does not do anything differently?

Author: dlonCreated Nov 4, 2018Updated Aug 9, 2026
LabelsSurfaceneeds-testsneeds-testingneeds-investigationeasy

It looks like src isn't used and it does the same thing as if you don't pass in a surface at all:

c
    pgSurface_Prep(self);
    if (srcsurf) {
        /*
         * hmm, we have to figure this out, not all depths have good
         * support for alpha
         */
        src = pgSurface_AsSurface(srcsurf);
        newsurf = SDL_DisplayFormatAlpha(surf);
    }
    else
        newsurf = SDL_DisplayFormatAlpha(surf);
    pgSurface_Unprep(self);

https://github.com/pygame/pygame/blob/b9f8f97fc06c1285e453099bd186b38c3fab8796/src_c/surface.c#L1780-L1816

To Do to close:

  • Write a unit test that checks whether passing a surface to convert_alpha has any effect on the eventual output. Check it in pygame 1.9.6 and pygame 2.0.0 (Travis and Appveryor should do this for you).
  • Discuss if there are any good use cases for this doing anything. Either here or discord.
  • If it's confirmed that it doesn't do anything, and we don't want it to do anything, we should remove the option from the docs (and probably the .pyi stubs) to move people away from using it -without breaking compatibility.

Related Docs: https://www.pygame.org/docs/ref/surface.html#pygame.Surface.convert_alpha