Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [Solved] Exceptions not propagated  (Read 5604 times)

0 Members and 1 Guest are viewing this topic.

Crashed

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
[Solved] Exceptions not propagated
« on: October 09, 2013, 04:41:23 am »
import sfml as sf

window = sf.RenderWindow(sf.VideoMode(640, 480), 'Test')

class DummyDrawable(sf.Drawable):
        def draw(self, *args, **kwargs):
                print 'draw'
                raise Exception('Sample exception')

dummy = DummyDrawable()

for x in xrange(10):
        print x

        window.draw(dummy)

print 'Finished'
 


0
draw
1
draw
2
draw
3
draw
4
draw
5
draw
6
draw
7
draw
8
draw
9
draw
Traceback (most recent call last):
  File "C:\...\wtf.py", line 12, in <module>
    for x in xrange(10):
  File "C:\...\wtf.py", line 8, in draw
    raise Exception('Sample exception')
Exception: Sample exception
 

pySFML-1.3.0.win32-py2.7, encountering strange issues with threading (putting this in a while loop will instead suppress error messages until after 'Finished', with a traceback coming from threading module). I've read over the source code to python-sfml and tried to debug with pdb and I cannot for the life of me understand what the hell is going on. I'm at the edge of insanity, please advise.
« Last Edit: November 03, 2013, 09:48:22 pm by Sonkun »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: wat
« Reply #1 on: October 09, 2013, 08:02:50 am »
Can you choose a better topic title please?
Laurent Gomila - SFML developer

Crashed

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: python-sfml strange behaviour
« Reply #2 on: October 09, 2013, 01:47:54 pm »
I apologize for the ambiguous title, my brain had gone to mush after trying to debug a larger application with tracebacks suppressed. For some more strange behaviour:

import sfml as sf

window = sf.RenderWindow(sf.VideoMode(640, 480), 'Test')

class DummyDrawable(sf.Drawable):
        def draw(self, *args, **kwargs):
                print 'draw'
                raise Exception('Sample exception')

dummy = DummyDrawable()

while window.is_open:
        for event in window.events:
                if isinstance(event, sf.CloseEvent):
                        window.close()

        window.draw(dummy)

print 'Finished'
 

draw
draw
draw
Finished
Exception Exception: Exception('Sample exception',) in <module 'threading' from C:\...\Python27\lib\threading.pyc'> ignored
 


Only the dummy's draw method causes this, throwing an exception anywhere else will halt execution as is normal. I've read over the python-sfml source from github, unless the code there is very different to the precompiled binary I installed then I assert there is voodoo magic at play here.

Sonkun

  • Moderator
  • Full Member
  • *****
  • Posts: 241
    • View Profile
Re: python-sfml strange behaviour
« Reply #3 on: November 03, 2013, 05:52:08 pm »
Thanks for reporting this bug. :) I forgot to propagate the exception in src/sfml/DerivableDrawable.cpp. I'll send a fix.
Interested in using SFML with Python ? Try out its Python binding!

Sonkun

  • Moderator
  • Full Member
  • *****
  • Posts: 241
    • View Profile
Re: [Solved] Exceptions not propagated
« Reply #4 on: November 03, 2013, 09:50:23 pm »
This is fixed: 0805d64

Thank you!
Interested in using SFML with Python ? Try out its Python binding!

 

anything