Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 592d019

Browse filesBrowse files
committed
Simplify parsing of tuple in C extension code.
1 parent 8d62769 commit 592d019
Copy full SHA for 592d019

File tree

Expand file treeCollapse file tree

1 file changed

+6
-24
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-24
lines changed

‎src/_path_wrapper.cpp

Copy file name to clipboardExpand all lines: src/_path_wrapper.cpp
+6-24Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -680,14 +680,13 @@ static PyObject *Py_convert_to_string(PyObject *self, PyObject *args, PyObject *
680680
bool simplify = false;
681681
SketchParams sketch;
682682
int precision;
683-
PyObject *codesobj;
684683
char *codes[5];
685684
bool postfix;
686685
std::string buffer;
687686
bool status;
688687

689688
if (!PyArg_ParseTuple(args,
690-
"O&O&O&OO&iOO&:convert_to_string",
689+
"O&O&O&OO&i(yyyyy)O&:convert_to_string",
691690
&convert_path,
692691
&path,
693692
&convert_trans_affine,
@@ -698,7 +697,11 @@ static PyObject *Py_convert_to_string(PyObject *self, PyObject *args, PyObject *
698697
&convert_sketch_params,
699698
&sketch,
700699
&precision,
701-
&codesobj,
700+
&codes[0],
701+
&codes[1],
702+
&codes[2],
703+
&codes[3],
704+
&codes[4],
702705
&convert_bool,
703706
&postfix)) {
704707
return NULL;
@@ -710,27 +713,6 @@ static PyObject *Py_convert_to_string(PyObject *self, PyObject *args, PyObject *
710713
simplify = true;
711714
}
712715

713-
if (!PySequence_Check(codesobj)) {
714-
return NULL;
715-
}
716-
if (PySequence_Size(codesobj) != 5) {
717-
PyErr_SetString(
718-
PyExc_ValueError,
719-
"codes must be a 5-length sequence of byte strings");
720-
return NULL;
721-
}
722-
for (int i = 0; i < 5; ++i) {
723-
PyObject *item = PySequence_GetItem(codesobj, i);
724-
if (item == NULL) {
725-
return NULL;
726-
}
727-
codes[i] = PyBytes_AsString(item);
728-
Py_DECREF(item);
729-
if (codes[i] == NULL) {
730-
return NULL;
731-
}
732-
}
733-
734716
CALL_CPP("convert_to_string",
735717
(status = convert_to_string(
736718
path, trans, cliprect, simplify, sketch,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.