2024-03-23 16:56:08

Hello,
So I have experienced this thing lately, where for whatever reason, my system will reject Pygame. It doesn't matter what it is. I can open ANY game that was made in Python that uses Pygame, and boom. It crashes.
Usually I'll just shrug and go, "probably another video system initialization mistake. No problem. It happens."
But then when I go to the error log, I'm hit with this.

    events = pygame.event.get()
SystemError: <built-in function get> returned a result with an exception set

So then I'm like, what on earth am I looking at? Okay, searching time.
My search was quite unsuccessful. All I was finding was the classic video system not initialized errors, or issues with using the library's mouse.
Has anyone experienced this strange predicament? This is the second or third time it has happened to me now.

-----
YouTube
GitHub
Discord: @tunmi13#1880

2024-03-23 17:26:38

ok this is a weird one, but a phew things come to mind even though I doubt it's the reason.
1. Are you 64bit? Very common duh question I know but who knows.
2. Tried running under administrator? Another duh but some forget to try that.
3. Try deleting temp? I doubt this is the issue but you never know.
4. Are you running from the unextracted zip file? Never do that. Always causes issues.
5. By any chance you have sdl2 in your system's path? If you don't know that probably isn't the issue because you have to put it yourself, Why it can be an issue because pygame uses pysdl2, and not sure if it uses the dll or does cython but if it was the former it can be an issue if there's a conflict?
6. Try updating drivers using your device's manifacturor's driver updating method, or if you don't have/know, just try windows updates. IT could be a driver update breaking something up.


other than that dunno, it's weird, I never scene that error, but if you lost hope maybe clone pygame's source and search for what could throw that exception, that should lead you somewhere, probably.

2024-03-23 18:24:50

Odd. Most times i've seen that particular line of code written differently though, such as "for events in pygame.event.get()". You could try resetting your system, or try troubleshooting it with your own python script.

-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2024-03-23 18:44:25

I got that just last week. I think it's a variable missing because of a miscommunication with SDL, or the game expecting a device that doesn't exist, or something. I got it while messing with a joystick, fwiw.

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.

2024-03-23 19:21:18

Pretty sure this error has something to do with the Python interpreter itself. In C/C++, when an exception is raised on the Python side, the python C API sets the error indicator. It is up to the consumer of the C API to check this indicator and to handle it as necessary. I'm pretty sure that this error is  caused because for whatever reason this isn't being done, and so Python is, naturally, complaining about it because the code is trying to keep going when an exception occurred on the Python side of things. I'd recommend just switching to Raylib via raylibpy or another library for the games you write because you won't be able to do anything with Pygame until this gets fixed, which could take who knows how long. As for all other games that use Pygame, well, not much you can do about that.

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.
My Github

2024-03-24 18:04:17

Well it's weird, because now it's working again.
I checked out Raylib, and it is brilliant. I may start using it.

-----
YouTube
GitHub
Discord: @tunmi13#1880

2024-03-25 02:11:40 (edited by Ethin 2024-03-25 02:23:19)

@6, it definitely is. If your used to the BGT way of doing things though you'll definitely have to rethink how you write games though. It's worth noting that if you do use it, your game loop must call BeginDrawing/EndDrawing regardless of whether you actually draw anything or not (EndDrawing in particular does all the event handling and stuff). You can set up a function to throw exceptions on Raylib errors by just calling SetTraceLogCallback, which is also nice, because by default the library logs everything to stdout (though if you don't like having try/except everywhere you don't have to obviously). An alternative to Begin/EndDrawing is if you want full frame control you can first call SwapScreenBuffer, then PollInputEvents, and then WaitTime, but I'd just call EndDrawing and let it do all that for you.

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.
My Github

2024-03-25 23:22:46 (edited by tunmi13 2024-03-25 23:24:25)

Yeah I noticed the begin drawing and end drawing thing as well. I'll look further into this  library too to figure out its functions, but so far it looks quite promising.
EDIT: To be honest the BGT way of doing it sort of throws me off, since I've gotten so used to the Pygame way.

-----
YouTube
GitHub
Discord: @tunmi13#1880

2024-03-26 03:42:09

@8, yeah, this doesn't do the BGT way of doing things at all. All your update stuff should go in your game loop and of course take as little time as possible.

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.
My Github