Commits

marcus  committed c744791

Added note about file-like object meaning in documentation.
Minor documentation cleanups.
Fixed Python 3.x write support for sdl.rwops.

  • Participants
  • Parent commits e1aacde
  • Branches pgreloaded

Comments (0)

Files changed (25)

File doc/RELEASE.txt

 * update README.txt and doc/BuildXXX.txt to point to the latest required
   dependency versions.
 
+Releasing
+---------
+TODO
+
 Postprocessing
 --------------
 

File doc/capi/base.rst

-==================
-pygame2.base C API
-==================
+============
+pygame2.base
+============
 
 The :mod:`pygame2.base` C API contains fundamental core objects and
 functions used throughout nearly all :mod:`pygame2` modules. As such, it

File doc/capi/mask.rst

-==================
-pygame2.mask C API
-==================
+============
+pygame2.mask
+============
 
 The :mod:`pygame2.mask` C API contains some objects and functions for
 bitmask operations.

File doc/capi/sdlbase.rst

-======================
-pygame2.sdl.base C API
-======================
+================
+pygame2.sdl.base
+================
 
 The :mod:`pygame2.sdl.base` C API contains fundamental core functions
 used throughout nearly all :mod:`pygame2.sdl` related modules. As such,

File doc/capi/sdlcdrom.rst

-=======================
-pygame2.sdl.cdrom C API
-=======================
+=================
+pygame2.sdl.cdrom
+=================
 
 The :mod:`pygame2.sdl.cdrom` C API contains objects and functions for
 accessing the physical CD- and DVD-ROMS of the computer.

File doc/capi/sdlevent.rst

-=======================
-pygame2.sdl.event C API
-=======================
+=================
+pygame2.sdl.event
+=================
 
 The :mod:`pygame2.sdl.event` C API contains objects and functions for
 accessing and manipulating the SDL event system queue.

File doc/capi/sdlext.rst

-=========================
-pygame2.sdlext.base C API
-=========================
+===================
+pygame2.sdlext.base
+===================
 
 The :mod:`pygame2.sdlext.base` C API contains objects and functions for
 accessing and manipulating :mod:`pygame2.sdl` objects in a specialised

File doc/capi/sdlgfx.rst

-=========================
-pygame2.sdlgfx.base C API
-=========================
+===================
+pygame2.sdlgfx.base
+===================
 
 The :mod:`pygame2.sdlgfx.base` C API contains objects for managing
 constant frame rates and update steps for SDL based screen surfaces.

File doc/capi/sdljoystick.rst

-==========================
-pygame2.sdl.joystick C API
-==========================
+====================
+pygame2.sdl.joystick
+====================
 
 The :mod:`pygame2.sdl.joystick` C API contains objects and functions for
 accessing the physical joystick input devices of the computer.

File doc/capi/sdlmouse.rst

-=======================
-pygame2.sdl.mouse C API
-=======================
+=================
+pygame2.sdl.mouse
+=================
 
 The :mod:`pygame2.sdl.mouse` C API contains objects and functions for
 accessing and manipulating the mouse input device and cursor design.

File doc/capi/sdlrwops.rst

-=======================
-pygame2.sdl.rwops C API
-=======================
+=================
+pygame2.sdl.rwops
+=================
 
 The :mod:`pygame2.sdl.rwops` C API contains objects for
 accessing :ctype:`SDL_RWops` from Python objects.
 
+.. note::
+
+  All Python objects to be used by the :mod:`pygame2.sdl.rwops` API
+  *must* support binary read and write access. This is especially
+  important for Python 3.x users.
+ 
 Import
 ------
 Include headers::
   Closes a :ctype:`SDL_RWops` object. if *autoclose* is not 0, the bound data
   source will be closed, too (if it is a Python object). Otherwise it will be
   kept open.
- 
+ 

File doc/capi/sdlttf.rst

-=========================
-pygame2.sdlttf.base C API
-=========================
+===================
+pygame2.sdlttf.base
+===================
 
 The :mod:`pygame2.sdlttf.base` C API contains objects and functions for
 accessing TrueType font rendering on SDL surfaces.

File doc/capi/sdlvideo.rst

-=======================
-pygame2.sdl.video C API
-=======================
+=================
+pygame2.sdl.video
+=================
 
 The :mod:`pygame2.sdl.video` C API contains fundamental objects and functions
 for accessing and manipulating the screen display, image surface objects and
 # built documents.
 #
 # The short X.Y version.
-version = '2.0.0'
+version = '2.0.0-alpha1'
 # The full version, including alpha/beta/rc tags.
-release = '2.0.0'
+release = '2.0.0-alpha1'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.

File doc/modules.rst

 :ref:`modindex`. If you just want to look up a specific class, attribute
 method or function, use the :ref:`genindex` or :ref:`search`.
 
-Modules:
+General Notes for Reading
+-------------------------
+
+.. note::
+
+  Whenever the API documentation refers to file-like objects, those
+  *must* support binary read and write access. This is especially
+  important for Python 3.x users and the new :mod:`io` module.
+
+Modules
+---------
 
 .. toctree::
-   :maxdepth: 3
+   :maxdepth: 2
 
    ref/pygame2_base.rst
    ref/pygame2_font.rst

File doc/src/sdlimage.xml

     
       Loads a BMP file and creates a :class:`pygame2.sdl.video.Surface` from it.
       The file argument can be either a file object or the filename.
+
+      .. note::
+      
+        The file object *must* support binary read and write
+        access. This is especially important for Python 3.x users.
+
     </desc>
   </func>
   <func name="save_bmp">
 
       Saves a :class:`pygame2.sdl.video.Surface` to the specified file, where
       file can be a filename or file object.
+
+      .. note::
+      
+        The file object *must* support binary read and write
+        access. This is especially important for Python 3.x users.
     </desc>
   </func>
 </module>

File doc/src/sdlimagebase.xml

       :class:`pygame2.sdl.video.Surface` from it. The file argument can
       be a file object or filename. type is an optional argument
       indicating the image type as string.
+
+      .. note::
+      
+        The file object *must* support binary read and write
+        access. This is especially important for Python 3.x users.
+
     </desc>
   </func>
   <func name="read_xpm_from_array">

File doc/src/sdlmixerbase.xml

 
   <class name="Chunk">
     <constructor>TODO</constructor>
-    <desc></desc>
+    <desc>
+
+      .. note::
+
+        The file object *must* support binary read and write
+        access. This is especially important for Python 3.x users.
+    </desc>
     <attr name="buf">
       <desc></desc>
     </attr>
 
   <class name="Music">
     <constructor>TODO</constructor>
-    <desc></desc>
+    <desc>
+
+      .. note::
+
+        The file object *must* support binary read and write
+        access. This is especially important for Python 3.x users.
+    </desc>
     <method name="fade_in">
       <call></call>
       <desc></desc>

File doc/src/sdlttfbase.xml

       Creates a new Font from a TTF font file using the specified size in
       points. If the font features different faces, they can be chosen using
       the optional index.
+
+      .. note::
+
+        The file object *must* support binary read and write
+        access. This is especially important for Python 3.x users.
     </desc>
     <attr name="ascent">
       <desc>Gets the ascent of the Font.</desc>

File doc/src/sdlvideo.xml

 
         If no type information is supplied and the file type cannot be
         determined either, it will use TGA.
+
+        .. note::
+      
+          The file object *must* support binary read and write
+          access. This is especially important for Python 3.x users.
       </desc>
     </method>
     <method name="set_alpha">

File src/sdl/png.c

 _write_data (png_structp png_ptr, png_bytep data, png_size_t length)
 {
     SDL_RWops* dst = (SDL_RWops*) png_get_io_ptr (png_ptr);
-    SDL_RWwrite(dst, data, 1, length);
+    SDL_RWwrite (dst, data, 1, length);
 } 
 
 static int

File src/sdl/rwopsmod.c

     if (!wrapper->write)
         return -1;
 
+#ifdef IS_PYTHON_3
+    result = PyObject_CallFunction (wrapper->write, "y#", ptr, size * num);
+#else
     result = PyObject_CallFunction (wrapper->write, "s#", ptr, size * num);
+#endif
     if (!result)
         return -1;
 
     PyEval_AcquireLock ();
     oldstate = PyThreadState_Swap (wrapper->thread);
 
+#ifdef IS_PYTHON_3
+    result = PyObject_CallFunction (wrapper->write, "y#", ptr, size * num);
+#else
     result = PyObject_CallFunction (wrapper->write, "s#", ptr, size * num);
+#endif
     if (!result)
     {
         PyErr_Print ();

File test/pgunittest.py

                 if testFnName not in testFnNames:  # handle overridden methods
                     testFnNames.append(testFnName)
         if self.sortTestMethodsUsing:
-            testFnNames.sort(key=CmpToKey(self.sortTestMethodsUsing))
+            testFnNames.sort(key=CmpToKey(cmp))
         return testFnNames
 
 

File test/sdl_image_test.py

-import os
+import os, sys
 try:
     import StringIO as stringio
 except ImportError:
         # can be a filename or file object.
         imgdir = os.path.dirname (os.path.abspath (__file__))
         sf = image.load_bmp (os.path.join (imgdir, "test.bmp"))
-        buf = stringio.StringIO ()
+        buf = None
+        if sys.version_info[0] >= 3:
+            buf = stringio.BytesIO ()
+        else:
+            buf = stringio.StringIO ()
         self.assert_ (image.save_bmp (sf, buf) == None)
         self.assertEquals (os.stat (os.path.join (imgdir, "test.bmp")).st_size,
                            len (buf.getvalue ()))

File test/sdl_video_surface_test.py

+import sys
 try:
     import pygame2.test.pgunittest as unittest
 except:
         video.init ()
         sf1 = video.Surface (16, 16, 32)
         sf1.fill (pygame2.Color ("red"))
-        buf = stringio.StringIO ()
-        
+        bufcreat = None
+        if sys.version_info[0] >= 3:
+            bufcreat = stringio.BytesIO
+        else:
+            bufcreat = stringio.StringIO
+        buf = bufcreat ()
         
         sf1.save (buf, "bmp")
         buf.seek (0)
         self.assert_ (sf1.size == sf2.size)
         self.assert_ (cmppixels (sf1, sf2) == True)
 
-        buf = stringio.StringIO ()
+        buf = bufcreat ()
         sf1.save (buf, "jpg")
         buf.seek (0)
         sf2 = sdlimage.load (buf, "jpg")
         self.assert_ (sf1.size == sf2.size)
 
-        buf = stringio.StringIO ()
+        buf = bufcreat ()
         sf1.save (buf, "png")
         buf.seek (0)
         sf2 = sdlimage.load (buf, "png")
         self.assert_ (sf1.size == sf2.size)
         self.assert_ (cmppixels (sf1, sf2) == True)
 
-        buf = stringio.StringIO ()
+        buf = bufcreat ()
         sf1.save (buf, "tga")
         buf.seek (0)
         sf2 = sdlimage.load (buf, "tga")