diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-01-25 04:51:28 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-01-25 04:51:28 +0300 |
commit | 27cb6218a34a440a83c3b275e3cf69ea79245a1e (patch) | |
tree | 95652627317f61e5109777e030bbb7f81203ba3f | |
parent | 8e83dd0933cc02683ebbd9d8a9471b07f62dad55 (diff) |
fix [#25778] Memoryblock Data from SCR: end corrupt
+ other minor changes.
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 6 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 1 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 5 | ||||
-rw-r--r-- | source/tests/pep8.py | 2 |
4 files changed, 10 insertions, 4 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 6fa70b0a9c2..e34a84139aa 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -5279,7 +5279,11 @@ static void direct_link_screen(FileData *fd, bScreen *sc) for(cl= sconsole->history.first; cl; cl= cl_next) { cl_next= cl->next; cl->line= newdataadr(fd, cl->line); - if (cl->line == NULL) { + if (cl->line) { + /* the allocted length is not written, so reset here */ + cl->len_alloc= cl->len + 1; + } + else { BLI_remlink(&sconsole->history, cl); MEM_freeN(cl); } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 263d799aa69..c4623169aee 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2139,6 +2139,7 @@ static void write_screens(WriteData *wd, ListBase *scrbase) ConsoleLine *cl; for (cl=con->history.first; cl; cl=cl->next) { + /* 'len_alloc' is invalid on write, set from 'len' on read */ writestruct(wd, DATA, "ConsoleLine", 1, cl); writedata(wd, DATA, cl->len+1, cl->line); } diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index f789ed922e2..fc36784ef84 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -1071,7 +1071,6 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb case PROP_STRING: { const char *param; - Py_ssize_t param_size= 0; #ifdef USE_STRING_COERCE PyObject *value_coerce= NULL; int subtype= RNA_property_subtype(prop); @@ -1080,10 +1079,10 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb param= PyC_UnicodeAsByte(value, &value_coerce); } else { - param= _PyUnicode_AsStringAndSize(value, ¶m_size); + param= _PyUnicode_AsString(value); } #else // USE_STRING_COERCE - param= _PyUnicode_AsStringAndSize(value, ¶m_size); + param= _PyUnicode_AsStringSize(value); #endif // USE_STRING_COERCE if (param==NULL) { diff --git a/source/tests/pep8.py b/source/tests/pep8.py index 3ccd7dd79b6..2932d55d815 100644 --- a/source/tests/pep8.py +++ b/source/tests/pep8.py @@ -48,6 +48,8 @@ def file_list_py(path): def is_pep8(path): print(path) + if open(path, 'rb').read(3) == b'\xef\xbb\xbf': + print("\nfile contains BOM, remove first 3 bytes: %r\n" % path) f = open(path, 'r', encoding="utf8") for i in range(PEP8_SEEK_COMMENT): line = f.readline() |