[ pyopengl-Bugs-3534110 ] hasGLExtension fail wrt circular import

SourceForge.net <[email protected]> Sun, 10 Jun 2012 19:33:24 -0700
Newsgroups gmane.comp.python.opengl.devel
Message-ID <[email protected]>
Bugs item #3534110, was opened at 2012-06-10 03:02
Message generated for change (Settings changed) made by mcfletch
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105988&aid=3534110&group_id=5988

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: GL
Group: v3.0.0
Status: Open
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: Alexander Sabourenkov (lxnt)
Assigned to: Mike C. Fletcher (mcfletch)
Summary: hasGLExtension fail wrt circular import

Initial Comment:
Given a 3.0+ forward-compatible context, that is, with glGetString barking at GL_EXTENSIONS, "from OpenGL.GL import *" may fail if one of OpenGL.GL.VERSION.GL_* submodules with version below 3.0  calls hasGLExtension() due to the fact that until "from OpenGL.GL.VERSION.GL_3_0 import *" line is executed in OpenGL/GL/__init__.py, the line "from OpenGL.GL import GL_NUM_EXTENSIONS, glGetStringi, glGetIntegerv" is guaranteed to throw an ImportError.

Suggested solution:

replace the aforementioned import statement in the hasExtension() function with the following two lines:

                from OpenGL.GL.VERSION.GL_3_0 import GL_NUM_EXTENSIONS, glGetStringi
                from OpenGL.GL import glGetIntegerv

Works for me.

Attached patch: the above fix plus a couple of nits to make it all work under Python 3.2



----------------------------------------------------------------------

>Comment By: Mike C. Fletcher (mcfletch)
Date: 2012-06-10 19:33

Message:
I've merged approximately this patch in.

I reverted the "as" changes, as I don't believe I've ever officially
announced dropping support for Python 2.5 (though I likely should some day
soon).  The change that would break unicode string checking on Python 2.x
was also not included (AFAIK that code would work perfectly well on Python
3.x); there was a real reason to say "string or unicode" there.  I had to
add an alias for the __bool__ as well so that earlier Python's would still
be able to do boolean checking.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105988&aid=3534110&group_id=5988

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
PyOpenGL Homepage
http://pyopengl.sourceforge.net