Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

You can't have everything... where would you put it? -- Steven Wright


devel / comp.lang.python / To Erik Sun, bug #105312 or why subprocess.run() is not working properly

SubjectAuthor
* To Erik Sun, bug #105312 or why subprocess.run() is not working properlymoi
`- Re: To Erik Sun, bug #105312 or why subprocess.run() is not working properlymoi

1
To Erik Sun, bug #105312 or why subprocess.run() is not working properly

<b94521a3-4b00-416e-8e5b-542077494f7fn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23539&group=comp.lang.python#23539

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:a05:622a:18a7:b0:3f0:abe7:24a7 with SMTP id v39-20020a05622a18a700b003f0abe724a7mr416345qtc.6.1686212619703;
Thu, 08 Jun 2023 01:23:39 -0700 (PDT)
X-Received: by 2002:aca:ef56:0:b0:396:1512:6fd5 with SMTP id
n83-20020acaef56000000b0039615126fd5mr2249351oih.10.1686212619415; Thu, 08
Jun 2023 01:23:39 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Thu, 8 Jun 2023 01:23:39 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=2a02:1210:689b:7a00:dc92:6f5e:15fc:bec5;
posting-account=ung4FAoAAAC46zhHJ0Nsnuox7M5gDvs_
NNTP-Posting-Host: 2a02:1210:689b:7a00:dc92:6f5e:15fc:bec5
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b94521a3-4b00-416e-8e5b-542077494f7fn@googlegroups.com>
Subject: To Erik Sun, bug #105312 or why subprocess.run() is not working properly
From: wxjmfa...@gmail.com (moi)
Injection-Date: Thu, 08 Jun 2023 08:23:39 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2916
 by: moi - Thu, 8 Jun 2023 08:23 UTC

I will be short and *you* will understand what I wrote.

1) Applications are exchanging data/text in a text mode and only in text mode.
An application does not know what is a byte and consequently the coding
of characters.

2) It is however possible to pass/transfer "an encoded text" as text. For this
one needs a codecs which covers the complete byte range. This is where Python
fails.

Small illustration. piping from an "utf-16 output" to a reciever application.
The transfer should always succeed and it is up to the reciever to know what
to do with the incoming text, even if it represents bytes.

(U+8161)
>>> '腡'.encode('utf-16-le').decode('latin1')
'a\x81'
>>> '腡'.encode('utf-16-le').decode('cp1252')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\Python311\Lib\encodings\cp1252.py", line 15, in decode
return codecs.charmap_decode(input,errors,decoding_table)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 1: character maps to <undefined>
>>>

cp1252 beeing the os.device_encoding, the "transfer encoding"

It is very to easy to mimick this behaviour in PowerShell with Python, just by using
a keyboard, understand text.

You may argue, "use bytes". This will no work, or only work with and within
Python applications (decoding the sys.stdout.buffer). A non sense, because
applications are "speaking text."

---

What I presented has nothing to do with the exemples of the guy who is
not using the coding of characters correctly.

It is similar to the issues, that this "US-girl" (?) presented some time ago. She
had difficulties to "pipe" in PowerShell.

That's my understanding.

Re: To Erik Sun, bug #105312 or why subprocess.run() is not working properly

<5fc2f765-baef-4dc5-83d7-e7f33c68801cn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23548&group=comp.lang.python#23548

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:a05:622a:1d0:b0:3f8:6a39:5441 with SMTP id t16-20020a05622a01d000b003f86a395441mr410066qtw.11.1686299163908;
Fri, 09 Jun 2023 01:26:03 -0700 (PDT)
X-Received: by 2002:a05:6870:a8ad:b0:196:6371:c8fb with SMTP id
eb45-20020a056870a8ad00b001966371c8fbmr395127oab.11.1686299163614; Fri, 09
Jun 2023 01:26:03 -0700 (PDT)
Path: i2pn2.org!i2pn.org!news.neodome.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer02.ams4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Fri, 9 Jun 2023 01:26:03 -0700 (PDT)
In-Reply-To: <b94521a3-4b00-416e-8e5b-542077494f7fn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a02:1210:689b:7a00:dc92:6f5e:15fc:bec5;
posting-account=ung4FAoAAAC46zhHJ0Nsnuox7M5gDvs_
NNTP-Posting-Host: 2a02:1210:689b:7a00:dc92:6f5e:15fc:bec5
References: <b94521a3-4b00-416e-8e5b-542077494f7fn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5fc2f765-baef-4dc5-83d7-e7f33c68801cn@googlegroups.com>
Subject: Re: To Erik Sun, bug #105312 or why subprocess.run() is not working properly
From: wxjmfa...@gmail.com (moi)
Injection-Date: Fri, 09 Jun 2023 08:26:03 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 1922
 by: moi - Fri, 9 Jun 2023 08:26 UTC

1) Sorry: Eryk Sun

2) If "Qt" is installed, there is QProcess to toy with

3)
PS C:\humour> # C# in action
PS C:\humour>
PS C:\humour> $a = "import subprocess;"
PS C:\humour> $b = "p = subprocess.run(['.\\textcs.exe'], shell=True, capture_output=True, text=True);"
PS C:\humour> $c = "print(p)"
PS C:\humour> py311 -c ($a + $b + $c)
CompletedProcess(args=['.\\textcs.exe'], returncode=0, stdout='abc需\n', stderr='')
PS C:\humour>
PS C:\humour> .\textcs.exe
abc需
PS C:\humour>

Yes, but...

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor