Revision: 35386
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35386
Author:   campbellbarton
Date:     2011-03-07 11:53:40 +0000 (Mon, 07 Mar 2011)
Log Message:
-----------
Drop support for python 3.1.
for building py3.2 on *nix see:
  
http://wiki.blender.org/index.php?title=Dev:2.5/Doc/Building_Blender/Linux/Troubleshooting#Python

also fixed possible buffer overrun with getting the fake filepath for a blender 
textblock.

Modified Paths:
--------------
    trunk/blender/CMakeLists.txt
    trunk/blender/release/scripts/ui/space_userpref.py
    trunk/blender/source/blender/python/generic/bpy_internal_import.c
    trunk/blender/source/blender/python/generic/bpy_internal_import.h
    trunk/blender/source/blender/python/generic/py_capi_utils.c
    trunk/blender/source/blender/python/intern/bpy_interface.c
    trunk/blender/source/blender/python/intern/bpy_util.h
    trunk/blender/source/gameengine/GameLogic/SCA_PythonController.cpp

Modified: trunk/blender/CMakeLists.txt
===================================================================
--- trunk/blender/CMakeLists.txt        2011-03-07 11:51:09 UTC (rev 35385)
+++ trunk/blender/CMakeLists.txt        2011-03-07 11:53:40 UTC (rev 35386)
@@ -190,9 +190,9 @@
 
 # For alternate Python locations the commandline can be used to override 
detected/default cache settings, e.g:
 # On Unix: 
-#   cmake -D PYTHON_LIBRARY=/usr/local/lib/python3.1/config/libpython3.1.so -D 
PYTHON_INCLUDE_DIRS=/usr/local/include/python3.1 -G "Unix Makefiles" ../blender
+#   cmake -D PYTHON_LIBRARY=/usr/local/lib/python3.2/config/libpython3.2.so -D 
PYTHON_INCLUDE_DIRS=/usr/local/include/python3.2 ../blender
 # On Macs: 
-#   cmake -D 
PYTHON_INCLUDE_DIRS=/System/Library/Frameworks/Python.framework/Versions/3.1/include/python3.1
 -D 
PYTHON_LIBPATH=/System/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/config
 -G Xcode ../blender
+#   cmake -D 
PYTHON_INCLUDE_DIRS=/System/Library/Frameworks/Python.framework/Versions/3.2/include/python3.2
 -D 
PYTHON_LIBPATH=/System/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/config
 -G Xcode ../blender
 #
 # When changing any of this remember to update the notes in 
doc/build_systems/cmake.txt
 
@@ -250,7 +250,7 @@
                # No way to set py31. remove for now.
                # find_package(PythonLibs)
                set(PYTHON /usr)
-               set(PYTHON_VERSION 3.1 CACHE STRING "")
+               set(PYTHON_VERSION 3.2 CACHE STRING "")
                mark_as_advanced(PYTHON_VERSION)
                set(PYTHON_INCLUDE_DIRS 
"${PYTHON}/include/python${PYTHON_VERSION}" CACHE STRING "")
                mark_as_advanced(PYTHON_INCLUDE_DIRS)
@@ -772,7 +772,7 @@
        set(PYTHON_VERSION 3.2)
 
        if(PYTHON_VERSION MATCHES 3.2)
-               # we use precompiled libraries for py 3.1 and up by default
+               # we use precompiled libraries for py 3.2 and up by default
 
                set(PYTHON ${LIBDIR}/python)
                set(PYTHON_INCLUDE_DIRS 
"${PYTHON}/include/python${PYTHON_VERSION}")
@@ -784,7 +784,7 @@
                # otherwise, use custom system framework
 
                set(PYTHON 
/System/Library/Frameworks/Python.framework/Versions/)
-               set(PYTHON_VERSION 3.1)
+               set(PYTHON_VERSION 3.2)
                set(PYTHON_INCLUDE_DIRS 
"${PYTHON}${PYTHON_VERSION}/include/python${PYTHON_VERSION}")
                # set(PYTHON_BINARY 
${PYTHON}${PYTHON_VERSION}/bin/python${PYTHON_VERSION}) # not used yet
                set(PYTHON_LIBRARY "")

Modified: trunk/blender/release/scripts/ui/space_userpref.py
===================================================================
--- trunk/blender/release/scripts/ui/space_userpref.py  2011-03-07 11:51:09 UTC 
(rev 35385)
+++ trunk/blender/release/scripts/ui/space_userpref.py  2011-03-07 11:53:40 UTC 
(rev 35386)
@@ -1089,8 +1089,7 @@
         addon_path = ""
         pyfile_dir = os.path.dirname(pyfile)
         for addon_path in addon_utils.paths():
-            # if os.path.samefile(pyfile_dir, addon_path):  # Py3.2 only!, 
upgrade soon!
-            if (hasattr(os.path, "samefile") and os.path.samefile(pyfile_dir, 
addon_path)) or pyfile_dir == addon_path:
+            if os.path.samefile(pyfile_dir, addon_path):
                 self.report({'ERROR'}, "Source file is in the addon search 
path: %r" % addon_path)
                 return {'CANCELLED'}
         del addon_path

Modified: trunk/blender/source/blender/python/generic/bpy_internal_import.c
===================================================================
--- trunk/blender/source/blender/python/generic/bpy_internal_import.c   
2011-03-07 11:51:09 UTC (rev 35385)
+++ trunk/blender/source/blender/python/generic/bpy_internal_import.c   
2011-03-07 11:53:40 UTC (rev 35386)
@@ -74,16 +74,9 @@
 }
 
 /* returns a dummy filename for a textblock so we can tell what file a text 
block comes from */
-void bpy_text_filename_get(char *fn, Text *text)
+void bpy_text_filename_get(char *fn, size_t fn_len, Text *text)
 {
-#if PY_VERSION_HEX >=  0x03020000
-       sprintf(fn, "%s%c%s", text->id.lib ? text->id.lib->filepath : 
G.main->name, SEP, text->id.name+2);
-#else
-       /* this is a bug in python's Py_CompileString()!, fixed for python 3.2.
-        the string encoding should not be required to be utf-8
-        reported: http://bugs.python.org/msg115202  */
-       strcpy(fn, text->id.name+2);
-#endif
+       BLI_snprintf(fn, fn_len, "%s%c%s", text->id.lib ? 
text->id.lib->filepath : G.main->name, SEP, text->id.name+2);
 }
 
 PyObject *bpy_text_import(Text *text)
@@ -94,7 +87,7 @@
 
        if( !text->compiled ) {
                char fn_dummy[256];
-               bpy_text_filename_get(fn_dummy, text);
+               bpy_text_filename_get(fn_dummy, sizeof(fn_dummy), text);
 
                buf = txt_to_buf( text );
                text->compiled = Py_CompileString( buf, fn_dummy, Py_file_input 
);

Modified: trunk/blender/source/blender/python/generic/bpy_internal_import.h
===================================================================
--- trunk/blender/source/blender/python/generic/bpy_internal_import.h   
2011-03-07 11:51:09 UTC (rev 35385)
+++ trunk/blender/source/blender/python/generic/bpy_internal_import.h   
2011-03-07 11:53:40 UTC (rev 35386)
@@ -52,7 +52,7 @@
 PyObject*      bpy_text_reimport(PyObject *module, int *found);
 /* void                bpy_text_clear_modules(int clear_all);*/ /* Clear user 
modules */ 
 
-void bpy_text_filename_get(char *fn, struct Text *text);
+void bpy_text_filename_get(char *fn, size_t fn_len, struct Text *text);
 
 extern PyMethodDef bpy_import_meth;
 extern PyMethodDef bpy_reload_meth;

Modified: trunk/blender/source/blender/python/generic/py_capi_utils.c
===================================================================
--- trunk/blender/source/blender/python/generic/py_capi_utils.c 2011-03-07 
11:51:09 UTC (rev 35385)
+++ trunk/blender/source/blender/python/generic/py_capi_utils.c 2011-03-07 
11:53:40 UTC (rev 35386)
@@ -60,18 +60,6 @@
        fprintf(stderr, "%s:%d\n", filename, lineno);
 }
 
-/* python 3.2 only, copied from frameobjec.c */
-#if PY_VERSION_HEX <  0x03020000
-int
-PyFrame_GetLineNumber(PyFrameObject *f)
-{
-    if (f->f_trace)
-        return f->f_lineno;
-    else
-        return PyCode_Addr2Line(f->f_code, f->f_lasti);
-}
-#endif
-
 void PyC_FileAndNum(const char **filename, int *lineno)
 {
        PyFrameObject *frame;

Modified: trunk/blender/source/blender/python/intern/bpy_interface.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_interface.c  2011-03-07 
11:51:09 UTC (rev 35385)
+++ trunk/blender/source/blender/python/intern/bpy_interface.c  2011-03-07 
11:53:40 UTC (rev 35386)
@@ -378,7 +378,7 @@
 
        if (text) {
                char fn_dummy[FILE_MAXDIR];
-               bpy_text_filename_get(fn_dummy, text);
+               bpy_text_filename_get(fn_dummy, sizeof(fn_dummy), text);
 
                if( !text->compiled ) { /* if it wasn't already compiled, do it 
now */
                        char *buf = txt_to_buf( text );

Modified: trunk/blender/source/blender/python/intern/bpy_util.h
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_util.h       2011-03-07 
11:51:09 UTC (rev 35385)
+++ trunk/blender/source/blender/python/intern/bpy_util.h       2011-03-07 
11:53:40 UTC (rev 35386)
@@ -30,7 +30,7 @@
 #ifndef BPY_UTIL_H
 #define BPY_UTIL_H
 
-#if PY_VERSION_HEX <  0x03010000
+#if PY_VERSION_HEX <  0x03020000
 #error "Python versions below 3.1 are not supported anymore, you'll need to 
update your python."
 #endif
 

Modified: trunk/blender/source/gameengine/GameLogic/SCA_PythonController.cpp
===================================================================
--- trunk/blender/source/gameengine/GameLogic/SCA_PythonController.cpp  
2011-03-07 11:51:09 UTC (rev 35385)
+++ trunk/blender/source/gameengine/GameLogic/SCA_PythonController.cpp  
2011-03-07 11:53:40 UTC (rev 35386)
@@ -415,11 +415,7 @@
 
                excdict= PyDict_Copy(m_pythondictionary);
 
-#if PY_VERSION_HEX >=  0x03020000
                resultobj = PyEval_EvalCode((PyObject *)m_bytecode, excdict, 
excdict);
-#else
-               resultobj = PyEval_EvalCode((PyCodeObject *)m_bytecode, 
excdict, excdict);
-#endif
 
                /* PyRun_SimpleString(m_scriptText.Ptr()); */
                break;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to