https://github.com/python/cpython/commit/25eee578c8e369b027da6d9d2725f29df6ef1cbd
commit: 25eee578c8e369b027da6d9d2725f29df6ef1cbd
branch: main
author: Hood Chatham <[email protected]>
committer: freakboy3742 <[email protected]>
date: 2024-12-06T10:47:51+08:00
summary:

gh-127627: Add `posix._emscripten_debugger` function (#127628)

Add a posix._emscripten_debugger function to add an emscripten breakpoint.

files:
A Misc/NEWS.d/next/Library/2024-12-05-10-14-52.gh-issue-127627.fgCHOZ.rst
M Modules/clinic/posixmodule.c.h
M Modules/posixmodule.c

diff --git 
a/Misc/NEWS.d/next/Library/2024-12-05-10-14-52.gh-issue-127627.fgCHOZ.rst 
b/Misc/NEWS.d/next/Library/2024-12-05-10-14-52.gh-issue-127627.fgCHOZ.rst
new file mode 100644
index 00000000000000..48a6c7d30b4a26
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-12-05-10-14-52.gh-issue-127627.fgCHOZ.rst
@@ -0,0 +1,2 @@
+Added ``posix._emscripten_debugger()`` to help with debugging the test suite on
+the Emscripten target.
diff --git a/Modules/clinic/posixmodule.c.h b/Modules/clinic/posixmodule.c.h
index cd0c4faeac83d1..554299b8598299 100644
--- a/Modules/clinic/posixmodule.c.h
+++ b/Modules/clinic/posixmodule.c.h
@@ -12447,6 +12447,28 @@ os__create_environ(PyObject *module, PyObject 
*Py_UNUSED(ignored))
     return os__create_environ_impl(module);
 }
 
+#if defined(__EMSCRIPTEN__)
+
+PyDoc_STRVAR(os__emscripten_debugger__doc__,
+"_emscripten_debugger($module, /)\n"
+"--\n"
+"\n"
+"Create a breakpoint for the JavaScript debugger. Emscripten only.");
+
+#define OS__EMSCRIPTEN_DEBUGGER_METHODDEF    \
+    {"_emscripten_debugger", (PyCFunction)os__emscripten_debugger, 
METH_NOARGS, os__emscripten_debugger__doc__},
+
+static PyObject *
+os__emscripten_debugger_impl(PyObject *module);
+
+static PyObject *
+os__emscripten_debugger(PyObject *module, PyObject *Py_UNUSED(ignored))
+{
+    return os__emscripten_debugger_impl(module);
+}
+
+#endif /* defined(__EMSCRIPTEN__) */
+
 #ifndef OS_TTYNAME_METHODDEF
     #define OS_TTYNAME_METHODDEF
 #endif /* !defined(OS_TTYNAME_METHODDEF) */
@@ -13114,4 +13136,8 @@ os__create_environ(PyObject *module, PyObject 
*Py_UNUSED(ignored))
 #ifndef OS__SUPPORTS_VIRTUAL_TERMINAL_METHODDEF
     #define OS__SUPPORTS_VIRTUAL_TERMINAL_METHODDEF
 #endif /* !defined(OS__SUPPORTS_VIRTUAL_TERMINAL_METHODDEF) */
-/*[clinic end generated code: output=7ee14f5e880092f5 input=a9049054013a1b77]*/
+
+#ifndef OS__EMSCRIPTEN_DEBUGGER_METHODDEF
+    #define OS__EMSCRIPTEN_DEBUGGER_METHODDEF
+#endif /* !defined(OS__EMSCRIPTEN_DEBUGGER_METHODDEF) */
+/*[clinic end generated code: output=9c2ca1dbf986c62c input=a9049054013a1b77]*/
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 2c26fbeac9a1be..2045c6065b8e7a 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -84,6 +84,9 @@
    extern char * _getpty(int *, int, mode_t, int);
 #endif
 
+#ifdef __EMSCRIPTEN__
+#include "emscripten.h" // emscripten_debugger()
+#endif
 
 /*
  * A number of APIs are available on macOS from a certain macOS version.
@@ -16845,8 +16848,24 @@ os__create_environ_impl(PyObject *module)
 }
 
 
-static PyMethodDef posix_methods[] = {
+#ifdef __EMSCRIPTEN__
+/*[clinic input]
+os._emscripten_debugger
+
+Create a breakpoint for the JavaScript debugger. Emscripten only.
+[clinic start generated code]*/
+
+static PyObject *
+os__emscripten_debugger_impl(PyObject *module)
+/*[clinic end generated code: output=ad47dc3bf0661343 input=d814b1877fb6083a]*/
+{
+    emscripten_debugger();
+    Py_RETURN_NONE;
+}
+#endif /* __EMSCRIPTEN__ */
+
 
+static PyMethodDef posix_methods[] = {
     OS_STAT_METHODDEF
     OS_ACCESS_METHODDEF
     OS_TTYNAME_METHODDEF
@@ -17060,6 +17079,7 @@ static PyMethodDef posix_methods[] = {
     OS__INPUTHOOK_METHODDEF
     OS__IS_INPUTHOOK_INSTALLED_METHODDEF
     OS__CREATE_ENVIRON_METHODDEF
+    OS__EMSCRIPTEN_DEBUGGER_METHODDEF
     {NULL,              NULL}            /* Sentinel */
 };
 

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to