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

Delta Between Two Patch Sets: Python/_warnings.c

Issue 11619: On Windows, don't encode filenames in the import machinery
Left Patch Set: Created 8 years, 8 months ago
Right Patch Set: Created 6 years, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « Python/symtable.c ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 #include "Python.h" 1 #include "Python.h"
2 #include "frameobject.h" 2 #include "frameobject.h"
3 3
4 #define MODULE_NAME "_warnings" 4 #define MODULE_NAME "_warnings"
5 5
6 PyDoc_STRVAR(warnings__doc__, 6 PyDoc_STRVAR(warnings__doc__,
7 MODULE_NAME " provides basic warning filtering support.\n" 7 MODULE_NAME " provides basic warning filtering support.\n"
8 "It is a helper module to speed up interpreter start-up."); 8 "It is a helper module to speed up interpreter start-up.");
9 9
10 /* Both 'filters' and 'onceregistry' can be set in warnings.py; 10 /* Both 'filters' and 'onceregistry' can be set in warnings.py;
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 700
701 /* Get the source line. */ 701 /* Get the source line. */
702 source_line = PyList_GetItem(source_list, lineno-1); 702 source_line = PyList_GetItem(source_list, lineno-1);
703 if (!source_line) { 703 if (!source_line) {
704 Py_DECREF(source_list); 704 Py_DECREF(source_list);
705 return NULL; 705 return NULL;
706 } 706 }
707 707
708 /* Handle the warning. */ 708 /* Handle the warning. */
709 returned = warn_explicit(category, message, filename, lineno, module, 709 returned = warn_explicit(category, message, filename, lineno, module,
710 registry, source_line); 710 registry, source_line);
711 Py_DECREF(source_list); 711 Py_DECREF(source_list);
712 return returned; 712 return returned;
713 } 713 }
714 714
715 standard_call: 715 standard_call:
716 return warn_explicit(category, message, filename, lineno, module, 716 return warn_explicit(category, message, filename, lineno, module,
717 registry, NULL); 717 registry, NULL);
718 } 718 }
719 719
720 720
721 /* Function to issue a warning message; may raise an exception. */ 721 /* Function to issue a warning message; may raise an exception. */
722 722
723 static int 723 static int
724 warn_unicode(PyObject *category, PyObject *message, 724 warn_unicode(PyObject *category, PyObject *message,
725 Py_ssize_t stack_level) 725 Py_ssize_t stack_level)
726 { 726 {
727 PyObject *res; 727 PyObject *res;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 #undef PyErr_Warn 779 #undef PyErr_Warn
780 780
781 PyAPI_FUNC(int) 781 PyAPI_FUNC(int)
782 PyErr_Warn(PyObject *category, char *text) 782 PyErr_Warn(PyObject *category, char *text)
783 { 783 {
784 return PyErr_WarnEx(category, text, 1); 784 return PyErr_WarnEx(category, text, 1);
785 } 785 }
786 786
787 /* Warning with explicit origin */ 787 /* Warning with explicit origin */
788 int 788 int
789 PyErr_WarnExplicitObject(PyObject *category, PyObject *message,
790 PyObject *filename, int lineno,
791 PyObject *module, PyObject *registry)
792 {
793 PyObject *res;
794 if (category == NULL)
795 category = PyExc_RuntimeWarning;
796 res = warn_explicit(category, message, filename, lineno,
797 module, registry, NULL);
798 if (res == NULL)
799 return -1;
800 Py_DECREF(res);
801 return 0;
802 }
803
804 int
789 PyErr_WarnExplicit(PyObject *category, const char *text, 805 PyErr_WarnExplicit(PyObject *category, const char *text,
790 const char *filename_str, int lineno, 806 const char *filename_str, int lineno,
791 const char *module_str, PyObject *registry) 807 const char *module_str, PyObject *registry)
792 { 808 {
793 PyObject *res;
794 PyObject *message = PyUnicode_FromString(text); 809 PyObject *message = PyUnicode_FromString(text);
795 PyObject *filename = PyUnicode_DecodeFSDefault(filename_str); 810 PyObject *filename = PyUnicode_DecodeFSDefault(filename_str);
796 PyObject *module = NULL; 811 PyObject *module = NULL;
797 int ret = -1; 812 int ret = -1;
798 813
799 if (message == NULL || filename == NULL) 814 if (message == NULL || filename == NULL)
800 goto exit; 815 goto exit;
801 if (module_str != NULL) { 816 if (module_str != NULL) {
802 module = PyUnicode_FromString(module_str); 817 module = PyUnicode_FromString(module_str);
803 if (module == NULL) 818 if (module == NULL)
804 goto exit; 819 goto exit;
805 } 820 }
806 821
807 if (category == NULL) 822 ret = PyErr_WarnExplicitObject(category, message, filename, lineno,
808 category = PyExc_RuntimeWarning; 823 module, registry);
809 res = warn_explicit(category, message, filename, lineno, module, registry,
810 NULL);
811 if (res == NULL)
812 goto exit;
813 Py_DECREF(res);
814 ret = 0;
815 824
816 exit: 825 exit:
817 Py_XDECREF(message); 826 Py_XDECREF(message);
818 Py_XDECREF(module); 827 Py_XDECREF(module);
819 Py_XDECREF(filename); 828 Py_XDECREF(filename);
820 return ret; 829 return ret;
821 } 830 }
822 831
823 int 832 int
824 PyErr_WarnExplicitFormat(PyObject *category, 833 PyErr_WarnExplicitFormat(PyObject *category,
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 if (_default_action == NULL) { 1031 if (_default_action == NULL) {
1023 _default_action = PyUnicode_FromString("default"); 1032 _default_action = PyUnicode_FromString("default");
1024 if (_default_action == NULL) 1033 if (_default_action == NULL)
1025 return NULL; 1034 return NULL;
1026 } 1035 }
1027 Py_INCREF(_default_action); 1036 Py_INCREF(_default_action);
1028 if (PyModule_AddObject(m, "_defaultaction", _default_action) < 0) 1037 if (PyModule_AddObject(m, "_defaultaction", _default_action) < 0)
1029 return NULL; 1038 return NULL;
1030 return m; 1039 return m;
1031 } 1040 }
LEFTRIGHT

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