Mercurial > pygame
annotate src/rwobject.c @ 3194:9fcb7abf3185 default tip
Remove some gcc 4.7.2 compiler warnings
| author | Lenard Lindstrom <len-l@telus.net> |
|---|---|
| date | Tue, 23 Apr 2013 19:53:36 -0700 |
| parents | 62ddfa716ba9 |
| children |
| rev | line source |
|---|---|
| 7 | 1 /* |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
2 pygame - Python Game Library |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
3 Copyright (C) 2000-2001 Pete Shinners |
| 7 | 4 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
6 modify it under the terms of the GNU Library General Public |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
7 License as published by the Free Software Foundation; either |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
8 version 2 of the License, or (at your option) any later version. |
| 7 | 9 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
13 Library General Public License for more details. |
| 7 | 14 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
15 You should have received a copy of the GNU Library General Public |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
16 License along with this library; if not, write to the Free |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 7 | 18 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
19 Pete Shinners |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
20 pete@shinners.org |
| 7 | 21 */ |
| 22 | |
| 23 /* | |
| 24 * SDL_RWops support for python objects | |
| 25 */ | |
| 346 | 26 #define NO_PYGAME_C_API |
| 7 | 27 #define PYGAMEAPI_RWOBJECT_INTERNAL |
| 28 #include "pygame.h" | |
|
1553
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
29 #include "pgcompat.h" |
|
2105
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
30 #include "doc/pygame_doc.h" |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
31 |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
32 /* With Python 2.5 exception types became new-style classes and |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
33 * PyExc_BaseException was introduced. |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
34 */ |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
35 #if PY_VERSION_HEX < 0x02050000 |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
36 #define ExcClassType_Check(o) PyClass_Check(o) |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
37 #define PyExc_BaseException PyExc_Exception |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
38 #else |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
39 #define ExcClassType_Check(o) PyType_Check(o) |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
40 #endif |
| 7 | 41 |
| 42 typedef struct | |
| 43 { | |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
44 PyObject* read; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
45 PyObject* write; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
46 PyObject* seek; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
47 PyObject* tell; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
48 PyObject* close; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
49 } RWHelper; |
| 7 | 50 |
|
2114
952681766cc1
Looks like the Mac build error is coming from rwobject.c; nothing obvious, so try the less obvious
Lenard Lindstrom <len-l@telus.net>
parents:
2108
diff
changeset
|
51 /*static const char default_encoding[] = "unicode_escape";*/ |
|
952681766cc1
Looks like the Mac build error is coming from rwobject.c; nothing obvious, so try the less obvious
Lenard Lindstrom <len-l@telus.net>
parents:
2108
diff
changeset
|
52 /*static const char default_errors[] = "backslashreplace";*/ |
|
2116
04bace00377c
remove Mac error debugging
Lenard Lindstrom <len-l@telus.net>
parents:
2115
diff
changeset
|
53 static const char default_encoding[] = "unicode_escape"; |
|
04bace00377c
remove Mac error debugging
Lenard Lindstrom <len-l@telus.net>
parents:
2115
diff
changeset
|
54 static const char default_errors[] = "backslashreplace"; |
|
2105
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
55 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
56 static int rw_seek (SDL_RWops* context, int offset, int whence); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
57 static int rw_read (SDL_RWops* context, void* ptr, int size, int maxnum); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
58 static int rw_write (SDL_RWops* context, const void* ptr, int size, int maxnum); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
59 static int rw_close (SDL_RWops* context); |
| 7 | 60 |
| 272 | 61 #ifdef WITH_THREAD |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
62 static int rw_seek_th (SDL_RWops* context, int offset, int whence); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
63 static int rw_read_th (SDL_RWops* context, void* ptr, int size, int maxnum); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
64 static int rw_write_th (SDL_RWops* context, const void* ptr, int size, |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
65 int maxnum); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
66 static int rw_close_th (SDL_RWops* context); |
| 272 | 67 #endif |
| 7 | 68 |
|
2105
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
69 static int |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
70 is_exception_class(PyObject *obj, void **optr) |
| 7 | 71 { |
|
2105
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
72 PyObject **rval = (PyObject **)optr; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
73 PyObject *oname; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
74 #if PY3 |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
75 PyObject *tmp; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
76 #endif |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
77 |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
78 if (!ExcClassType_Check(obj) || /* conditional or */ |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
79 !PyObject_IsSubclass(obj, PyExc_BaseException)) { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
80 oname = PyObject_Str(obj); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
81 if (oname == NULL) { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
82 return 0; |
|
2063
3d9fd0473d2e
corrected encoding of unicode file path strings
Lenard Lindstrom <len-l@telus.net>
parents:
1589
diff
changeset
|
83 } |
|
2105
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
84 #if PY3 |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
85 tmp = PyUnicode_AsEncodedString(oname, "ascii", "replace"); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
86 Py_DECREF(tmp); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
87 if (tmp == NULL) { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
88 return 0; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
89 } |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
90 oname = tmp; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
91 #endif |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
92 PyErr_Format(PyExc_TypeError, |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
93 "Expected an exception class: got %.1024s", |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
94 Bytes_AS_STRING(oname)); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
95 Py_DECREF(oname); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
96 return 0; |
|
2063
3d9fd0473d2e
corrected encoding of unicode file path strings
Lenard Lindstrom <len-l@telus.net>
parents:
1589
diff
changeset
|
97 } |
|
2105
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
98 *rval = obj; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
99 return 1; |
| 272 | 100 } |
| 7 | 101 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
102 static void |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
103 fetch_object_methods (RWHelper* helper, PyObject* obj) |
| 272 | 104 { |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
105 helper->read = helper->write = helper->seek = helper->tell = |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
106 helper->close = NULL; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
107 |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
108 if (PyObject_HasAttrString (obj, "read")) |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
109 { |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
110 helper->read = PyObject_GetAttrString (obj, "read"); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
111 if(helper->read && !PyCallable_Check (helper->read)) |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
112 { |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
113 Py_DECREF (helper->read); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
114 helper->read = NULL; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
115 } |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
116 } |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
117 if (PyObject_HasAttrString (obj, "write")) |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
118 { |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
119 helper->write = PyObject_GetAttrString (obj, "write"); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
120 if (helper->write && !PyCallable_Check (helper->write)) |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
121 { |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
122 Py_DECREF (helper->write); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
123 helper->write = NULL; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
124 } |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
125 } |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
126 if (PyObject_HasAttrString (obj, "seek")) |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
127 { |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
128 helper->seek = PyObject_GetAttrString (obj, "seek"); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
129 if (helper->seek && !PyCallable_Check (helper->seek)) |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
130 { |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
131 Py_DECREF (helper->seek); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
132 helper->seek = NULL; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
133 } |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
134 } |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
135 if (PyObject_HasAttrString (obj, "tell")) |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
136 { |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
137 helper->tell = PyObject_GetAttrString (obj, "tell"); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
138 if (helper->tell && !PyCallable_Check (helper->tell)) |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
139 { |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
140 Py_DECREF (helper->tell); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
141 helper->tell = NULL; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
142 } |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
143 } |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
144 if(PyObject_HasAttrString(obj, "close")) |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
145 { |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
146 helper->close = PyObject_GetAttrString (obj, "close"); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
147 if (helper->close && !PyCallable_Check (helper->close)) |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
148 { |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
149 Py_DECREF (helper->close); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
150 helper->close = NULL; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
151 } |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
152 } |
| 272 | 153 } |
| 7 | 154 |
|
2105
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
155 static PyObject* |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
156 RWopsEncodeString(PyObject *obj, |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
157 const char *encoding, |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
158 const char *errors, |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
159 PyObject *eclass) |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
160 { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
161 PyObject *oencoded; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
162 PyObject *exc_type; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
163 PyObject *exc_value; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
164 PyObject *exc_trace; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
165 PyObject *str; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
166 |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
167 if (obj == NULL) { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
168 /* Assume an error was raise; forward it */ |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
169 return NULL; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
170 } |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
171 if (encoding == NULL) { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
172 encoding = default_encoding; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
173 } |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
174 if (errors == NULL) { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
175 errors = default_errors; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
176 } |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
177 if (PyUnicode_Check(obj)) { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
178 oencoded = PyUnicode_AsEncodedString(obj, encoding, errors); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
179 if (oencoded != NULL) { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
180 return oencoded; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
181 } |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
182 else if (PyErr_ExceptionMatches(PyExc_MemoryError)) { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
183 /* Forward memory errors */ |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
184 return NULL; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
185 } |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
186 else if (eclass != NULL) { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
187 /* Foward as eclass error */ |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
188 PyErr_Fetch(&exc_type, &exc_value, &exc_trace); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
189 Py_DECREF(exc_type); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
190 Py_XDECREF(exc_trace); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
191 if (exc_value == NULL) { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
192 PyErr_SetString(eclass, |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
193 "Unicode encoding error"); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
194 } |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
195 else { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
196 str = PyObject_Str(exc_value); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
197 Py_DECREF(exc_value); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
198 if (str != NULL) { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
199 PyErr_SetObject(eclass, str); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
200 Py_DECREF(str); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
201 } |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
202 } |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
203 return NULL; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
204 } |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
205 else if (encoding == default_encoding && errors == default_errors) { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
206 /* The default encoding and error handling should not fail */ |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
207 return RAISE(PyExc_SystemError, |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
208 "Pygame bug (in RWopsEncodeString):" |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
209 " unexpected encoding error"); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
210 } |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
211 PyErr_Clear(); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
212 } |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
213 else if (Bytes_Check(obj)) { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
214 Py_INCREF(obj); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
215 return obj; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
216 } |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
217 |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
218 Py_RETURN_NONE; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
219 } |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
220 |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
221 static PyObject* |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
222 RWopsEncodeFilePath(PyObject *obj, PyObject *eclass) |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
223 { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
224 PyObject *result = RWopsEncodeString(obj, |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
225 UNICODE_DEF_FS_CODEC, |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
226 UNICODE_DEF_FS_ERROR, |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
227 eclass); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
228 if (result == NULL || result == Py_None) { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
229 return result; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
230 } |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
231 if ((size_t)Bytes_GET_SIZE(result) != strlen(Bytes_AS_STRING(result))) { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
232 if (eclass != NULL) { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
233 Py_DECREF(result); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
234 result = RWopsEncodeString(obj, NULL, NULL, NULL); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
235 if (result == NULL) { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
236 return NULL; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
237 } |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
238 PyErr_Format(eclass, |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
239 "File path '%.1024s' contains null characters", |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
240 Bytes_AS_STRING(result)); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
241 Py_DECREF(result); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
242 return NULL; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
243 } |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
244 Py_DECREF(result); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
245 Py_RETURN_NONE; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
246 } |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
247 return result; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
248 } |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
249 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
250 static SDL_RWops* |
|
2105
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
251 RWopsFromFileObject(PyObject *obj) |
| 272 | 252 { |
|
2105
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
253 SDL_RWops *rw = NULL; |
|
2074
2336cf356f03
fix rwobject memory leak when raising a memory error
Lenard Lindstrom <len-l@telus.net>
parents:
2065
diff
changeset
|
254 RWHelper *helper; |
| 272 | 255 |
|
2105
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
256 if (obj == NULL) { |
|
2074
2336cf356f03
fix rwobject memory leak when raising a memory error
Lenard Lindstrom <len-l@telus.net>
parents:
2065
diff
changeset
|
257 return (SDL_RWops *)RAISE(PyExc_TypeError, "Invalid filetype object"); |
|
2063
3d9fd0473d2e
corrected encoding of unicode file path strings
Lenard Lindstrom <len-l@telus.net>
parents:
1589
diff
changeset
|
258 } |
|
2105
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
259 #if PY2 |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
260 if (PyFile_Check(obj)) |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
261 { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
262 rw = SDL_RWFromFP(PyFile_AsFile(obj), 0); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
263 if (rw) { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
264 return rw; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
265 } |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
266 SDL_ClearError(); |
|
2063
3d9fd0473d2e
corrected encoding of unicode file path strings
Lenard Lindstrom <len-l@telus.net>
parents:
1589
diff
changeset
|
267 } |
|
2105
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
268 #endif |
|
2074
2336cf356f03
fix rwobject memory leak when raising a memory error
Lenard Lindstrom <len-l@telus.net>
parents:
2065
diff
changeset
|
269 helper = PyMem_New(RWHelper, 1); |
|
2336cf356f03
fix rwobject memory leak when raising a memory error
Lenard Lindstrom <len-l@telus.net>
parents:
2065
diff
changeset
|
270 if (helper == NULL) { |
|
2336cf356f03
fix rwobject memory leak when raising a memory error
Lenard Lindstrom <len-l@telus.net>
parents:
2065
diff
changeset
|
271 return (SDL_RWops *)PyErr_NoMemory(); |
|
2063
3d9fd0473d2e
corrected encoding of unicode file path strings
Lenard Lindstrom <len-l@telus.net>
parents:
1589
diff
changeset
|
272 } |
|
2074
2336cf356f03
fix rwobject memory leak when raising a memory error
Lenard Lindstrom <len-l@telus.net>
parents:
2065
diff
changeset
|
273 rw = SDL_AllocRW(); |
|
2336cf356f03
fix rwobject memory leak when raising a memory error
Lenard Lindstrom <len-l@telus.net>
parents:
2065
diff
changeset
|
274 if (rw == NULL) { |
|
2336cf356f03
fix rwobject memory leak when raising a memory error
Lenard Lindstrom <len-l@telus.net>
parents:
2065
diff
changeset
|
275 PyMem_Del(helper); |
|
2336cf356f03
fix rwobject memory leak when raising a memory error
Lenard Lindstrom <len-l@telus.net>
parents:
2065
diff
changeset
|
276 return (SDL_RWops *)PyErr_NoMemory(); |
|
2063
3d9fd0473d2e
corrected encoding of unicode file path strings
Lenard Lindstrom <len-l@telus.net>
parents:
1589
diff
changeset
|
277 } |
|
2074
2336cf356f03
fix rwobject memory leak when raising a memory error
Lenard Lindstrom <len-l@telus.net>
parents:
2065
diff
changeset
|
278 fetch_object_methods(helper, obj); |
|
2336cf356f03
fix rwobject memory leak when raising a memory error
Lenard Lindstrom <len-l@telus.net>
parents:
2065
diff
changeset
|
279 rw->hidden.unknown.data1 = (void *)helper; |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
280 rw->seek = rw_seek; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
281 rw->read = rw_read; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
282 rw->write = rw_write; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
283 rw->close = rw_close; |
| 7 | 284 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
285 return rw; |
| 7 | 286 } |
| 287 | |
|
2105
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
288 static SDL_RWops* |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
289 RWopsFromObject(PyObject *obj) |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
290 { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
291 PyObject *oencoded; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
292 SDL_RWops *rw = NULL; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
293 |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
294 if (obj != NULL) { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
295 oencoded = RWopsEncodeFilePath(obj, NULL); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
296 if (oencoded == NULL) { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
297 return NULL; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
298 } |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
299 if (oencoded != Py_None) { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
300 rw = SDL_RWFromFile(Bytes_AS_STRING(oencoded), "rb"); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
301 } |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
302 Py_DECREF(oencoded); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
303 if (rw) { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
304 return rw; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
305 } |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
306 SDL_ClearError(); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
307 } |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
308 return RWopsFromFileObject(obj); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
309 } |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
310 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
311 static int |
|
2105
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
312 RWopsCheckObject (SDL_RWops* rw) |
| 168 | 313 { |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
314 return rw->close == rw_close; |
| 168 | 315 } |
| 316 | |
| 7 | 317 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
318 static int |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
319 rw_seek (SDL_RWops* context, int offset, int whence) |
| 7 | 320 { |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
321 RWHelper* helper = (RWHelper*) context->hidden.unknown.data1; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
322 PyObject* result; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
323 int retval; |
| 7 | 324 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
325 if (!helper->seek || !helper->tell) |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
326 return -1; |
| 7 | 327 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
328 if (!(offset == 0 && whence == SEEK_CUR)) /*being called only for 'tell'*/ |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
329 { |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
330 result = PyObject_CallFunction (helper->seek, "ii", offset, whence); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
331 if (!result) |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
332 return -1; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
333 Py_DECREF (result); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
334 } |
| 7 | 335 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
336 result = PyObject_CallFunction (helper->tell, NULL); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
337 if (!result) |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
338 return -1; |
| 7 | 339 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
340 retval = PyInt_AsLong (result); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
341 Py_DECREF (result); |
| 7 | 342 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
343 return retval; |
| 7 | 344 } |
| 345 | |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
346 static int |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
347 rw_read (SDL_RWops* context, void* ptr, int size, int maxnum) |
| 7 | 348 { |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
349 RWHelper* helper = (RWHelper*) context->hidden.unknown.data1; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
350 PyObject* result; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
351 int retval; |
| 7 | 352 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
353 if (!helper->read) |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
354 return -1; |
| 7 | 355 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
356 result = PyObject_CallFunction (helper->read, "i", size * maxnum); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
357 if (!result) |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
358 return -1; |
| 486 | 359 |
|
1553
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
360 if (!Bytes_Check (result)) |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
361 { |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
362 Py_DECREF (result); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
363 return -1; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
364 } |
| 486 | 365 |
|
1553
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
366 retval = Bytes_GET_SIZE (result); |
|
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
367 memcpy (ptr, Bytes_AsString (result), retval); |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
368 retval /= size; |
| 7 | 369 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
370 Py_DECREF (result); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
371 return retval; |
| 7 | 372 } |
| 373 | |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
374 static int |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
375 rw_write (SDL_RWops* context, const void* ptr, int size, int num) |
| 7 | 376 { |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
377 RWHelper* helper = (RWHelper*) context->hidden.unknown.data1; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
378 PyObject* result; |
| 7 | 379 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
380 if (!helper->write) |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
381 return -1; |
| 7 | 382 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
383 result = PyObject_CallFunction (helper->write, "s#", ptr, size * num); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
384 if(!result) |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
385 return -1; |
| 7 | 386 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
387 Py_DECREF (result); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
388 return num; |
| 7 | 389 } |
| 390 | |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
391 static int |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
392 rw_close (SDL_RWops* context) |
| 7 | 393 { |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
394 RWHelper* helper = (RWHelper*) context->hidden.unknown.data1; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
395 PyObject* result; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
396 int retval = 0; |
| 7 | 397 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
398 if (helper->close) |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
399 { |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
400 result = PyObject_CallFunction (helper->close, NULL); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
401 if (result) |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
402 retval = -1; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
403 Py_XDECREF (result); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
404 } |
| 7 | 405 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
406 Py_XDECREF (helper->seek); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
407 Py_XDECREF (helper->tell); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
408 Py_XDECREF (helper->write); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
409 Py_XDECREF (helper->read); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
410 Py_XDECREF (helper->close); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
411 PyMem_Del (helper); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
412 SDL_FreeRW (context); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
413 return retval; |
| 7 | 414 } |
| 415 | |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
416 static SDL_RWops* |
|
2105
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
417 RWopsFromFileObjectThreaded(PyObject *obj) |
| 272 | 418 { |
|
2074
2336cf356f03
fix rwobject memory leak when raising a memory error
Lenard Lindstrom <len-l@telus.net>
parents:
2065
diff
changeset
|
419 SDL_RWops *rw; |
|
2336cf356f03
fix rwobject memory leak when raising a memory error
Lenard Lindstrom <len-l@telus.net>
parents:
2065
diff
changeset
|
420 RWHelper *helper; |
| 486 | 421 |
|
2074
2336cf356f03
fix rwobject memory leak when raising a memory error
Lenard Lindstrom <len-l@telus.net>
parents:
2065
diff
changeset
|
422 if (obj == NULL) { |
|
2336cf356f03
fix rwobject memory leak when raising a memory error
Lenard Lindstrom <len-l@telus.net>
parents:
2065
diff
changeset
|
423 return (SDL_RWops *)RAISE(PyExc_TypeError, "Invalid filetype object"); |
|
2336cf356f03
fix rwobject memory leak when raising a memory error
Lenard Lindstrom <len-l@telus.net>
parents:
2065
diff
changeset
|
424 } |
| 272 | 425 |
| 426 #ifndef WITH_THREAD | |
|
2074
2336cf356f03
fix rwobject memory leak when raising a memory error
Lenard Lindstrom <len-l@telus.net>
parents:
2065
diff
changeset
|
427 return (SDL_RWops *)RAISE(PyExc_NotImplementedError, |
|
2336cf356f03
fix rwobject memory leak when raising a memory error
Lenard Lindstrom <len-l@telus.net>
parents:
2065
diff
changeset
|
428 "Python built without thread support"); |
| 272 | 429 #else |
|
2074
2336cf356f03
fix rwobject memory leak when raising a memory error
Lenard Lindstrom <len-l@telus.net>
parents:
2065
diff
changeset
|
430 helper = PyMem_New(RWHelper, 1); |
|
2336cf356f03
fix rwobject memory leak when raising a memory error
Lenard Lindstrom <len-l@telus.net>
parents:
2065
diff
changeset
|
431 if (helper == NULL) { |
|
2336cf356f03
fix rwobject memory leak when raising a memory error
Lenard Lindstrom <len-l@telus.net>
parents:
2065
diff
changeset
|
432 return (SDL_RWops *)PyErr_NoMemory(); |
|
2336cf356f03
fix rwobject memory leak when raising a memory error
Lenard Lindstrom <len-l@telus.net>
parents:
2065
diff
changeset
|
433 } |
|
2336cf356f03
fix rwobject memory leak when raising a memory error
Lenard Lindstrom <len-l@telus.net>
parents:
2065
diff
changeset
|
434 rw = SDL_AllocRW(); |
|
2336cf356f03
fix rwobject memory leak when raising a memory error
Lenard Lindstrom <len-l@telus.net>
parents:
2065
diff
changeset
|
435 if (rw == NULL) { |
|
2336cf356f03
fix rwobject memory leak when raising a memory error
Lenard Lindstrom <len-l@telus.net>
parents:
2065
diff
changeset
|
436 PyMem_Del(helper); |
|
2336cf356f03
fix rwobject memory leak when raising a memory error
Lenard Lindstrom <len-l@telus.net>
parents:
2065
diff
changeset
|
437 return (SDL_RWops *)PyErr_NoMemory(); |
|
2336cf356f03
fix rwobject memory leak when raising a memory error
Lenard Lindstrom <len-l@telus.net>
parents:
2065
diff
changeset
|
438 } |
|
2336cf356f03
fix rwobject memory leak when raising a memory error
Lenard Lindstrom <len-l@telus.net>
parents:
2065
diff
changeset
|
439 fetch_object_methods(helper, obj); |
|
2336cf356f03
fix rwobject memory leak when raising a memory error
Lenard Lindstrom <len-l@telus.net>
parents:
2065
diff
changeset
|
440 rw->hidden.unknown.data1 = (void *)helper; |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
441 rw->seek = rw_seek_th; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
442 rw->read = rw_read_th; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
443 rw->write = rw_write_th; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
444 rw->close = rw_close_th; |
| 272 | 445 |
|
2074
2336cf356f03
fix rwobject memory leak when raising a memory error
Lenard Lindstrom <len-l@telus.net>
parents:
2065
diff
changeset
|
446 PyEval_InitThreads(); |
| 272 | 447 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
448 return rw; |
| 272 | 449 #endif |
| 450 } | |
| 451 | |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
452 static int |
|
2105
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
453 RWopsCheckObjectThreaded (SDL_RWops* rw) |
| 272 | 454 { |
| 455 #ifdef WITH_THREAD | |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
456 return rw->close == rw_close_th; |
| 272 | 457 #else |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
458 return 0; |
| 272 | 459 #endif |
| 460 } | |
| 461 | |
| 462 #ifdef WITH_THREAD | |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
463 static int |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
464 rw_seek_th (SDL_RWops* context, int offset, int whence) |
| 272 | 465 { |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
466 RWHelper* helper = (RWHelper*) context->hidden.unknown.data1; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
467 PyObject* result; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
468 int retval; |
|
2121
62ddfa716ba9
[BUG] fix Bugzilla 54: movieplayer.py fails with Python 3.2
Lenard Lindstrom <len-l@telus.net>
parents:
2120
diff
changeset
|
469 PyGILState_STATE state; |
|
62ddfa716ba9
[BUG] fix Bugzilla 54: movieplayer.py fails with Python 3.2
Lenard Lindstrom <len-l@telus.net>
parents:
2120
diff
changeset
|
470 |
| 272 | 471 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
472 if (!helper->seek || !helper->tell) |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
473 return -1; |
| 272 | 474 |
|
2121
62ddfa716ba9
[BUG] fix Bugzilla 54: movieplayer.py fails with Python 3.2
Lenard Lindstrom <len-l@telus.net>
parents:
2120
diff
changeset
|
475 state = PyGILState_Ensure(); |
| 486 | 476 |
|
1245
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
477 if (!(offset == 0 && whence == SEEK_CUR)) /* being seek'd, not just tell'd */ |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
478 { |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
479 result = PyObject_CallFunction (helper->seek, "ii", offset, whence); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
480 if(!result) |
|
1245
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
481 { |
|
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
482 PyErr_Print(); |
|
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
483 retval = -1; |
|
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
484 goto end; |
|
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
485 } |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
486 Py_DECREF (result); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
487 } |
| 272 | 488 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
489 result = PyObject_CallFunction (helper->tell, NULL); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
490 if (!result) |
|
1245
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
491 { |
|
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
492 PyErr_Print(); |
|
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
493 retval = -1; |
|
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
494 goto end; |
|
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
495 } |
| 272 | 496 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
497 retval = PyInt_AsLong (result); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
498 Py_DECREF (result); |
| 272 | 499 |
|
1245
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
500 end: |
|
2121
62ddfa716ba9
[BUG] fix Bugzilla 54: movieplayer.py fails with Python 3.2
Lenard Lindstrom <len-l@telus.net>
parents:
2120
diff
changeset
|
501 PyGILState_Release(state); |
| 486 | 502 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
503 return retval; |
| 272 | 504 } |
| 505 | |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
506 static int |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
507 rw_read_th (SDL_RWops* context, void* ptr, int size, int maxnum) |
| 272 | 508 { |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
509 RWHelper* helper = (RWHelper*) context->hidden.unknown.data1; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
510 PyObject* result; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
511 int retval; |
|
2121
62ddfa716ba9
[BUG] fix Bugzilla 54: movieplayer.py fails with Python 3.2
Lenard Lindstrom <len-l@telus.net>
parents:
2120
diff
changeset
|
512 PyGILState_STATE state; |
| 272 | 513 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
514 if (!helper->read) |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
515 return -1; |
| 272 | 516 |
|
2121
62ddfa716ba9
[BUG] fix Bugzilla 54: movieplayer.py fails with Python 3.2
Lenard Lindstrom <len-l@telus.net>
parents:
2120
diff
changeset
|
517 state = PyGILState_Ensure(); |
| 486 | 518 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
519 result = PyObject_CallFunction (helper->read, "i", size * maxnum); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
520 if (!result) |
|
1245
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
521 { |
|
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
522 PyErr_Print(); |
|
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
523 retval = -1; |
|
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
524 goto end; |
|
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
525 } |
| 486 | 526 |
|
1553
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
527 if (!Bytes_Check (result)) |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
528 { |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
529 Py_DECREF (result); |
|
1245
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
530 PyErr_Print(); |
|
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
531 retval = -1; |
|
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
532 goto end; |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
533 } |
| 486 | 534 |
|
1553
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
535 retval = Bytes_GET_SIZE (result); |
|
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
536 memcpy (ptr, Bytes_AsString (result), retval); |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
537 retval /= size; |
| 272 | 538 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
539 Py_DECREF (result); |
| 272 | 540 |
|
1245
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
541 end: |
|
2121
62ddfa716ba9
[BUG] fix Bugzilla 54: movieplayer.py fails with Python 3.2
Lenard Lindstrom <len-l@telus.net>
parents:
2120
diff
changeset
|
542 PyGILState_Release(state); |
| 486 | 543 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
544 return retval; |
| 272 | 545 } |
| 546 | |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
547 static int |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
548 rw_write_th (SDL_RWops* context, const void* ptr, int size, int num) |
| 272 | 549 { |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
550 RWHelper* helper = (RWHelper*) context->hidden.unknown.data1; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
551 PyObject* result; |
|
1245
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
552 int retval; |
|
2121
62ddfa716ba9
[BUG] fix Bugzilla 54: movieplayer.py fails with Python 3.2
Lenard Lindstrom <len-l@telus.net>
parents:
2120
diff
changeset
|
553 PyGILState_STATE state; |
| 486 | 554 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
555 if (!helper->write) |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
556 return -1; |
| 272 | 557 |
|
2121
62ddfa716ba9
[BUG] fix Bugzilla 54: movieplayer.py fails with Python 3.2
Lenard Lindstrom <len-l@telus.net>
parents:
2120
diff
changeset
|
558 state = PyGILState_Ensure(); |
| 486 | 559 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
560 result = PyObject_CallFunction (helper->write, "s#", ptr, size * num); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
561 if (!result) |
|
1245
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
562 { |
|
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
563 PyErr_Print(); |
|
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
564 retval = -1; |
|
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
565 goto end; |
|
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
566 } |
| 272 | 567 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
568 Py_DECREF (result); |
|
1245
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
569 retval = num; |
| 272 | 570 |
|
1245
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
571 end: |
|
2121
62ddfa716ba9
[BUG] fix Bugzilla 54: movieplayer.py fails with Python 3.2
Lenard Lindstrom <len-l@telus.net>
parents:
2120
diff
changeset
|
572 PyGILState_Release(state); |
| 486 | 573 |
|
1245
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
574 return retval; |
| 272 | 575 } |
| 576 | |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
577 static int |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
578 rw_close_th (SDL_RWops* context) |
| 272 | 579 { |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
580 RWHelper* helper = (RWHelper*) context->hidden.unknown.data1; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
581 PyObject* result; |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
582 int retval = 0; |
|
2121
62ddfa716ba9
[BUG] fix Bugzilla 54: movieplayer.py fails with Python 3.2
Lenard Lindstrom <len-l@telus.net>
parents:
2120
diff
changeset
|
583 PyGILState_STATE state; |
| 486 | 584 |
|
2121
62ddfa716ba9
[BUG] fix Bugzilla 54: movieplayer.py fails with Python 3.2
Lenard Lindstrom <len-l@telus.net>
parents:
2120
diff
changeset
|
585 state = PyGILState_Ensure(); |
| 486 | 586 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
587 if (helper->close) |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
588 { |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
589 result = PyObject_CallFunction (helper->close, NULL); |
|
1245
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
590 if (!result) |
|
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
591 { |
|
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
592 PyErr_Print(); |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
593 retval = -1; |
|
1245
ea7a6d4d39e3
patch from Forrest Voight for file-likes in music, thanks Brian and Forrest.
Rene Dudfield <renesd@gmail.com>
parents:
1211
diff
changeset
|
594 } |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
595 Py_XDECREF (result); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
596 } |
| 272 | 597 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
598 Py_XDECREF (helper->seek); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
599 Py_XDECREF (helper->tell); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
600 Py_XDECREF (helper->write); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
601 Py_XDECREF (helper->read); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
602 Py_XDECREF (helper->close); |
| 272 | 603 |
|
832
d09261f3074c
Fix for rw_close_th using helper after PyMem_Del(helper) is called.
Rene Dudfield <renesd@gmail.com>
parents:
831
diff
changeset
|
604 PyMem_Del (helper); |
|
d09261f3074c
Fix for rw_close_th using helper after PyMem_Del(helper) is called.
Rene Dudfield <renesd@gmail.com>
parents:
831
diff
changeset
|
605 |
|
2121
62ddfa716ba9
[BUG] fix Bugzilla 54: movieplayer.py fails with Python 3.2
Lenard Lindstrom <len-l@telus.net>
parents:
2120
diff
changeset
|
606 PyGILState_Release(state); |
| 486 | 607 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
608 SDL_FreeRW (context); |
|
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
609 return retval; |
| 272 | 610 } |
| 611 #endif | |
| 612 | |
|
2105
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
613 static PyObject* |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
614 rwobject_encode_string(PyObject *self, PyObject *args, PyObject *keywds) |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
615 { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
616 PyObject *obj = NULL; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
617 PyObject *eclass = NULL; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
618 const char *encoding = NULL; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
619 const char *errors = NULL; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
620 static char *kwids[] = {"obj", "encoding", "errors", "etype", NULL}; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
621 |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
622 if (!PyArg_ParseTupleAndKeywords(args, keywds, "|OssO&", kwids, |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
623 &obj, &encoding, &errors, |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
624 &is_exception_class, &eclass)) { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
625 return NULL; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
626 } |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
627 |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
628 if (obj == NULL) { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
629 RAISE(PyExc_SyntaxError, "Forwarded exception"); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
630 } |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
631 return RWopsEncodeString(obj, encoding, errors, eclass); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
632 } |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
633 |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
634 static PyObject* |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
635 rwobject_encode_file_path(PyObject *self, PyObject *args, PyObject *keywds) |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
636 { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
637 PyObject *obj = NULL; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
638 PyObject *eclass = NULL; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
639 static char *kwids[] = {"obj", "etype", NULL}; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
640 |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
641 if (!PyArg_ParseTupleAndKeywords(args, keywds, "|OO&", kwids, |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
642 &obj, &is_exception_class, &eclass)) { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
643 return NULL; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
644 } |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
645 |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
646 if (obj == NULL) { |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
647 RAISE(PyExc_SyntaxError, "Forwarded exception"); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
648 } |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
649 return RWopsEncodeFilePath(obj, eclass); |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
650 } |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
651 |
|
1553
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
652 static PyMethodDef _rwobject_methods[] = |
| 7 | 653 { |
|
2105
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
654 { "encode_string", (PyCFunction)rwobject_encode_string, |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
655 METH_VARARGS | METH_KEYWORDS, DOC_PYGAMEENCODESTRING }, |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
656 { "encode_file_path", (PyCFunction)rwobject_encode_file_path, |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
657 METH_VARARGS | METH_KEYWORDS, DOC_PYGAMEENCODEFILEPATH }, |
|
2116
04bace00377c
remove Mac error debugging
Lenard Lindstrom <len-l@telus.net>
parents:
2115
diff
changeset
|
658 { NULL, NULL, 0, NULL } |
| 7 | 659 }; |
| 660 | |
|
1553
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
661 /*DOC*/ static char _rwobject_doc[] = |
|
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
662 /*DOC*/ "SDL_RWops support"; |
|
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
663 |
|
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
664 MODINIT_DEFINE (rwobject) |
| 7 | 665 { |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
666 PyObject *module, *dict, *apiobj; |
|
1553
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
667 int ecode; |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
668 static void* c_api[PYGAMEAPI_RWOBJECT_NUMSLOTS]; |
| 7 | 669 |
|
1553
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
670 #if PY3 |
|
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
671 static struct PyModuleDef _module = { |
|
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
672 PyModuleDef_HEAD_INIT, |
|
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
673 "rwobject", |
|
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
674 _rwobject_doc, |
|
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
675 -1, |
|
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
676 _rwobject_methods, |
|
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
677 NULL, NULL, NULL, NULL |
|
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
678 }; |
|
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
679 #endif |
|
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
680 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
681 /* Create the module and add the functions */ |
|
1553
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
682 #if PY3 |
|
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
683 module = PyModule_Create (&_module); |
|
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
684 #else |
| 1589 | 685 module = Py_InitModule3 (MODPREFIX "rwobject", |
| 686 _rwobject_methods, | |
|
1553
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
687 _rwobject_doc); |
|
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
688 #endif |
|
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
689 if (module == NULL) { |
|
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
690 MODINIT_ERROR; |
|
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
691 } |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
692 dict = PyModule_GetDict (module); |
| 7 | 693 |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
694 /* export the c api */ |
|
2105
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
695 c_api[0] = RWopsFromObject; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
696 c_api[1] = RWopsCheckObject; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
697 c_api[2] = RWopsFromFileObjectThreaded; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
698 c_api[3] = RWopsCheckObjectThreaded; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
699 c_api[4] = RWopsEncodeFilePath; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
700 c_api[5] = RWopsEncodeString; |
|
297803165311
merge fsencoding branch back into trunk, correcting Unicode file path encoding
Lenard Lindstrom <len-l@telus.net>
parents:
2077
diff
changeset
|
701 c_api[6] = RWopsFromFileObject; |
|
2120
42e2bde1a12c
Use capsule objects in preference to cobject objects. This allows Pygame to build an run from Python 3.2, which has to cobjects.
Lenard Lindstrom <len-l@telus.net>
parents:
2116
diff
changeset
|
702 apiobj = encapsulate_api (c_api, "rwobject"); |
|
1553
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
703 if (apiobj == NULL) { |
|
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
704 DECREF_MOD (module); |
|
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
705 MODINIT_ERROR; |
|
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
706 } |
|
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
707 ecode = PyDict_SetItemString (dict, PYGAMEAPI_LOCAL_ENTRY, apiobj); |
|
831
8749d7c235f8
Changes from Marcus for ref counting bug fixes and
Rene Dudfield <renesd@gmail.com>
parents:
565
diff
changeset
|
708 Py_DECREF (apiobj); |
|
1553
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
709 if (ecode == -1) { |
|
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
710 DECREF_MOD (module); |
|
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
711 MODINIT_ERROR; |
|
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
712 } |
|
ebd545641c8b
merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents:
1245
diff
changeset
|
713 MODINIT_RETURN (module); |
| 7 | 714 } |
