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

Side by Side Diff: Modules/_codecsmodule.c

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 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:
View unified diff | Download patch
« no previous file with comments | « Modules/cjkcodecs/_codecs_tw.c ('k') | Modules/_ctypes/libffi/src/dlmalloc.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* ------------------------------------------------------------------------ 1 /* ------------------------------------------------------------------------
2 2
3 _codecs -- Provides access to the codec registry and the builtin 3 _codecs -- Provides access to the codec registry and the builtin
4 codecs. 4 codecs.
5 5
6 This module should never be imported directly. The standard library 6 This module should never be imported directly. The standard library
7 module "codecs" wraps this builtin module for use within Python. 7 module "codecs" wraps this builtin module for use within Python.
8 8
9 The codec registry is accessible via: 9 The codec registry is accessible via:
10 10
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 &pbuf, &errors, &mapping)) 581 &pbuf, &errors, &mapping))
582 return NULL; 582 return NULL;
583 if (mapping == Py_None) 583 if (mapping == Py_None)
584 mapping = NULL; 584 mapping = NULL;
585 585
586 unicode = PyUnicode_DecodeCharmap(pbuf.buf, pbuf.len, mapping, errors); 586 unicode = PyUnicode_DecodeCharmap(pbuf.buf, pbuf.len, mapping, errors);
587 PyBuffer_Release(&pbuf); 587 PyBuffer_Release(&pbuf);
588 return codec_tuple(unicode, pbuf.len); 588 return codec_tuple(unicode, pbuf.len);
589 } 589 }
590 590
591 #ifdef HAVE_MBCS 591 #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
592 592
593 static PyObject * 593 static PyObject *
594 mbcs_decode(PyObject *self, 594 mbcs_decode(PyObject *self,
595 PyObject *args) 595 PyObject *args)
596 { 596 {
597 Py_buffer pbuf; 597 Py_buffer pbuf;
598 const char *errors = NULL; 598 const char *errors = NULL;
599 int final = 0; 599 int final = 0;
600 Py_ssize_t consumed; 600 Py_ssize_t consumed;
601 PyObject *decoded = NULL; 601 PyObject *decoded = NULL;
602 602
603 if (!PyArg_ParseTuple(args, "y*|zi:mbcs_decode", 603 if (!PyArg_ParseTuple(args, "y*|zi:mbcs_decode",
604 &pbuf, &errors, &final)) 604 &pbuf, &errors, &final))
605 return NULL; 605 return NULL;
606 consumed = pbuf.len; 606 consumed = pbuf.len;
607 607
608 decoded = PyUnicode_DecodeMBCSStateful(pbuf.buf, pbuf.len, errors, 608 decoded = PyUnicode_DecodeMBCSStateful(pbuf.buf, pbuf.len, errors,
609 final ? NULL : &consumed); 609 final ? NULL : &consumed);
610 PyBuffer_Release(&pbuf); 610 PyBuffer_Release(&pbuf);
611 if (decoded == NULL) 611 if (decoded == NULL)
612 return NULL; 612 return NULL;
613 return codec_tuple(decoded, consumed); 613 return codec_tuple(decoded, consumed);
614 } 614 }
615 615
616 #endif /* HAVE_MBCS */ 616 #endif /* MS_WINDOWS */
617 617
618 /* --- Encoder ------------------------------------------------------------ */ 618 /* --- Encoder ------------------------------------------------------------ */
619 619
620 static PyObject * 620 static PyObject *
621 readbuffer_encode(PyObject *self, 621 readbuffer_encode(PyObject *self,
622 PyObject *args) 622 PyObject *args)
623 { 623 {
624 Py_buffer pdata; 624 Py_buffer pdata;
625 const char *data; 625 const char *data;
626 Py_ssize_t size; 626 Py_ssize_t size;
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 982
983 static PyObject* 983 static PyObject*
984 charmap_build(PyObject *self, PyObject *args) 984 charmap_build(PyObject *self, PyObject *args)
985 { 985 {
986 PyObject *map; 986 PyObject *map;
987 if (!PyArg_ParseTuple(args, "U:charmap_build", &map)) 987 if (!PyArg_ParseTuple(args, "U:charmap_build", &map))
988 return NULL; 988 return NULL;
989 return PyUnicode_BuildEncodingMap(map); 989 return PyUnicode_BuildEncodingMap(map);
990 } 990 }
991 991
992 #ifdef HAVE_MBCS 992 #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
993 993
994 static PyObject * 994 static PyObject *
995 mbcs_encode(PyObject *self, 995 mbcs_encode(PyObject *self,
996 PyObject *args) 996 PyObject *args)
997 { 997 {
998 PyObject *str, *v; 998 PyObject *str, *v;
999 const char *errors = NULL; 999 const char *errors = NULL;
1000 1000
1001 if (!PyArg_ParseTuple(args, "O|z:mbcs_encode", 1001 if (!PyArg_ParseTuple(args, "O|z:mbcs_encode",
1002 &str, &errors)) 1002 &str, &errors))
1003 return NULL; 1003 return NULL;
1004 1004
1005 str = PyUnicode_FromObject(str); 1005 str = PyUnicode_FromObject(str);
1006 if (str == NULL) 1006 if (str == NULL)
1007 return NULL; 1007 return NULL;
1008 v = codec_tuple(PyUnicode_EncodeMBCS( 1008 v = codec_tuple(PyUnicode_EncodeMBCS(
1009 PyUnicode_AS_UNICODE(str), 1009 PyUnicode_AS_UNICODE(str),
1010 PyUnicode_GET_SIZE(str), 1010 PyUnicode_GET_SIZE(str),
1011 errors), 1011 errors),
1012 PyUnicode_GET_SIZE(str)); 1012 PyUnicode_GET_SIZE(str));
1013 Py_DECREF(str); 1013 Py_DECREF(str);
1014 return v; 1014 return v;
1015 } 1015 }
1016 1016
1017 #endif /* HAVE_MBCS */ 1017 #endif /* MS_WINDOWS */
1018 1018
1019 /* --- Error handler registry --------------------------------------------- */ 1019 /* --- Error handler registry --------------------------------------------- */
1020 1020
1021 PyDoc_STRVAR(register_error__doc__, 1021 PyDoc_STRVAR(register_error__doc__,
1022 "register_error(errors, handler)\n\ 1022 "register_error(errors, handler)\n\
1023 \n\ 1023 \n\
1024 Register the specified error handler under the name\n\ 1024 Register the specified error handler under the name\n\
1025 errors. handler must be a callable object, that\n\ 1025 errors. handler must be a callable object, that\n\
1026 will be called with an exception instance containing\n\ 1026 will be called with an exception instance containing\n\
1027 information about the location of the encoding/decoding\n\ 1027 information about the location of the encoding/decoding\n\
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 {"raw_unicode_escape_encode", raw_unicode_escape_encode, METH_VARARGS}, 1094 {"raw_unicode_escape_encode", raw_unicode_escape_encode, METH_VARARGS},
1095 {"raw_unicode_escape_decode", raw_unicode_escape_decode, METH_VARARGS}, 1095 {"raw_unicode_escape_decode", raw_unicode_escape_decode, METH_VARARGS},
1096 {"latin_1_encode", latin_1_encode, METH_VARARGS}, 1096 {"latin_1_encode", latin_1_encode, METH_VARARGS},
1097 {"latin_1_decode", latin_1_decode, METH_VARARGS}, 1097 {"latin_1_decode", latin_1_decode, METH_VARARGS},
1098 {"ascii_encode", ascii_encode, METH_VARARGS}, 1098 {"ascii_encode", ascii_encode, METH_VARARGS},
1099 {"ascii_decode", ascii_decode, METH_VARARGS}, 1099 {"ascii_decode", ascii_decode, METH_VARARGS},
1100 {"charmap_encode", charmap_encode, METH_VARARGS}, 1100 {"charmap_encode", charmap_encode, METH_VARARGS},
1101 {"charmap_decode", charmap_decode, METH_VARARGS}, 1101 {"charmap_decode", charmap_decode, METH_VARARGS},
1102 {"charmap_build", charmap_build, METH_VARARGS}, 1102 {"charmap_build", charmap_build, METH_VARARGS},
1103 {"readbuffer_encode", readbuffer_encode, METH_VARARGS}, 1103 {"readbuffer_encode", readbuffer_encode, METH_VARARGS},
1104 #ifdef HAVE_MBCS 1104 #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
1105 {"mbcs_encode", mbcs_encode, METH_VARARGS}, 1105 {"mbcs_encode", mbcs_encode, METH_VARARGS},
1106 {"mbcs_decode", mbcs_decode, METH_VARARGS}, 1106 {"mbcs_decode", mbcs_decode, METH_VARARGS},
1107 #endif 1107 #endif
1108 {"register_error", register_error, METH_VARARGS, 1108 {"register_error", register_error, METH_VARARGS,
1109 register_error__doc__}, 1109 register_error__doc__},
1110 {"lookup_error", lookup_error, METH_VARARGS, 1110 {"lookup_error", lookup_error, METH_VARARGS,
1111 lookup_error__doc__}, 1111 lookup_error__doc__},
1112 {NULL, NULL} /* sentinel */ 1112 {NULL, NULL} /* sentinel */
1113 }; 1113 };
1114 1114
1115 static struct PyModuleDef codecsmodule = { 1115 static struct PyModuleDef codecsmodule = {
1116 PyModuleDef_HEAD_INIT, 1116 PyModuleDef_HEAD_INIT,
1117 "_codecs", 1117 "_codecs",
1118 NULL, 1118 NULL,
1119 -1, 1119 -1,
1120 _codecs_functions, 1120 _codecs_functions,
1121 NULL, 1121 NULL,
1122 NULL, 1122 NULL,
1123 NULL, 1123 NULL,
1124 NULL 1124 NULL
1125 }; 1125 };
1126 1126
1127 PyMODINIT_FUNC 1127 PyMODINIT_FUNC
1128 PyInit__codecs(void) 1128 PyInit__codecs(void)
1129 { 1129 {
1130 return PyModule_Create(&codecsmodule); 1130 return PyModule_Create(&codecsmodule);
1131 } 1131 }
OLDNEW
« no previous file with comments | « Modules/cjkcodecs/_codecs_tw.c ('k') | Modules/_ctypes/libffi/src/dlmalloc.c » ('j') | no next file with comments »

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