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

Side by Side Diff: Python/_warnings.c

Issue 3255: Issue #3602 (Closed) SVN Base: http://svn.python.org/view/*checkout*/python/trunk/
Patch Set: Created 1 year, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 #include "Python.h" 1 #include "Python.h"
2 #include "code.h" /* For DeprecationWarning about adding 'line'. */
2 #include "frameobject.h" 3 #include "frameobject.h"
3 4
4 #define MODULE_NAME "_warnings" 5 #define MODULE_NAME "_warnings"
5 #define DEFAULT_ACTION_NAME "default_action" 6 #define DEFAULT_ACTION_NAME "default_action"
6 7
7 PyDoc_STRVAR(warnings__doc__, 8 PyDoc_STRVAR(warnings__doc__,
8 MODULE_NAME " provides basic warning filtering support.\n" 9 MODULE_NAME " provides basic warning filtering support.\n"
9 "It is a helper module to speed up interpreter start-up."); 10 "It is a helper module to speed up interpreter start-up.");
10 11
11 /* Both 'filters' and 'onceregistry' can be set in warnings.py; 12 /* Both 'filters' and 'onceregistry' can be set in warnings.py;
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 "warnings.showwarning() must be set to a " 410 "warnings.showwarning() must be set to a "
410 "function or method"); 411 "function or method");
411 Py_DECREF(show_fxn); 412 Py_DECREF(show_fxn);
412 goto cleanup; 413 goto cleanup;
413 } 414 }
414 415
415 defaults = PyFunction_GetDefaults(check_fxn); 416 defaults = PyFunction_GetDefaults(check_fxn);
416 /* A proper implementation of warnings.showwarning() should 417 /* A proper implementation of warnings.showwarning() should
417 have at least two default arguments. */ 418 have at least two default arguments. */
418 if ((defaults == NULL) || (PyTuple_Size(defaults) < 2)) { 419 if ((defaults == NULL) || (PyTuple_Size(defaults) < 2)) {
419 if (PyErr_WarnEx(PyExc_DeprecationWarning, msg, 1) < 0) { 420 » PyCodeObject *code = (PyCodeObject *)
420 Py_DECREF(show_fxn); 421 » » » » » » PyFunction_GetCode(check_fxn);
421 goto cleanup; 422 » » if (!(code->co_flags & CO_VARARGS)) {
423 » » if (PyErr_WarnEx(PyExc_DeprecationWarning, msg, 1) <
424 » » » » 0) {
425 Py_DECREF(show_fxn);
426 goto cleanup;
427 }
422 } 428 }
423 } 429 » » }
424 res = PyObject_CallFunctionObjArgs(show_fxn, message, category, 430 res = PyObject_CallFunctionObjArgs(show_fxn, message, category,
425 filename, lineno_obj, 431 filename, lineno_obj,
426 NULL); 432 NULL);
427 Py_DECREF(show_fxn); 433 Py_DECREF(show_fxn);
428 Py_XDECREF(res); 434 Py_XDECREF(res);
429 if (res == NULL) 435 if (res == NULL)
430 goto cleanup; 436 goto cleanup;
431 } 437 }
432 } 438 }
433 } 439 }
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 Py_INCREF(_once_registry); 905 Py_INCREF(_once_registry);
900 if (PyModule_AddObject(m, "once_registry", _once_registry) < 0) 906 if (PyModule_AddObject(m, "once_registry", _once_registry) < 0)
901 return; 907 return;
902 908
903 default_action = PyString_InternFromString("default"); 909 default_action = PyString_InternFromString("default");
904 if (default_action == NULL) 910 if (default_action == NULL)
905 return; 911 return;
906 if (PyModule_AddObject(m, DEFAULT_ACTION_NAME, default_action) < 0) 912 if (PyModule_AddObject(m, DEFAULT_ACTION_NAME, default_action) < 0)
907 return; 913 return;
908 } 914 }
OLDNEW

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld r497