Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(18)

Side by Side Diff: Modules/_ctypes/stgdict.c

Issue 10744: ctypes arrays have incorrect buffer information (PEP-3118)
Patch Set: Created 5 years, 9 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Modules/_ctypes/ctypes.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "Python.h" 1 #include "Python.h"
2 #include <ffi.h> 2 #include <ffi.h>
3 #ifdef MS_WIN32 3 #ifdef MS_WIN32
4 #include <windows.h> 4 #include <windows.h>
5 #include <malloc.h> 5 #include <malloc.h>
6 #endif 6 #endif
7 #include "ctypes.h" 7 #include "ctypes.h"
8 8
9 /******************************************************************/ 9 /******************************************************************/
10 /* 10 /*
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 498
499 buf = PyMem_Malloc(len + 2 + 1); 499 buf = PyMem_Malloc(len + 2 + 1);
500 if (buf == NULL) { 500 if (buf == NULL) {
501 Py_DECREF(pair); 501 Py_DECREF(pair);
502 PyErr_NoMemory(); 502 PyErr_NoMemory();
503 return -1; 503 return -1;
504 } 504 }
505 sprintf(buf, "%s:%s:", fieldfmt, fieldname); 505 sprintf(buf, "%s:%s:", fieldfmt, fieldname);
506 506
507 ptr = stgdict->format; 507 ptr = stgdict->format;
508 stgdict->format = _ctypes_alloc_format_string(stgdict->format, buf); 508 if (dict->shape != NULL) {
509 stgdict->format = _ctypes_alloc_format_string_with_shape(
510 dict->ndim, dict->shape, stgdict->format, buf);
511 } else {
512 stgdict->format = _ctypes_alloc_format_string(stgdict->format, b uf);
513 }
509 PyMem_Free(ptr); 514 PyMem_Free(ptr);
510 PyMem_Free(buf); 515 PyMem_Free(buf);
511 516
512 if (stgdict->format == NULL) { 517 if (stgdict->format == NULL) {
513 Py_DECREF(pair); 518 Py_DECREF(pair);
514 return -1; 519 return -1;
515 } 520 }
516 } 521 }
517 522
518 if (isStruct) { 523 if (isStruct) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 have been set until now. */ 578 have been set until now. */
574 if (stgdict->flags & DICTFLAG_FINAL) { 579 if (stgdict->flags & DICTFLAG_FINAL) {
575 PyErr_SetString(PyExc_AttributeError, 580 PyErr_SetString(PyExc_AttributeError,
576 "Structure or union cannot contain itself"); 581 "Structure or union cannot contain itself");
577 return -1; 582 return -1;
578 } 583 }
579 stgdict->flags |= DICTFLAG_FINAL; 584 stgdict->flags |= DICTFLAG_FINAL;
580 585
581 return MakeAnonFields(type); 586 return MakeAnonFields(type);
582 } 587 }
OLDNEW
« no previous file with comments | « Modules/_ctypes/ctypes.h ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+