Re: name 'aLOCK' is not defined When I add aLOCK = threading.RLock() behind if __name__ == "__main__"
On Fri, 10 Aug 2018 08:15:09 +0200, Karsten Hilbert wrote: > On Fri, Aug 10, 2018 at 12:24:25AM +0800, xuanwu348 wrote: > >> Yes, move the code from positionA(can run normally) to >> positionB(exception with name undefined) I find this content >> "https://docs.python.org/3.3/tutorial/classes.html#python-scopes-and- namespaces" >> But I still don't undewrstand the differenct of scopes-and-namespaces >> between positionA and positionB, >> >> I think the variable "aLock" at these positionA or positionB are all >> global. > > When something goes wrong in an unexpected way: test your assumptions > ;-) xuanwu348's assumptions are correct. aLock is a global, in both positions. The problem is not the scope of the variable, but whether or not the variable is assigned to or not. -- Steven D'Aprano "Ever since I learned about confirmation bias, I've been seeing it everywhere." -- Jon Ronson -- https://mail.python.org/mailman/listinfo/python-list
Re: Embedded Python and multiprocessing on Windows?
On 09/08/2018 19:33, Apple wrote:> So my program runs one script file, and multiprocessing commands from that script file seem to fail to spawn new processes. > > However, if that script file calls a function in a separate script file that > it has imported, and that function calls multiprocessing functions, it all > works exactly the way it should. > On Thursday, August 9, 2018 at 12:09:36 PM UTC-4, Apple wrote: >> I've been working on a project involving embedding Python into a Windows >> application. I've got all of that working fine on the C++ side, but the >> script side seems to be hitting a dead end with multiprocessing. When my >> script tries to run the same multiprocessing code that works in a >> non-embedded environment, the code doesn't appear to be executed at all. >> >> Still no joy. However, a Python.exe window does pop up for a tenth of a >> second, so *something* is happening. That may be something simple: Did you actually protected the entry-point of your Python script with if __name__ == '__main__': ? -- https://mail.python.org/mailman/listinfo/python-list
Re: Re: name 'aLOCK' is not defined When I add aLOCK = threading.RLock() behind if __name__ == "__main__"
On Fri, Aug 10, 2018 at 12:24:25AM +0800, xuanwu348 wrote: > Yes, move the code from positionA(can run normally) to positionB(exception > with name undefined) > I find this content > "https://docs.python.org/3.3/tutorial/classes.html#python-scopes-and-namespaces"; > But I still don't undewrstand the differenct of scopes-and-namespaces > between positionA and positionB, > > I think the variable "aLock" at these positionA or positionB are all global. When something goes wrong in an unexpected way: test your assumptions ;-) Best, Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B -- https://mail.python.org/mailman/listinfo/python-list
[Promotion] Book for Data Science Aspirants
Hello Python people, Two years ago, my profession changed, I had to do data science work. When I started it, I (though I knew Python) found it to be extremely difficult and I had these doubts: What to learn? Where to learn? Am I doing things right? Where can I find a person who would guide me in the right path? Were the questions that arose in my mind. I had no proper guide and it was pain. So I wrote this book "How To Become A Data Scientist" https://www.amazon.com/dp/B07FYVTNX7 , a guide for those who would like to become Data Scientist. I have crystallized two years of my struggle and answers to it in this book. I hope this book would help you. - Karthikeyan A K -- https://mail.python.org/mailman/listinfo/python-list
回复: Re: name 'aLOCK' is not defined When I add aLOCK = threading.RLock() behind if __name__ == "__main__"
Thanks, I think I get the answer. thanks all, have a good day! 从三星移动设备发送 原始邮件 发件人: MRAB 日期:2018-08-10 03:05 (GMT+08:00) 收件人: python-list@python.org 主题: Re: name 'aLOCK' is not defined When I add aLOCK = threading.RLock() behind if __name__ == "__main__" On 2018-08-09 16:16, xuanwu348 wrote: > Hi team > > Good day > The problem I meet when I add "aLOCK = threading.RLock()" to PositionB, the > program will report error "name 'aLOCK' is not defined ", > but when I change this code to PositionA, it can run normally, is there any > difference for the code between 'if __name__ == "__main__:"', can you help > me, thanks! > > The file I was attached, please change the extend ".pyx" to ".py", thanks, > code as below, tried python2.7 and python3.4: > > import threading > import time > from multiprocessing import Process > > #PositionA > aLOCK = threading.RLock() > > def Save_runnedCMD(filename, strings): > aLOCK.acquire() > with open(filename, "at") as f: > f.write(str(strings) + "\n\r") > aLOCK.release() > > def runCMD(filename): > time.sleep(1) > cmd = "testtest" > Save_runnedCMD(filename, cmd) > > > def Thr_run(filename): > t = [] > for i in range(2): > tt = threading.Thread(target = runCMD, args=(filename,)) > tt.start() > t.append(tt) > for tt in t: > tt.join() > > if __name__ == "__main__": > filename = "./testa.log" > > #PositionB > #aLOCK = threading.RLock() > > while 1: > t1 = Process(target=Thr_run, args=(filename, )) > t1.start() > t1.join() > > Error info as below: > D:\Ap>python testa.py > Exception in thread Thread-1: > Traceback (most recent call last): > File "C:\Python34\lib\threading.py", line 921, in _bootstrap_inner > self.run() > File "C:\Python34\lib\threading.py", line 869, in run > self._target(*self._args, **self._kwargs) > File "D:\Ap\testa.py", line 15, in runCMD > Save_runnedCMD(filename, cmd) > File "D:\Ap\testa.py", line 7, in Save_runnedCMD > aLOCK.acquire() > NameError: name 'aLOCK' is not defined > > Exception in thread Thread-2: > Traceback (most recent call last): > File "C:\Python34\lib\threading.py", line 921, in _bootstrap_inner > self.run() > File "C:\Python34\lib\threading.py", line 869, in run > self._target(*self._args, **self._kwargs) > File "D:\Ap\testa.py", line 15, in runCMD > Save_runnedCMD(filename, cmd) > File "D:\Ap\testa.py", line 7, in Save_runnedCMD > aLOCK.acquire() > NameError: name 'aLOCK' is not defined > When you run the script, __name__ will be "__main__". When script uses the multiprocessing module to run the function "Thr_run" in another process, it actually starts another instance of itself, and in that other instance, name _won't_ be "__main__". Here's a simple example: from multiprocessing import Process def test_func(): print('test_func') print('__name__ is {!a}'.format(__name__)) if __name__ == "__main__": p = Process(target=test_func) p.start() p.join() When run, it prints: __name__ is '__main__' __name__ is '__mp_main__' test_func So, if you put the lock at PositionB, it won't be created by the subprocess. -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Python MySQL Guide
Refer this complete guide on working with Python and MySQL https://pynative.com/python-mysql-tutorial/ -- https://mail.python.org/mailman/listinfo/python-list
tabs vs. spaces
https://www.youtube.com/watch?v=SsoOG6ZeyUI&feature=youtu.be -- https://mail.python.org/mailman/listinfo/python-list
Re: name 'aLOCK' is not defined When I add aLOCK = threading.RLock() behind if __name__ == "__main__"
On 2018-08-09 16:16, xuanwu348 wrote: Hi team Good day The problem I meet when I add "aLOCK = threading.RLock()" to PositionB, the program will report error "name 'aLOCK' is not defined ", but when I change this code to PositionA, it can run normally, is there any difference for the code between 'if __name__ == "__main__:"', can you help me, thanks! The file I was attached, please change the extend ".pyx" to ".py", thanks, code as below, tried python2.7 and python3.4: import threading import time from multiprocessing import Process #PositionA aLOCK = threading.RLock() def Save_runnedCMD(filename, strings): aLOCK.acquire() with open(filename, "at") as f: f.write(str(strings) + "\n\r") aLOCK.release() def runCMD(filename): time.sleep(1) cmd = "testtest" Save_runnedCMD(filename, cmd) def Thr_run(filename): t = [] for i in range(2): tt = threading.Thread(target = runCMD, args=(filename,)) tt.start() t.append(tt) for tt in t: tt.join() if __name__ == "__main__": filename = "./testa.log" #PositionB #aLOCK = threading.RLock() while 1: t1 = Process(target=Thr_run, args=(filename, )) t1.start() t1.join() Error info as below: D:\Ap>python testa.py Exception in thread Thread-1: Traceback (most recent call last): File "C:\Python34\lib\threading.py", line 921, in _bootstrap_inner self.run() File "C:\Python34\lib\threading.py", line 869, in run self._target(*self._args, **self._kwargs) File "D:\Ap\testa.py", line 15, in runCMD Save_runnedCMD(filename, cmd) File "D:\Ap\testa.py", line 7, in Save_runnedCMD aLOCK.acquire() NameError: name 'aLOCK' is not defined Exception in thread Thread-2: Traceback (most recent call last): File "C:\Python34\lib\threading.py", line 921, in _bootstrap_inner self.run() File "C:\Python34\lib\threading.py", line 869, in run self._target(*self._args, **self._kwargs) File "D:\Ap\testa.py", line 15, in runCMD Save_runnedCMD(filename, cmd) File "D:\Ap\testa.py", line 7, in Save_runnedCMD aLOCK.acquire() NameError: name 'aLOCK' is not defined When you run the script, __name__ will be "__main__". When script uses the multiprocessing module to run the function "Thr_run" in another process, it actually starts another instance of itself, and in that other instance, name _won't_ be "__main__". Here's a simple example: from multiprocessing import Process def test_func(): print('test_func') print('__name__ is {!a}'.format(__name__)) if __name__ == "__main__": p = Process(target=test_func) p.start() p.join() When run, it prints: __name__ is '__main__' __name__ is '__mp_main__' test_func So, if you put the lock at PositionB, it won't be created by the subprocess. -- https://mail.python.org/mailman/listinfo/python-list
Re: Why this regex for string literals can't handle escaped quotes?.... '"(\\.|[^"])*"'
Wow. Thanks. That cleared everything up. cs -- https://mail.python.org/mailman/listinfo/python-list
Re: Why this regex for string literals can't handle escaped quotes?.... '"(\\.|[^"])*"'
cseber...@gmail.com wrote: > Why this regex for string literals > can't handle escaped quotes? '"(\\.|[^"])*"' > > See this... > string_re = '"(\\.|[^"])*"' > re.match(string_re, '""') > <_sre.SRE_Match object; span=(0, 6), match='""'> > re.match(string_re, '"aa\"aa"') > <_sre.SRE_Match object; span=(0, 4), match='"aa"'> > > How make the last match be the entire string '"aa\"aa"' ? > > cs You did not escape the string literals: >>> '"aa\"aa"' == '"aa"aa"' True Once you fix this for both the regex and the search string you get the expected match: >>> re.match('"(.|[^"])*"', '"aa\\"aa"') <_sre.SRE_Match object; span=(0, 8), match='"aa\\"aa"'> Raw strings make this a bit easier to read: >>> re.match(r'"(\\.|[^"])*"', r'"aa\"aa"') <_sre.SRE_Match object; span=(0, 8), match='"aa\\"aa"'> -- https://mail.python.org/mailman/listinfo/python-list
Re:Re: name 'aLOCK' is not defined When I add aLOCK = threading.RLock() behind if __name__ == "__main__"
Thanks for your reply! Yes, move the code from positionA(can run normally) to positionB(exception with name undefined) I find this content "https://docs.python.org/3.3/tutorial/classes.html#python-scopes-and-namespaces"; But I still don't undewrstand the differenct of scopes-and-namespaces between positionA and positionB, I think the variable "aLock" at these positionA or positionB are all global. The function can find threading.RLock() by name ""aLock". At 2018-08-09 23:51:45, "Karsten Hilbert" wrote: >On Thu, Aug 09, 2018 at 11:16:37PM +0800, xuanwu348 wrote: > >> The problem I meet when I add "aLOCK = threading.RLock()" to PositionB, the >> program will report error "name 'aLOCK' is not defined ", > >You mean to say: *move*, not *add*. > >That is why aLock is out of scope. > > /python3-doc/html/tutorial/classes.html#python-scopes-and-namespaces > >> but when I change this code to PositionA, it can run normally, is there any >> difference for the code between 'if __name__ == "__main__:"', can you help >> me, thanks! >> >> The file I was attached, please change the extend ".pyx" to ".py", thanks, >> code as below, tried python2.7 and python3.4: >> >> import threading >> import time >> from multiprocessing import Process >> >> #PositionA >> aLOCK = threading.RLock() >> >> def Save_runnedCMD(filename, strings): >> aLOCK.acquire() >> with open(filename, "at") as f: >> f.write(str(strings) + "\n\r") >> aLOCK.release() >> >> def runCMD(filename): >> time.sleep(1) >> cmd = "testtest" >> Save_runnedCMD(filename, cmd) >> >> >> def Thr_run(filename): >> t = [] >> for i in range(2): >> tt = threading.Thread(target = runCMD, args=(filename,)) >> tt.start() >> t.append(tt) >> for tt in t: >> tt.join() >> >> if __name__ == "__main__": >> filename = "./testa.log" >> >> #PositionB >> #aLOCK = threading.RLock() >> >> while 1: >> t1 = Process(target=Thr_run, args=(filename, )) >> t1.start() >> t1.join() >> >> Error info as below: >> D:\Ap>python testa.py >> Exception in thread Thread-1: >> Traceback (most recent call last): >> File "C:\Python34\lib\threading.py", line 921, in _bootstrap_inner >> self.run() >> File "C:\Python34\lib\threading.py", line 869, in run >> self._target(*self._args, **self._kwargs) >> File "D:\Ap\testa.py", line 15, in runCMD >> Save_runnedCMD(filename, cmd) >> File "D:\Ap\testa.py", line 7, in Save_runnedCMD >> aLOCK.acquire() >> NameError: name 'aLOCK' is not defined >> >> Exception in thread Thread-2: >> Traceback (most recent call last): >> File "C:\Python34\lib\threading.py", line 921, in _bootstrap_inner >> self.run() >> File "C:\Python34\lib\threading.py", line 869, in run >> self._target(*self._args, **self._kwargs) >> File "D:\Ap\testa.py", line 15, in runCMD >> Save_runnedCMD(filename, cmd) >> File "D:\Ap\testa.py", line 7, in Save_runnedCMD >> aLOCK.acquire() >> NameError: name 'aLOCK' is not defined >> -- >> https://mail.python.org/mailman/listinfo/python-list > >-- >GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B >-- >https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: name 'aLOCK' is not defined When I add aLOCK = threading.RLock() behind if __name__ == "__main__"
On Thu, Aug 09, 2018 at 11:16:37PM +0800, xuanwu348 wrote: > The problem I meet when I add "aLOCK = threading.RLock()" to PositionB, the > program will report error "name 'aLOCK' is not defined ", You mean to say: *move*, not *add*. That is why aLock is out of scope. /python3-doc/html/tutorial/classes.html#python-scopes-and-namespaces > but when I change this code to PositionA, it can run normally, is there any > difference for the code between 'if __name__ == "__main__:"', can you help > me, thanks! > > The file I was attached, please change the extend ".pyx" to ".py", thanks, > code as below, tried python2.7 and python3.4: > > import threading > import time > from multiprocessing import Process > > #PositionA > aLOCK = threading.RLock() > > def Save_runnedCMD(filename, strings): > aLOCK.acquire() > with open(filename, "at") as f: > f.write(str(strings) + "\n\r") > aLOCK.release() > > def runCMD(filename): > time.sleep(1) > cmd = "testtest" > Save_runnedCMD(filename, cmd) > > > def Thr_run(filename): > t = [] > for i in range(2): > tt = threading.Thread(target = runCMD, args=(filename,)) > tt.start() > t.append(tt) > for tt in t: > tt.join() > > if __name__ == "__main__": > filename = "./testa.log" > > #PositionB > #aLOCK = threading.RLock() > > while 1: > t1 = Process(target=Thr_run, args=(filename, )) > t1.start() > t1.join() > > Error info as below: > D:\Ap>python testa.py > Exception in thread Thread-1: > Traceback (most recent call last): > File "C:\Python34\lib\threading.py", line 921, in _bootstrap_inner > self.run() > File "C:\Python34\lib\threading.py", line 869, in run > self._target(*self._args, **self._kwargs) > File "D:\Ap\testa.py", line 15, in runCMD > Save_runnedCMD(filename, cmd) > File "D:\Ap\testa.py", line 7, in Save_runnedCMD > aLOCK.acquire() > NameError: name 'aLOCK' is not defined > > Exception in thread Thread-2: > Traceback (most recent call last): > File "C:\Python34\lib\threading.py", line 921, in _bootstrap_inner > self.run() > File "C:\Python34\lib\threading.py", line 869, in run > self._target(*self._args, **self._kwargs) > File "D:\Ap\testa.py", line 15, in runCMD > Save_runnedCMD(filename, cmd) > File "D:\Ap\testa.py", line 7, in Save_runnedCMD > aLOCK.acquire() > NameError: name 'aLOCK' is not defined > -- > https://mail.python.org/mailman/listinfo/python-list -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B -- https://mail.python.org/mailman/listinfo/python-list
Why this regex for string literals can't handle escaped quotes?.... '"(\\.|[^"])*"'
Why this regex for string literals can't handle escaped quotes? '"(\\.|[^"])*"' See this... >>> string_re = '"(\\.|[^"])*"' >>> re.match(string_re, '""') <_sre.SRE_Match object; span=(0, 6), match='""'> >>> re.match(string_re, '"aa\"aa"') <_sre.SRE_Match object; span=(0, 4), match='"aa"'> How make the last match be the entire string '"aa\"aa"' ? cs -- https://mail.python.org/mailman/listinfo/python-list
name 'aLOCK' is not defined When I add aLOCK = threading.RLock() behind if __name__ == "__main__"
Hi team Good day The problem I meet when I add "aLOCK = threading.RLock()" to PositionB, the program will report error "name 'aLOCK' is not defined ", but when I change this code to PositionA, it can run normally, is there any difference for the code between 'if __name__ == "__main__:"', can you help me, thanks! The file I was attached, please change the extend ".pyx" to ".py", thanks, code as below, tried python2.7 and python3.4: import threading import time from multiprocessing import Process #PositionA aLOCK = threading.RLock() def Save_runnedCMD(filename, strings): aLOCK.acquire() with open(filename, "at") as f: f.write(str(strings) + "\n\r") aLOCK.release() def runCMD(filename): time.sleep(1) cmd = "testtest" Save_runnedCMD(filename, cmd) def Thr_run(filename): t = [] for i in range(2): tt = threading.Thread(target = runCMD, args=(filename,)) tt.start() t.append(tt) for tt in t: tt.join() if __name__ == "__main__": filename = "./testa.log" #PositionB #aLOCK = threading.RLock() while 1: t1 = Process(target=Thr_run, args=(filename, )) t1.start() t1.join() Error info as below: D:\Ap>python testa.py Exception in thread Thread-1: Traceback (most recent call last): File "C:\Python34\lib\threading.py", line 921, in _bootstrap_inner self.run() File "C:\Python34\lib\threading.py", line 869, in run self._target(*self._args, **self._kwargs) File "D:\Ap\testa.py", line 15, in runCMD Save_runnedCMD(filename, cmd) File "D:\Ap\testa.py", line 7, in Save_runnedCMD aLOCK.acquire() NameError: name 'aLOCK' is not defined Exception in thread Thread-2: Traceback (most recent call last): File "C:\Python34\lib\threading.py", line 921, in _bootstrap_inner self.run() File "C:\Python34\lib\threading.py", line 869, in run self._target(*self._args, **self._kwargs) File "D:\Ap\testa.py", line 15, in runCMD Save_runnedCMD(filename, cmd) File "D:\Ap\testa.py", line 7, in Save_runnedCMD aLOCK.acquire() NameError: name 'aLOCK' is not defined -- https://mail.python.org/mailman/listinfo/python-list
Re: failed to execute scapy commands from remote server
On 09/08/18 13:11, Iranna Mathapati wrote: 2. When I try to execute scapy cmds in remote server I get the below error child_remote.sendline=sendp(arp3,iface='enp6s0f0',count=100) Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.7/site-packages/scapy/sendrecv.py", line 256, in sendp __gen_send(conf.L2socket(iface=iface, *args, **kargs), x, inter=inter, loop=loop, count=count, verbose=verbose, realtime=realtime) File "/usr/local/lib/python2.7/site-packages/scapy/arch/linux.py", line 425, in __init__ self.ins.bind((iface, type)) File "/usr/local/lib/python2.7/socket.py", line 224, in meth return getattr(self._sock,name)(*args) socket.error: [Errno 19] No such device At a guess, you are asking to send on an interface that doesn't exist. Does your machine have a network interface called "enp6s0f0"? -- Rhodri James *-* Kynesim Ltd -- https://mail.python.org/mailman/listinfo/python-list
failed to execute scapy commands from remote server
Hi Team, I have to ssh a remote server and execute scapy commands there. but its able to execute all linux commands from remote server handle I use pexpect and hitting issue. 1. SSH to remote shell via pexpect from current server parser_ip_add='192.168.1.83' child_remote = pexpect.spawn('/usr/bin/ssh',['AST@ {0}'.format(parser_ip_add)]) ssh_newkey = 'Are you sure you want to continue connecting' i=child_remote.expect([pexpect.TIMEOUT, ssh_newkey, 'password:']) if i==2: child_remote.sendline('X') <<< password child_remote.sendline('sudo su') child_remote.expect('password for AST: ') child_remote.sendline('X') >> child_remote.sendline=sendp(arp3,iface='enp6s0f0',count=100) Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.7/site-packages/scapy/sendrecv.py", line 256, in sendp __gen_send(conf.L2socket(iface=iface, *args, **kargs), x, inter=inter, loop=loop, count=count, verbose=verbose, realtime=realtime) File "/usr/local/lib/python2.7/site-packages/scapy/arch/linux.py", line 425, in __init__ self.ins.bind((iface, type)) File "/usr/local/lib/python2.7/socket.py", line 224, in meth return getattr(self._sock,name)(*args) socket.error: [Errno 19] No such device >>> child_remote.sendline(sendp(arp3,iface='enp6s0f0',count=100)) KeyboardInterrupt -- https://mail.python.org/mailman/listinfo/python-list
Re: using python's logo in your own logo
On Thu, Aug 9, 2018 at 8:38 PM, Alister via Python-list wrote: > On Thu, 09 Aug 2018 12:13:07 +0400, Abdur-Rahmaan Janhangeer wrote: > >> in short, >> >> can you use python's logo in your own logo without credit? >> >> yours, >> >> Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Mauritius > > I would expect the answer to that to be a big NO. > I am pretty sure you would need to get permission. Not quite! If you check the links that Thomas posted, you'll see that there are a number of uses that don't require permission. Or rather, uses for which blanket permission has been granted. https://www.python.org/psf/trademarks/ ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: using python's logo in your own logo
On Thu, 09 Aug 2018 12:13:07 +0400, Abdur-Rahmaan Janhangeer wrote: > in short, > > can you use python's logo in your own logo without credit? > > yours, > > Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Mauritius I would expect the answer to that to be a big NO. I am pretty sure you would need to get permission. -- VICARIOUSLY experience some reason to LIVE!! -- https://mail.python.org/mailman/listinfo/python-list
Re: using python's logo in your own logo
On 09/08/18 10:13, Abdur-Rahmaan Janhangeer wrote: > in short, > > can you use python's logo in your own logo without credit? > > yours, > > Abdur-Rahmaan Janhangeer > https://github.com/Abdur-rahmaanJ > Mauritius > See https://www.python.org/community/logos/ and https://www.python.org/psf/trademarks/ -- https://mail.python.org/mailman/listinfo/python-list
using python's logo in your own logo
in short, can you use python's logo in your own logo without credit? yours, Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Mauritius -- https://mail.python.org/mailman/listinfo/python-list
Re: Non-unicode file names
On 09/08/18 05:13, INADA Naoki wrote: > Please use Python 3.7. > > Python 3.7 has several improvements on this area. Thanks! Darkly remembering something about UTF-8 mode, I suspected it might... > > * When PEP 538 or 540 is used, default error handler for stdio is > surrogateescape > * You can sys.stdout.reconfigure(errors='surrogateescape') > > For Python 3.6, I think best way to allow arbitrary bytes on stdout is using > `PYTHONIOENCODING=utf-8:surrogateescape` environment variable. -- https://mail.python.org/mailman/listinfo/python-list