Skip to content

Commit

Permalink
format mymodule.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
szabolcsdombi authored Jul 4, 2023
1 parent 7148670 commit a8be63c
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions mymodule/mymodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,18 +261,13 @@ void sec_websocket_accept(const void * src, void * dst) {

PyObject * c_accept(PyObject * self, PyObject * arg) {
char result[28];
const char* src;
Py_ssize_t len;
src = PyUnicode_AsUTF8AndSize(arg, &len);
if (src == NULL) {
// error will have been set by Python
Py_ssize_t len = 0;
const char * key = PyUnicode_AsUTF8AndSize(arg, &len);
if (!key || len != 24) {
PyErr_SetString(PyExc_ValueError, "invalid key");
return NULL;
}
if (len != 24) {
PyErr_SetString(PyExc_ValueError, "Invalid length");
return NULL;
}
sec_websocket_accept(src, result);
sec_websocket_accept(key, result);
return PyUnicode_FromStringAndSize(result, 28);
}

Expand Down

0 comments on commit a8be63c

Please sign in to comment.