Mercurial > cpython-lru_cache-weakref
annotate Python/structmember.c @ 44742:14d4104976fc
Merged revisions 59985-60000,60002,60005-60007,60009-60042 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59987 | raymond.hettinger | 2008-01-15 21:52:42 +0100 (Tue, 15 Jan 2008) | 1 line
Refactor if/elif chain for clarity and speed. Remove dependency on subclasses having to implement _empty and _full.
........
r59988 | raymond.hettinger | 2008-01-15 22:22:47 +0100 (Tue, 15 Jan 2008) | 1 line
Fix-up half-written paragraph in the docs
........
r59989 | amaury.forgeotdarc | 2008-01-15 22:25:11 +0100 (Tue, 15 Jan 2008) | 3 lines
test_doctest fails since r59984.
Not sure if these are the correct values, but save_stdout has to be set before its usage...
........
r59992 | andrew.kuchling | 2008-01-16 01:32:03 +0100 (Wed, 16 Jan 2008) | 1 line
Docstring typos
........
r59993 | andrew.kuchling | 2008-01-16 04:17:25 +0100 (Wed, 16 Jan 2008) | 1 line
Add PEP 3141 section
........
r59998 | andrew.kuchling | 2008-01-16 14:01:51 +0100 (Wed, 16 Jan 2008) | 1 line
Markup fix
........
r59999 | georg.brandl | 2008-01-16 17:56:29 +0100 (Wed, 16 Jan 2008) | 2 lines
Fix MSDN library URL. (#1854)
........
r60006 | georg.brandl | 2008-01-16 21:27:56 +0100 (Wed, 16 Jan 2008) | 3 lines
Add Python-specific content to Doc dir. Update configuration file
to work with the newest Sphinx.
........
r60007 | georg.brandl | 2008-01-16 21:29:00 +0100 (Wed, 16 Jan 2008) | 2 lines
Doc build should work with 2.4 now.
........
r60009 | raymond.hettinger | 2008-01-17 00:38:16 +0100 (Thu, 17 Jan 2008) | 1 line
Minor wordsmithing.
........
r60010 | raymond.hettinger | 2008-01-17 00:40:45 +0100 (Thu, 17 Jan 2008) | 1 line
Add queues will alternative fetch orders (priority based and stack based).
........
r60011 | raymond.hettinger | 2008-01-17 00:49:35 +0100 (Thu, 17 Jan 2008) | 1 line
Add news entry.
........
r60013 | raymond.hettinger | 2008-01-17 04:02:14 +0100 (Thu, 17 Jan 2008) | 1 line
Make starmap() match its pure python definition and accept any itertable input (not just tuples).
........
r60015 | gregory.p.smith | 2008-01-17 08:43:20 +0100 (Thu, 17 Jan 2008) | 3 lines
Comply with RFC 3207.
Fixes issue 829951 - http://bugs.python.org/issue829951
........
r60018 | gregory.p.smith | 2008-01-17 09:03:17 +0100 (Thu, 17 Jan 2008) | 2 lines
entry for r60015
........
r60019 | raymond.hettinger | 2008-01-17 09:07:05 +0100 (Thu, 17 Jan 2008) | 1 line
Note versionadded.
........
r60020 | gregory.p.smith | 2008-01-17 09:35:49 +0100 (Thu, 17 Jan 2008) | 8 lines
Fixes (accepts patch) issue1339 - http://bugs.python.org/issue1339
- Factor out the duplication of EHLO/HELO in login() and sendmail() to
a new function, ehlo_or_helo_if_needed().
- Use ehlo_or_helo_if_needed() in starttls()
- Check for the starttls exception in starttls() in the same way as
login() checks for the auth extension.
Contributed by Bill Fenner.
........
r60021 | andrew.kuchling | 2008-01-17 13:00:15 +0100 (Thu, 17 Jan 2008) | 1 line
Revise 3141 section a bit; add some Windows items
........
r60022 | brett.cannon | 2008-01-17 19:45:10 +0100 (Thu, 17 Jan 2008) | 2 lines
Fix a function pointer declaration to silence the compiler.
........
r60024 | raymond.hettinger | 2008-01-17 20:31:38 +0100 (Thu, 17 Jan 2008) | 1 line
Issue #1861: Add read-only attribute listing upcoming events in the order they will be run.
........
r60025 | andrew.kuchling | 2008-01-17 20:49:24 +0100 (Thu, 17 Jan 2008) | 1 line
Correction from Jordan Lewis: halfdelay() uses tenths of a second, not milliseconds
........
r60026 | raymond.hettinger | 2008-01-17 23:27:49 +0100 (Thu, 17 Jan 2008) | 1 line
Add advice on choosing between scheduler and threading.Timer().
........
r60028 | christian.heimes | 2008-01-18 00:01:44 +0100 (Fri, 18 Jan 2008) | 2 lines
Updated new property syntax. An elaborate example for subclassing and the getter was missing.
Added comment about VS 2008 and PGO builds.
........
r60029 | raymond.hettinger | 2008-01-18 00:32:01 +0100 (Fri, 18 Jan 2008) | 1 line
Fix-up Timer() example.
........
r60030 | raymond.hettinger | 2008-01-18 00:56:56 +0100 (Fri, 18 Jan 2008) | 1 line
Fix markup
........
r60031 | raymond.hettinger | 2008-01-18 01:10:42 +0100 (Fri, 18 Jan 2008) | 1 line
clearcache() needs to remove the dict as well as clear it.
........
r60033 | andrew.kuchling | 2008-01-18 03:26:16 +0100 (Fri, 18 Jan 2008) | 1 line
Bump verson
........
r60034 | andrew.kuchling | 2008-01-18 03:42:52 +0100 (Fri, 18 Jan 2008) | 1 line
Typo fix
........
r60035 | christian.heimes | 2008-01-18 08:30:20 +0100 (Fri, 18 Jan 2008) | 3 lines
Coverity issue CID #197
var_decl: Declared variable "stm" without initializer
ninit_use_in_call: Using uninitialized value "stm" (field "stm".tm_zone uninitialized) in call to function "mktime"
........
r60036 | christian.heimes | 2008-01-18 08:45:30 +0100 (Fri, 18 Jan 2008) | 11 lines
Coverity issue CID #167
Event alloc_fn: Called allocation function "metacompile" [model]
Event var_assign: Assigned variable "gr" to storage returned from "metacompile"
gr = metacompile(n);
Event pass_arg: Variable "gr" not freed or pointed-to in function "maketables" [model]
g = maketables(gr);
translatelabels(g);
addfirstsets(g);
Event leaked_storage: Returned without freeing storage "gr"
return g;
........
r60038 | christian.heimes | 2008-01-18 09:04:57 +0100 (Fri, 18 Jan 2008) | 3 lines
Coverity issue CID #182
size_error: Allocating 1 bytes to pointer "children", which needs at least 4 bytes
........
r60041 | christian.heimes | 2008-01-18 09:47:59 +0100 (Fri, 18 Jan 2008) | 4 lines
Coverity issue CID #169
local_ptr_assign_local: Assigning address of stack variable "namebuf" to pointer "filename"
out_of_scope: Variable "namebuf" goes out of scope
use_invalid: Used "filename" pointing to out-of-scope variable "namebuf"
........
r60042 | christian.heimes | 2008-01-18 09:53:45 +0100 (Fri, 18 Jan 2008) | 2 lines
Coverity CID #168
leaked_storage: Returned without freeing storage "fp"
........
| author | Christian Heimes <christian@cheimes.de> |
|---|---|
| date | Fri, 18 Jan 2008 09:56:22 +0000 |
| parents | f324631462a2 |
| children | fefaa0e66fdd |
| rev | line source |
|---|---|
| 145 | 1 |
| 86 | 2 /* Map C struct members to Python object attributes */ |
| 3 | |
|
5373
5880384d7c71
Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents:
5287
diff
changeset
|
4 #include "Python.h" |
| 86 | 5 |
| 6 #include "structmember.h" | |
| 7 | |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
8 PyObject * |
|
36114
e9a10f74cf88
const poisoning, spreading to fix new const warnings
Tim Peters <tim.peters@gmail.com>
parents:
34677
diff
changeset
|
9 PyMember_GetOne(const char *addr, PyMemberDef *l) |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
10 { |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
11 PyObject *v; |
|
41715
f60c877d52c8
Merged revisions 55270-55324 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41317
diff
changeset
|
12 |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
13 addr += l->offset; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
14 switch (l->type) { |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
15 case T_BYTE: |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
43603
diff
changeset
|
16 v = PyLong_FromLong(*(char*)addr); |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
17 break; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
18 case T_UBYTE: |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
19 v = PyLong_FromUnsignedLong(*(unsigned char*)addr); |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
20 break; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
21 case T_SHORT: |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
43603
diff
changeset
|
22 v = PyLong_FromLong(*(short*)addr); |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
23 break; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
24 case T_USHORT: |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
25 v = PyLong_FromUnsignedLong(*(unsigned short*)addr); |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
26 break; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
27 case T_INT: |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
43603
diff
changeset
|
28 v = PyLong_FromLong(*(int*)addr); |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
29 break; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
30 case T_UINT: |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
31 v = PyLong_FromUnsignedLong(*(unsigned int*)addr); |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
32 break; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
33 case T_LONG: |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
43603
diff
changeset
|
34 v = PyLong_FromLong(*(long*)addr); |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
35 break; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
36 case T_ULONG: |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
37 v = PyLong_FromUnsignedLong(*(unsigned long*)addr); |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
38 break; |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
39 case T_PYSSIZET: |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
43603
diff
changeset
|
40 v = PyLong_FromSsize_t(*(Py_ssize_t*)addr); |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
41 break; |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
42 case T_FLOAT: |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
43 v = PyFloat_FromDouble((double)*(float*)addr); |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
44 break; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
45 case T_DOUBLE: |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
46 v = PyFloat_FromDouble(*(double*)addr); |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
47 break; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
48 case T_STRING: |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
49 if (*(char**)addr == NULL) { |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
50 Py_INCREF(Py_None); |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
51 v = Py_None; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
52 } |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
53 else |
|
43603
dd03aa741f56
This is the uncontroversial half of patch 1263 by Thomas Lee:
Guido van Rossum <guido@python.org>
parents:
42560
diff
changeset
|
54 v = PyUnicode_FromString(*(char**)addr); |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
55 break; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
56 case T_STRING_INPLACE: |
|
43603
dd03aa741f56
This is the uncontroversial half of patch 1263 by Thomas Lee:
Guido van Rossum <guido@python.org>
parents:
42560
diff
changeset
|
57 v = PyUnicode_FromString((char*)addr); |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
58 break; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
59 case T_CHAR: |
|
43603
dd03aa741f56
This is the uncontroversial half of patch 1263 by Thomas Lee:
Guido van Rossum <guido@python.org>
parents:
42560
diff
changeset
|
60 v = PyUnicode_FromStringAndSize((char*)addr, 1); |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
61 break; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
62 case T_OBJECT: |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
63 v = *(PyObject **)addr; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
64 if (v == NULL) |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
65 v = Py_None; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
66 Py_INCREF(v); |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
67 break; |
|
21187
ef6f692c76e2
Fix SF bug #486144: Uninitialized __slot__ vrbl is None.
Guido van Rossum <guido@python.org>
parents:
20456
diff
changeset
|
68 case T_OBJECT_EX: |
|
ef6f692c76e2
Fix SF bug #486144: Uninitialized __slot__ vrbl is None.
Guido van Rossum <guido@python.org>
parents:
20456
diff
changeset
|
69 v = *(PyObject **)addr; |
|
ef6f692c76e2
Fix SF bug #486144: Uninitialized __slot__ vrbl is None.
Guido van Rossum <guido@python.org>
parents:
20456
diff
changeset
|
70 if (v == NULL) |
|
ef6f692c76e2
Fix SF bug #486144: Uninitialized __slot__ vrbl is None.
Guido van Rossum <guido@python.org>
parents:
20456
diff
changeset
|
71 PyErr_SetString(PyExc_AttributeError, l->name); |
|
ef6f692c76e2
Fix SF bug #486144: Uninitialized __slot__ vrbl is None.
Guido van Rossum <guido@python.org>
parents:
20456
diff
changeset
|
72 Py_XINCREF(v); |
|
ef6f692c76e2
Fix SF bug #486144: Uninitialized __slot__ vrbl is None.
Guido van Rossum <guido@python.org>
parents:
20456
diff
changeset
|
73 break; |
|
34677
e9ffad6d8822
Patch #1115086: support PY_LONGLONG in structmember.
Martin v. Löwis <martin@v.loewis.de>
parents:
30979
diff
changeset
|
74 #ifdef HAVE_LONG_LONG |
|
e9ffad6d8822
Patch #1115086: support PY_LONGLONG in structmember.
Martin v. Löwis <martin@v.loewis.de>
parents:
30979
diff
changeset
|
75 case T_LONGLONG: |
|
e9ffad6d8822
Patch #1115086: support PY_LONGLONG in structmember.
Martin v. Löwis <martin@v.loewis.de>
parents:
30979
diff
changeset
|
76 v = PyLong_FromLongLong(*(PY_LONG_LONG *)addr); |
|
e9ffad6d8822
Patch #1115086: support PY_LONGLONG in structmember.
Martin v. Löwis <martin@v.loewis.de>
parents:
30979
diff
changeset
|
77 break; |
|
e9ffad6d8822
Patch #1115086: support PY_LONGLONG in structmember.
Martin v. Löwis <martin@v.loewis.de>
parents:
30979
diff
changeset
|
78 case T_ULONGLONG: |
|
e9ffad6d8822
Patch #1115086: support PY_LONGLONG in structmember.
Martin v. Löwis <martin@v.loewis.de>
parents:
30979
diff
changeset
|
79 v = PyLong_FromUnsignedLongLong(*(unsigned PY_LONG_LONG *)addr); |
|
e9ffad6d8822
Patch #1115086: support PY_LONGLONG in structmember.
Martin v. Löwis <martin@v.loewis.de>
parents:
30979
diff
changeset
|
80 break; |
|
e9ffad6d8822
Patch #1115086: support PY_LONGLONG in structmember.
Martin v. Löwis <martin@v.loewis.de>
parents:
30979
diff
changeset
|
81 #endif /* HAVE_LONG_LONG */ |
|
39536
8f5b9982beba
Completely get rid of PyClass and PyInstance.
Guido van Rossum <guido@python.org>
parents:
38453
diff
changeset
|
82 case T_NONE: |
|
8f5b9982beba
Completely get rid of PyClass and PyInstance.
Guido van Rossum <guido@python.org>
parents:
38453
diff
changeset
|
83 v = Py_None; |
|
8f5b9982beba
Completely get rid of PyClass and PyInstance.
Guido van Rossum <guido@python.org>
parents:
38453
diff
changeset
|
84 Py_INCREF(v); |
|
8f5b9982beba
Completely get rid of PyClass and PyInstance.
Guido van Rossum <guido@python.org>
parents:
38453
diff
changeset
|
85 break; |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
86 default: |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
87 PyErr_SetString(PyExc_SystemError, "bad memberdescr type"); |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
88 v = NULL; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
89 } |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
90 return v; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
91 } |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
92 |
|
42560
0fcc18aba385
PyErr_Warn is deprecated in 2.5 - goes away for 3.0
Skip Montanaro <skip@pobox.com>
parents:
42537
diff
changeset
|
93 #define WARN(msg) \ |
|
0fcc18aba385
PyErr_Warn is deprecated in 2.5 - goes away for 3.0
Skip Montanaro <skip@pobox.com>
parents:
42537
diff
changeset
|
94 do { \ |
|
0fcc18aba385
PyErr_Warn is deprecated in 2.5 - goes away for 3.0
Skip Montanaro <skip@pobox.com>
parents:
42537
diff
changeset
|
95 if (PyErr_WarnEx(PyExc_RuntimeWarning, msg, 1) < 0) \ |
|
0fcc18aba385
PyErr_Warn is deprecated in 2.5 - goes away for 3.0
Skip Montanaro <skip@pobox.com>
parents:
42537
diff
changeset
|
96 return -1; \ |
|
42466
3fc3cedc49ca
Merged revisions 56753-56781 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42110
diff
changeset
|
97 } while (0) |
|
3fc3cedc49ca
Merged revisions 56753-56781 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42110
diff
changeset
|
98 |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
99 int |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
100 PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v) |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
101 { |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
102 PyObject *oldv; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
103 |
|
30979
86fdf8fe7f17
Getting rid of all the code inside #ifdef macintosh too.
Jack Jansen <jack.jansen@cwi.nl>
parents:
21187
diff
changeset
|
104 if ((l->flags & READONLY) || l->type == T_STRING) |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
105 { |
|
41317
b897b77a004f
Make readonly members defined in C throw an AttributeError on modification. This brings them into sync with Python-level attributes. Fixes bug #1687163.
Collin Winter <collinw@gmail.com>
parents:
40450
diff
changeset
|
106 PyErr_SetString(PyExc_AttributeError, "readonly attribute"); |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
107 return -1; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
108 } |
|
21187
ef6f692c76e2
Fix SF bug #486144: Uninitialized __slot__ vrbl is None.
Guido van Rossum <guido@python.org>
parents:
20456
diff
changeset
|
109 if (v == NULL && l->type != T_OBJECT_EX && l->type != T_OBJECT) { |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
110 PyErr_SetString(PyExc_TypeError, |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
111 "can't delete numeric/char attribute"); |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
112 return -1; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
113 } |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
114 addr += l->offset; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
115 switch (l->type) { |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
116 case T_BYTE:{ |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
43603
diff
changeset
|
117 long long_val = PyLong_AsLong(v); |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
118 if ((long_val == -1) && PyErr_Occurred()) |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
119 return -1; |
|
42466
3fc3cedc49ca
Merged revisions 56753-56781 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42110
diff
changeset
|
120 *(char*)addr = (char)long_val; |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
121 /* XXX: For compatibility, only warn about truncations |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
122 for now. */ |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
123 if ((long_val > CHAR_MAX) || (long_val < CHAR_MIN)) |
|
42466
3fc3cedc49ca
Merged revisions 56753-56781 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42110
diff
changeset
|
124 WARN("Truncation of value to char"); |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
125 break; |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
126 } |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
127 case T_UBYTE:{ |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
43603
diff
changeset
|
128 long long_val = PyLong_AsLong(v); |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
129 if ((long_val == -1) && PyErr_Occurred()) |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
130 return -1; |
|
42466
3fc3cedc49ca
Merged revisions 56753-56781 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42110
diff
changeset
|
131 *(unsigned char*)addr = (unsigned char)long_val; |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
132 if ((long_val > UCHAR_MAX) || (long_val < 0)) |
|
42466
3fc3cedc49ca
Merged revisions 56753-56781 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42110
diff
changeset
|
133 WARN("Truncation of value to unsigned char"); |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
134 break; |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
135 } |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
136 case T_SHORT:{ |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
43603
diff
changeset
|
137 long long_val = PyLong_AsLong(v); |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
138 if ((long_val == -1) && PyErr_Occurred()) |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
139 return -1; |
|
42466
3fc3cedc49ca
Merged revisions 56753-56781 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42110
diff
changeset
|
140 *(short*)addr = (short)long_val; |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
141 if ((long_val > SHRT_MAX) || (long_val < SHRT_MIN)) |
|
42466
3fc3cedc49ca
Merged revisions 56753-56781 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42110
diff
changeset
|
142 WARN("Truncation of value to short"); |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
143 break; |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
144 } |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
145 case T_USHORT:{ |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
43603
diff
changeset
|
146 long long_val = PyLong_AsLong(v); |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
147 if ((long_val == -1) && PyErr_Occurred()) |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
148 return -1; |
|
42466
3fc3cedc49ca
Merged revisions 56753-56781 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42110
diff
changeset
|
149 *(unsigned short*)addr = (unsigned short)long_val; |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
150 if ((long_val > USHRT_MAX) || (long_val < 0)) |
|
42466
3fc3cedc49ca
Merged revisions 56753-56781 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42110
diff
changeset
|
151 WARN("Truncation of value to unsigned short"); |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
152 break; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
153 } |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
154 case T_INT:{ |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
43603
diff
changeset
|
155 long long_val = PyLong_AsLong(v); |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
156 if ((long_val == -1) && PyErr_Occurred()) |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
157 return -1; |
|
42466
3fc3cedc49ca
Merged revisions 56753-56781 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42110
diff
changeset
|
158 *(int *)addr = (int)long_val; |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
159 if ((long_val > INT_MAX) || (long_val < INT_MIN)) |
|
42466
3fc3cedc49ca
Merged revisions 56753-56781 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42110
diff
changeset
|
160 WARN("Truncation of value to int"); |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
161 break; |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
162 } |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
163 case T_UINT:{ |
|
42466
3fc3cedc49ca
Merged revisions 56753-56781 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42110
diff
changeset
|
164 unsigned long ulong_val = PyLong_AsUnsignedLong(v); |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
165 if ((ulong_val == (unsigned int)-1) && PyErr_Occurred()) { |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
166 /* XXX: For compatibility, accept negative int values |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
167 as well. */ |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
168 PyErr_Clear(); |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
169 ulong_val = PyLong_AsLong(v); |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
170 if ((ulong_val == (unsigned int)-1) && PyErr_Occurred()) |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
171 return -1; |
|
42466
3fc3cedc49ca
Merged revisions 56753-56781 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42110
diff
changeset
|
172 *(unsigned int *)addr = (unsigned int)ulong_val; |
|
3fc3cedc49ca
Merged revisions 56753-56781 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42110
diff
changeset
|
173 WARN("Writing negative value into unsigned field"); |
|
3fc3cedc49ca
Merged revisions 56753-56781 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42110
diff
changeset
|
174 } else |
|
3fc3cedc49ca
Merged revisions 56753-56781 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42110
diff
changeset
|
175 *(unsigned int *)addr = (unsigned int)ulong_val; |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
176 if (ulong_val > UINT_MAX) |
|
42466
3fc3cedc49ca
Merged revisions 56753-56781 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42110
diff
changeset
|
177 WARN("Truncation of value to unsigned int"); |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
178 break; |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
179 } |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
180 case T_LONG:{ |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
181 *(long*)addr = PyLong_AsLong(v); |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
182 if ((*(long*)addr == -1) && PyErr_Occurred()) |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
183 return -1; |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
184 break; |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
185 } |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
186 case T_ULONG:{ |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
187 *(unsigned long*)addr = PyLong_AsUnsignedLong(v); |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
188 if ((*(unsigned long*)addr == (unsigned long)-1) |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
189 && PyErr_Occurred()) { |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
190 /* XXX: For compatibility, accept negative int values |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
191 as well. */ |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
192 PyErr_Clear(); |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
193 *(unsigned long*)addr = PyLong_AsLong(v); |
|
42466
3fc3cedc49ca
Merged revisions 56753-56781 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42110
diff
changeset
|
194 if ((*(unsigned long*)addr == (unsigned int)-1) |
|
3fc3cedc49ca
Merged revisions 56753-56781 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42110
diff
changeset
|
195 && PyErr_Occurred()) |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
196 return -1; |
|
42466
3fc3cedc49ca
Merged revisions 56753-56781 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42110
diff
changeset
|
197 WARN("Writing negative value into unsigned field"); |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
198 } |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
199 break; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
200 } |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
201 case T_PYSSIZET:{ |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
43603
diff
changeset
|
202 *(Py_ssize_t*)addr = PyLong_AsSsize_t(v); |
|
42110
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
203 if ((*(Py_ssize_t*)addr == (Py_ssize_t)-1) |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
204 && PyErr_Occurred()) |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
205 return -1; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
206 break; |
|
e4f649c4f457
Merged revisions 55962-56019 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42084
diff
changeset
|
207 } |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
208 case T_FLOAT:{ |
|
42466
3fc3cedc49ca
Merged revisions 56753-56781 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
42110
diff
changeset
|
209 double double_val = PyFloat_AsDouble(v); |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
210 if ((double_val == -1) && PyErr_Occurred()) |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
211 return -1; |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
212 *(float*)addr = (float)double_val; |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
213 break; |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
214 } |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
215 case T_DOUBLE: |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
216 *(double*)addr = PyFloat_AsDouble(v); |
|
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39536
diff
changeset
|
217 if ((*(double*)addr == -1) && PyErr_Occurred()) |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
218 return -1; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
219 break; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
220 case T_OBJECT: |
|
21187
ef6f692c76e2
Fix SF bug #486144: Uninitialized __slot__ vrbl is None.
Guido van Rossum <guido@python.org>
parents:
20456
diff
changeset
|
221 case T_OBJECT_EX: |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
222 Py_XINCREF(v); |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
223 oldv = *(PyObject **)addr; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
224 *(PyObject **)addr = v; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
225 Py_XDECREF(oldv); |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
226 break; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
227 case T_CHAR: |
|
43603
dd03aa741f56
This is the uncontroversial half of patch 1263 by Thomas Lee:
Guido van Rossum <guido@python.org>
parents:
42560
diff
changeset
|
228 if (PyUnicode_Check(v) && PyUnicode_GetSize(v) == 1) { |
|
dd03aa741f56
This is the uncontroversial half of patch 1263 by Thomas Lee:
Guido van Rossum <guido@python.org>
parents:
42560
diff
changeset
|
229 *(char*)addr = PyUnicode_AsString(v)[0]; |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
230 } |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
231 else { |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
232 PyErr_BadArgument(); |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
233 return -1; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
234 } |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
235 break; |
|
34677
e9ffad6d8822
Patch #1115086: support PY_LONGLONG in structmember.
Martin v. Löwis <martin@v.loewis.de>
parents:
30979
diff
changeset
|
236 #ifdef HAVE_LONG_LONG |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41715
diff
changeset
|
237 case T_LONGLONG:{ |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41715
diff
changeset
|
238 PY_LONG_LONG value; |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41715
diff
changeset
|
239 *(PY_LONG_LONG*)addr = value = PyLong_AsLongLong(v); |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41715
diff
changeset
|
240 if ((value == -1) && PyErr_Occurred()) |
|
34677
e9ffad6d8822
Patch #1115086: support PY_LONGLONG in structmember.
Martin v. Löwis <martin@v.loewis.de>
parents:
30979
diff
changeset
|
241 return -1; |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41715
diff
changeset
|
242 break; |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41715
diff
changeset
|
243 } |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41715
diff
changeset
|
244 case T_ULONGLONG:{ |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41715
diff
changeset
|
245 unsigned PY_LONG_LONG value; |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41715
diff
changeset
|
246 /* ??? PyLong_AsLongLong accepts an int, but PyLong_AsUnsignedLongLong |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41715
diff
changeset
|
247 doesn't ??? */ |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41715
diff
changeset
|
248 if (PyLong_Check(v)) |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41715
diff
changeset
|
249 *(unsigned PY_LONG_LONG*)addr = value = PyLong_AsUnsignedLongLong(v); |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41715
diff
changeset
|
250 else |
|
44099
f324631462a2
Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents:
43603
diff
changeset
|
251 *(unsigned PY_LONG_LONG*)addr = value = PyLong_AsLong(v); |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41715
diff
changeset
|
252 if ((value == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred()) |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41715
diff
changeset
|
253 return -1; |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41715
diff
changeset
|
254 break; |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41715
diff
changeset
|
255 } |
|
34677
e9ffad6d8822
Patch #1115086: support PY_LONGLONG in structmember.
Martin v. Löwis <martin@v.loewis.de>
parents:
30979
diff
changeset
|
256 #endif /* HAVE_LONG_LONG */ |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
257 default: |
|
20456
bff6c2d76f33
Put descr name in "bad memberdescr type" error message.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
20012
diff
changeset
|
258 PyErr_Format(PyExc_SystemError, |
|
bff6c2d76f33
Put descr name in "bad memberdescr type" error message.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
20012
diff
changeset
|
259 "bad memberdescr type for %s", l->name); |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
260 return -1; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
261 } |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
262 return 0; |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
19942
diff
changeset
|
263 } |
