[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] BUG: required modules not raising error when failing to import was Re: [pygame] Surfarray.array_alpha() bugfix, py2exe/py2app segfault



Hi,

SVN rev. 1904 adds a bufferproxy import to __init__.py. Hopefully py2app/py2exe will pick up on it. Though the import is conditional on surface and mixer modules being available, I would rather not see module dependencies reflected in __init__.py. Preferably the import errors would happen in the extension modules that rely on bufferproxy. I am considering ways to combine the import check with api imports so that it is relatively simple to do and can be implemented consistently across all Pygame extension modules. Then __init__.py can be refactored so that it only has to show a token import statement for modules it doesn't actually use directly, as it does with pygame.macosx and numpy. Once all this is worked out it would make for a new wiki topic: "How to Add an Extension Module to Pygame".

Lenard


Lenard Lindstrom wrote:
[snip]


Yes, errors should be raised for missing modules. It would also keep Pygame's setup file honest. A bufferproxy import also needs to be added to __init__.py, which I will do now.

Lenard


René Dudfield wrote:
hi,

[snip]

I too prefer making it a requirement... and raising import error if it
is not there.

cheers,


On Wed, Feb 4, 2009 at 2:40 PM, Lenard Lindstrom <len-l@xxxxxxxxx> wrote:
Hi,

Zack Schilling has the distinction of being the first Pygame developer to use py2app/py2exe to wrap a game using NumPy. Before that no one noticed
bufferproxy was missing.

So where to generate the import errors. bufferproxy is not critical to
surface unless some other module needs a surface buffer. Either
Surface.get_buffer can check for NULL pointers and raise an
NotImplementedError if bufferproxy is missing or bufferproxy is made a
requirement for surface to import properly. The former option could save a little space if array packages are not used, but is potentially confusing.
Since buffers may be used elsewhere I prefer the later option myself.

[snip]



René Dudfield wrote:
ah yes, good one.


On Wed, Feb 4, 2009 at 2:07 PM, Lenard Lindstrom <len-l@xxxxxxxxx> wrote:

Simple. The bufferproxy module is not included in the executables.
[snip]


The moral of the story, when critical modules are missing, they should
not
be quietly ignored. An exception has to be raised. Brian Fisher did this
with _numericsurfarray when Numeric is missing.