diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-03-07 14:53:40 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-03-07 14:53:40 +0300 |
commit | cfd9d6d190dc8fc35920714d252f6c93bd3d96f6 (patch) | |
tree | 360fc879522be7068bbfc1c8eeb6ee9443997abb /source/blender/python | |
parent | daff7a447e75a7901b7f3d782839c5a15c16efc1 (diff) |
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.
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/generic/bpy_internal_import.c | 13 | ||||
-rw-r--r-- | source/blender/python/generic/bpy_internal_import.h | 2 | ||||
-rw-r--r-- | source/blender/python/generic/py_capi_utils.c | 12 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_interface.c | 2 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_util.h | 2 |
5 files changed, 6 insertions, 25 deletions
diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c index 533225b1135..e0af6e085eb 100644 --- a/source/blender/python/generic/bpy_internal_import.c +++ b/source/blender/python/generic/bpy_internal_import.c @@ -74,16 +74,9 @@ void bpy_import_main_set(struct Main *maggie) } /* 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 @@ PyObject *bpy_text_import(Text *text) 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 ); diff --git a/source/blender/python/generic/bpy_internal_import.h b/source/blender/python/generic/bpy_internal_import.h index 45169b1b56f..7aabdcf3bf2 100644 --- a/source/blender/python/generic/bpy_internal_import.h +++ b/source/blender/python/generic/bpy_internal_import.h @@ -52,7 +52,7 @@ PyObject* bpy_text_import_name(char *name, int *found); 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; diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index ed24c164921..3f2fbb1bbec 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -60,18 +60,6 @@ void PyC_LineSpit(void) { 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; diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 03d5f528670..b54771f6b0e 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -378,7 +378,7 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text, st 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 ); diff --git a/source/blender/python/intern/bpy_util.h b/source/blender/python/intern/bpy_util.h index 9b217e77844..606eefc8960 100644 --- a/source/blender/python/intern/bpy_util.h +++ b/source/blender/python/intern/bpy_util.h @@ -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 |