diff options
author | Karl Berry <karl@freefriends.org> | 2022-02-13 21:27:21 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-02-13 21:27:21 +0000 |
commit | 41e0a376b50d2614a40ed17972ee2933b686354a (patch) | |
tree | 0a34fc89a4bc7c8137fb2b26fbaac503e727d5de /Master/texmf-dist/tex | |
parent | 24041c1e41a3999c280f7b0139c5ab5117d71330 (diff) |
pyluatex (13feb22)
git-svn-id: svn://tug.org/texlive/trunk@62008 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/lualatex/pyluatex/pyluatex.lua | 26 | ||||
-rw-r--r-- | Master/texmf-dist/tex/lualatex/pyluatex/pyluatex.sty | 2 |
2 files changed, 19 insertions, 9 deletions
diff --git a/Master/texmf-dist/tex/lualatex/pyluatex/pyluatex.lua b/Master/texmf-dist/tex/lualatex/pyluatex/pyluatex.lua index f95ab989c08..f9d8ff68a65 100644 --- a/Master/texmf-dist/tex/lualatex/pyluatex/pyluatex.lua +++ b/Master/texmf-dist/tex/lualatex/pyluatex/pyluatex.lua @@ -33,7 +33,6 @@ pyluatex = pyluatex or { -- status.filename: path to pyluatex.sty local folder = file.pathpart(file.collapsepath(status.filename, true)) -local script = file.join(folder, "pyluatex-interpreter.py") local tcp = nil local env_end = nil @@ -53,6 +52,7 @@ local function err_cmd(message) end function pyluatex.start(executable) + local script = file.join(folder, "pyluatex-interpreter.py") local is_windows = package.config:sub(1,1) ~= "/" local cmd if is_windows then @@ -61,15 +61,25 @@ function pyluatex.start(executable) cmd = executable .. " \"" .. script .. "\" &" end local f = io.popen(cmd, "r") - local port = f:read("*l"):gsub("\r", ""):gsub("\n", "") + local port = f:read("*l") f:close() - if port then - tcp = socket.tcp() - tcp:connect("127.0.0.1", port) - else - tex.sprint(err_cmd("Python backend (executable: " .. executable .. - ") could not be started")) + function err(message) + tex.sprint(err_cmd("Python backend could not be started (" .. message .. ")")) + end + + if port == nil then + err("executable: " .. executable) + return + end + port = trim(port) + if port:match("^%d+$") == nil then + err("invalid TCP port: " .. port) + return + end + tcp = socket.tcp() + if tcp:connect("127.0.0.1", port) == nil then + err("TCP connection failed") end end diff --git a/Master/texmf-dist/tex/lualatex/pyluatex/pyluatex.sty b/Master/texmf-dist/tex/lualatex/pyluatex/pyluatex.sty index cf67916d198..6c247993a91 100644 --- a/Master/texmf-dist/tex/lualatex/pyluatex/pyluatex.sty +++ b/Master/texmf-dist/tex/lualatex/pyluatex/pyluatex.sty @@ -9,7 +9,7 @@ %% version 2005/12/01 or later. \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{pyluatex}[2022/02/04 v0.4.1 Execute Python code on the fly] +\ProvidesPackage{pyluatex}[2022/02/13 v0.4.2 Execute Python code on the fly] \RequirePackage{expl3} \ExplSyntaxOn |