fix [#25778] Memoryblock Data from SCR: end corrupt
authorCampbell Barton <ideasman42@gmail.com>
Tue, 25 Jan 2011 01:51:28 +0000 (01:51 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 25 Jan 2011 01:51:28 +0000 (01:51 +0000)
 + other minor changes.

source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/python/intern/bpy_rna.c
source/tests/pep8.py

index 6fa70b0a9c253df1fbd69a06ba82b2858814ef16..e34a84139aaeee37e57ca4078ed8498f2cc8070f 100644 (file)
@@ -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);
                                        }
index 263d799aa69656f94fc17ada50d9ea336fec5bc1..c4623169aeee4c381e2965657148fba9401ed5ae 100644 (file)
@@ -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);
                                        }
index f789ed922e243aa777c37ee3d9237f4f0ac3a6e0..fc36784ef844952178b79e9f24fc7b78d8bf648a 100644 (file)
@@ -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, &param_size);
+                               param= _PyUnicode_AsString(value);
                        }
 #else // USE_STRING_COERCE
-                       param= _PyUnicode_AsStringAndSize(value, &param_size);
+                       param= _PyUnicode_AsStringSize(value);
 #endif // USE_STRING_COERCE
 
                        if (param==NULL) {
index 3ccd7dd79b6a500d09a75803e69244e08f5eab1d..2932d55d815221bda22769077596db4e080aea2c 100644 (file)
@@ -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()