pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/9e19ca42d31ba9ff3bc3dc901d832877d3815adb

locale.bindtextdomain(): use PyUnicode_FSConverter() to parse the fil… · python/cpython@9e19ca4 · GitHub
Skip to content

Commit 9e19ca4

Browse files
author
Victor Stinner
committed
locale.bindtextdomain(): use PyUnicode_FSConverter() to parse the filename
1 parent c629d51 commit 9e19ca4

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

Modules/_localemodule.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -572,19 +572,31 @@ PyDoc_STRVAR(bindtextdomain__doc__,
572572
static PyObject*
573573
PyIntl_bindtextdomain(PyObject* self,PyObject*args)
574574
{
575-
char *domain, *dirname;
576-
if (!PyArg_ParseTuple(args, "sz", &domain, &dirname))
575+
char *domain, *dirname, *current_dirname;
576+
PyObject *dirname_obj, *dirname_bytes = NULL, *result;
577+
if (!PyArg_ParseTuple(args, "sO", &domain, &dirname_obj))
577578
return 0;
578579
if (!strlen(domain)) {
579580
PyErr_SetString(Error, "domain must be a non-empty string");
580581
return 0;
581582
}
582-
dirname = bindtextdomain(domain, dirname);
583-
if (!dirname) {
583+
if (dirname_obj != Py_None) {
584+
if (!PyUnicode_FSConverter(dirname_obj, &dirname_bytes))
585+
return NULL;
586+
dirname = PyBytes_AsString(dirname_bytes);
587+
} else {
588+
dirname_bytes = NULL;
589+
dirname = NULL;
590+
}
591+
current_dirname = bindtextdomain(domain, dirname);
592+
if (current_dirname == NULL) {
593+
Py_XDECREF(dirname_bytes);
584594
PyErr_SetFromErrno(PyExc_OSError);
585595
return NULL;
586596
}
587-
return str2uni(dirname);
597+
result = str2uni(current_dirname);
598+
Py_XDECREF(dirname_bytes);
599+
return result;
588600
}
589601

590602
#ifdef HAVE_BIND_TEXTDOMAIN_CODESET

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy