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

Segfault when setting a pixel in a PixelArray #4163

Open
ParzivalWolfram opened this issue Feb 24, 2024 · 2 comments
Open

Segfault when setting a pixel in a PixelArray #4163

ParzivalWolfram opened this issue Feb 24, 2024 · 2 comments
Labels

Comments

@ParzivalWolfram
Copy link

ParzivalWolfram commented Feb 24, 2024

Environment:

  • Operating system: Linux (Endeavour)
  • Python version : 3.11.7
  • SDL version: 2.30.0
  • PyGame version: 2.4.0 (manually compiled 2.6.0.dev1, issue continues)

Current behavior:

Segfault when changing a pixel in a PixelArray.

Expected behavior:

Target pixel is set to the requested color in the PixelArray, as per documentation.

Test code

import pygame
test = pygame.Surface([800,800])
testBuf = pygame.PixelArray(test)
testBuf[400][400] = [255,255,0]

Stack trace/error output/other error logs

$ python3.11
Python 3.11.7 (main, Jan 29 2024, 16:03:57) [GCC 13.2.1 20230801] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
pygame 2.4.0 (SDL 2.30.0, Python 3.11.7)
Hello from the pygame community. https://www.pygame.org/contribute.html
>>> test = pygame.Surface([800,800])
>>> testBuf = pygame.PixelArray(test)
>>> testBuf[400][400] = [255,255,0]
Segmentation fault (core dumped)
@rhit-duffdl
Copy link

See this:
https://www.pygame.org/docs/ref/pixelarray.html

image

So you would want to do something like:
testBuf[400, 400] = pygame.Color(255, 255, 0)

@ParzivalWolfram
Copy link
Author

This should probably be handled more gracefully than segfaulting, since this seems like a common mistake to make.

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

No branches or pull requests

2 participants