From webhook-mailer at python.org Fri Jul 1 03:23:49 2022 From: webhook-mailer at python.org (tiran) Date: Fri, 01 Jul 2022 07:23:49 -0000 Subject: [Python-checkins] gh-90005-ffi: Fix building _ctypes without pkg-config (GH-94451) Message-ID: https://github.com/python/cpython/commit/d6acdc1b60de4f6fd05c6654a9661b7edddf0448 commit: d6acdc1b60de4f6fd05c6654a9661b7edddf0448 branch: main author: Christian Heimes committer: tiran date: 2022-07-01T09:23:41+02:00 summary: gh-90005-ffi: Fix building _ctypes without pkg-config (GH-94451) The fallback path did not set LIBFFI_LIBS variable to link with ``-lffi``. files: A Misc/NEWS.d/next/Build/2022-06-30-17-00-54.gh-issue-90005.iiq5qD.rst M configure M configure.ac diff --git a/Misc/NEWS.d/next/Build/2022-06-30-17-00-54.gh-issue-90005.iiq5qD.rst b/Misc/NEWS.d/next/Build/2022-06-30-17-00-54.gh-issue-90005.iiq5qD.rst new file mode 100644 index 0000000000000..62f40b8f95f6c --- /dev/null +++ b/Misc/NEWS.d/next/Build/2022-06-30-17-00-54.gh-issue-90005.iiq5qD.rst @@ -0,0 +1 @@ +Fix building ``_ctypes`` extension without ``pkg-config``. diff --git a/configure b/configure index 014d2cefb47f9..9144ee1903617 100755 --- a/configure +++ b/configure @@ -12133,7 +12133,10 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ffi_ffi_call" >&5 $as_echo "$ac_cv_lib_ffi_ffi_call" >&6; } if test "x$ac_cv_lib_ffi_ffi_call" = xyes; then : - have_libffi=yes + + have_libffi=yes + LIBFFI_LIBS="-lffi" + else have_libffi=no fi @@ -12200,7 +12203,10 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ffi_ffi_call" >&5 $as_echo "$ac_cv_lib_ffi_ffi_call" >&6; } if test "x$ac_cv_lib_ffi_ffi_call" = xyes; then : - have_libffi=yes + + have_libffi=yes + LIBFFI_LIBS="-lffi" + else have_libffi=no fi diff --git a/configure.ac b/configure.ac index ab1c6873f731d..12ae2ae8d87eb 100644 --- a/configure.ac +++ b/configure.ac @@ -3605,7 +3605,10 @@ AS_VAR_IF([with_system_ffi], [yes], [ PKG_CHECK_MODULES([LIBFFI], [libffi], [have_libffi=yes], [ AC_CHECK_HEADER([ffi.h], [ WITH_SAVE_ENV([ - AC_CHECK_LIB([ffi], [ffi_call], [have_libffi=yes], [have_libffi=no]) + AC_CHECK_LIB([ffi], [ffi_call], [ + have_libffi=yes + LIBFFI_LIBS="-lffi" + ], [have_libffi=no]) ]) ]) ]) From webhook-mailer at python.org Fri Jul 1 04:33:17 2022 From: webhook-mailer at python.org (ezio-melotti) Date: Fri, 01 Jul 2022 08:33:17 -0000 Subject: [Python-checkins] Add a workflow to add issues/PRs to projects. (#94447) Message-ID: https://github.com/python/cpython/commit/5f2c91a343fb20f8c2fc78cbb3e68234bcba40a8 commit: 5f2c91a343fb20f8c2fc78cbb3e68234bcba40a8 branch: main author: Ezio Melotti committer: ezio-melotti date: 2022-07-01T10:33:10+02:00 summary: Add a workflow to add issues/PRs to projects. (#94447) * Add a workflow to add issues/PRs to projects. * Apply suggestions from code review Co-authored-by: CAM Gerlach Co-authored-by: CAM Gerlach files: A .github/workflows/project-updater.yml diff --git a/.github/workflows/project-updater.yml b/.github/workflows/project-updater.yml new file mode 100644 index 0000000000000..4231b03870d6e --- /dev/null +++ b/.github/workflows/project-updater.yml @@ -0,0 +1,23 @@ +name: Update GH projects + +on: + issues: + types: + - opened + - labeled + pull_request: + types: + - opened + - labeled + +jobs: + add-to-project: + name: Add to the Release and Deferred Blocker project + runs-on: ubuntu-latest + steps: + - uses: actions/add-to-project at v0.1.0 + with: + project-url: https://github.com/orgs/python/projects/2 + github-token: ${{ secrets.ADD_TO_PROJECT_PAT }} + labeled: release-blocker, deferred-blocker + label-operator: OR From webhook-mailer at python.org Fri Jul 1 05:53:25 2022 From: webhook-mailer at python.org (tiran) Date: Fri, 01 Jul 2022 09:53:25 -0000 Subject: [Python-checkins] gh-84461: Improve WebAssembly in-browser demo (#91879) Message-ID: https://github.com/python/cpython/commit/a8e333d79aa639417e496181bcbad2cb801a7a56 commit: a8e333d79aa639417e496181bcbad2cb801a7a56 branch: main author: Trey Hunner committer: tiran date: 2022-07-01T11:52:58+02:00 summary: gh-84461: Improve WebAssembly in-browser demo (#91879) * Buffer standard input line-by-line * Add non-root .editorconfig for JS & HTML indent * Add support for clearing REPL with CTRL+L * Support unicode in stdout and stderr * Remove \r\n normalization * Note that local .editorconfig file extends root * Only normalize lone \r characters (convert to \n) * Skip non-printable characters in buffered input * Fix Safari bug (regex lookbehind not supported) Co-authored-by: Christian Heimes files: A Tools/wasm/.editorconfig M Tools/wasm/python.html M Tools/wasm/python.worker.js diff --git a/Tools/wasm/.editorconfig b/Tools/wasm/.editorconfig new file mode 100644 index 0000000000000..da1aa6acaccc7 --- /dev/null +++ b/Tools/wasm/.editorconfig @@ -0,0 +1,7 @@ +root = false # This extends the root .editorconfig + +[*.{html,js}] +trim_trailing_whitespace = true +insert_final_newline = true +indent_style = space +indent_size = 4 diff --git a/Tools/wasm/python.html b/Tools/wasm/python.html index c8d17488b2e70..41cf5fcf6b6df 100644 --- a/Tools/wasm/python.html +++ b/Tools/wasm/python.html @@ -100,6 +100,7 @@ class WasmTerminal { constructor() { + this.inputBuffer = new BufferQueue(); this.input = '' this.resolveInput = null this.activeInput = false @@ -123,28 +124,47 @@ this.xterm.open(container); } - handleReadComplete(lastChar) { - this.resolveInput(this.input + lastChar) - this.activeInput = false - } - handleTermData = (data) => { - if (!this.activeInput) { - return - } const ord = data.charCodeAt(0); - let ofs; + data = data.replace(/\r(?!\n)/g, "\n") // Convert lone CRs to LF + // Handle pasted data + if (data.length > 1 && data.includes("\n")) { + let alreadyWrittenChars = 0; + // If line already had data on it, merge pasted data with it + if (this.input != '') { + this.inputBuffer.addData(this.input); + alreadyWrittenChars = this.input.length; + this.input = ''; + } + this.inputBuffer.addData(data); + // If input is active, write the first line + if (this.activeInput) { + let line = this.inputBuffer.nextLine(); + this.writeLine(line.slice(alreadyWrittenChars)); + this.resolveInput(line); + this.activeInput = false; + } + // When input isn't active, add to line buffer + } else if (!this.activeInput) { + // Skip non-printable characters + if (!(ord === 0x1b || ord == 0x7f || ord < 32)) { + this.inputBuffer.addData(data); + } // TODO: Handle ANSI escape sequences - if (ord === 0x1b) { + } else if (ord === 0x1b) { // Handle special characters } else if (ord < 32 || ord === 0x7f) { switch (data) { - case "\r": // ENTER + case "\x0c": // CTRL+L + this.clear(); + break; + case "\n": // ENTER case "\x0a": // CTRL+J case "\x0d": // CTRL+M - this.xterm.write('\r\n'); - this.handleReadComplete('\n'); + this.resolveInput(this.input + this.writeLine('\n')); + this.input = ''; + this.activeInput = false; break; case "\x7F": // BACKSPACE case "\x08": // CTRL+H @@ -157,6 +177,12 @@ } } + writeLine(line) { + this.xterm.write(line.slice(0, -1)) + this.xterm.write('\r\n'); + return line; + } + handleCursorInsert(data) { this.input += data; this.xterm.write(data) @@ -176,9 +202,19 @@ this.activeInput = true // Hack to allow stdout/stderr to finish before we figure out where input starts setTimeout(() => {this.inputStartCursor = this.xterm.buffer.active.cursorX}, 1) + // If line buffer has a line ready, send it immediately + if (this.inputBuffer.hasLineReady()) { + return new Promise((resolve, reject) => { + resolve(this.writeLine(this.inputBuffer.nextLine())); + this.activeInput = false; + }) + // If line buffer has an incomplete line, use it for the active line + } else if (this.inputBuffer.lastLineIsIncomplete()) { + // Hack to ensure cursor input start doesn't end up after user input + setTimeout(() => {this.handleCursorInsert(this.inputBuffer.nextLine())}, 1); + } return new Promise((resolve, reject) => { this.resolveInput = (value) => { - this.input = '' resolve(value) } }) @@ -188,9 +224,44 @@ this.xterm.clear(); } - print(message) { - const normInput = message.replace(/[\r\n]+/g, "\n").replace(/\n/g, "\r\n"); - this.xterm.write(normInput); + print(charCode) { + let array = [charCode]; + if (charCode == 10) { + array = [13, 10]; // Replace \n with \r\n + } + this.xterm.write(new Uint8Array(array)); + } +} + +class BufferQueue { + constructor(xterm) { + this.buffer = [] + } + + isEmpty() { + return this.buffer.length == 0 + } + + lastLineIsIncomplete() { + return !this.isEmpty() && !this.buffer[this.buffer.length-1].endsWith("\n") + } + + hasLineReady() { + return !this.isEmpty() && this.buffer[0].endsWith("\n") + } + + addData(data) { + let lines = data.match(/.*(\n|$)/g) + if (this.lastLineIsIncomplete()) { + this.buffer[this.buffer.length-1] += lines.shift() + } + for (let line of lines) { + this.buffer.push(line) + } + } + + nextLine() { + return this.buffer.shift() } } @@ -202,8 +273,8 @@ terminal.open(document.getElementById('terminal')) const stdio = { - stdout: (s) => { terminal.print(s) }, - stderr: (s) => { terminal.print(s) }, + stdout: (charCode) => { terminal.print(charCode) }, + stderr: (charCode) => { terminal.print(charCode) }, stdin: async () => { return await terminal.prompt() } diff --git a/Tools/wasm/python.worker.js b/Tools/wasm/python.worker.js index c3a8bdf7d2fc2..1b794608fffe7 100644 --- a/Tools/wasm/python.worker.js +++ b/Tools/wasm/python.worker.js @@ -35,15 +35,11 @@ class StdinBuffer { } } -const stdoutBufSize = 128; -const stdoutBuf = new Int32Array() -let index = 0; - const stdout = (charCode) => { if (charCode) { postMessage({ type: 'stdout', - stdout: String.fromCharCode(charCode), + stdout: charCode, }) } else { console.log(typeof charCode, charCode) @@ -54,7 +50,7 @@ const stderr = (charCode) => { if (charCode) { postMessage({ type: 'stderr', - stderr: String.fromCharCode(charCode), + stderr: charCode, }) } else { console.log(typeof charCode, charCode) From webhook-mailer at python.org Fri Jul 1 05:54:34 2022 From: webhook-mailer at python.org (tiran) Date: Fri, 01 Jul 2022 09:54:34 -0000 Subject: [Python-checkins] gh-84461: Tool/wasm/python.html: Add subresource integrity hashes (#93953) Message-ID: https://github.com/python/cpython/commit/1df9449db24f16c9c96bdd7dc283a5062bca68e6 commit: 1df9449db24f16c9c96bdd7dc283a5062bca68e6 branch: main author: Petr Viktorin committer: tiran date: 2022-07-01T11:54:30+02:00 summary: gh-84461: Tool/wasm/python.html: Add subresource integrity hashes (#93953) files: M Tools/wasm/python.html diff --git a/Tools/wasm/python.html b/Tools/wasm/python.html index 41cf5fcf6b6df..17ffa0ea8bfef 100644 --- a/Tools/wasm/python.html +++ b/Tools/wasm/python.html @@ -7,7 +7,7 @@ wasm-python terminal - + - + +