/
module.django.core.wsgi.cpp
364 lines (293 loc) · 12.4 KB
/
module.django.core.wsgi.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
// Generated code for Python source for module 'django.core.wsgi'
// created by Nuitka version 0.4.4pre3
// This code is in part copyright 2013 Kay Hayen.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "nuitka/prelude.hpp"
#include "__modules.hpp"
#include "__constants.hpp"
#include "__helpers.hpp"
// The _module_django__core__wsgi is a Python object pointer of module type.
// Note: For full compatability with CPython, every module variable access
// needs to go through it except for cases where the module cannot possibly
// have changed in the mean time.
PyObject *_module_django__core__wsgi;
PyDictObject *_moduledict_django__core__wsgi;
// The module level variables.
static PyObjectGlobalVariable_django__core__wsgi _mvar_django__core__wsgi_WSGIHandler( &_module_django__core__wsgi, &_python_str_plain_WSGIHandler );
// The module function declarations.
static PyObject *MAKE_FUNCTION_function_1_get_wsgi_application_of_module_django__core__wsgi( );
// The module function definitions.
static PyObject *impl_function_1_get_wsgi_application_of_module_django__core__wsgi( Nuitka_FunctionObject *self )
{
// No context is used.
// Local variable declarations.
// Actual function code.
static PyFrameObject *frame_function_1_get_wsgi_application_of_module_django__core__wsgi = NULL;
if ( isFrameUnusable( frame_function_1_get_wsgi_application_of_module_django__core__wsgi ) )
{
if ( frame_function_1_get_wsgi_application_of_module_django__core__wsgi )
{
#if _DEBUG_REFRAME
puts( "reframe for function_1_get_wsgi_application_of_module_django__core__wsgi" );
#endif
Py_DECREF( frame_function_1_get_wsgi_application_of_module_django__core__wsgi );
}
frame_function_1_get_wsgi_application_of_module_django__core__wsgi = MAKE_FRAME( _codeobj_c810a516394c0bac5d085cf76f158baa, _module_django__core__wsgi );
}
FrameGuard frame_guard( frame_function_1_get_wsgi_application_of_module_django__core__wsgi );
try
{
assert( Py_REFCNT( frame_function_1_get_wsgi_application_of_module_django__core__wsgi ) == 2 ); // Frame stack
frame_guard.setLineNumber( 13 );
return CALL_FUNCTION_NO_ARGS( _mvar_django__core__wsgi_WSGIHandler.asObject0() );
}
catch ( PythonException &_exception )
{
if ( !_exception.hasTraceback() )
{
_exception.setTraceback( MAKE_TRACEBACK( frame_guard.getFrame() ) );
}
else
{
_exception.addTraceback( frame_guard.getFrame0() );
}
if ( frame_guard.getFrame0() == frame_function_1_get_wsgi_application_of_module_django__core__wsgi )
{
Py_DECREF( frame_function_1_get_wsgi_application_of_module_django__core__wsgi );
frame_function_1_get_wsgi_application_of_module_django__core__wsgi = NULL;
}
_exception.toPython();
return NULL;
}
}
static PyObject *fparse_function_1_get_wsgi_application_of_module_django__core__wsgi( Nuitka_FunctionObject *self, PyObject **args, Py_ssize_t args_size, PyObject *kw )
{
assert( kw == NULL || PyDict_Check( kw ) );
NUITKA_MAY_BE_UNUSED Py_ssize_t kw_size = kw ? PyDict_Size( kw ) : 0;
NUITKA_MAY_BE_UNUSED Py_ssize_t kw_found = 0;
NUITKA_MAY_BE_UNUSED Py_ssize_t kw_only_found = 0;
Py_ssize_t args_given = args_size;
if (unlikely( args_given + kw_size > 0 ))
{
#if PYTHON_VERSION < 330
PyErr_Format( PyExc_TypeError, "get_wsgi_application() takes no arguments (%zd given)", args_given + kw_size );
#else
if ( kw_size == 0 )
{
PyErr_Format( PyExc_TypeError, "get_wsgi_application() takes 0 positional arguments but %zd was given", args_given );
}
else
{
PyObject *tmp_iter = PyObject_GetIter( kw );
PyObject *tmp_arg_name = PyIter_Next( tmp_iter );
Py_DECREF( tmp_iter );
PyErr_Format( PyExc_TypeError, "get_wsgi_application() got an unexpected keyword argument '%s'", Nuitka_String_AsString( tmp_arg_name ) );
Py_DECREF( tmp_arg_name );
}
#endif
goto error_exit;
}
return impl_function_1_get_wsgi_application_of_module_django__core__wsgi( self );
error_exit:;
return NULL;
}
static PyObject *dparse_function_1_get_wsgi_application_of_module_django__core__wsgi( Nuitka_FunctionObject *self, PyObject **args, int size )
{
if ( size == 0)
{
return impl_function_1_get_wsgi_application_of_module_django__core__wsgi( self );
}
else
{
PyObject *result = fparse_function_1_get_wsgi_application_of_module_django__core__wsgi( self, args, size, NULL );
return result;
}
}
static PyObject *MAKE_FUNCTION_function_1_get_wsgi_application_of_module_django__core__wsgi( )
{
PyObject *result = Nuitka_Function_New(
fparse_function_1_get_wsgi_application_of_module_django__core__wsgi,
dparse_function_1_get_wsgi_application_of_module_django__core__wsgi,
_python_str_plain_get_wsgi_application,
#if PYTHON_VERSION >= 330
NULL,
#endif
_codeobj_c810a516394c0bac5d085cf76f158baa,
INCREASE_REFCOUNT( Py_None ),
#if PYTHON_VERSION >= 300
INCREASE_REFCOUNT( Py_None ),
NULL,
#endif
_module_django__core__wsgi,
_python_str_digest_fe0d72585976fe3c3b2a73d1a6219cd3
);
return result;
}
#if PYTHON_VERSION >= 300
static struct PyModuleDef _moduledef =
{
PyModuleDef_HEAD_INIT,
"django.core.wsgi", /* m_name */
NULL, /* m_doc */
-1, /* m_size */
NULL, /* m_methods */
NULL, /* m_reload */
NULL, /* m_traverse */
NULL, /* m_clear */
NULL, /* m_free */
};
#endif
#define _MODULE_UNFREEZER 0
#if _MODULE_UNFREEZER
// For embedded modules, to be unpacked. Used by main program/package only
extern void registerMetaPathBasedUnfreezer( struct _inittab *_frozen_modules );
// Our own inittab for lookup of "frozen" modules, i.e. the ones included in this binary.
static struct _inittab _frozen_modules[] =
{
{ NULL, NULL }
};
// For loader attribute.
#if PYTHON_VERSION >= 330
extern PyObject *loader_frozen_modules;
#endif
#endif
// The exported interface to CPython. On import of the module, this function
// gets called. It has to have an exact function name, in cases it's a shared
// library export. This is hidden behind the MOD_INIT_DECL.
MOD_INIT_DECL( django__core__wsgi )
{
#if defined( _NUITKA_EXE ) || PYTHON_VERSION >= 300
static bool _init_done = false;
// Packages can be imported recursively in deep executables.
if ( _init_done )
{
return MOD_RETURN_VALUE( _module_django__core__wsgi );
}
else
{
_init_done = true;
}
#endif
#ifdef _NUITKA_MODULE
// In case of a stand alone extension module, need to call initialization
// the init here because that's the first and only time we are going to get
// called here.
// Initialize the constant values used.
_initBuiltinModule();
_initConstants();
// Initialize the compiled types of Nuitka.
PyType_Ready( &Nuitka_Generator_Type );
PyType_Ready( &Nuitka_Function_Type );
PyType_Ready( &Nuitka_Method_Type );
PyType_Ready( &Nuitka_Frame_Type );
patchInspectModule();
patchBuiltinModule();
#endif
#if _MODULE_UNFREEZER
registerMetaPathBasedUnfreezer( _frozen_modules );
#endif
// puts( "in initdjango__core__wsgi" );
// Create the module object first. There are no methods initially, all are
// added dynamically in actual code only. Also no "__doc__" is initially
// set at this time, as it could not contain NUL characters this way, they
// are instead set in early module code. No "self" for modules, we have no
// use for it.
#if PYTHON_VERSION < 300
_module_django__core__wsgi = Py_InitModule4(
"django.core.wsgi", // Module Name
NULL, // No methods initially, all are added
// dynamically in actual module code only.
NULL, // No __doc__ is initially set, as it could
// not contain NUL this way, added early in
// actual code.
NULL, // No self for modules, we don't use it.
PYTHON_API_VERSION
);
#else
_module_django__core__wsgi = PyModule_Create( &_moduledef );
#endif
_moduledict_django__core__wsgi = (PyDictObject *)((PyModuleObject *)_module_django__core__wsgi)->md_dict;
assertObject( _module_django__core__wsgi );
#ifndef _NUITKA_MODULE
// Seems to work for Python2.7 out of the box, but for Python3.2, the module
// doesn't automatically enter "sys.modules" with the object that it should, so
// do it manually.
#if PYTHON_VERSION >= 300
{
int r = PyObject_SetItem( PySys_GetObject( (char *)"modules" ), _python_str_digest_c08dd42bef643b4e923cc7d534465b58, _module_django__core__wsgi );
assert( r != -1 );
}
#endif
#endif
// For deep importing of a module we need to have "__builtins__", so we set
// it ourselves in the same way than CPython does. Note: This must be done
// before the frame object is allocated, or else it may fail.
PyObject *module_dict = PyModule_GetDict( _module_django__core__wsgi );
if ( PyDict_GetItem( module_dict, _python_str_plain___builtins__ ) == NULL )
{
PyObject *value = ( PyObject *)module_builtin;
#ifdef _NUITKA_EXE
if ( _module_django__core__wsgi != _module___main__ )
{
#endif
value = PyModule_GetDict( value );
#ifdef _NUITKA_EXE
}
#endif
#ifndef __NUITKA_NO_ASSERT__
int res =
#endif
PyDict_SetItem( module_dict, _python_str_plain___builtins__, value );
assert( res == 0 );
}
#if PYTHON_VERSION >= 330
#if _MODULE_UNFREEZER
PyDict_SetItem( module_dict, _python_str_plain___loader__, loader_frozen_modules );
#else
PyDict_SetItem( module_dict, _python_str_plain___loader__, Py_None );
#endif
#endif
// Module code
UPDATE_STRING_DICT0( _moduledict_django__core__wsgi, (Nuitka_StringObject *)_python_str_plain___doc__, Py_None );
UPDATE_STRING_DICT0( _moduledict_django__core__wsgi, (Nuitka_StringObject *)_python_str_plain___file__, _python_str_digest_479f1001fb455284bb766a5dd7737cc6 );
PyFrameObject *frame_module_django__core__wsgi = MAKE_FRAME( _codeobj_f526ed1c3ff0ebede2c7219a9c003cf3, _module_django__core__wsgi );
FrameGuard frame_guard( frame_module_django__core__wsgi );
try
{
assert( Py_REFCNT( frame_module_django__core__wsgi ) == 2 ); // Frame stack
frame_guard.setLineNumber( 1 );
UPDATE_STRING_DICT1( _moduledict_django__core__wsgi, (Nuitka_StringObject *)_python_str_plain_WSGIHandler, IMPORT_NAME( PyObjectTemporary( IMPORT_MODULE( _python_str_digest_dd2ca06c03fa07d107a6c76ca4d8ba93, ((PyModuleObject *)_module_django__core__wsgi)->md_dict, ((PyModuleObject *)_module_django__core__wsgi)->md_dict, _python_list_str_plain_WSGIHandler_list, _python_int_neg_1 ) ).asObject(), _python_str_plain_WSGIHandler ) );
}
catch ( PythonException &_exception )
{
if ( !_exception.hasTraceback() )
{
_exception.setTraceback( MAKE_TRACEBACK( frame_guard.getFrame() ) );
}
else
{
_exception.addTraceback( frame_guard.getFrame0() );
}
#if 0
// TODO: Recognize the need for it
Py_XDECREF( frame_guard.getFrame0()->f_locals );
frame_guard.getFrame0()->f_locals = INCREASE_REFCOUNT( ((PyModuleObject *)_module_django__core__wsgi)->md_dict );
#endif
// Return the error.
_exception.toPython();
return MOD_RETURN_VALUE( NULL );
}
UPDATE_STRING_DICT1( _moduledict_django__core__wsgi, (Nuitka_StringObject *)_python_str_plain_get_wsgi_application, MAKE_FUNCTION_function_1_get_wsgi_application_of_module_django__core__wsgi( ) );
return MOD_RETURN_VALUE( _module_django__core__wsgi );
}