Re: How execute at least two python files at once when imported?

2019-11-06 Thread Cameron Simpson

On 06Nov2019 08:16, Spencer Du  wrote:

Sorry if I haven't stated my requirements clearly.
I just wanted a way to import at least two python files in parallel and 
I wanted to know how this can be done or a reason why its bad as stated 
in another post.


Parallel imports can be fine.

However, you want to avoid parallel code which works on shared data 
structures without the necessary synchronisation may be hazardous.


Your modules look like this:

   import stuff ...

   define functions and classes

   inline code performing a kind of "main programme"

That inline code gets run unconditionally, at import time.

What would be better would be if your modules looked like this:

   import stuff ...

   define functions and classes

   def main():
   inline code performing a kind of "main programme"

Then your "real" main programme can go:

   import your_module1
   import your_module2

   start a thread running your_module1.main()
   start a thread running your_module2.main()

which gets the imports done; they happen in series but just defining 
things (classes and functions) is very fast.


Then dispatch some Threads to run your main functions from each module.

If those main functions do not share data it will probably all just 
work. If they do share data then you may need to debug some 
synchronisation issues; it depends on the code itself.


Cheers,
Cameron Simpson 
--
https://mail.python.org/mailman/listinfo/python-list


Re: How execute at least two python files at once when imported?

2019-11-06 Thread Cameron Simpson

On 06Nov2019 18:15, Rhodri James  wrote:

On 06/11/2019 16:02, Spencer Du wrote:

Why is importing modules in parallel bad?


To put it as simply as I can:

1. The import mechanism is complicated, even the bits that are 
user-visible.  Fiddling with it has a high chance of going wrong.


2. Multi-threading is less complicated than import, but still requires 
a lot of careful thought.  For example you've asserted that the 
modules you want to import simultaneously, but you also need to 
consider the import mechanism itself.


Put 1 and 2 together, and multi-threaded import sounds like a 
nightmare.


The import machinery has an internal lock. Parallel import statements 
via threads is, of itself, a safe thing to do. But if the module does 
significant work on things outside itself (eg doing work beyond defining 
local classes, constants etc) that work needs to be thread safe.


Provided the imported modules do only local work it should be safe.

Spencer's modules run unconditional stuff in addition to defining 
classes. That may cause trouble.


Cheers,
Cameron Simpson 
--
https://mail.python.org/mailman/listinfo/python-list


[issue38440] Possible new issues with IDLE

2019-11-06 Thread Ned Deily


Ned Deily  added the comment:

> That would be very helpful! If you do so I'd be happy to test on Windows, 
> macOS.

Sorry, I meant for macOS only.  I'm not getting into the business of building 
Windows installers, too. :)  As for Ubuntu, you should be able to build that 
yourself.  But I think Kevin's point is that there are a lot of macOS-specific 
changes in Tk 8.6.10 and that's what we can really help to test.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38440] Possible new issues with IDLE

2019-11-06 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Quick summary and opinions so far:
* Jump to top: general IDLE bug, fixed.

* Repeated quit message: never seen by me, likely IDLE bug.  I need to check 
code where message emitted.

* Arrow keys emit ? replacement char: never seen by me, likely tcl bug. IDLE 
only binds  and  for completion, font, and path/browser 
lists, but not editor.  So if bug happens in editor, as implied, IDLE likely 
not involved.

* SaveFile crash: never seen by me with this dialog that I remember, likely tcl 
or even macOS bug.  The dialog matches Safari SaveAs box with Python-specific 
formats.  It results from IDLE tkinter call, which calls tcl, which calls 
AppKit -- lines 41-40 in C call stack.  Line 35 is the only non-OS (tcl) call 
thereafter.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38440] Possible new issues with IDLE

2019-11-06 Thread Tal Einat


Tal Einat  added the comment:

Ned:
- I could also try to make a 3.8.0 and/or 3.7.5 with 8.6.10rc1 installer 
available informally.

That would be very helpful! If you do so I'd be happy to test on Windows, 
macOS. I'm also able to test on Ubuntu if that would help.

I suggest we somehow collect new issues we find with the 3.6.10 release 
candidates and follow up those with the Tk developers - perhaps we could use a 
dedicated issue here or some other shared document?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38440] Possible new issues with IDLE

2019-11-06 Thread Ned Deily


Ned Deily  added the comment:

Thanks, Kevin.  I do see that 8.6.10rc1 is now available.  Yay!

Tal:
> How can we work with the Tk developers to ensure it works with Python across 
> platforms?

We have the first 3.9.0 alpha scheduled in about 10 days. I will try to build 
8.6.10rc1 (or later release) and include it in 3.9.0a1. I could also try to 
make a 3.8.0 and/or 3.7.5 with 8.6.10rc1 installer available informally.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38731] bad input crashes py_compile library

2019-11-06 Thread Kaoru Esashika


New submission from Kaoru Esashika :

How to reproduction:
Step 1: make bad source code
Step 2: run "python -m py_compile bad_source_code.py"
Step 3: errors printed

It seems that this problem is introduced at issue 22640 (commit 
https://github.com/python/cpython/commit/2e33ecd7c9b0cac3efc6fcbdd4547fd086b4e2d1)
and it have not fixed yet.

variable 'quiet' is not defined in main function as far as I can see.

```
Traceback (most recent call last):
  File "c:\users\\.scoop\apps\python\3.8.0\Lib\py_compile.py", line 
144, in compile
code = loader.source_to_code(source_bytes, dfile or file,
  File "", line 846, in source_to_code
  File "", line 219, in _call_with_frames_removed
  File "c:/Users//AppData/Local/Temp/flycheckrIYLj4/test.py", line 25
def calc_entropy(self):
^
IndentationError: expected an indented block

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\\.scoop\apps\python\3.8.0\Lib\py_compile.py", line 
209, in main
compile(filename, doraise=True)
  File "c:\users\\.scoop\apps\python\3.8.0\Lib\py_compile.py", line 
150, in compile
raise py_exc
__main__.PyCompileError: Sorry: IndentationError: expected an indented block 
(c:/Users//AppData/Local/Temp/flycheckrIYLj4/test.py, line 25)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\\.scoop\apps\python\3.8.0\Lib\runpy.py", line 192, 
in _run_module_as_main
return _run_code(code, main_globals, None,
  File "c:\users\\.scoop\apps\python\3.8.0\Lib\runpy.py", line 85, in 
_run_code
exec(code, run_globals)
  File "c:\users\\.scoop\apps\python\3.8.0\Lib\py_compile.py", line 
218, in 
sys.exit(main())
  File "c:\users\\.scoop\apps\python\3.8.0\Lib\py_compile.py", line 
213, in main
if quiet < 2:
NameError: name 'quiet' is not defined

```

--
components: Library (Lib)
messages: 356173
nosy: Kaoru Esashika
priority: normal
severity: normal
status: open
title: bad input crashes py_compile library
type: crash
versions: Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38440] Possible new issues with IDLE

2019-11-06 Thread Tal Einat


Tal Einat  added the comment:

Thanks for the report on the freezes, Raymond! My mac was recently fixed and 
I've upgraded to the latest OS version, so I'll take a look at this as well.

Thanks for the update on the Tk side, Kevin. It's very unfortunate that we've 
found 3.6.9 unusable with Python, and I certainly hope that 3.6.10 will not be 
like that. How can we work with the Tk developers to ensure it works with 
Python across platforms?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Trouble trying to get started with pygame

2019-11-06 Thread René Dudfield
Hi,

either use python 3.7, or use the pre-release of pygame 2.
py -m pip install pygame==2.0.0.dev6

We're not going to do a python 3.8 release for pygame 1.9.x


cheers,





On Thu, Nov 7, 2019 at 7:06 AM  wrote:

> > > Well, "py -m pip install pygame" has come the closest so far to
> working. I saw it try to load it and everything, but then, it spat out a
> series of errors, but, the primary one seemed to be this:
> > >
> > > WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
> > >
> > How about downloading the wheel from Christoph Gohlke's site and using
> > pip on that, as I suggested on 2019-11-01?
>
> What's the difference in syntax? Because, I DID notice that it seemed to
> be trying to open the other Pygame I had (The tar.gz version), so, I'm
> imagining there would be some difference somewhere. Or, could I simply
> switch out the tar.gz version with the wheel version inside the folder?
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Trouble trying to get started with pygame

2019-11-06 Thread originallmoney
> > Well, "py -m pip install pygame" has come the closest so far to working. I 
> > saw it try to load it and everything, but then, it spat out a series of 
> > errors, but, the primary one seemed to be this:
> > 
> > WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
> >   
> How about downloading the wheel from Christoph Gohlke's site and using 
> pip on that, as I suggested on 2019-11-01?

What's the difference in syntax? Because, I DID notice that it seemed to be 
trying to open the other Pygame I had (The tar.gz version), so, I'm imagining 
there would be some difference somewhere. Or, could I simply switch out the 
tar.gz version with the wheel version inside the folder?
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue38382] statistics.harmonic_mean fails to raise error with negative input that follows a 0

2019-11-06 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset 6b66dc387935df432cdbc01397ddef534a84ade9 by Raymond Hettinger 
(Miss Islington (bot)) in branch '3.8':
bpo-38382: Document the early-out behavior for a zero (GH-17037) (GH-17078)
https://github.com/python/cpython/commit/6b66dc387935df432cdbc01397ddef534a84ade9


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38382] statistics.harmonic_mean fails to raise error with negative input that follows a 0

2019-11-06 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
resolution:  -> not a bug
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38382] statistics.harmonic_mean fails to raise error with negative input that follows a 0

2019-11-06 Thread miss-islington


Change by miss-islington :


--
pull_requests: +16588
pull_request: https://github.com/python/cpython/pull/17078

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38382] statistics.harmonic_mean fails to raise error with negative input that follows a 0

2019-11-06 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset 7f460494d2309ace004a400bae8fc59134dc325c by Raymond Hettinger in 
branch 'master':
bpo-38382: Document the early-out behavior for a zero (GH-17037)
https://github.com/python/cpython/commit/7f460494d2309ace004a400bae8fc59134dc325c


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36406] doctest.testmod(empty_package) raises TypeError in 3.7 (and no errors in 3.6)

2019-11-06 Thread larabrian

larabrian  added the comment:

A subscriptable object is any object that implements the __getitem__ special 
method (think lists, dictionaries). It is an object that records the operations 
done to it and it can store them as a "script" which can be replayed. You are 
trying to subscript an object which you think is a list or dict, but actually 
is None. NoneType is the type of the None object which represents a lack of 
value, for example, a function that does not explicitly return a value will 
return None. 'NoneType' object is not subscriptable is the one thrown by python 
when you use the square bracket notation object[key] where an object doesn't 
define the __getitem__ method . You might have noticed that the method sort() 
that only modify the list have no return value printed – they return the 
default None. This is a design principle for all mutable data structures in 
Python. http://net-informations.com/python/err/nonetype.htm

--
nosy: +larabrian

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37731] Possible redifinition of _POSIX_C_SOURCE in ./pyconfig.h

2019-11-06 Thread Benjamin Peterson


Benjamin Peterson  added the comment:


New changeset 089e5f52a34377193a9e6c03088114b14c8507af by Benjamin Peterson in 
branch '2.7':
bpo-37731: Squish another _POSIX_C_SOURCE redefinition problem in expat. 
(GH-17077)
https://github.com/python/cpython/commit/089e5f52a34377193a9e6c03088114b14c8507af


--
nosy: +benjamin.peterson

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37731] Possible redifinition of _POSIX_C_SOURCE in ./pyconfig.h

2019-11-06 Thread Benjamin Peterson


Change by Benjamin Peterson :


--
pull_requests: +16587
pull_request: https://github.com/python/cpython/pull/17077

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37731] Possible redifinition of _POSIX_C_SOURCE in ./pyconfig.h

2019-11-06 Thread miss-islington


miss-islington  added the comment:


New changeset 30114c7119a9ae0e610d6974f57f22d8d05ed50d by Miss Islington (bot) 
in branch '2.7':
bpo-37731: Reorder includes in xmltok.c to avoid redefinition of 
_POSIX_C_SOURCE (GH-16733)
https://github.com/python/cpython/commit/30114c7119a9ae0e610d6974f57f22d8d05ed50d


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37731] Possible redifinition of _POSIX_C_SOURCE in ./pyconfig.h

2019-11-06 Thread miss-islington


Change by miss-islington :


--
pull_requests: +16586
pull_request: https://github.com/python/cpython/pull/17076

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38730] 2.7 modern compiler warnings

2019-11-06 Thread Benjamin Peterson


Change by Benjamin Peterson :


--
keywords: +patch
pull_requests: +16585
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/17075

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38730] 2.7 modern compiler warnings

2019-11-06 Thread Benjamin Peterson


New submission from Benjamin Peterson :

GCC 9's -Wstringop-truncation warnings trigger several times in 2.7. Some of 
these instances are all actual bugs. In all cases, we should clarify the code 
to make the compiler happy.

--
components: Build
messages: 356166
nosy: benjamin.peterson
priority: normal
severity: normal
status: open
title: 2.7 modern compiler warnings
versions: Python 2.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38440] Possible new issues with IDLE

2019-11-06 Thread Kevin Walzer


Kevin Walzer  added the comment:

On macOS, Tk 8.6.8 is considered ancient, even obsolete, on 10.14 or later. Tk 
has required huge re-work to accommodate changes in the Mac's drawing API's on 
10.14, mostly done by Marc Culler; these issues are not observable with the 
current tip of 8.6 development and IDLE 3.7.4. An RC of 8.6.10 has just gone 
out and we are anticipating the final release by Nov. 21, which includes too 
many changes to enumerate here. In any case, it should be considerably more 
stable than what is being reported.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: How execute at least two python files at once when imported?

2019-11-06 Thread Richard Damon
On 11/6/19 3:37 PM, Michael Torrie wrote:
> On 11/6/19 9:16 AM, Spencer Du wrote:
>> I just wanted a way to import at least two python files in parallel
>> and I wanted to know how this can be done or a reason why its bad as
>> stated in another post.
> It's not "bad," but it's also not possible.  Nor does it make sense.
> That's why so many people are questioning what you are really trying to
> accomplish.  By definition a Python script is a sequence of statements
> that are read and executed in sequence.  You can't just run them all at
> once, nor would it make sense to do so.
>
> If you want to run multiple python functions in parallel, there are
> threads for that, multiprocessing, and also asynchronous scheduling.
>
> But no one can tell you what to do because none of us have any clue what
> you are trying to accomplish.

I would disagree that it isn't possible, depending on exactly what is
wanted, I can think of several ways to do it.

Simplest option is fork off a separate process and run the second script
from that process, that would work if the two scripts don't need much
communication between themselves, and you would need to manually add
what ever communication was needed.

A second option is to create a second thread, and do one if the imports
in that thread, and one in the main thread. This is likely the closest
to the stated goal, but likely, due to the GIL, slower than doing one
after the other.

-- 
Richard Damon

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Trouble trying to get started with pygame

2019-11-06 Thread MRAB

On 2019-11-07 02:26, originallmo...@gmail.com wrote:

Can py find Python?

Did you try to install pygame with:

py -m pip install pygame


Well, "py -m pip install pygame" has come the closest so far to working. I saw 
it try to load it and everything, but then, it spat out a series of errors, but, the 
primary one seemed to be this:

WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
  
How about downloading the wheel from Christoph Gohlke's site and using 
pip on that, as I suggested on 2019-11-01?

--
https://mail.python.org/mailman/listinfo/python-list


SSL/TLS in Python using STARTTLS and ssl/ssltelnet and telnetlib

2019-11-06 Thread Veek M
Could someone suggest some introductory reading material that will allow 
me to use 'telnetlib' with 'ssl' or 'ssltelnet'. 
(currently using Pan since Knode is dropped on Debian)

I'm trying to write something that will download the NNTP headers over 
TLS.

The idea is to 
1. telnet to port 119, send 'CAPABILITIES\r\n' using telnetlib
2. then switch to TLS using STARTTLS
3. I tried just connecting to port 119 using a new TLS connection NOT 
OVER telnet and it didn't work. Apparently you need to pass the TLS 
context to telnetlib or vice versa.

Codes crap i've used bl_varname (bytes list) inconsistently - till I 
figure out what to do with TLS.

import ssl, socket
import sys, time
from telnetlib import Telnet
from ssltelnet import SslTelnet

port = 119
server = 'news.eternal-september.org'

user = 'v'
passwd = 'b'


class Response(object):
def __init__(self, tn, cmds = '', wmsg = ''):
self.tn = tn; self.total_data = []; self.wmsg = wmsg

d = { 
'r': self.read_server, 
'w': self.write_server, 
'p': self.bl_print 
}

for c in cmds:
d[c]()


def read_server(self):
tn = self.tn; total_data = []; count = 0
while True:
data = tn.read_very_eager()
if len(data):
count = 0
total_data.append(data)
else:
time.sleep(1)
count += 1
if count > 4:
self.total_data = total_data
return

def write_server(self):
tn = self.tn; txt = self.wmsg
for line in txt.split('\n'):
b_line = bytes(line + '\r\n', encoding='ascii')
tn.write(b_line)

def bl_print(self):
data = self.total_data
if len(data):
for line in data:
print(line.decode())
else:
print('no data')

def tls():
sock = socket.socket(family=AF_INET, type=SOCK_STREAM)
ssl_sock = ssl.wrap_socket(sock)

class Server(object):
def __init__(self, server = server, port = port):
with Telnet(server, port, timeout = 10) as tn:
Response(tn = tn, cmds = 'rp')
Response(tn = tn, cmds = 'wrp', wmsg='CAPABILITIES')
Response(tn = tn, cmds = 'wrp', wmsg='STARTTLS')
s = SslTelnet(force_ssl = False, telnet_tls = True, host = 
server, port = port)
print(s.read_very_eager())
time.sleep(2)
print(s.read_very_eager())



s = Server()

-- 
https://mail.python.org/mailman/listinfo/python-list


[issue38692] add a pidfd child process watcher

2019-11-06 Thread Benjamin Peterson


Benjamin Peterson  added the comment:

On Wed, Nov 6, 2019, at 09:57, STINNER Victor wrote:
> 
> STINNER Victor  added the comment:
> 
> Would it be useful to use a pidfd in subprocess.Popen to fix bpo-38630 
> root issue, when pidfd is available?

Probably, but as noted above, we need to figure out the best way to integrate 
pidfds into subprocess. (Probably not in this issue.)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16575] ctypes: unions as arguments

2019-11-06 Thread Ammar Askar


Change by Ammar Askar :


--
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: How execute at least two python files at once when imported?

2019-11-06 Thread jfong
Igor Korot於 2019年11月7日星期四 UTC+8上午12時34分35秒寫道:
> Hi,
> 
> On Wed, Nov 6, 2019 at 10:22 AM Spencer Du  wrote:
> >
> > Hi
> >
> > Sorry if I haven't stated my requirements clearly.
> >
> > I just wanted a way to import at least two python files in parallel and I 
> > wanted to know how this can be done or a reason why its bad as stated in 
> > another post.
> 
> This is not a requirements.
> 
> Let me rephrase my question - what problem are you trying to solve?
> 
> Also, as I said before - I believe there is a language barrier.
> 
> Find some python forum in your native language and ask your question there.
> 
> Thank you.
> 
> >
> > Thanks
> > Spencer
> > --
> > https://mail.python.org/mailman/listinfo/python-list

If the OP is a Chinese, from my experience, I doubt there is a chance he can 
express his problem clearly enough for us who want to help to understand. There 
is not only the language barrier, but the causes of China education system. 
Starts from the very beginning in primary school, students are not allowed to 
think independently and logically. So after growing up, they just lost the 
ability of expressing things in a logic way.

--Jach
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Trouble trying to get started with pygame

2019-11-06 Thread originallmoney
> Can py find Python?
> 
> Did you try to install pygame with:
> 
> py -m pip install pygame

Well, "py -m pip install pygame" has come the closest so far to working. I saw 
it try to load it and everything, but then, it spat out a series of errors, 
but, the primary one seemed to be this:

WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
 
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue11588] Add "necessarily inclusive" groups to argparse

2019-11-06 Thread Jack Wong


Change by Jack Wong :


--
nosy: +iforapsy

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38729] mock.create_autospec generates incorrect signature for some decorated methods

2019-11-06 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
components: +Library (Lib) -Tests
nosy: +cjw296, lisroach, mariocj89, michael.foord, xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38440] Possible new issues with IDLE

2019-11-06 Thread Ned Deily


Ned Deily  added the comment:

That's quite a stack trace, bouncing back and forth between Python and Tk and 
macOS.  I don't really have any experience with the flow of control there with 
call outs to file save dialogs.  CCing Kevin Walzer on the off chance that this 
might be familiar and hopefully fixed in the forthcoming Tk 8.6.10 release.  
Kevin, we are still running with a vanilla 8.6.8 release built on macOS 10.9.

--
nosy: +wordtech

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36906] Compile time textwrap.dedent() equivalent for str or bytes literals

2019-11-06 Thread Gregory P. Smith


Gregory P. Smith  added the comment:

.cleandoc is _probably_ more of what people want than .dedent?  I hadn't 
bothered to even try to pick between the two yet.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38440] Possible new issues with IDLE

2019-11-06 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

A new intermittent problem has arisen on macOS since I updated to Catalina.  It 
occurs on both 10.15.0 and 10.15.1.  I'm using the 3.8.0 mac 64-bit install 
taken directly from python.org.

In a long-running session of IDLE, the process freezes-up during File/SaveAs.  
The file save dialog comes-up.  When typing the filename, the dialog window 
greys-out, the list of files goes blank, and the situation is unrecoverable 
(see the attached screenshot).

And see below for the core dump in the terminal session.




$ python3.8 -m idlelib.idle
2019-11-06 13:52:34.765 Python[38668:423017] WARNING:  running implicitly; please run panels using NSSavePanel rather 
than NSApplication.
2019-11-06 13:52:40.958 Python[38668:423017] *** Assertion failure in 
-[NSSavePanel _attachSandboxExtensions:toURL:orURLs:], 
/BuildRoot/Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1894.10.126/Nav.subproj/OpenAndSavePanelRemote/NSVBOpenAndSavePanels.m:711
2019-11-06 13:52:40.963 Python[38668:423017] -[NSSavePanel 
observeValueForKeyPath:ofObject:change:context:] caught non-fatal 
NSInternalInconsistencyException 'unexpected class type for sandbox extension 
string!' with backtrace (
0   CoreFoundation  0x7fff3b080f53 
__exceptionPreprocess + 250
1   libobjc.A.dylib 0x7fff71146835 
objc_exception_throw + 48
2   CoreFoundation  0x7fff3b09c810 
+[NSException raise:format:arguments:] + 88
3   Foundation  0x7fff3d77c5d1 
-[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] 
+ 191
4   AppKit  0x7fff38be944c 
__53-[NSSavePanel _attachSandboxExtensions:toURL:orURLs:]_block_invoke + 240
5   CoreFoundation  0x7fff3b0d15a7 
__NSARRAY_IS_CALLING_OUT_TO_A_BLOCK__ + 7
6   CoreFoundation  0x7fff3b00923d 
-[__NSSingleObjectArrayI enumerateObjectsWithOptions:usingBlock:] + 80
7   AppKit  0x7fff38be925c 
-[NSSavePanel _attachSandboxExtensions:toURL:orURLs:] + 125
8   AppKit  0x7fff38bedf4b 
-[NSSavePanel _URLsWithSecurityScoped:] + 193
9   AppKit  0x7fff38be9481 
-[NSSavePanel _attachSandboxExtensionsAndStartAccessing] + 48
10  AppKit  0x7fff38bea7ce 
-[NSSavePanel completeWithReturnCode:url:urls:] + 164
11  AppKit  0x7fff38bec787 
-[NSSavePanel observeValueForKeyPath:ofObject:change:context:] + 341
12  Foundation  0x7fff3d672412 
NSKeyValueNotifyObserver + 335
13  Foundation  0x7fff3d7faf56 
NSKeyValueDidChange.llvm.18255262684423441536 + 434
14  Foundation  0x7fff3d7fa761 
NSKeyValueDidChangeWithPerThreadPendingNotifications.llvm.18255262684423441536 
+ 146
15  ViewBridge  0x7fff6d7d8adc 
__41-[NSViewBridge setObject:forKey:withKVO:]_block_invoke + 360
16  ViewBridge  0x7fff6d860b5c 
withHintInProgress + 472
17  ViewBridge  0x7fff6d7cf17b 
-[NSViewBridge setObject:forKey:withKVO:] + 856
18  ViewBridge  0x7fff6d7d087a 
-[NSViewBridge nonLocalChangeInProgress:block:] + 352
19  ViewBridge  0x7fff6d7d04d7 
-[NSRemoteViewMarshal exceptionSafeSetRemoteObject:forKey:withReply:] + 264
20  ViewBridge  0x7fff6d7d038b 
-[NSRemoteViewMarshal setRemoteObject:forKey:withReply:] + 56
21  CoreFoundation  0x7fff3afdf1dc 
__invoking___ + 140
22  CoreFoundation  0x7fff3afdf07f 
-[NSInvocation invoke] + 305
23  ViewBridge  0x7fff6d7cdb1e 
__deferNSXPCInvocationOntoMainThread_block_invoke + 228
24  ViewBridge  0x7fff6d7c33ec 
__wrapBlockWithVoucher_block_invoke + 37
25  ViewBridge  0x7fff6d7c31b1 
__deferBlockOntoMainThread_block_invoke_2 + 507
26  CoreFoundation  0x7fff3b00cd6b 
__CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
27  CoreFoundation  0x7fff3afcffdd 
__CFRunLoopDoBlocks + 379
28  CoreFoundation  0x7fff3afcfd50 
__CFRunLoopRun + 2792
29  CoreFoundation  0x7fff3afcefe3 
CFRunLoopRunSpecific + 499
30  HIToolbox   0x7fff39b5667d 
RunCurrentEventLoopInMode + 292
31  HIToolbox   0x7fff39b563bd 
ReceiveNextEventCommon + 

Re: psutil.boot_time() ... doesn't ?

2019-11-06 Thread Luciano Ramalho
On Wed, Nov 6, 2019 at 7:54 PM Terry Reedy  wrote:
> I don't know how much Linux is customized for RP, but last I knew,
> Python on RP is MicroPython, not CPython.  So I expect OS-related
> functions to not necessarily match Linux on a desktop.

The default OS on all Raspberry Pi models is Raspbian, a full-blown
Debian Linux derivative, which comes with Python 2 and Python 3
installed -- CPython, to be clear.

MicroPython was designed for microcontroller boards that are too small
to run an OS. Popular boards are the BBC microbit and ESP8266. Those
devices don't run Linux. To use MicroPython on them, you install
firmware that boots directly into the MicroPython runtime, which
includes a REPL.

Cheers,

Luciano




>
> --
> Terry Jan Reedy
>
> --
> https://mail.python.org/mailman/listinfo/python-list



-- 
Luciano Ramalho
|  Author of Fluent Python (O'Reilly, 2015)
| http://shop.oreilly.com/product/0636920032519.do
|  Technical Principal at ThoughtWorks
|  Twitter: @ramalhoorg
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: psutil.boot_time() ... doesn't ?

2019-11-06 Thread Eryk Sun
On 11/6/19, Chris Angelico  wrote:
>
> Yes, but even if it's not recorded as a timestamp but as an uptime
> counter, that counter can be referenced against the current time in
> UTC. A DST switch affects the displayed time, but not the internal
> definition of "current time" (at least, not on Linux, where the system
> clock should be in UTC - the rules are different on Windows, and may
> also be different on other Unix-like OSes);

Windows timestamps are UTC, but the epoch and base time unit are
different from Unix. It uses the number of 100 ns intervals since
1601, instead of the number of seconds since 1970.

psutil subtracts the value of GetTickCount64() from
GetSystemTimeAsFileTime(), so changing the system time will change the
reported boot time. But that's expected behavior. Even the kernel's
KeBootTime value gets adjusted to account for the time delta when the
system time is updated. Otherwise the system would be inconsistent.
That said, the kernel (NT 5+) also also has a KeBootTimeBias value
that tracks the net delta of KeBootTime from its original value.

What psutil does should suffice, but if we need the kernel's exact
boot time, without the expense and complexity of a WMI or perflib
query, the native system call is NtQuerySystemInformation:
SystemTimeOfDayInformation. This returns a
SYSTEM_TIMEOFDAY_INFORMATION record, which includes BootTime and
BootTimeBias fields. This query is implemented for internal use only,
however. The fields and layout of the record are subject to change in
future versions of Windows, so caveat emptor. To date, this record was
only modified once, back in NT 5 (2000) to augment it with
BootTimeBias and SleepTimeBias fields.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue13214] Cmd: list available completions from the cmd.Cmd subclass and filter out EOF handler(s)

2019-11-06 Thread Roundup Robot


Change by Roundup Robot :


--
pull_requests: +16584
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/17074

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38710] unsynchronized write pointer in io.TextIOWrapper in 'r+' mode

2019-11-06 Thread Josh Rosenberg


Change by Josh Rosenberg :


--
nosy: +josh.r

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38710] unsynchronized write pointer in io.TextIOWrapper in 'r+' mode

2019-11-06 Thread Josh Rosenberg


Change by Josh Rosenberg :


--
components: +Library (Lib)

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36906] Compile time textwrap.dedent() equivalent for str or bytes literals

2019-11-06 Thread Josh Rosenberg


Josh Rosenberg  added the comment:

Is there a reason folks are supporting a textwrap.dedent-like behavior over the 
generally cleaner inspect.cleandoc behavior? The main advantage to the latter 
being that it handles:

'''First
Second
Third
'''

just fine (removing the common indentation from Second/Third), and produces 
identical results with:

'''
First
Second
Third
'''

where textwrap.dedent behavior would leave the first string unmodified (because 
it removes the largest common indentation, and First has no leading 
indentation), and dedenting the second, but leaving a leading newline in place 
(where cleandoc removes it), that can only be avoided by using the typically 
discouraged line continuation character to make it:

'''\
First
Second
Third
'''

cleandoc behavior means the choice of whether the text begins and ends on the 
same line at the triple quote doesn't matter, and most use cases seem like 
they'd benefit from that flexibility.

--
nosy: +josh.r

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: psutil.boot_time() ... doesn't ?

2019-11-06 Thread MRAB

On 2019-11-06 22:53, Terry Reedy wrote:

On 11/6/2019 3:09 PM, R.Wieser wrote:

Dennis,

Depends upon the OS...


My apologies, its Linux (as on a Raspberry Pi).


I don't know how much Linux is customized for RP, but last I knew,
Python on RP is MicroPython, not CPython.  So I expect OS-related
functions to not necessarily match Linux on a desktop.

MicroPython is for smaller systems. Raspberry Pi has a full Python 
implementation, as far as I can tell. I have one running Python 3.5 with 
the regex module installed, the module being downloaded via pip from 
PyPI and built from source on the RP. No changes were needed to make it 
work.

--
https://mail.python.org/mailman/listinfo/python-list


[issue38729] mock.create_autospec generates incorrect signature for some decorated methods

2019-11-06 Thread Ben Reilly


Change by Ben Reilly :


--
components: +Tests

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38729] mock.create_autospec generates incorrect signature for some decorated methods

2019-11-06 Thread Ben Reilly


New submission from Ben Reilly :

mock.create_autospec is meant to create a mock that will ensure, among other 
things, that method calls on the mock correspond to real methods on the 
original object and that the arguments match the signature of the original 
method. However, if the original method is decorated with a method that returns 
a callable object, the signature check may fail.

Attached is a script that demonstrates the error.

The essential part of the script looks like this:

def decorator(m):
return Wrapper(m)

class Wrapper(object):
def __init__(self, method):
self.method = method
update_wrapper(self, method)

def __call__(self, instance, *args, **kwargs):
return self.__get__(instance, type(instance))(*args, **kwargs)

def __get__(self, instance, owner):
... # do the wrapping


The `decorator` method returns an instance of the `Wrapper` class, which is 
callable. Mock will calculate the signature of a method wrapped with 
`decorator` to be equal to that of `Wrapper.__call__`, namely `(instance, 
*args, **kwargs)`. Consequently, calls to the mocked method...

1. will incorrectly fail if the method usually takes no arguments, and
2. will incorrectly pass if the method takes at least one argument but too many 
arguments are provided.

This list of incorrect behaviour is not exhaustive, but hopefully you get the 
point.

If anyone's concerned about real-life examples, this kind of wrapper is used, 
for example, in the public Box SDK, as shown here: 
https://github.com/box/box-python-sdk/blob/b7f41d9a3f8be0ff3622a0c417bf31d2fbbee969/boxsdk/util/api_call_decorator.py#L10

--
files: decorator.py
messages: 356159
nosy: breilly_box
priority: normal
severity: normal
status: open
title: mock.create_autospec generates incorrect signature for some decorated 
methods
type: behavior
versions: Python 3.7
Added file: https://bugs.python.org/file48698/decorator.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: psutil.boot_time() ... doesn't ?

2019-11-06 Thread Chris Angelico
On Thu, Nov 7, 2019 at 9:55 AM Terry Reedy  wrote:
>
> On 11/6/2019 3:09 PM, R.Wieser wrote:
> > Dennis,
> >> Depends upon the OS...
> >
> > My apologies, its Linux (as on a Raspberry Pi).
>
> I don't know how much Linux is customized for RP, but last I knew,
> Python on RP is MicroPython, not CPython.  So I expect OS-related
> functions to not necessarily match Linux on a desktop.
>

Fair point, although in this case, I think the interpreter won't make
a difference - the psutil module is pure Python and depends on
underlying OS facilities.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: psutil.boot_time() ... doesn't ?

2019-11-06 Thread Terry Reedy

On 11/6/2019 3:09 PM, R.Wieser wrote:

Dennis,

Depends upon the OS...


My apologies, its Linux (as on a Raspberry Pi).


I don't know how much Linux is customized for RP, but last I knew, 
Python on RP is MicroPython, not CPython.  So I expect OS-related 
functions to not necessarily match Linux on a desktop.


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


[issue38728] Update PC/pyconfig.h to support disabling auto linking

2019-11-06 Thread Jean-Christophe Fillion-Robin


New submission from Jean-Christophe Fillion-Robin :

When configuring project using build-system generator like CMake, the linking 
is explicitly handled and does not to be implicitly hard-coded in pyconfig.h

Having the "pythonXY.lib" library hard-coded in pyconfig.h currently requires 
to explicitly specify a link directory. While possible, this require to 
increase the complexity of our build-system.

I suggest we introduce a new macro (e.g PY_CONFIG_AUTOLINK_DISABLED)

--
components: Windows
messages: 356158
nosy: Jean-Christophe Fillion-Robin, paul.moore, steve.dower, tim.golden, 
zach.ware
priority: normal
severity: normal
status: open
title: Update PC/pyconfig.h to support disabling auto linking
type: enhancement
versions: Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38599] Deprecate creation of asyncio object when the loop is not running

2019-11-06 Thread Emmanuel Arias


Emmanuel Arias  added the comment:

Hi, 

@asvetlov are you thinking something like the patch attached?

--
keywords: +patch
Added file: 
https://bugs.python.org/file48697/0001-Add-a-deprectation-warning-for-queue-w-o-event-runni.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: [pythran] Pythran 0.9.4 - Hollsent

2019-11-06 Thread Serge Guelton
On Thu, Oct 31, 2019 at 07:32:25AM +0100, Serge Guelton wrote:
> Hi folks,
> 
> It's always a pleasure to announce a Pythran release, and here we go for a
> version bump!
> [...]

For those of you who are interested in technical details,

http://serge-sans-paille.github.io/pythran-stories/pythran-094-hollsent.html

may be an interesting read!

++
Serge
--
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/

Support the Python Software Foundation:
http://www.python.org/psf/donations/


[issue38599] Deprecate creation of asyncio object when the loop is not running

2019-11-06 Thread Emmanuel Arias


Change by Emmanuel Arias :


--
nosy: +eamanu

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38716] logging: rotating handlers set namer and rotator null

2019-11-06 Thread Vinay Sajip


Vinay Sajip  added the comment:


New changeset 519cb8772a9745b1c7d8218cabcd2f96ceda4d62 by Vinay Sajip (l0rb) in 
branch 'master':
bpo-38716: stop rotating handlers from setting inherited namer and rotator to 
None (GH-17072)
https://github.com/python/cpython/commit/519cb8772a9745b1c7d8218cabcd2f96ceda4d62


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36906] Compile time textwrap.dedent() equivalent for str or bytes literals

2019-11-06 Thread Marco Sulla


Marco Sulla  added the comment:

If I can say my two cents:

1. I preferred that the default behaviour of multi-line was to dedent. But 
breaking old code, even if for a little percentage of code, IMHO is never a 
good idea. Py2->Py3 should have proved it.

2. ``` remembers me too much the Markdown for add a code block, not a text block

3. yes, the new prefix is really useless, because it's significant only for 
multiline strings. Anyway, if this solution is accepted, I propose `t` for 
`trim`.

--
nosy: +Marco Sulla

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: psutil.boot_time() ... doesn't ?

2019-11-06 Thread Chris Angelico
On Thu, Nov 7, 2019 at 7:31 AM R.Wieser  wrote:
>
> Chris,
>
> > I don't think boot time would be affected by a DST switch, though.
> > It should be recorded in UTC.
>
> The point is, it /isn't/ a recorded constant (at least not on my machine).
> Its just dragged around with the clocks current time (as in: current time
> minus uptime).   And as such I could easily imagine a DST change will cause
> the "boot time" to change accordingly.
>

Yes, but even if it's not recorded as a timestamp but as an uptime
counter, that counter can be referenced against the current time in
UTC. A DST switch affects the displayed time, but not the internal
definition of "current time" (at least, not on Linux, where the system
clock should be in UTC - the rules are different on Windows, and may
also be different on other Unix-like OSes); if your current UTC time
is 1573072926 seconds and your uptime is 7469247.52 seconds, then you
can deduce that your system booted at 1565603679, and then convert
that to a displayable boot time in whatever timezone you like (for
instance, "Mon Aug 12 19:54:39 2019\n" which is what my ctime()
returns). A DST switch wouldn't affect any of this, assuming you have
the correct tzdata to figure out whether the boot time was on summer
or winter time.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Robot Drift correction help

2019-11-06 Thread Isaiah Foss
Any pointers or help is appreciated, I'm not necessarily asking for answers but 
any response is appreciated 
-- 
https://mail.python.org/mailman/listinfo/python-list


Robot Drift correction help

2019-11-06 Thread Isaiah Foss
We have a robot needed coding, we succeeded however the left wheel has an issue 
with drift. This was compiled by a professor that requires drift correction. He 
is overseas and uncontactable the code is as follows.

define a procedure to recalibrate rotational speeds when any wheel can be 
affected by random offset.

import matplotlib.pyplot as plt #enables plotting capabilities for the robot
#for this case this is the OUTPUT as the whole 
#robot is simulated through this notebook
import numpy as np #Numerical Python library as described in the Intro Python 
Notebook
import math #math module 
import scipy.constants as sc #shortcut for physical and mathematical constants 
 #and units
import sympy as sym #SymPy is a Python library for symbolic mathematics
import decimal
decimal.getcontext().prec = 100
from math import sin, cos

class Robot(object):
"""Defines basic mobile robot properties. Defines __init__, step, 
print_xya, and 
plot_robot methods. Is called in the main class of DDRobot."""
def __init__(self):
#initialization class. 
self.pos_x  = 0.0 #placing bot at origin: (x,y) = (0,0)
self.pos_y  = 0.0 
self.angle  = 0.0 # IN RAD setting alpha = 0
self.plot   = False #intializing no plot to show
self._delta = 0.01 #
self.step_plot = int(8) #plotting every 5 iterations
self.mag_plot = 1.5 # arrow magnification
self.angle_evol = []

# Movement
def step(self):
""" updates the x,y and alpha """
self.deltax()
self.deltay()
self.deltaa()
self.angle_evol.append(self.angle)

def move(self, seconds):
""" Moves the robot for an 's' amount of seconds. Takes argument of 
seconds as type 
int"""
for i in range(int(seconds/self._delta)):
self.step()
if i % self.step_plot == 0 and self.plot: # plot path every 5 steps
self.plot_xya() #plots a dot in the position of the robot 

# Printing-and-plotting:
def print_xya(self):
""" prints the x,y position and angle """
print ("x = " + str(self.pos_x) +" "+ "y = " + str(self.pos_y))
print ("a = " + str(self.angle))

def plot_robot(self):
""" plots an arrow representation of the robot. """
plt.arrow(self.pos_x, self.pos_y, 0.001
  * cos(self.angle), 0.001 * sin(self.angle),
  head_width=self.mag_plot*self.length, 
head_length=self.mag_plot*self.length,
  fc='k', ec='k')

def plot_xya(self):
""" plots a dot in the position of the robot """
plt.scatter(self.pos_x, self.pos_y, c='r', edgecolors='r')


class DDRobot(Robot):
"""Defines a differential drive robot. Is the main class. Moves the robot. 
Class Robot is effectively created within class DDRobot as many of the 
methods from Robot class are called within DDRobot class."""

def __init__(self):
"""__init__ : Initialization class (for DDRobot class)"""
Robot.__init__(self)
self.radius = 0.1 #radius of bot wheel as defined in Fig 3
self.length = 0.4 #length between bot wheels as defined in Fig 3
self.rt_spd_left = 0.0 #initializing rotation speed, left wheel to 0
self.rt_spd_right = 0.0 #initializing rotation speed, right wheel to 0
a = 0
while a == 0:
a = np.random.randint(-1,2)
self.drift = a*np.random.uniform(0.0,0.1)

def deltax(self):
""" update x position depending on L and R angular speeds """
self.pos_x += self._delta * (self.radius*0.5) \
* (self.rt_spd_right + (self.rt_spd_left + self.drift))*cos(self.angle)

def deltay(self):
""" update y position depending on l and r angular speeds """
self.pos_y += self._delta * (self.radius*0.5) \
* (self.rt_spd_right + (self.rt_spd_left + self.drift))*sin(self.angle)

def deltaa(self):
""" update angle depending on l and r angular speeds """
self.angle += self._delta * (self.radius/self.length) \
* (self.rt_spd_right - (self.rt_spd_left + self.drift))

def D2R(a):
"""function to convert degrees to radians. Takes single argument of 
degrees."""
return float(((math.pi)*float(a))/180.0)
def R2D(a):
"""Function to convert radians to degrees. Takes single argument of 
radians."""
return float((180.0*float(a)/(math.pi)))


plt.figure(figsize=(6,6))
pos_x_0 = 0
pos_y_0 = 0
wheelradius = 0.5
wheelseparation = 1
omega = 1
line_length = 10
Delta_t = 0.01

# Robot dimension and wheel rotation speed
mybot = DDRobot() # enables methods to be passed to the Robot and DDRobot 
classes as objects
mybot.radius = wheelradius
mybot.length = wheelseparation

#initialization block
mybot.pos_x = pos_x_0  # calling pos_x method to set x initial 
position - in center of plot

Re: psutil.boot_time() ... doesn't ?

2019-11-06 Thread Chris Angelico
On Thu, Nov 7, 2019 at 7:21 AM R.Wieser  wrote:
>
> Chris
>
> > That's possibly because you're looking at psutil, which is a third
> > party package. Here's its documentation:
>
> My info came frome here:
> https://www.programcreek.com/python/example/53873/psutil.boot_time
>
> Looking at example 1 it looks the be the same.

Yep, looks like that site probably cribbed the example from the docs,
or similar. Your code is fine.

> > But I don't know what its definition is, whether it's "current time
> > minus uptime" or "timestamp recorded during bootup". It might
> > not even be consistent across platforms.
>
> Oh yoy !   :-\

Yeah... welcome to the wonderful world of cross-platform libraries
that depend on different facilities. Different OSes make different
promises, and the library has to try to paper over those distinctions
and give a consistent result. It's usually fine, but there WILL be
edge cases.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How execute at least two python files at once when imported?

2019-11-06 Thread Michael Torrie
On 11/6/19 9:16 AM, Spencer Du wrote:
> I just wanted a way to import at least two python files in parallel
> and I wanted to know how this can be done or a reason why its bad as
> stated in another post.
It's not "bad," but it's also not possible.  Nor does it make sense.
That's why so many people are questioning what you are really trying to
accomplish.  By definition a Python script is a sequence of statements
that are read and executed in sequence.  You can't just run them all at
once, nor would it make sense to do so.

If you want to run multiple python functions in parallel, there are
threads for that, multiprocessing, and also asynchronous scheduling.

But no one can tell you what to do because none of us have any clue what
you are trying to accomplish.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue36906] Compile time textwrap.dedent() equivalent for str or bytes literals

2019-11-06 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I think it would be better to use use backtick quotes for f-strings instead of 
the f prefix. This would stress the special nature of f-strings (they are not 
literals, but expressions). But there was strong opposition to using backticks 
anywhere in Python syntax.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: psutil.boot_time() ... doesn't ?

2019-11-06 Thread R.Wieser
Chris,

> I don't think boot time would be affected by a DST switch, though.
> It should be recorded in UTC.

The point is, it /isn't/ a recorded constant (at least not on my machine). 
Its just dragged around with the clocks current time (as in: current time 
minus uptime).   And as such I could easily imagine a DST change will cause 
the "boot time" to change accordingly.

Regards,
Rudy Wieser


-- 
https://mail.python.org/mailman/listinfo/python-list


[issue36906] Compile time textwrap.dedent() equivalent for str or bytes literals

2019-11-06 Thread Gregory P. Smith


Gregory P. Smith  added the comment:

Another option not using a new letter: A triple-backtick token.


def foo():
value = ```this is a
 
long multi line string i don't want indented.
```

A discuss thread was started so I reconnected it with this issue.  See
 https://discuss.python.org/t/trimmed-multiline-string/2600/8

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: psutil.boot_time() ... doesn't ?

2019-11-06 Thread R.Wieser
Chris

> That's possibly because you're looking at psutil, which is a third
> party package. Here's its documentation:

My info came frome here:
https://www.programcreek.com/python/example/53873/psutil.boot_time

Looking at example 1 it looks the be the same.

> But I don't know what its definition is, whether it's "current time
> minus uptime" or "timestamp recorded during bootup". It might
> not even be consistent across platforms.

Oh yoy !   :-\

Regards,
Rudy Wieser


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: psutil.boot_time() ... doesn't ?

2019-11-06 Thread Chris Angelico
On Thu, Nov 7, 2019 at 7:16 AM R.Wieser  wrote:
> But granted, on a Raspberry thats a bit of a problem.   On the other hand,
> just dragging the "last boot time" around by whatever time you now set feels
> like fakery.
>
> Oh man, I can already imagine a CSI plot where someone tries to use as linux
> machines boot time as an alibi, but summer time just arrived, causing it to
> appear an hour later .. :-)

https://www.youtube.com/watch?v=w45QkL9blG4 :)

I don't think boot time would be affected by a DST switch, though. It
should be recorded in UTC.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: psutil.boot_time() ... doesn't ?

2019-11-06 Thread R.Wieser
Dennis,

> Depends upon the OS...

My apologies, its Linux (as on a Raspberry Pi).

> You can easily look at the code used by psutil

:-) I somehow assumed that those where build-in into the language itself. 
I'll have to take a peek at what else is available there too.

> I read somewhere that the kernel calculates the btime from the
> current gettimeofday minus the jiffies since boot converted to
> seconds.

That was also my guess to what happened.

> last file system modification time
> hardware RTC (if equipped)
> NTP update (if networked)
> what should your "boot time" be referenced against?

The built-in clock ofcourse. :-)   But I would not mind if it would be set 
to some believable time by the fake-hwclock.

But granted, on a Raspberry thats a bit of a problem.   On the other hand, 
just dragging the "last boot time" around by whatever time you now set feels 
like fakery.

Oh man, I can already imagine a CSI plot where someone tries to use as linux 
machines boot time as an alibi, but summer time just arrived, causing it to 
appear an hour later .. :-)

> but that boot time will depend on exactly when the CRON job ran
> in relation to the three potential sources of clock time.

I was already thinking of something similar (running a script at boot), but 
also saw such race-time problems.
I might edit the fake-hwclock code though.   Copying the clocks current 
date/time after it has just been set (or not, when an RTC is installed) 
would be enough for my purposes.

... Though I would rather not mess around in/with system files.

Regards,
Rudy Wieser


-- 
https://mail.python.org/mailman/listinfo/python-list


[issue38727] setup.py sdist --format=gztar should use (equivalent of) `gzip -n`

2019-11-06 Thread Zack Weinberg


New submission from Zack Weinberg :

Recent versions of the gzip command-line utility have an option `-n` which 
causes it to omit the FNAME field of the gzip file header, and write out the 
MTIME field as zero.  Both of these properties are desirable when constructing 
reproducible build artifacts (see https://reproducible-builds.org/ ).

An sdist tarball is a build artifact and it should be created as reproducibly 
as possible.  In particular, --format=gztar should behave as-if `gzip -n` were 
in use.  (The stdlib's gzip module can produce output equivalent to what gzip 
-n does, but this is not currently documented nor is it accessible via 
`tarfile`.  Both of those should be easy fixes.  See bug 38725 and bug 38726.)

--
components: Distutils
messages: 356152
nosy: dstufft, eric.araujo, zwol
priority: normal
severity: normal
status: open
title: setup.py sdist --format=gztar should use (equivalent of) `gzip -n`

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38726] Add equivalent of `gzip -n` (omit timestamp and original file name) to tarfile module's auto-compression support

2019-11-06 Thread Zack Weinberg


New submission from Zack Weinberg :

Recent versions of the gzip command-line utility have an option `-n` which 
causes it to omit the FNAME field of the gzip file header, and write out the 
MTIME field as zero.  Both of these properties are desirable when constructing 
reproducible build artifacts (see https://reproducible-builds.org/ ).

Right now, it's possible to get the `gzip` module to do the same thing (it's 
not documented, but it's possible; see bug 38725) but, as far as I can tell, if 
you use `tarfile`'s "w:gz" or "w|gz" modes you will always get a timestamp and 
a filename in the output.  Please add `w[:|]gzn`, or something like that, that 
behaves as-if the output were piped through `gzip -n`.

(It might make sense to remove the manual creation of a gzip file header from 
the tarfile module at the same time; it looks like this code predates the 
addition of the gzip module to the stdlib.)

--
messages: 356151
nosy: zwol
priority: normal
severity: normal
status: open
title: Add equivalent of `gzip -n` (omit timestamp and original file name) to 
tarfile module's auto-compression support

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38725] Documented equivalent of `gzip -n` (omit timestamp and original file name) in gzip module

2019-11-06 Thread Zack Weinberg


New submission from Zack Weinberg :

Recent versions of the gzip command-line utility have an option `-n` which 
causes it to omit the FNAME field of the gzip file header, and write out the 
MTIME field as zero.  Both of these properties are desirable when constructing 
reproducible build artifacts (see https://reproducible-builds.org/ ).

Right now, the gzip module lets you set MTIME to zero explicitly by passing 
`mtime=0` to the GzipFile constructor, but this is not documented.  You can 
avoid writing out a filename by opening the output file yourself:

with gzip.GzipFile(fileobj=open("foo.gz", "wb"),
   filename='', mtime=0) as ofp:
... write to ofp ...

but that's awkward and, again, not documented.  I'd like to be able to write 
something like this instead:

with gzip.open("foo.gz", mtime=0, record_filename=False) as ofp:

with this being the documented way to achieve the same effect as `gzip -n`.

--
components: Library (Lib)
messages: 356150
nosy: zwol
priority: normal
severity: normal
status: open
title: Documented equivalent of `gzip -n` (omit timestamp and original file 
name) in gzip module

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Discontinuing the pymssql Project

2019-11-06 Thread Randy Syring
I believe it's become necessary to discontinue the pymssql project. 
Pymssql is a dbapi2 drive for Microsoft SQL server.


Full Announcement: https://github.com/pymssql/pymssql/issues/668

Thank you to everyone who has contributed to pymssql over the years. 
Unfortunately, I believe it's time to discontinue pymssql. It provides 
an incredible amount of utility to those of us that need to connect to 
MSSQL from Python. But, as a project, it has failed to attract enough 
interest/talent/funding to maintain it.


Why discontinue it and not let someone else maintain it? We've tried 
over the years. See #516 
. We have got a few 
people drop by to help occasionally, but nothing sustained enough to 
feel like transfer of the project was warranted.


I had always hoped my consulting business would be able to help 
maintain the library for clients that use it. But there is too much 
work here for us to tackle that doesn't really benefit our client's 
usage and we transitioned to PyODBC earlier this year.


I'm also concerned that if I simply abandon the project a bad actor 
could gain control and start installing nasty stuff on what I am sure 
is a lot of corporate servers.


It's my hope that by discontinuing this project better solutions will 
be developed and/or adopted to take it's place.



  Other Related Issues

  * Proposal to discontinue pymssql in favor of pyodbc #477

  * Maintainers Needed - Apply Within #516

  * Finding grants/funding for pymssql development #621



  Alternatives

  * pyodbc : Microsoft backed
  o But see: https://github.com/level12/sqlalchemy_pyodbc_mssql
  * ctds : by Zillow


  Interested in Taking Over?

Just fork pymssql and start your own project. Gain momentum, show 
progress, and I'd be happy to link to your project from here.



  Next Steps

I'm going to leave this issue open for suggestions on how best to 
deprecate/discontinue pymssql as a project. I'm sure there will be 
some who will suddenly be very interested in helping. I won't be 
considering those requests at this point. If you want to help, see 
above about forking.


At the end of November, 2019 I'm going to Archive this GH repository 
which will make it read-only.


I'll also need to figure out how to deprecate packages on PyPI so that 
people installing know the project is being discontinued.





*Randy Syring*
Husband | Father | Redeemed Sinner

/"For what does it profit a man to gain the whole world
and forfeit his soul?" (Mark 8:36 ESV)/

--
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/

   Support the Python Software Foundation:
   http://www.python.org/psf/donations/


[issue38724] Implement subprocess.Popen.__repr__

2019-11-06 Thread Ammar Askar


Change by Ammar Askar :


--
nosy: +gregory.p.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38724] Implement subprocess.Popen.__repr__

2019-11-06 Thread Ram Rachum


Change by Ram Rachum :


--
nosy: +taleinat

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38724] Implement subprocess.Popen.__repr__

2019-11-06 Thread Ram Rachum


New submission from Ram Rachum :

I was working with a Popen object recently in the shell and it was annoying to 
see the `` display. It would be nice to get some 
kind of minimal detail about the Popen, for example its args and return code, 
if finished.

--
components: Library (Lib)
messages: 356149
nosy: cool-RR, pitrou
priority: normal
severity: normal
status: open
title: Implement subprocess.Popen.__repr__
type: enhancement
versions: Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ANN] pvfactors: a view-factor network model for bifacial PV by SunPower

2019-11-06 Thread Dr. Mark Alexander Mikofski PhD
SunPower has just released the latest version of pvfactors (v1.3.0), a
Python package for modeling the incident irradiance on bifacial
photovoltaic (PV) using the network radiosity model. Bifacial PV are solar
panels that can generate energy from both the front and back surfaces.

PyPI: https://pypi.org/project/pvfactors/
GitHub: https://github.com/SunPower/pvfactors/releases


Thanks SunPower!

-- 
Mark Mikofski, PhD (2005)
*Fiat Lux*
--
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/

Support the Python Software Foundation:
http://www.python.org/psf/donations/


Re: psutil.boot_time() ... doesn't ?

2019-11-06 Thread Chris Angelico
On Thu, Nov 7, 2019 at 6:11 AM R.Wieser  wrote:
>
> I also tried to google "python BOOT_TIME", but got nowhere (the latter parts
> casing was ignored).  Hence me posting here.
>

That's possibly because you're looking at psutil, which is a third
party package. Here's its documentation:

https://psutil.readthedocs.io/en/latest/#psutil.boot_time

But I don't know what its definition is, whether it's "current time
minus uptime" or "timestamp recorded during bootup". It might not even
be consistent across platforms.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: psutil.boot_time() ... doesn't ?

2019-11-06 Thread R.Wieser
Maxime,

> You may want to read PEP 418 which nicely summaries the
> different clock available on each platform and their limitations.

You mean the CLOCK_REALTIME and CLOCK_MONOTONIC ones ?  Yeah, that was what 
I was looking at :-)

> It looks like CLOCK_BOOTTIME is what you want but it is only
> available on Linux.

While googeling for an explanation and/or solution to the behaviour of 
psutil.boot_time() I also came across it - and it was marked as depricated, 
with the above function as its successor.

I did try to use it though, but Raspberry Pi's Python3 threw a "no idea what 
that is" error. :-\

I also tried to google "python BOOT_TIME", but got nowhere (the latter parts 
casing was ignored).  Hence me posting here.

Regards,
Rudy Wieser


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How execute at least two python files at once when imported?

2019-11-06 Thread Bob van der Poel
On Wed, Nov 6, 2019 at 11:15 AM Rhodri James  wrote:

> On 06/11/2019 16:02, Spencer Du wrote:
> > Why is importing modules in parallel bad?
>
> To put it as simply as I can:
>
> 1. The import mechanism is complicated, even the bits that are
> user-visible.  Fiddling with it has a high chance of going wrong.
>
> 2. Multi-threading is less complicated than import, but still requires a
> lot of careful thought.  For example you've asserted that the modules
> you want to import simultaneously, but you also need to consider the
> import mechanism itself.
>
> Put 1 and 2 together, and multi-threaded import sounds like a nightmare.
>
> --
> Rhodri James *-* Kynesim Ltd
> --
> https://mail.python.org/mailman/listinfo/python-list
>


After spending way too much time chasing my tail down the rabbit hole on a
similar project I decided that using the work of others was more
productive. I've been using parallel with good success. Depends on how much
you need to share with the different components. For details see
https://www.gnu.org/software/parallel/


-- 

 Listen to my FREE CD at http://www.mellowood.ca/music/cedars 
Bob van der Poel ** Wynndel, British Columbia, CANADA **
EMAIL: b...@mellowood.ca
WWW:   http://www.mellowood.ca
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How execute at least two python files at once when imported?

2019-11-06 Thread Rhodri James

On 06/11/2019 16:02, Spencer Du wrote:

Why is importing modules in parallel bad?


To put it as simply as I can:

1. The import mechanism is complicated, even the bits that are 
user-visible.  Fiddling with it has a high chance of going wrong.


2. Multi-threading is less complicated than import, but still requires a 
lot of careful thought.  For example you've asserted that the modules 
you want to import simultaneously, but you also need to consider the 
import mechanism itself.


Put 1 and 2 together, and multi-threaded import sounds like a nightmare.

--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list


[issue38692] add a pidfd child process watcher

2019-11-06 Thread STINNER Victor


STINNER Victor  added the comment:

Would it be useful to use a pidfd in subprocess.Popen to fix bpo-38630 root 
issue, when pidfd is available?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33450] unexpected EPROTOTYPE returned by sendto on MAC OSX

2019-11-06 Thread Daniel King


Change by Daniel King :


--
nosy: +Daniel King

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: psutil.boot_time() ... doesn't ?

2019-11-06 Thread Maxime S
Hello,

You may want to read PEP 418 which nicely summaries the different clock
available on each platform and their limitations.

It looks like CLOCK_BOOTTIME is what you want but it is only available on
Linux.

Regards,

Maxime.

Le mer. 6 nov. 2019 à 18:23, R.Wieser  a écrit :

> Hello all,
>
> I was doing a "lets print some time-related data", and also diaplayed the
> result of "psutil.boot_time()".
>
> Somewhere while doing that I saw that my clock was off, so I used the
> "date"
> command to rectify it.
>
> The thing is, after that the result of "psutil.boot_time()" was changed -
> and that I did (and do) not expect. :-(
> (Remark: the difference was exactly the same as the change I made with the
> "date" command).
>
> Question: Is there a way to retrieve the "last boot" time /without/ it
> getting changed by ... whatever ?
>
> Regards,
> Rudy Wieser
>
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue16575] ctypes: unions as arguments

2019-11-06 Thread Ammar Askar


Ammar Askar  added the comment:

Will close after 
https://buildbot.python.org/all/#/builders?tags=%2Brefleak=%2B3.7 go back 
to green.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



psutil.boot_time() ... doesn't ?

2019-11-06 Thread R.Wieser
Hello all,

I was doing a "lets print some time-related data", and also diaplayed the
result of "psutil.boot_time()".

Somewhere while doing that I saw that my clock was off, so I used the "date"
command to rectify it.

The thing is, after that the result of "psutil.boot_time()" was changed -
and that I did (and do) not expect. :-(
(Remark: the difference was exactly the same as the change I made with the
"date" command).

Question: Is there a way to retrieve the "last boot" time /without/ it
getting changed by ... whatever ?

Regards,
Rudy Wieser



-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OOP - how to abort an __init__ when the initialisation code fails ?

2019-11-06 Thread Oscar Benjamin
On Tue, 5 Nov 2019 at 21:52, Gregory Ewing  wrote:
>
> Peter J. Holzer wrote:
> > On 2019-11-04 18:18:39 -0300, Luciano Ramalho wrote:
> >
> > Or maybe don't catch it here at all but just let it bubble up until it
> > hits a level where dealing with it makes sense from the user's point of
> > view
>
> Often it makes sense to do both -- catch the exception and
> re-raise it with a more informative error message, e.g.
>
>   try:
>   with open(filename, "w") as f:
>   f.write("some")
>   f.write("data")
>   except OSError as e:
>   raise OSError("Couldn't write fibble data to %s: %s" % (filename, 
> e))
>
> That way you don't get frustrating Microsoft style error
> messages which say "The system could not open the specified file"
> while giving no clue about *which* file was specified... aarggh!

Of course it doesn't apply to simples cases like above but my
experience of catching and reraising is that it often is the *cause*
of those kind of uninformative or even misleading error messages. In
Python the original exception message plus traceback is often very
informative (to a programmer!) about the problem. Catching and
reraising can mean that you end up crafting an error message somewhere
higher up where the filename isn't known any more. Even worse is if
the author's assumption about the source of the exception is
incorrect.

The problem with trying to specify how much should go into a try block
is that one line can be thousands of lines if it calls a function that
calls another function and so on. Even if you have a very narrow
lexical scope for the try block it can still cover the whole of your
codebase (or even that of all the dependencies you use) so the danger
of overly broad exception handling can not be understood in such
simple terms.

One thing that is clear though is that you should catch the most
specific kind of exception possible. Ideally if the exception is
raised in your code then it should be a dedicated exception class. If
that exception is only raised in one specific place I see nothing
wrong with wrapping all of your code in a try/except that catches that
one exception: when the exception is caught you know exactly why and
can handle appropriately.

Oscar
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: How execute at least two python files at once when imported?

2019-11-06 Thread David Raymond
"Why is importing modules in parallel bad?"

In general I'd say that
"import foo"
is supposed to be there because you want the classes, functions, variables etc. 
in foo to be available in your current program. A module should never run a 
whole bunch of time consuming stuff when it's imported.

If you want to "run foo" rather than import it, then inside foo all the 
"running" code should be in a function which can be called later. If you want 
foo to be runnable directly you can then call that function from the classic if 
__name__ == "__main__": construct. That lets foo be importable, and lets you 
pick when you want the actual long stuff to run.

#In foo.py

def run_long_task():
long_stuff_here
if __name__ == "__main__":
#foo.py is being called directly, not imported
run_long_task()


So your main program should look something like:

import foo  #quick as just the definitions are processed
foo.run_long_task()

Or to "run" multiple other things at once it should look more like:

import threading  #multiprocessing, or other module here
import foo  #quick as just the definitions are processed
import bar  #quick as just the definitions are processed

kick off foo.run_long_task() as its own thread/process/task/etc
kick off bar.run_long_task() as its own thread/process/task/etc

wait for them to finish and process results, or do stuff while they're running


So again, "import" should never be used to "run" another file, just to "bring 
in the stuff from" another file. And any file designed to be imported should 
not run extra stuff during that import.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How execute at least two python files at once when imported?

2019-11-06 Thread Igor Korot
Hi,

On Wed, Nov 6, 2019 at 10:22 AM Spencer Du  wrote:
>
> Hi
>
> Sorry if I haven't stated my requirements clearly.
>
> I just wanted a way to import at least two python files in parallel and I 
> wanted to know how this can be done or a reason why its bad as stated in 
> another post.

This is not a requirements.

Let me rephrase my question - what problem are you trying to solve?

Also, as I said before - I believe there is a language barrier.

Find some python forum in your native language and ask your question there.

Thank you.

>
> Thanks
> Spencer
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue38583] The activate script in Windows is not correct for venvs created in git-bash

2019-11-06 Thread Mo


Mo  added the comment:

I had also tested with pathlib and posixpath and come to the same conclusion.

As suggested by you, I looked into `activate` determining path when run. I 
believe this should do the trick (My bashfoo isn't strong, this is mostly from 
https://stackoverflow.com/a/179231):

pushd . > /dev/null
SCRIPT_PATH="${BASH_SOURCE[0]}"
if ([ -h "${SCRIPT_PATH}" ]); then
  while([ -h "${SCRIPT_PATH}" ]); do cd `dirname "$SCRIPT_PATH"`; 
  SCRIPT_PATH=`readlink "${SCRIPT_PATH}"`; done
fi
cd `dirname ${SCRIPT_PATH}` > /dev/null
cd .. > /dev/null
SCRIPT_PATH=`pwd`;
popd  > /dev/null

VIRTUAL_ENV="$SCRIPT_PATH"

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: How execute at least two python files at once when imported?

2019-11-06 Thread Karsten Hilbert
On Wed, Nov 06, 2019 at 08:16:07AM -0800, Spencer Du wrote:

> Sorry if I haven't stated my requirements clearly.
>
> I just wanted a way to import at least two python files in parallel and I 
> wanted to know how this can be done or a reason why its bad as stated in 
> another post.

You stated your *desire* but not which (external)
*requirement* this desire comes from.

Long answer short: if you want exactly what you say then
you'll have to run two separate machines and overcome the
Heisenberg Principle with regards to syncronizing their
runtime behaviour.

Karsten
--
GPG  40BE 5B0E C98E 1713 AFA6  5BC0 3BEA AC80 7D4F C89B
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How execute at least two python files at once when imported?

2019-11-06 Thread Spencer Du
Hi

Sorry if I haven't stated my requirements clearly.

I just wanted a way to import at least two python files in parallel and I 
wanted to know how this can be done or a reason why its bad as stated in 
another post.

Thanks
Spencer
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How execute at least two python files at once when imported?

2019-11-06 Thread Igor Korot
Hi,
I think what you are trying is a "chicken-egg" problem.
You should clearly state you requirements in order for us to help you.

If you have a problem with English I'm sure there is some
python-related list/forum in your native language.
Just google it.

Thank you.

On Wed, Nov 6, 2019 at 10:07 AM Spencer Du  wrote:
>
> Why is importing modules in parallel bad?
>
> Thanks
> Spencer
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue38722] runpy should use io.open_code() instead of open()

2019-11-06 Thread Dominic Littlewood


New submission from Dominic Littlewood <11dlittlew...@gmail.com>:

Fairly obviously, if you're using something called runpy you're probably trying 
to run some code. To do this it has to open the script as a file.

This is similar to two other issues I'm posting, but they're in different 
modules, so different bugs.

--
components: Library (Lib)
messages: 356144
nosy: plokmijnuhby
priority: normal
severity: normal
status: open
title: runpy should use io.open_code() instead of open()
type: security
versions: Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38723] Pdb._runscript should use io.open_code() instead of open()

2019-11-06 Thread Dominic Littlewood


New submission from Dominic Littlewood <11dlittlew...@gmail.com>:

Fairly obviously, if you're using something called _runscript you're probably 
trying to run some code. To do this it has to open the script as a file.

This is similar to two other issues I'm posting, but they're in different 
modules, so different bugs.

--
messages: 356145
nosy: plokmijnuhby
priority: normal
severity: normal
status: open
title: Pdb._runscript should use io.open_code() instead of open()

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: How execute at least two python files at once when imported?

2019-11-06 Thread Spencer Du
Why is importing modules in parallel bad?

Thanks
Spencer
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue38723] Pdb._runscript should use io.open_code() instead of open()

2019-11-06 Thread Dominic Littlewood


Change by Dominic Littlewood <11dlittlew...@gmail.com>:


--
components: +Library (Lib)
type:  -> security
versions: +Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38721] modulefinder should use io.open_code() instead of open()

2019-11-06 Thread Dominic Littlewood


New submission from Dominic Littlewood <11dlittlew...@gmail.com>:

modulefinder currently will detect modules imported by a script dynamically by 
running the script, and to do this it has to open the script as a file.

This would also fix what appears to be a bug where modulefinder failed to open 
files in bytes mode sometimes, causing it to fail for some modules (like 
functools) if the wrong encoding is used. I say "appears to be", because the 
structure of the module seems to imply this was intended behaviour, but I can't 
think why anyone would want this.

This is similar to two other issues I'm posting, but they're in different 
modules, so different bugs.

--
components: Library (Lib)
messages: 356143
nosy: plokmijnuhby
priority: normal
severity: normal
status: open
title: modulefinder should use io.open_code() instead of open()
type: security
versions: Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38716] logging: rotating handlers set namer and rotator null

2019-11-06 Thread lorb


lorb  added the comment:

I have changed the PR accordingly.

Am Mi., 6. Nov. 2019 um 16:36 Uhr schrieb Vinay Sajip :
>
>
> Vinay Sajip  added the comment:
>
> > Would you consider it more acceptable to just turn
> them into class level attributes of BaseRotatingHandler instead of
> setting them in init?
>
> Yes, that would be better.
>
> --
>
> ___
> Python tracker 
> 
> ___

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16575] ctypes: unions as arguments

2019-11-06 Thread Vinay Sajip


Vinay Sajip  added the comment:


New changeset 484edbf9bf1a9e6bae0fcb10a0c165b89ea79295 by Vinay Sajip (Ammar 
Askar) in branch '3.7':
bpo-16575: Fix refleak on passing unions in ctypes (GH-17064)
https://github.com/python/cpython/commit/484edbf9bf1a9e6bae0fcb10a0c165b89ea79295


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38716] logging: rotating handlers set namer and rotator null

2019-11-06 Thread Vinay Sajip


Vinay Sajip  added the comment:

> Would you consider it more acceptable to just turn
them into class level attributes of BaseRotatingHandler instead of
setting them in init?

Yes, that would be better.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38696] HTTP modules documentation error

2019-11-06 Thread Stojan Jovic


Stojan Jovic  added the comment:

Thank you, guys, for really quick fix!

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38720] Logging failure with timestamp messages

2019-11-06 Thread xtobes


New submission from xtobes :

This only happings on Windows, the scripts runs some seconds and then stops and 
exit with: Process finished with exit code -1073740940 (0xC374). This 
happens when the format variable of a logging config object contains the 
identifier '%(asctime)s'.

--
components: Windows
messages: 356138
nosy: paul.moore, steve.dower, tim.golden, xtobes, zach.ware
priority: normal
severity: normal
status: open
title: Logging failure with timestamp messages
type: crash
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38696] HTTP modules documentation error

2019-11-06 Thread Zachary Ware


Zachary Ware  added the comment:

Thanks for the report, Stojan, and for the patch, Ammar!

--
nosy: +ammar2
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
type: resource usage -> behavior
versions: +Python 3.7, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38696] HTTP modules documentation error

2019-11-06 Thread miss-islington


miss-islington  added the comment:


New changeset 91f4b9282fe7cdc51c6612002d033da654f422c1 by Miss Islington (bot) 
in branch '3.7':
bpo-38696: Fix usage example of HTTPStatus (GH-17066)
https://github.com/python/cpython/commit/91f4b9282fe7cdc51c6612002d033da654f422c1


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38696] HTTP modules documentation error

2019-11-06 Thread miss-islington


miss-islington  added the comment:


New changeset 30da387df193b9f05c2891ae601ae5a1d669a5c1 by Miss Islington (bot) 
in branch '3.8':
bpo-38696: Fix usage example of HTTPStatus (GH-17066)
https://github.com/python/cpython/commit/30da387df193b9f05c2891ae601ae5a1d669a5c1


--
nosy: +miss-islington

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37645] Replace PyEval_GetFuncName/PyEval_GetFuncDesc

2019-11-06 Thread Petr Viktorin


Petr Viktorin  added the comment:

With this change, CPython no longer uses PyEval_GetFuncName/PyEval_GetFuncDesc 
internally.
Shall we deprecate/discourage them?
Shall we expose PyObject_FunctionStr publicly?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   >