Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
1f8fae76
Commit
1f8fae76
authored
Aug 26, 2007
by
Neal Norwitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use unicode
parent
01d1a679
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
39 deletions
+14
-39
Modules/_localemodule.c
Modules/_localemodule.c
+14
-39
No files found.
Modules/_localemodule.c
View file @
1f8fae76
...
...
@@ -107,7 +107,7 @@ PyLocale_setlocale(PyObject* self, PyObject* args)
PyErr_SetString
(
Error
,
"unsupported locale setting"
);
return
NULL
;
}
result_object
=
Py
String
_FromString
(
result
);
result_object
=
Py
Unicode
_FromString
(
result
);
if
(
!
result_object
)
return
NULL
;
}
else
{
...
...
@@ -117,7 +117,7 @@ PyLocale_setlocale(PyObject* self, PyObject* args)
PyErr_SetString
(
Error
,
"locale query failed"
);
return
NULL
;
}
result_object
=
Py
String
_FromString
(
result
);
result_object
=
Py
Unicode
_FromString
(
result
);
}
return
result_object
;
}
...
...
@@ -143,7 +143,7 @@ PyLocale_localeconv(PyObject* self)
involved herein */
#define RESULT_STRING(s)\
x = Py
String
_FromString(l->s);\
x = Py
Unicode
_FromString(l->s);\
if (!x) goto failed;\
PyDict_SetItemString(result, #s, x);\
Py_XDECREF(x)
...
...
@@ -206,33 +206,14 @@ PyLocale_strcoll(PyObject* self, PyObject* args)
#else
PyObject
*
os1
,
*
os2
,
*
result
=
NULL
;
wchar_t
*
ws1
=
NULL
,
*
ws2
=
NULL
;
int
rel1
=
0
,
rel2
=
0
,
len1
,
len2
;
int
len1
,
len2
;
if
(
!
PyArg_UnpackTuple
(
args
,
"strcoll"
,
2
,
2
,
&
os1
,
&
os2
))
return
NULL
;
/* If both arguments are byte strings, use strcoll. */
if
(
PyString_Check
(
os1
)
&&
PyString_Check
(
os2
))
return
PyInt_FromLong
(
strcoll
(
PyString_AS_STRING
(
os1
),
PyString_AS_STRING
(
os2
)));
/* If neither argument is unicode, it's an error. */
if
(
!
PyUnicode_Check
(
os1
)
&&
!
PyUnicode_Check
(
os2
))
{
/* Both arguments must be unicode, or it's an error. */
if
(
!
PyUnicode_Check
(
os1
)
||
!
PyUnicode_Check
(
os2
))
{
PyErr_SetString
(
PyExc_ValueError
,
"strcoll arguments must be strings"
);
}
/* Convert the non-unicode argument to unicode. */
if
(
!
PyUnicode_Check
(
os1
))
{
os1
=
PyUnicode_FromObject
(
os1
);
if
(
!
os1
)
return
NULL
;
rel1
=
1
;
}
if
(
!
PyUnicode_Check
(
os2
))
{
os2
=
PyUnicode_FromObject
(
os2
);
if
(
!
os2
)
{
Py_DECREF
(
os1
);
return
NULL
;
}
rel2
=
1
;
}
/* Convert the unicode strings to wchar[]. */
len1
=
PyUnicode_GET_SIZE
(
os1
)
+
1
;
ws1
=
PyMem_MALLOC
(
len1
*
sizeof
(
wchar_t
));
...
...
@@ -258,12 +239,6 @@ PyLocale_strcoll(PyObject* self, PyObject* args)
/* Deallocate everything. */
if
(
ws1
)
PyMem_FREE
(
ws1
);
if
(
ws2
)
PyMem_FREE
(
ws2
);
if
(
rel1
)
{
Py_DECREF
(
os1
);
}
if
(
rel2
)
{
Py_DECREF
(
os2
);
}
return
result
;
#endif
}
...
...
@@ -295,7 +270,7 @@ PyLocale_strxfrm(PyObject* self, PyObject* args)
return
PyErr_NoMemory
();
strxfrm
(
buf
,
s
,
n2
);
}
result
=
Py
String
_FromString
(
buf
);
result
=
Py
Unicode
_FromString
(
buf
);
PyMem_Free
(
buf
);
return
result
;
}
...
...
@@ -490,7 +465,7 @@ PyLocale_nl_langinfo(PyObject* self, PyObject* args)
return
NULL
;
/* Check whether this is a supported constant. GNU libc sometimes
returns numeric values in the char* return value, which would
crash Py
String
_FromString. */
crash Py
Unicode
_FromString. */
for
(
i
=
0
;
langinfo_constants
[
i
].
name
;
i
++
)
if
(
langinfo_constants
[
i
].
value
==
item
)
{
/* Check NULL as a workaround for GNU libc's returning NULL
...
...
@@ -516,7 +491,7 @@ PyIntl_gettext(PyObject* self, PyObject *args)
char
*
in
;
if
(
!
PyArg_ParseTuple
(
args
,
"z"
,
&
in
))
return
0
;
return
Py
String
_FromString
(
gettext
(
in
));
return
Py
Unicode
_FromString
(
gettext
(
in
));
}
PyDoc_STRVAR
(
dgettext__doc__
,
...
...
@@ -529,7 +504,7 @@ PyIntl_dgettext(PyObject* self, PyObject *args)
char
*
domain
,
*
in
;
if
(
!
PyArg_ParseTuple
(
args
,
"zz"
,
&
domain
,
&
in
))
return
0
;
return
Py
String
_FromString
(
dgettext
(
domain
,
in
));
return
Py
Unicode
_FromString
(
dgettext
(
domain
,
in
));
}
PyDoc_STRVAR
(
dcgettext__doc__
,
...
...
@@ -543,7 +518,7 @@ PyIntl_dcgettext(PyObject *self, PyObject *args)
int
category
;
if
(
!
PyArg_ParseTuple
(
args
,
"zzi"
,
&
domain
,
&
msgid
,
&
category
))
return
0
;
return
Py
String
_FromString
(
dcgettext
(
domain
,
msgid
,
category
));
return
Py
Unicode
_FromString
(
dcgettext
(
domain
,
msgid
,
category
));
}
PyDoc_STRVAR
(
textdomain__doc__
,
...
...
@@ -561,7 +536,7 @@ PyIntl_textdomain(PyObject* self, PyObject* args)
PyErr_SetFromErrno
(
PyExc_OSError
);
return
NULL
;
}
return
Py
String
_FromString
(
domain
);
return
Py
Unicode
_FromString
(
domain
);
}
PyDoc_STRVAR
(
bindtextdomain__doc__
,
...
...
@@ -579,7 +554,7 @@ PyIntl_bindtextdomain(PyObject* self,PyObject*args)
PyErr_SetFromErrno
(
PyExc_OSError
);
return
NULL
;
}
return
Py
String
_FromString
(
dirname
);
return
Py
Unicode
_FromString
(
dirname
);
}
#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
...
...
@@ -595,7 +570,7 @@ PyIntl_bind_textdomain_codeset(PyObject* self,PyObject*args)
return
NULL
;
codeset
=
bind_textdomain_codeset
(
domain
,
codeset
);
if
(
codeset
)
return
Py
String
_FromString
(
codeset
);
return
Py
Unicode
_FromString
(
codeset
);
Py_RETURN_NONE
;
}
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment