8000 Switch PyArg_ParseTupleAndKeywords from "es" to "s". by anntzer · Pull Request #13866 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Switch PyArg_ParseTupleAndKeywords from "es" to "s". #13866

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/_macosx.m
Original file line number Diff line number Diff line change
Expand Up @@ -812,10 +812,10 @@ static CGFloat _get_device_scale(CGContextRef cr)
FigureManager_set_window_title(FigureManager* self,
PyObject *args, PyObject *kwds)
{
char* title;
if(!PyArg_ParseTuple(args, "es", "UTF-8", &title))
const char* title;
if (!PyArg_ParseTuple(args, "s", &title)) {
return NULL;

}
Window* window = self->window;
if(window)
{
Expand All @@ -826,7 +826,6 @@ static CGFloat _get_device_scale(CGContextRef cr)
[window setTitle: ns_title];
[pool release];
}
PyMem_Free(title);
Py_RETURN_NONE;
}

Expand Down Expand Up @@ -1369,18 +1368,17 @@ -(void)save_figure:(id)sender
{
int result;
const char* title;
char* default_filename;
if(!PyArg_ParseTuple(args, "ses", &title, "UTF-8", &default_filename))
const char* default_filename;
if (!PyArg_ParseTuple(args, "ss", &title, &default_filename)) {
return NULL;

}
NSSavePanel* panel = [NSSavePanel savePanel];
[panel setTitle: [NSString stringWithCString: title
encoding: NSASCIIStringEncoding]];
NSString* ns_default_filename =
[[NSString alloc]
initWithCString: default_filename
encoding: NSUTF8StringEncoding];
PyMem_Free(default_filename);
#ifdef COMPILING_FOR_10_6
[panel setNameFieldStringValue: ns_default_filename];
result = [panel runModal];
Expand Down
12 changes: 2 additions & 10 deletions src/ft2font_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1066,15 +1066,10 @@ static PyObject *PyFT2Font_get_name_index(PyFT2Font *self, PyObject *args, PyObj
{
char *glyphname;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No const here in this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FT_Get_Name_Index takes a non-const char* as argument (so we'd need a const_cast... not really worth it IMO? can add it if you prefer), even though it does not actually modify it. See also thread starting at http://lists.nongnu.org/archive/html/freetype/2019-04/msg00004.html.

long name_index;

if (!PyArg_ParseTuple(args, "es:get_name_index", "ascii", &glyphname)) {
if (!PyArg_ParseTuple(args, "s:get_name_index", &glyphname)) {
return NULL;
}

CALL_CPP("get_name_index", name_index = self->x->get_name_index(glyphname));

PyMem_Free(glyphname);

return PyLong_FromLong(name_index);
}

Expand Down Expand Up @@ -1114,8 +1109,7 @@ const char *PyFT2Font_get_sfnt_table__doc__ =
static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObject *kwds)
{
char *tagname;

if (!PyArg_ParseTuple(args, "es:get_sfnt_table", "ascii", &tagname)) {
if (!PyArg_ParseTuple(args, "s:get_sfnt_table", &tagname)) {
return NULL;
}

Expand All @@ -1128,8 +1122,6 @@ static PyObject *PyFT2Font_get_sfnt_table(PyFT2Font *self, PyObject *args, PyObj
}
}

PyMem_Free(tagname);

void *table = FT_Get_Sfnt_Table(self->x->get_face(), (FT_Sfnt_Tag)tag);
if (!table) {
Py_RETURN_NONE;
Expand Down
0