Was: Dynamic Data type assignment

2020-01-29 Thread DL Neil via Python-list

Further thoughts on the OP's point:-



On 29/01/20 4:51 PM, sushma ms wrote:

...


But why can't we make output of input also dynamic data assignment.

...
 when i'm assigning value dynamically and when we comparing in "if" 
loop

 it is throwing compiler error. It should not throw error it should
 assign
 and act as int why it is thinking as string.


NB am not disputing the facts:

WebRef: https://docs.python.org/3/library/functions.html#input



Coincidentally, not long after this list-conversation, I was asked to 
take a look at a command-line program(me) which was not accepting 
arguments per spec.


First, I dived into the PSL to refresh my memory. There we find all 
manner of 'goodies' for formatting the cmdLN I/P, selecting its type, 
defaults, etc, etc.


Why do we have this at the cmdLN and yet not have something similar for 
input?


Perhaps there is a small library available (that I've never gone looking 
to find) which wraps input() and facilitates the input of int[egers], 
for example?


What the OP asks is not really 'out there', we used FORMAT to type INPUT 
data in FORTRAN, back in the ?good old days!

(don't over-excite me or I'll threaten you with my walking-stick...)

--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list


[issue39499] ValueError using index on tuple is not showing the tuple value

2020-01-29 Thread Oscar


New submission from Oscar :

When trying to retrieve the index of an element that is not in a tuple the 
error message of ValueError is not showing the value looking for but instead a 
static message tuple.index(x): x not in tuple

>>> b = (1, 2, 3, 4)
>>> b.index(5)
Traceback (most recent call last):
  File "", line 1, in 
ValueError: tuple.index(x): x not in tuple

I would expect something like what happen in lists where the element (5 in this 
case) is showed on the ValueError.
>>> a = [1, 2, 3, 4]
>>> a.index(5)
Traceback (most recent call last):
  File "", line 1, in 
ValueError: 5 is not in list

--
messages: 361016
nosy: tuxskar
priority: normal
severity: normal
status: open
title: ValueError using index on tuple is not showing the tuple value
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



Re: Help on dictionaries...

2020-01-29 Thread Souvik Dutta
How do I connect it with my dictionary

On Thu, Jan 30, 2020, 7:03 AM Tim Chase 
wrote:

> On 2020-01-30 06:44, Souvik Dutta wrote:
> > Hey I was thinking how I can save a dictionary in python(obviously)
> > so that the script is rerun it automatically loads the dictionary.
>
> This is almost exactly what the "dbm" (nee "anydbm") module does, but
> persisting the dictionary out to the disk:
>
>   import dbm
>   from sys import argv
>   with dbm.open("my_cache", "c") as db:
> if len(argv) > 1:
>   key = argv[1]
>   if key in db:
> print("Found it:", db[key])
>   else:
> print("Not found. Adding")
> if len(argv) > 2:
>   value = argv[2]
> else:
>   value = key
> db[key] = value
> else:
>   print("There are %i items in the cache" % len(db))
>
> The resulting "db" acts like a dictionary, but persists.
>
> If you really must have the results as a "real" dict, you can do the
> conversion:
>
>   real_dict = dict(db)
>
> -tkc
>
>
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue39495] xml.etree.ElementTree.TreeBuilder.start differs between pure Python and C implementations

2020-01-29 Thread Shantanu


Change by Shantanu :


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

___
Python tracker 

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



[issue39495] xml.etree.ElementTree.TreeBuilder.start differs between pure Python and C implementations

2020-01-29 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

According to the documentation the attrs parameter does not have default value. 
I think that the C implementation should be changed.

https://docs.python.org/3/library/xml.etree.elementtree.html#xml.etree.ElementTree.TreeBuilder.start

--

___
Python tracker 

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



[issue39401] [CVE-2020-8315] Unsafe dll loading in getpathp.c on Win7

2020-01-29 Thread miss-islington


miss-islington  added the comment:


New changeset ad4a20b87d79a619ffbdea3f26848780899494e5 by Steve Dower in branch 
'3.8':
[3.8] bpo-39401: Avoid unsafe DLL load on Windows 7 and earlier (GH-18231) 
(GH-18234)
https://github.com/python/cpython/commit/ad4a20b87d79a619ffbdea3f26848780899494e5


--

___
Python tracker 

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



[issue39401] [CVE-2020-8315] Unsafe dll loading in getpathp.c on Win7

2020-01-29 Thread miss-islington


miss-islington  added the comment:


New changeset 561c59777c8426fde0ef48b57cf02eddaeb2a5b8 by Steve Dower in branch 
'3.7':
[3.7] bpo-39401: Avoid unsafe DLL load on Windows 7 and earlier (GH-18231) 
(GH-18232)
https://github.com/python/cpython/commit/561c59777c8426fde0ef48b57cf02eddaeb2a5b8


--
nosy: +miss-islington

___
Python tracker 

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



[issue39493] typing.py has an incorrect definition of closed

2020-01-29 Thread Guido van Rossum


Guido van Rossum  added the comment:


New changeset 194c7aeb6f3d6c2b0015457d22b38253652f4f38 by Miss Islington (bot) 
in branch '3.7':
[3.7] bpo-39493: Fix definition of IO.closed in typing.py (GH-18273)
https://github.com/python/cpython/commit/194c7aeb6f3d6c2b0015457d22b38253652f4f38


--

___
Python tracker 

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



[issue39493] typing.py has an incorrect definition of closed

2020-01-29 Thread Guido van Rossum


Guido van Rossum  added the comment:

Thanks, Shantanu!

--
resolution:  -> fixed
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



[issue39493] typing.py has an incorrect definition of closed

2020-01-29 Thread miss-islington


miss-islington  added the comment:


New changeset 58076df0c59677111dc77b72852cb2a313a2ef91 by Miss Islington (bot) 
in branch '3.8':
bpo-39493: Fix definition of IO.closed in typing.py (GH-18265)
https://github.com/python/cpython/commit/58076df0c59677111dc77b72852cb2a313a2ef91


--
nosy: +miss-islington

___
Python tracker 

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



[issue39493] typing.py has an incorrect definition of closed

2020-01-29 Thread miss-islington


Change by miss-islington :


--
pull_requests: +17649
pull_request: https://github.com/python/cpython/pull/18274

___
Python tracker 

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



[issue39493] typing.py has an incorrect definition of closed

2020-01-29 Thread miss-islington


Change by miss-islington :


--
pull_requests: +17648
pull_request: https://github.com/python/cpython/pull/18273

___
Python tracker 

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



[issue39498] Signpost security considerations in library

2020-01-29 Thread anthony shaw


Change by anthony shaw :


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

___
Python tracker 

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



[issue39498] Signpost security considerations in library

2020-01-29 Thread anthony shaw


New submission from anthony shaw :

Within the documentation, there are some really important security 
considerations for standard library modules. e.g. subprocess, ssl, pickle, xml.

There is currently no "index" of these, so you have to go hunting for them. 
They're easter eggs within the docs. There isn't a unique admonition type 
either, so you have to search across many criteria.

In particular for security researchers, it would be useful to consolidate and 
signpost these security best-practices in one index.

PR to follow,

--
assignee: docs@python
components: Documentation
messages: 361009
nosy: anthonypjshaw, docs@python
priority: normal
severity: normal
status: open
title: Signpost security considerations in library
type: enhancement

___
Python tracker 

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



[issue39497] Unused variable script_str in pysqlite_cursor_executescript

2020-01-29 Thread Alex Henrie


Change by Alex Henrie :


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

___
Python tracker 

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



[issue39497] Unused variable script_str in pysqlite_cursor_executescript

2020-01-29 Thread Alex Henrie


New submission from Alex Henrie :

The function pysqlite_cursor_executescript defines a variable called 
script_str, initializes it to NULL, and calls Py_XDECREF on it. However, this 
variable has been unused since August 2007: 
https://github.com/python/cpython/commit/6d21456137836b8acd551cf6a51999ad4ff10a91#diff-26f74db3527991715b482a5ed2603870L752

--
components: Library (Lib)
messages: 361008
nosy: alex.henrie
priority: normal
severity: normal
status: open
title: Unused variable script_str in pysqlite_cursor_executescript
type: performance
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



[issue39494] Extra null terminators in keyword arrays in sqlite module

2020-01-29 Thread Berker Peksag


Change by Berker Peksag :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
type: resource usage -> 

___
Python tracker 

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



[issue39494] Extra null terminators in keyword arrays in sqlite module

2020-01-29 Thread Berker Peksag


Berker Peksag  added the comment:


New changeset 188bb5b1e868eecf2342195dc45caa332ac3b6c7 by Alex Henrie in branch 
'master':
bpo-39494: Remove extra null terminators from kwlist vars (GH-18267)
https://github.com/python/cpython/commit/188bb5b1e868eecf2342195dc45caa332ac3b6c7


--
nosy: +berker.peksag

___
Python tracker 

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



[issue39496] Inelegant loops in Modules/_sqlite/cursor.c

2020-01-29 Thread Alex Henrie


Change by Alex Henrie :


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

___
Python tracker 

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



[issue39496] Inelegant loops in Modules/_sqlite/cursor.c

2020-01-29 Thread Alex Henrie


New submission from Alex Henrie :

pysqlite_cursor_fetchall currently has the following bit of code:

/* just make sure we enter the loop */
row = (PyObject*)Py_None;

while (row) {
row = pysqlite_cursor_iternext(self);
if (row) {
PyList_Append(list, row);
Py_DECREF(row);
}
}

This can and should be rewritten as a for loop to avoid the unnecessary 
initialization to Py_None and the redundant if statement inside the loop.

pysqlite_cursor_fetchmany has the same problem.

--
components: Library (Lib)
messages: 361006
nosy: alex.henrie
priority: normal
severity: normal
status: open
title: Inelegant loops in Modules/_sqlite/cursor.c
type: performance
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



Re: Help on dictionaries...

2020-01-29 Thread MRAB

On 2020-01-30 01:51, Michael Torrie wrote:

On 1/29/20 6:14 PM, Souvik Dutta wrote:

Hey I was thinking how I can save a dictionary in python(obviously) so that
the script is rerun it automatically loads the dictionary.


You could use the pickle module for that. See the python.org
documentation on pickle.

Alternatively you could use a json library to write the dict to disk.  I
think this might be preferable to pickle in many situations.

Or serialize the data yourself to a file.

JSON itself supports only a limited range of types, so additional work 
is needed, especially when loading, if the dict contains any other types 
beyond those.

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


Re: on sorting things

2020-01-29 Thread Cameron Simpson

On 20Dec2019 08:23, Chris Angelico  wrote:

On Fri, Dec 20, 2019 at 8:06 AM Eli the Bearded <*@eli.users.panix.com> wrote:
Consider a sort that first compares file size and if the same number 
of

bytes, then compares file checksum. Any decently scaled real world
implementation would memoize the checksum for speed, but only work it out
for files that do not have a unique file size. The key method requires
it worked out in advance for everything.

But I see the key method handles the memoization under the hood for you,
so those simpler, more common sorts of sort get an easy to see benefit.


I guess that's a strange situation that might actually need this kind
of optimization, but if you really do have that situation, you can
make a magical key that behaves the way you want.

[... example implementation ...]

The classic situation matching Eli's criteria is comparing file trees 
for equivalent files, for backup or synchronisation or hard linking 
purposes; I've a script which does exactly what he describes in terms of 
comparison (size, then checksum, but I checksum a short prefix before 
doing a full file checksum, so even more fiddly).


However, my example above isn't very amenable to sorts, because you 
never bother looking at checksums at all for files of different sizes.  
OTOH, I do sort the files by size before processing the checksum phases, 
letting one sync/reclaim the big files first for example - a policy 
choice.


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


[issue39495] xml.etree.ElementTree.TreeBuilder.start differs between pure Python and C implementations

2020-01-29 Thread Shantanu


Shantanu  added the comment:

Based on 
https://github.com/python/cpython/blob/master/Modules/_elementtree.c#L2700 and 
the behaviour at runtime, something like the following patch could work:
```
diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py
index c8d898f328..bbfc1afe08 100644
--- a/Lib/xml/etree/ElementTree.py
+++ b/Lib/xml/etree/ElementTree.py
@@ -1452,7 +1452,7 @@ class TreeBuilder:
 """Add text to current element."""
 self._data.append(data)
 
-def start(self, tag, attrs):
+def start(self, tag, attrs=None):
 """Open new element and return it.
 
 *tag* is the element name, *attrs* is a dict containing element
@@ -1460,6 +1460,8 @@ class TreeBuilder:
 
 """
 self._flush()
+if attrs is None:
+attrs = {}
 self._last = elem = self._factory(tag, attrs)
 if self._elem:
 self._elem[-1].append(elem)
```

Happy to submit a PR!

--

___
Python tracker 

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



[issue39495] xml.etree.ElementTree.TreeBuilder.start differs between pure Python and C implementations

2020-01-29 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +eli.bendersky, scoder, serhiy.storchaka

___
Python tracker 

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



[issue39493] typing.py has an incorrect definition of closed

2020-01-29 Thread Guido van Rossum


Guido van Rossum  added the comment:


New changeset 2e6569b6692298fcc9aae0df3eb3181adb2a5099 by Shantanu in branch 
'master':
bpo-39493: Fix definition of IO.closed in typing.py (#18265)
https://github.com/python/cpython/commit/2e6569b6692298fcc9aae0df3eb3181adb2a5099


--
nosy: +gvanrossum

___
Python tracker 

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



[issue38792] IDLE calltips may not properly close on KeyboardInterrupt

2020-01-29 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I verified problem for KeyboardInterrupt and RestartShell but not for a newline 
that actually runs the statement.  In my experiments, if a newline in inserted 
instead of running, the cursor remains within a call and the calltip should not 
disappear.

--

___
Python tracker 

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



Re: Help on dictionaries...

2020-01-29 Thread Souvik Dutta
Thank you all.

On Thu, Jan 30, 2020, 7:25 AM DL Neil via Python-list <
python-list@python.org> wrote:

> On 30/01/20 2:14 PM, Souvik Dutta wrote:
> > Hey I was thinking how I can save a dictionary in python(obviously) so
> that
> > the script is rerun it automatically loads the dictionary.
>
>
> Perhaps a YAML or JSON file (which follow a very similar format and
> structure to Python dicts), or a 'NoSQL' database such as MongoDB.
>
> --
> Regards =dn
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue39495] xml.etree.ElementTree.TreeBuilder.start differs between pure Python and C implementations

2020-01-29 Thread Shantanu


New submission from Shantanu :

The C accelerated version of `xml.etree.ElementTree.TreeBuilder.start` has a 
default value for `attrs`, whereas the pure Python version does not.

```
In [41]: sys.version
   
Out[41]: '3.8.1 (default, Jan 23 2020, 23:36:06) \n[Clang 11.0.0 
(clang-1100.0.33.17)]'

In [42]: import xml.etree.ElementTree   
   

In [43]: inspect.signature(xml.etree.ElementTree.TreeBuilder.start) 
   
Out[43]: 

In [44]: from test.support import import_fresh_module   
   

In [45]: pyElementTree = import_fresh_module('xml.etree.ElementTree', 
blocked=['_elementtree'])

In [46]: inspect.signature(pyElementTree.TreeBuilder.start) 
   
Out[46]: 
```

>From PEP 399 (https://www.python.org/dev/peps/pep-0399/)
```
Acting as a drop-in replacement also dictates that no public API be provided in 
accelerated code that does not exist in the pure Python code. Without this 
requirement people could accidentally come to rely on a detail in the 
accelerated code which is not made available to other VMs that use the pure 
Python implementation. 
```

--
components: Library (Lib)
messages: 361002
nosy: hauntsaninja
priority: normal
severity: normal
status: open
title: xml.etree.ElementTree.TreeBuilder.start differs between pure Python and 
C implementations

___
Python tracker 

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



Re: PyQt5 QLineEditor help!!!

2020-01-29 Thread Michael Torrie
On 1/29/20 6:11 PM, Souvik Dutta wrote:
> Hi guys I just started to learn PyQt5 and was wondering if like kivy we can
> delete the text in a textbox after taking the input. That is I want to make
> the textbox blank after the text is read. Also can you suggest a way to
> connect a cancel button with a function so that when the cancel button is
> clicked it exists a window. Tank you in advance.

How do you know when the input is done (taken)?  If it's from pressing
Enter, then you'll probably have to capture that keystroke somehow (is
there a signal defined in QWidget that might do that?).  If it's from a
button press that activates something, then from the button click
callback handler you would call clear() on the QLineEditor instance.

You can definitely close a window on a cancel button click.  If you just
want to hide the window for displaying in the future, call
setVisible(false) on the window object.  If you want to destroy the
window object, you would probably call the "destroy()" method of the
window, and then delete the python reference to it (either let it go out
of scope, or use del on it).
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help on dictionaries...

2020-01-29 Thread Tim Chase
On 2020-01-30 06:44, Souvik Dutta wrote:
> Hey I was thinking how I can save a dictionary in python(obviously)
> so that the script is rerun it automatically loads the dictionary.

This is almost exactly what the "dbm" (nee "anydbm") module does, but
persisting the dictionary out to the disk:

  import dbm
  from sys import argv
  with dbm.open("my_cache", "c") as db:
if len(argv) > 1:
  key = argv[1]
  if key in db:
print("Found it:", db[key])
  else:
print("Not found. Adding")
if len(argv) > 2:
  value = argv[2]
else:
  value = key
db[key] = value
else:
  print("There are %i items in the cache" % len(db))

The resulting "db" acts like a dictionary, but persists.

If you really must have the results as a "real" dict, you can do the
conversion:

  real_dict = dict(db)

-tkc



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


Re: Help on dictionaries...

2020-01-29 Thread DL Neil via Python-list

On 30/01/20 2:14 PM, Souvik Dutta wrote:

Hey I was thinking how I can save a dictionary in python(obviously) so that
the script is rerun it automatically loads the dictionary.



Perhaps a YAML or JSON file (which follow a very similar format and 
structure to Python dicts), or a 'NoSQL' database such as MongoDB.


--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list


Re: Help on dictionaries...

2020-01-29 Thread Michael Torrie
On 1/29/20 6:14 PM, Souvik Dutta wrote:
> Hey I was thinking how I can save a dictionary in python(obviously) so that
> the script is rerun it automatically loads the dictionary.

You could use the pickle module for that. See the python.org
documentation on pickle.

Alternatively you could use a json library to write the dict to disk.  I
think this might be preferable to pickle in many situations.

Or serialize the data yourself to a file.

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


[issue39494] Extra null terminators in keyword arrays in sqlite module

2020-01-29 Thread Alex Henrie


Change by Alex Henrie :


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

___
Python tracker 

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



[issue39494] Extra null terminators in keyword arrays in sqlite module

2020-01-29 Thread Alex Henrie


New submission from Alex Henrie :

Modules/_sqlite/cursor.c currently has the following variable declaration:

static char *kwlist[] = {"size", NULL, NULL};

The second null terminator is unnecessary and detrimental in that it makes the 
code harder to read and understand.

Modules/_sqlite/module.c has two additional kwlist variables with the same 
problem.

--
components: Library (Lib)
messages: 361001
nosy: alex.henrie
priority: normal
severity: normal
status: open
title: Extra null terminators in keyword arrays in sqlite module
type: resource usage
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



[issue33339] Using default encoding with `subprocess.run()` is not obvious

2020-01-29 Thread Eryk Sun


Eryk Sun  added the comment:

This issue was already addressed for 3.x in bpo-31756, which added the a `text` 
parameter and updated the documentation. As to 2.7, it was officially retired 
as of the first of this month. Anyway, I don't think there was a pressing need 
to clarify the documentation in 2.7.

--
nosy: +eryksun
resolution:  -> duplicate
stage: needs patch -> resolved
status: open -> closed
superseder:  -> subprocess.run should alias universal_newlines to text

___
Python tracker 

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



Help on dictionaries...

2020-01-29 Thread Souvik Dutta
Hey I was thinking how I can save a dictionary in python(obviously) so that
the script is rerun it automatically loads the dictionary.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue39492] reference cycle affecting Pickler instances (Python3.8+)

2020-01-29 Thread Pierre Glaser


Change by Pierre Glaser :


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

___
Python tracker 

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



PyQt5 QLineEditor help!!!

2020-01-29 Thread Souvik Dutta
Hi guys I just started to learn PyQt5 and was wondering if like kivy we can
delete the text in a textbox after taking the input. That is I want to make
the textbox blank after the text is read. Also can you suggest a way to
connect a cancel button with a function so that when the cancel button is
clicked it exists a window. Tank you in advance.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue39493] typing.py has an incorrect definition of closed

2020-01-29 Thread Shantanu


Change by Shantanu :


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

___
Python tracker 

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



[issue39320] Handle unpacking of */** arguments and rvalues in the compiler

2020-01-29 Thread Brandt Bucher


Change by Brandt Bucher :


--
pull_requests: +17641
pull_request: https://github.com/python/cpython/pull/18264

___
Python tracker 

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



[issue39401] [CVE-2020-8315] Unsafe dll loading in getpathp.c on Win7

2020-01-29 Thread Steve Dower


Steve Dower  added the comment:

> I added 
> https://python-security.readthedocs.io/vuln/unsafe-dll-load-windows-7.html to 
> track fixes in all branches.

Thanks, Victor!

Python 2.7 and 3.5 are not vulnerable. The issue was added in 3.6 when I added 
support for installing Python into a long path name on up-to-date OS, which 
required dynamically loading an OS function. That dynamic load was the problem.

--

___
Python tracker 

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



[issue39401] [CVE-2020-8315] Unsafe dll loading in getpathp.c on Win7

2020-01-29 Thread Steve Dower


Steve Dower  added the comment:

Both of those buildbots should be retired (or repurposed for versions of Python 
that still support Windows 7) :)

--

___
Python tracker 

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



[issue39401] [CVE-2020-8315] Unsafe dll loading in getpathp.c on Win7

2020-01-29 Thread Eryk Sun


Eryk Sun  added the comment:

> this PR has caused failures of 2 buildbots

The master branch should no longer get built on Windows 7 machines. The initial 
build succeeds, but running "_freeze_importlib[_d].exe" fails with 
STATUS_DLL_NOT_FOUND (0xC135, i.e. -1073741515) since 
"api-ms-win-core-path-l1-1-0.dll" (linked from pathcch.lib) is not a Windows 7 
API set.

--

___
Python tracker 

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



[issue39493] typing.py has an incorrect definition of closed

2020-01-29 Thread Shantanu


New submission from Shantanu :

Hello!

typing.py has the following definition of `closed`:
https://github.com/python/cpython/blob/master/Lib/typing.py#L1834
```
@abstractmethod
def closed(self) -> bool:
pass
```

This is inconsistent with the behaviour at runtime:
```
In [17]: sys.version
  
Out[17]: '3.8.1 (default, Jan 23 2020, 23:36:06) \n[Clang 11.0.0 
(clang-1100.0.33.17)]'

In [18]: f = open("test", "w")  
  

In [19]: f.closed   
  
Out[19]: False
```

It seems like the right thing to do is add an @property, as we do with e.g. 
`mode` and `name`. I'll submit a PR with this change.

Note typeshed also types this as a property to indicate a read-only attribute.
https://github.com/python/typeshed/blob/master/stdlib/3/typing.pyi#L459

First time filing a bug on BPO, thanks a lot in advance!

--
messages: 360996
nosy: hauntsaninja
priority: normal
severity: normal
status: open
title: typing.py has an incorrect definition of closed
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



[issue38631] Replace Py_FatalError() with regular Python exceptions

2020-01-29 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +17640
pull_request: https://github.com/python/cpython/pull/18263

___
Python tracker 

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



[issue38631] Replace Py_FatalError() with regular Python exceptions

2020-01-29 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +17639
pull_request: https://github.com/python/cpython/pull/18262

___
Python tracker 

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



[issue39492] reference cycle affecting Pickler instances (Python3.8+)

2020-01-29 Thread Pierre Glaser


New submission from Pierre Glaser :

The new Pickler reducer_override mechanism introduced in `Python3.8` generates 
a reference cycle: for optimization purposes, a the pickler.reducer_override 
bound method is referenced into the reducer_override attribute of the Pickler's 
struct. Thus, until as a gc.collect call is performed, both the Pickler and all 
the elements it pickled (as they are part of its memo), wont be collected.

We should break this cycle a the end of the dump() method.

See reproducer below:
```
import threading
import weakref
import pickle
import io


class MyClass:
pass


my_object = MyClass()
collect = threading.Event()
_ = weakref.ref(my_object, lambda obj: collect.set())  # noqa


class MyPickler(pickle.Pickler):
def reducer_override(self, obj):
return NotImplemented


my_pickler = MyPickler(io.BytesIO())
my_pickler.dump(my_object)
del my_object
del my_pickler

# import gc
# gc.collect()

for i in range(5):
collected = collect.wait(timeout=0.1)
if collected:
print('my_object was successfully collected')
break
```

--
components: Library (Lib)
messages: 360995
nosy: pierreglaser, pitrou
priority: normal
severity: normal
status: open
title: reference cycle affecting Pickler instances (Python3.8+)
type: resource usage
versions: 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



[issue38631] Replace Py_FatalError() with regular Python exceptions

2020-01-29 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +17638
pull_request: https://github.com/python/cpython/pull/18258

___
Python tracker 

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



[issue39401] [CVE-2020-8315] Unsafe dll loading in getpathp.c on Win7

2020-01-29 Thread Jeremy Kloth


Jeremy Kloth  added the comment:

As noted on the PR landing page, this PR has caused failures of 2 buildbots:

https://buildbot.python.org/all/#builders/81/builds/272

https://buildbot.python.org/all/#builders/150/builds/227

(both are Windows 7)

--
nosy: +jkloth

___
Python tracker 

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



[issue39488] test_largefile: TestSocketSendfile.test_it() uses too much disk space

2020-01-29 Thread Giampaolo Rodola'


Change by Giampaolo Rodola' :


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

___
Python tracker 

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



[issue39487] Merge duplicated _Py_IDENTIFIER identifiers in C code

2020-01-29 Thread STINNER Victor


STINNER Victor  added the comment:

> That means this is a useful refactoring to help identify blockers to full 
> subinterpreter support.

I don't think that subinterpreter support should block this issue, since 
currently, _Py_IDENTIFIER() does *not* support subinterpreters.

> In the subinterpreter context: perhaps it would make sense to move *all* 
> Py_IDENTIFIER declarations to file scope?

What do you mean? _Py_IDENTIFIER() macro uses "static", so no identifier is 
visible outside the current C file. The scope may be the whole file, or the 
current function, depending where it's declared.

--

Once I discussed with Eric: _Py_IDENTIFIER() should use an "interpreter local 
storage" for identifiers values. _Py_IDENTIFIER() would only be a "key" and 
_PyUnicode_FromId() would store the value somewhere in a hash table stored in 
PyInterpreterState. Something similar to the TSS API:

* PyThread_create_key()
* PyThread_delete_key_value()
* PyThread_set_key_value()
* PyThread_get_key_value()

But per interpreter, rather than being per thread.

The key can be simply the variable address in memory. It only has to be unique 
in the process.

--

___
Python tracker 

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



[issue39487] Merge duplicated _Py_IDENTIFIER identifiers in C code

2020-01-29 Thread Nick Coghlan


Nick Coghlan  added the comment:

In the subinterpreter context: perhaps it would make sense to move *all* 
Py_IDENTIFIER declarations to file scope?

That would make it much clearer which of our extension modules actually have 
hidden state for caching purposes.

If we did that though, we'd also want to update the usage instructions in 
object.h

--

___
Python tracker 

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



[issue39487] Merge duplicated _Py_IDENTIFIER identifiers in C code

2020-01-29 Thread Nick Coghlan


Nick Coghlan  added the comment:

My apologies, my comment above was based on an outdated understanding of how 
the identifier structs get initialised (it's the usage that initialises them, 
not the declaration).

That means this is a useful refactoring to help identify blockers to full 
subinterpreter support.

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

___
Python tracker 

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



[issue39487] Merge duplicated _Py_IDENTIFIER identifiers in C code

2020-01-29 Thread Nick Coghlan


Nick Coghlan  added the comment:

We can't make this change, as it means the statics get initialised before the 
Python interpreter has been initialised, and won't be reinitialised if the 
interpreter is destroyed and recreated.

--
nosy: +ncoghlan
resolution:  -> rejected
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



[issue39479] [RFE] Add math.lcm() function: Least Common Multiple

2020-01-29 Thread Tim Peters


Tim Peters  added the comment:

+0 from me.

Another use is computing the Carmichael function for composite numbers (like an 
RSA encryption modulus, in which context the Carmichael function is routinely 
used).

But only +0 instead of +1 because it's so easy to build from gcd().

I don't agree it's tricky at all.  While lcm(0, 0) undoubtedly should return 0 
in a general-purpose library function, in my own code I've never supplied that. 
 Because in every application I've ever had for it, I would rather get an 
exception if I ever passed two zeroes - that would always have been a mistake.

--
nosy: +tim.peters

___
Python tracker 

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



Re: Suggestions on mechanism or existing code - maintain persistence of file download history

2020-01-29 Thread Chris Angelico
On Thu, Jan 30, 2020 at 8:59 AM DL Neil via Python-list
 wrote:
> * NB I don't use SQLite (in favor of going 'full-fat') and thus cannot
> vouch for its behavior under load/queuing mechanism/concurrent
> accesses... but I'm biased and probably think/write SQL more readily
> than Python - oops!

I don't use SQLite either, and I always have a PostgreSQL database
around that I can use. That said, though, I believe SQLite is fine in
terms of reliability; the reason it's a bad choice for concurrency is
that it uses large-scale locks to ensure safety, which means that
multiple writers will block against each other. But that's fine for
this use-case.

So my recommendations would be:
1) Something stateless, or where the state is intrinsic to the downloaded files
2) Or failing that, use a database rather than a flat file for your state.

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


[issue39491] Import PEP 593 (Flexible function and variable annotations) support already implemented in typing_extensions

2020-01-29 Thread Jakub Stasiak


Change by Jakub Stasiak :


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

___
Python tracker 

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



Re: Suggestions on mechanism or existing code - maintain persistence of file download history

2020-01-29 Thread DL Neil via Python-list

On 30/01/20 10:38 AM, jkn wrote:

On Wednesday, January 29, 2020 at 8:27:03 PM UTC, Chris Angelico wrote:

On Thu, Jan 30, 2020 at 7:06 AM jkn  wrote:

I want to be a able to use a simple 'download manager' which I was going to 
write
(in Python), but then wondered if there was something suitable already out 
there.
I haven't found it, but thought people here might have some ideas for existing 
work, or approaches.

The situation is this - I have a long list of file URLs and want to download 
these
as a 'background task'. I want this to process to be 'crudely persistent' - you
can CTRL-C out, and next time you run things it will pick up where it left off.


A decent project. I've done this before but in restricted ways.


The download part is not difficult. Is is the persistence bit I am thinking 
about.
It is not easy to tell the name of the downloaded file from the URL.

I could have a file with all the URLs listed and work through each line in turn.
But then I would have to rewrite the file (say, with the previously-successful
lines commented out) as I go.

...


 Thanks for the idea. I should perhaps have said more clearly that it is not
easy (though perhaps not impossible) to infer the name of the downloaded data
from the URL - it is not a 'simple' file URL, more of a tag.

However I guess your scheme would work if I just hashed the URL and created
a marker file - "a39321604c.downloaded" once downloaded. The downloaded content
would be separately (and somewhat opaquely) named, but that doesn't matter.

MRAB's scheme does have the disadvantages to me that Chris has pointed out.


Accordingly, +1 to @Dan's suggestion of a database*:

- it can be structured to act as a queue, for URLs yet to be downloaded
- when downloading starts, the pertinent row can be updated to include 
the fileNM in use (a separate field from the URL)
- when the download is complete, further update the row with a suitable 
'flag'
- as long as each write/update is commit-ed, the system will be 
interrupt-able (^c).


Upon resumption, query the DB looking for entries without 
completion-flags, and re-start/resume the download process.


If a downloaded file is (later) found to be corrupt, either add the 
details to the queue again, or remove the 'flag' from the original entry.


This method could also be extended/complicated to work if you (are smart 
about) implement multiple retrieval threads...



* NB I don't use SQLite (in favor of going 'full-fat') and thus cannot 
vouch for its behavior under load/queuing mechanism/concurrent 
accesses... but I'm biased and probably think/write SQL more readily 
than Python - oops!

--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list


[issue39491] Import PEP 593 (Flexible function and variable annotations) support already implemented in typing_extensions

2020-01-29 Thread Jakub Stasiak


Change by Jakub Stasiak :


--
components: Library (Lib)
nosy: jstasiak
priority: normal
severity: normal
status: open
title: Import PEP 593 (Flexible function and variable annotations) support 
already implemented in typing_extensions
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



[issue39489] Remove COUNT_ALLOCS special build

2020-01-29 Thread STINNER Victor


STINNER Victor  added the comment:

I looked for "Python COUNT_ALLOCS" on the Internet. This special build seems to 
be very badly documented on the Internet. Outside Python own documentation, I 
found almost zero reference to it. IMHO it's basically unused.


(*) bpo-33058: Two years ago (2018), attempt to make COUNT_ALLOCS build ABI 
compatible with release build. Extract:

> > Could tracemalloc help you?
> tracemalloc can't distinguish between the usage of gc allocs, normal mallocs, 
> and free list reuse.


(*) Documentation of all Python builds:

https://pythonextensionpatterns.readthedocs.io/en/latest/debugging/debug_python.html#debug-version-of-python-count-allocs-label

--

___
Python tracker 

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



[issue39489] Remove COUNT_ALLOCS special build

2020-01-29 Thread STINNER Victor


STINNER Victor  added the comment:

The COUNT_ALLOCS feature itself is quite old. It was added 27 years ago (in 
1993):

commit a9c3c22c33762699b362e7598268442fd2df9eb6
Author: Sjoerd Mullender 
Date:   Mon Oct 11 12:54:31 1993 +

* Extended X interface: pixmap objects, colormap objects visual objects,
  image objects, and lots of new methods.
* Added counting of allocations and deallocations of builtin types if
  COUNT_ALLOCS is defined.  Had to move calls to NEWREF down in some
  files.
* Bug fix in sorting lists.

--

___
Python tracker 

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



Re: Suggestions on mechanism or existing code - maintain persistence of file download history

2020-01-29 Thread jkn
On Wednesday, January 29, 2020 at 8:27:03 PM UTC, Chris Angelico wrote:
> On Thu, Jan 30, 2020 at 7:06 AM jkn  wrote:
> >
> > Hi all
> > I'm almost embarrassed to ask this as it's "so simple", but thought I'd 
> > give
> > it a go...
> 
> Hey, nothing wrong with that!
> 
> > I want to be a able to use a simple 'download manager' which I was going to 
> > write
> > (in Python), but then wondered if there was something suitable already out 
> > there.
> > I haven't found it, but thought people here might have some ideas for 
> > existing work, or approaches.
> >
> > The situation is this - I have a long list of file URLs and want to 
> > download these
> > as a 'background task'. I want this to process to be 'crudely persistent' - 
> > you
> > can CTRL-C out, and next time you run things it will pick up where it left 
> > off.
> 
> A decent project. I've done this before but in restricted ways.
> 
> > The download part is not difficult. Is is the persistence bit I am thinking 
> > about.
> > It is not easy to tell the name of the downloaded file from the URL.
> >
> > I could have a file with all the URLs listed and work through each line in 
> > turn.
> > But then I would have to rewrite the file (say, with the 
> > previously-successful
> > lines commented out) as I go.
> >
> 
> Hmm. The easiest way would be to have something from the URL in the
> file name. For instance, you could hash the URL and put the first few
> digits of the hash in the file name, so
> http://some.domain.example/some/path/filename.html might get saved
> into "a39321604c - filename.html". That way, if you want to know if
> it's been downloaded already, you just hash the URL and see if any
> file begins with those digits.
> 
> Would that kind of idea work?
> 
> ChrisA

Hi Chris
Thanks for the idea. I should perhaps have said more clearly that it is not
easy (though perhaps not impossible) to infer the name of the downloaded data
from the URL - it is not a 'simple' file URL, more of a tag.

However I guess your scheme would work if I just hashed the URL and created
a marker file - "a39321604c.downloaded" once downloaded. The downloaded content
would be separately (and somewhat opaquely) named, but that doesn't matter.

MRAB's scheme does have the disadvantages to me that Chris has pointed out.

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


[issue39489] Remove COUNT_ALLOCS special build

2020-01-29 Thread STINNER Victor


STINNER Victor  added the comment:

Python 2.7.15 got a PYTHONSHOWALLOCCOUNT environment variable to dump 
statistics on types at exit, if Python is built with COUNT_ALLOCS macro defined.

Example with Fedora python2.7-debug (package 
python2-debug-2.7.17-1.fc31.x86_64):

$ PYTHONSHOWALLOCCOUNT=1 python2.7-debug -c pass
exceptions.ImportError alloc'd: 2, freed: 2, max in use: 1
symtable entry alloc'd: 3, freed: 3, max in use: 1
enumerate alloc'd: 2, freed: 2, max in use: 1
dict alloc'd: 459, freed: 220, max in use: 346
str alloc'd: 13981, freed: 12142, max in use: 5991
tuple alloc'd: 5088, freed: 4096, max in use: 2337
(...)
fast tuple allocs: 2434, empty: 1753
fast int allocs: pos: 875, neg: 74
null strings: 81, 1-strings: 328

--

___
Python tracker 

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



[issue39489] Remove COUNT_ALLOCS special build

2020-01-29 Thread STINNER Victor


STINNER Victor  added the comment:

As far as I known, the Fedora package of Python is the most known user of 
COUNT_ALLOCS special build, and maybe the only user.

The Fedora package of Python 2.7 builds two binaries:

* python2.7: release mode, optimized
* python2.7-debug: debug mode, not optimized, built with COUNT_ALLOCS defined

Sadly, in practice, python2.7-debug is basically unusable since C extensions 
providing by Fedora are not compatible: the release and the debug modes have a 
different ABI. I only fixed this recently in Python 3.8.

It uses COUNT_ALLOCS since the following patch (package version 2.6.5-10, in 
2010) written by Dave Malcolm.


(1) There is a downstream patch adding --with-count-allocs flag to configure. 
Patch added to package version 2.6.5-10, in 2010:
https://src.fedoraproject.org/rpms/python2/c/ab11e4c10f6fef4e2e993ef446953df0f0dbb840


(2) Another downstream patch adds PYTHONDUMPCOUNTS environment variable to only 
dump statistics if the variable is set. Patch added to package version 2.7-8, 
in 2010:
https://src.fedoraproject.org/rpms/python2/c/5810c5d8b1c876ccc4c547cc71cf20520dd27d85

=> this patch was proposed upstream in bpo-19527. I merged it in Python 2.7.15 
(in 2017), but with a different environment variable name: PYTHONSHOWALLOCCOUNT.


(3) Finally, a 3rd downstream patch fix test_abc when COUNT_ALLOCS is defined. 
Patch added to package version 2.7.1-1, in 2010:
https://src.fedoraproject.org/rpms/python2/c/4b97eebe22c8c5db58ae65cdc7e79c3ccd45b0a4

=> Bohuslav "Slavek" Kabrda created bpo-19527 to propose to make multiple test 
fixes upstream. Serhiy Storchaka modified the proposed patch by adding 
@test.support.requires_type_collecting decorator. Change merged in 3.5 and 
default branches, but not in 2.7.


Another example of Fedora contribution: bpo-31692 reports that test_regrtest 
fails when Python 2.7.14 is built with COUNT_ALLOCS.

---

Now, the interesting part.

IMHO COUNT_ALLOCS was basically kept between 2010 and 2015 because "it was 
there" and nobody asked if it still made sense to use it. It wasn't too 
expensive to maintain in the Fedora package... until someone asked if it's 
still worth it to maintain it in 2015.

The COUNT_ALLOCS macro has been removed from the Fedora package of Python 3 in 
2015:

* https://bugzilla.redhat.com/show_bug.cgi?id=1291325
* "[cleanup] Remove COUNT_ALLOCS patches, see rhbz#1291325" commit:
  
https://src.fedoraproject.org/rpms/python3/c/19aade22cbfa57dc500f5fa82229b4b9ed0b4c30

Extract of the bugzilla, "Reply from Dave Malcolm":
"""
My hazy recollection is that at the time I was dealing with lots of
memory leak issues in Python 2, so I was keen to add as much help as
possible in tracking them down to Python 2 and Python 3.

I don't think this patch ever really bought us much, and it sounds like
there are better tools for this now, so feel free to drop the
COUNT_ALLOC patches.
"""

It confirms what I wrote in the initial message of this issue: there are now 
better tool to track Python memory leaks.

Supporting COUNT_ALLOC in the Fedora package was motivated by Dave Malcolm use 
case of tracking memory leak, but even Dave wrote: "I don't think this patch 
ever really bought us much".

--

___
Python tracker 

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



Re: Suggestions on mechanism or existing code - maintain persistence of file download history

2020-01-29 Thread Dan Sommers
On Thu, 30 Jan 2020 07:26:36 +1100
Chris Angelico  wrote:

> On Thu, Jan 30, 2020 at 7:06 AM jkn  wrote:

> > The situation is this - I have a long list of file URLs and want to
> > download these as a 'background task'. I want this to process to be
> > 'crudely persistent' - you can CTRL-C out, and next time you run
> > things it will pick up where it left off.

> A decent project. I've done this before but in restricted ways.

> > The download part is not difficult. Is is the persistence bit I am
> > thinking about.  It is not easy to tell the name of the downloaded
> > file from the URL.

Where do the names of the downloaded files come from now, and why can't
that same algorithm be used later to determine the existence of the
file?  How much control do you have over this algorithm (which leads to
what ChrisA suggested)?

> > I could have a file with all the URLs listed and work through each
> > line in turn.  But then I would have to rewrite the file (say, with
> > the previously-successful lines commented out) as I go.

Files have that problem.  Other solutions, e.g., a sqlite3 database,
don't.  Also, a database might give you a place to store other
information about the URL, such as the name of the associated file.

> Hmm. The easiest way would be to have something from the URL in the
> file name. For instance, you could hash the URL and put the first few
> digits of the hash in the file name, so
> http://some.domain.example/some/path/filename.html might get saved
> into "a39321604c - filename.html". That way, if you want to know if
> it's been downloaded already, you just hash the URL and see if any
> file begins with those digits.

> Would that kind of idea work?

Dan

-- 
“Atoms are not things.” – Werner Heisenberg
Dan Sommers, http://www.tombstonezero.net/dan
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Suggestions on mechanism or existing code - maintain persistence of file download history

2020-01-29 Thread Chris Angelico
On Thu, Jan 30, 2020 at 7:49 AM MRAB  wrote:
>
> On 2020-01-29 20:00, jkn wrote:
> > I could have a file with all the URLs listed and work through each line in 
> > turn.
> > But then I would have to rewrite the file (say, with the 
> > previously-successful
> > lines commented out) as I go.
> >
> Why comment out the lines yourself when the download manager could do it
> for you?
>
> Load the list from disk.
>
> For each uncommented line:
>
>  Download the file.
>
>  Comment out the line.
>
>  Write the list back to disk.
>

Isn't that exactly what the OP was talking about? It involves
rewriting the file at every step, with the consequent risks of
trampling on other changes, corruption on error, etc, etc, etc.

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


Re: Suggestions on mechanism or existing code - maintain persistence of file download history

2020-01-29 Thread MRAB

On 2020-01-29 20:00, jkn wrote:

Hi all
 I'm almost embarrassed to ask this as it's "so simple", but thought I'd 
give
it a go...

I want to be a able to use a simple 'download manager' which I was going to 
write
(in Python), but then wondered if there was something suitable already out 
there.
I haven't found it, but thought people here might have some ideas for existing 
work, or approaches.

The situation is this - I have a long list of file URLs and want to download 
these
as a 'background task'. I want this to process to be 'crudely persistent' - you
can CTRL-C out, and next time you run things it will pick up where it left off.

The download part is not difficult. Is is the persistence bit I am thinking 
about.
It is not easy to tell the name of the downloaded file from the URL.

I could have a file with all the URLs listed and work through each line in turn.
But then I would have to rewrite the file (say, with the previously-successful
lines commented out) as I go.

Why comment out the lines yourself when the download manager could do it 
for you?


Load the list from disk.

For each uncommented line:

Download the file.

Comment out the line.

Write the list back to disk.


I also thought of having the actual URLs as filenames (of zero length) in a
'source' directory. The process would then look at each filename in turn, and
download the appropriate URL. Then the 'filename file' would either be moved to
a 'done' directory, or perhaps renamed to something that the process wouldn't
subsequently pick up.

But I would have thought that some utility to do this kind of this exists 
already. Any pointers? Or any comments on the above suggested methods?


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


Re: Suggestions on mechanism or existing code - maintain persistence of file download history

2020-01-29 Thread Chris Angelico
On Thu, Jan 30, 2020 at 7:06 AM jkn  wrote:
>
> Hi all
> I'm almost embarrassed to ask this as it's "so simple", but thought I'd 
> give
> it a go...

Hey, nothing wrong with that!

> I want to be a able to use a simple 'download manager' which I was going to 
> write
> (in Python), but then wondered if there was something suitable already out 
> there.
> I haven't found it, but thought people here might have some ideas for 
> existing work, or approaches.
>
> The situation is this - I have a long list of file URLs and want to download 
> these
> as a 'background task'. I want this to process to be 'crudely persistent' - 
> you
> can CTRL-C out, and next time you run things it will pick up where it left 
> off.

A decent project. I've done this before but in restricted ways.

> The download part is not difficult. Is is the persistence bit I am thinking 
> about.
> It is not easy to tell the name of the downloaded file from the URL.
>
> I could have a file with all the URLs listed and work through each line in 
> turn.
> But then I would have to rewrite the file (say, with the previously-successful
> lines commented out) as I go.
>

Hmm. The easiest way would be to have something from the URL in the
file name. For instance, you could hash the URL and put the first few
digits of the hash in the file name, so
http://some.domain.example/some/path/filename.html might get saved
into "a39321604c - filename.html". That way, if you want to know if
it's been downloaded already, you just hash the URL and see if any
file begins with those digits.

Would that kind of idea work?

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


[issue39490] Python Uninstaller fails to clean up the old path variables when uninstalling

2020-01-29 Thread CJ Long


New submission from CJ Long :

I had Python 3.7 installed on my machine. However, I started having issues with 
it, so I uninstalled Python. However, when I reinstalled and attempted to run 
pip from Powershell, the old path was still in my variable, and therefore, 
could not run pip. Python still works.

--
components: Installation
messages: 360984
nosy: brucelong
priority: normal
severity: normal
status: open
title: Python Uninstaller fails to clean up the old path variables when 
uninstalling
type: behavior
versions: Python 3.7, Python 3.8

___
Python tracker 

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



Suggestions on mechanism or existing code - maintain persistence of file download history

2020-01-29 Thread jkn
Hi all
I'm almost embarrassed to ask this as it's "so simple", but thought I'd give
it a go...

I want to be a able to use a simple 'download manager' which I was going to 
write
(in Python), but then wondered if there was something suitable already out 
there.
I haven't found it, but thought people here might have some ideas for existing 
work, or approaches.

The situation is this - I have a long list of file URLs and want to download 
these
as a 'background task'. I want this to process to be 'crudely persistent' - you
can CTRL-C out, and next time you run things it will pick up where it left off.

The download part is not difficult. Is is the persistence bit I am thinking 
about.
It is not easy to tell the name of the downloaded file from the URL.

I could have a file with all the URLs listed and work through each line in turn.
But then I would have to rewrite the file (say, with the previously-successful
lines commented out) as I go.

I also thought of having the actual URLs as filenames (of zero length) in a
'source' directory. The process would then look at each filename in turn, and
download the appropriate URL. Then the 'filename file' would either be moved to
a 'done' directory, or perhaps renamed to something that the process wouldn't
subsequently pick up.

But I would have thought that some utility to do this kind of this exists 
already. Any pointers? Or any comments on the above suggested methods?

Thanks
J^n

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


[issue39483] Proposial add loop parametr to run in asyncio

2020-01-29 Thread Андрей Казанцев

Андрей Казанцев  added the comment:

How to make singleton class? I wrote this 

```
import asyncio


class Singleton:
_CREATE_LOCK = asyncio.Lock()

@classmethod
async def create(cls):
if not hasattr(cls, '_Singleton__instance'):
async with cls._CREATE_LOCK:
if not hasattr(cls, '_Singleton__instance'):
await asyncio.sleep(1)
cls.__instance = cls()
return cls.__instance


async def main():
await asyncio.wait([
Singleton.create(),
Singleton.create(),
])


if __name__ == '__main__':
asyncio.run(main())
```

and got `RuntimeError`

--

___
Python tracker 

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



[issue39489] Remove COUNT_ALLOCS special build

2020-01-29 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

I have never used this feature either.

--
nosy: +rhettinger

___
Python tracker 

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



[issue38628] Issue with ctypes in AIX

2020-01-29 Thread David Edelsohn


Change by David Edelsohn :


--
nosy: +David.Edelsohn, Michael.Felt

___
Python tracker 

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



[issue39484] time_ns() and time() cannot be compared on windows

2020-01-29 Thread Vincent Michel


Vincent Michel  added the comment:

I thought about it a bit more and I realized there is no way to recover the 
time in hundreds of nanoseconds from the float produced by `time.time()` (since 
the windows time currently takes 54 bits and will take 55 bits in 2028). 

That means `time()` and `time_ns()` cannot be compared by converting time() to 
nanoseconds, but it might still make sense to compare them by converting 
time_ns() to seconds (which is apparently broken at the moment).

If that makes sense, a possible roadmap to tackle this problem would be:
- fix `_PyTime_AsSecondsDouble` so that `time.time_ns() / 10**9 == time.time()`
- add a warning in the documentation that one should be careful when comparing 
the timestamps produced by `time()` and time_ns()` (in particular, `time()` 
should not be converted to nanoseconds)

--

___
Python tracker 

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



pytest 5.3.5

2020-01-29 Thread Daniel Hahler
pytest 5.3.5 has just been released to PyPI.

This is a bug-fix release, being a drop-in replacement. To upgrade::

  pip install --upgrade pytest

The full changelog is available at 
https://docs.pytest.org/en/latest/changelog.html.

Thanks to all who contributed to this release, among them:

* Daniel Hahler
* Ran Benita


Happy testing,
The pytest Development Team
--
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/


[issue39489] Remove COUNT_ALLOCS special build

2020-01-29 Thread STINNER Victor


Change by STINNER Victor :


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

___
Python tracker 

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



[issue39489] Remove COUNT_ALLOCS special build

2020-01-29 Thread STINNER Victor


STINNER Victor  added the comment:

See also bpo-19527 which discussed COUNT_ALLOCS in 2013.

COUNT_ALLOCS build is documented in Fedora "DebugPythonStacks" wiki page:
https://fedoraproject.org/wiki/Features/DebugPythonStacks#Verify_COUNT_ALLOCS

--

___
Python tracker 

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



[issue39489] Remove COUNT_ALLOCS special build

2020-01-29 Thread STINNER Victor


New submission from STINNER Victor :

Python has a COUNT_ALLOCS special build which adds sys.getcounts() function and 
shows statistics on Python types at exit if -X showalloccount command line 
option is used.

I never ever used this feature and I don't know anyone using it.

But "#ifdef COUNT_ALLOCS" code is scattered all around the code. It requires 
maintenance. I propose to remove the code to ease maintenance.

Attached PR shows how much code is requires to support this special build.

There are now more advanced tools to have similar features:

* tracemalloc can be used to track memory leaks
* gc.getobjects() can be called frequently to compute statistics on Python types
* There are many tools built around gc.getobjects()

The previous large change related to COUNT_ALLOCS was done in Python 3.6 by 
bpo-23034:

"The output of a special Python build with defined COUNT_ALLOCS, 
SHOW_ALLOC_COUNT or SHOW_TRACK_COUNT macros is now off by default. It can be 
re-enabled using the -X showalloccount option. It now outputs to stderr instead 
of stdout. (Contributed by Serhiy Storchaka in bpo-23034.)"

https://docs.python.org/dev/whatsnew/3.6.html#changes-in-python-command-behavior

--
components: Build
messages: 360978
nosy: vstinner
priority: normal
severity: normal
status: open
title: Remove COUNT_ALLOCS special build
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



[issue39486] bug in %-formatting in Python, related to escaped %-characters

2020-01-29 Thread SilentGhost


Change by SilentGhost :


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue39486] bug in %-formatting in Python, related to escaped %-characters

2020-01-29 Thread Carl Friedrich Bolz-Tereick


Carl Friedrich Bolz-Tereick  added the comment:

Ok, that means it's intentional. I still think it's missing a documentation 
change and consistent error messages.

--

___
Python tracker 

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



[issue39488] test_largefile: TestSocketSendfile.test_it() uses too much disk space

2020-01-29 Thread STINNER Victor


New submission from STINNER Victor :

TestSocketSendfile.test_it() failed with "OSError: [Errno 28] No space left on 
device" on PPC64LE Fedora 3.x buildbot.

It also caused troubles on "AMD64 Fedora Rawhide Clang 3.x" worker.

If I recall correctly, it writes like 8 GB of real data, not just empty files 
made of holes.

I suggest to either remove the test or to use way less disk space.

https://buildbot.python.org/all/#builders/11/builds/259

Traceback (most recent call last):
  File 
"/home/shager/cpython-buildarea/3.x.edelsohn-fedora-ppc64le/build/Lib/test/test_largefile.py",
 line 161, in test_it
shutil.copyfile(TESTFN, TESTFN2)
  File 
"/home/shager/cpython-buildarea/3.x.edelsohn-fedora-ppc64le/build/Lib/shutil.py",
 line 270, in copyfile
_fastcopy_sendfile(fsrc, fdst)
  File 
"/home/shager/cpython-buildarea/3.x.edelsohn-fedora-ppc64le/build/Lib/shutil.py",
 line 163, in _fastcopy_sendfile
raise err from None
  File 
"/home/shager/cpython-buildarea/3.x.edelsohn-fedora-ppc64le/build/Lib/shutil.py",
 line 149, in _fastcopy_sendfile
sent = os.sendfile(outfd, infd, offset, blocksize)
OSError: [Errno 28] No space left on device: '@test_38097_tmp' -> 
'@test_38097_tmp2'

--
components: Tests
keywords: buildbot
messages: 360976
nosy: giampaolo.rodola, vstinner
priority: normal
severity: normal
status: open
title: test_largefile: TestSocketSendfile.test_it() uses too much disk space
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



[issue38323] asyncio: MultiLoopWatcher has a race condition (test_asyncio: test_close_kill_running() hangs on AMD64 RHEL7 Refleaks 3.x)

2020-01-29 Thread STINNER Victor


STINNER Victor  added the comment:

> FYI, I'm able to reproduce the hang by running "python -m test -F 
> test_asyncio -m test_close_kill_running". Working on the fix.

Any update on this issue? It's still failing randomly on buildbots. Example:
https://buildbot.python.org/all/#/builders/158/builds/64

Another option is to skip the test_close_kill_running() until it's fixed which 
usually means forget about it until an user gets the bug for real in production.

--

___
Python tracker 

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



[issue39486] bug in %-formatting in Python, related to escaped %-characters

2020-01-29 Thread SilentGhost


SilentGhost  added the comment:

This seemed to be a consequence of #29568.

--
components: +Interpreter Core
nosy: +SilentGhost
type:  -> behavior

___
Python tracker 

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



Re: on sorting things

2020-01-29 Thread Peter Otten
Tony Flury via Python-list wrote:

> 
> On 20/12/2019 18:59, Peter Otten wrote:
>> Chris Angelico wrote:
>>
>>> On Sat, Dec 21, 2019 at 5:03 AM Peter Otten <__pete...@web.de> wrote:
 PS: If you are sorting files by size and checksum as part of a
 deduplication effort consider using dict-s instead:
>>> Yeah, I'd agree if that's the purpose. But let's say the point is to
>>> have a guaranteed-stable ordering of files that are primarily to be
>>> sorted by file size - in order to ensure that two files are in the
>>> same order every time you refresh the view, they get sorted by their
>>> checksums.
>> One thing that struck me about Eli's example is that it features two key
>> functions rather than a complex comparison.
>>
>> If sort() would accept a sequence of key functions each function could be
>> used to sort slices that compare equal when using the previous key.
> 
> You don't need a sequence of key functions : the sort algorithm used in
> Python (tim-sort) is stable - which means if two items (A ) are in a
> given order in the sequence before the sort starts, and A & B compare
> equal during the sort, then after the sort A & B retain their ordering.

Thank you for explaining that ;)
> 
> So if you want to sort by file size as the primary and then by checksum
> if file sizes are equal - you sort by checksum first, and then by file
> size: this guarantees that the items will always be in file size order -
> and if file sizes are equal then they will be ordered by checksum.
> 
> The rule to remember - is sort in the reverse order of criteria.

The idea behind the "sequence of key functions" suggestion is that you only 
calculate keys[n] where keys[:n] all compared equal.

Example: you have 1000 files and among those there are five pairs with equal 
size. Let's assume calculating the size is instantaneous whereas calculating 
the checksum takes one second. Then you spend 10 seconds on calculating the 
keys with my proposal versus 1000 seconds with a naive reliance on stable 
sorting.

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


[issue37972] unittest.mock.call does not chain __getitem__ to another _Call object

2020-01-29 Thread Chris Withers


Chris Withers  added the comment:


New changeset db5e86adbce12350c26e7ffc2c6673369971a2dc by Chris Withers in 
branch 'master':
Get mock coverage back to 100% (GH-18228)
https://github.com/python/cpython/commit/db5e86adbce12350c26e7ffc2c6673369971a2dc


--

___
Python tracker 

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



[issue39487] Merge duplicated _Py_IDENTIFIER identifiers in C code

2020-01-29 Thread Eric Snow


Eric Snow  added the comment:

FTR:

As Martin noted in #19514, there isn't any performance difference for statics, 
whether local or global.  For static locals the compiler (at least on linux) 
generates symbols named as ".<#>" and they are treated as global.

One key difference (again, at least on linux; seen using "nm") is that symbols 
for static globals preserve identifying information, like the originating 
source file.  For static locals the filename is not preserved and, when there 
are duplicates, you do not know from which function a particular symbol comes.  
So compiled symbols for static globals are *much* easier to identify in the 
source than symbols for static locals.

Hence static locals complicate something I'm working on: tooling to identify 
global variables in our source code.  So I'm a fan of efforts to remove 
duplicates (and move static locals to the explicit global namespace).  Thank 
you! :)

--
nosy: +eric.snow

___
Python tracker 

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



[issue39485] Bug in mock running on PyPy3

2020-01-29 Thread Chris Withers


Chris Withers  added the comment:

Thank you very much for this, that was a really good catch!

--
resolution:  -> fixed
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



[issue39485] Bug in mock running on PyPy3

2020-01-29 Thread Chris Withers


Chris Withers  added the comment:


New changeset 696d2324cf2a54e20e8d6a6739fa97ba815a8be9 by Miss Islington (bot) 
in branch '3.8':
bpo-39485: fix corner-case in method-detection of mock (GH-18255)
https://github.com/python/cpython/commit/696d2324cf2a54e20e8d6a6739fa97ba815a8be9


--

___
Python tracker 

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



[issue39485] Bug in mock running on PyPy3

2020-01-29 Thread Chris Withers


Chris Withers  added the comment:


New changeset cf0645a17acbc0c4dbbf82434e37637965748bbb by Miss Islington (bot) 
in branch '3.7':
bpo-39485: fix corner-case in method-detection of mock (GH-18256)
https://github.com/python/cpython/commit/cf0645a17acbc0c4dbbf82434e37637965748bbb


--

___
Python tracker 

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



[issue33339] Using default encoding with `subprocess.run()` is not obvious

2020-01-29 Thread Xavier Robin


Change by Xavier Robin :


--
nosy: +Xavier Robin

___
Python tracker 

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



Re: Python 3.8.1

2020-01-29 Thread Terry Reedy

On 1/29/2020 8:13 AM, J Conrado wrote:

I installed the Python3.8.1 in my computer. I have other versions 2.6 
and  3.7. When I use 2.6 and 3.7 I didn't have problem with:



python2
Python 2.6.6 (r266:84292, Jun 20 2019, 14:14:55)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-23)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> import numpy as np


No matplotlib import here.


python3.7
Python 3.7.3 | packaged by conda-forge | (default, Jul  1 2019, 21:52:21)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
 >>> import numpy
 >>> import numpy as np


No matplotlib import here, though Anaconda may include it.


But if I type:

python3.8 I had the error messages:


import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import BasemapTraceback (most recent call last):
   File "", line 1, in 
ModuleNotFoundError: No module named 'numpy'
 >>> Traceback (most recent call last):
   File "", line 1, in 
ModuleNotFoundError: No module named 'matplotlib'


Please what can I do to solve this erros.


Install matplotlib into your 3.8 install.  Possibly
$ python3.8 -m pip install matplotlib


--
Terry Jan Reedy


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


[issue39485] Bug in mock running on PyPy3

2020-01-29 Thread Chris Withers


Chris Withers  added the comment:


New changeset a327677905956ae0b239ff430a1346dfe265709e by Carl Friedrich 
Bolz-Tereick in branch 'master':
bpo-39485: fix corner-case in method-detection of mock (GH-18252)
https://github.com/python/cpython/commit/a327677905956ae0b239ff430a1346dfe265709e


--

___
Python tracker 

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



[issue39485] Bug in mock running on PyPy3

2020-01-29 Thread miss-islington


Change by miss-islington :


--
pull_requests: +17633
pull_request: https://github.com/python/cpython/pull/18256

___
Python tracker 

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



[issue39485] Bug in mock running on PyPy3

2020-01-29 Thread miss-islington


Change by miss-islington :


--
pull_requests: +17632
pull_request: https://github.com/python/cpython/pull/18255

___
Python tracker 

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



[issue39485] Bug in mock running on PyPy3

2020-01-29 Thread Chris Withers


Change by Chris Withers :


--
assignee:  -> cjw296

___
Python tracker 

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



[issue15600] expose the finder details used by the FileFinder path hook

2020-01-29 Thread Eric Snow


Eric Snow  added the comment:

I have many other things higher on my todo list. :)  I'll re-open this issue if 
I get back to the project that motivated this (i.e. "source translation via 
import hooks for filename suffix").

--
resolution:  -> out of date
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



[issue39487] Merge duplicated _Py_IDENTIFIER identifiers in C code

2020-01-29 Thread hai shi


Change by hai shi :


--
nosy: +vstinner

___
Python tracker 

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



[issue39487] Merge duplicated _Py_IDENTIFIER identifiers in C code

2020-01-29 Thread hai shi


Change by hai shi :


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

___
Python tracker 

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



[issue39487] Merge duplicated _Py_IDENTIFIER identifiers in C code

2020-01-29 Thread hai shi


New submission from hai shi :

As stinner said in issue19514

those _Py_IDENTIFIER should be merged:

./Modules/_ctypes/_ctypes.c:1054:_Py_IDENTIFIER(_type_);
./Modules/_ctypes/_ctypes.c:1132:_Py_IDENTIFIER(_type_);
./Modules/_ctypes/_ctypes.c:1494:_Py_IDENTIFIER(_type_);
./Modules/_ctypes/_ctypes.c:2071:_Py_IDENTIFIER(_type_);

./Modules/_ctypes/_ctypes.c:1692:_Py_IDENTIFIER(_as_parameter_);
./Modules/_ctypes/_ctypes.c:1759:_Py_IDENTIFIER(_as_parameter_);
./Modules/_ctypes/_ctypes.c:1826:_Py_IDENTIFIER(_as_parameter_);
./Modules/_ctypes/_ctypes.c:2256:_Py_IDENTIFIER(_as_parameter_);

./Modules/_ctypes/_ctypes.c:2474:_Py_IDENTIFIER(_check_retval_);
./Modules/_ctypes/_ctypes.c:3280:_Py_IDENTIFIER(_check_retval_);

./Modules/_pickle.c:3560:_Py_IDENTIFIER(__name__);
./Modules/_pickle.c:3979:_Py_IDENTIFIER(__name__);

./Modules/_pickle.c:4042:_Py_IDENTIFIER(__new__);
./Modules/_pickle.c:5771:_Py_IDENTIFIER(__new__);

./Python/ceval.c:5058:_Py_IDENTIFIER(__name__);
./Python/ceval.c:5134:_Py_IDENTIFIER(__name__);

./Python/import.c:386:_Py_IDENTIFIER(__spec__);
./Python/import.c:1569:_Py_IDENTIFIER(__spec__);

./Python/import.c:1571:_Py_IDENTIFIER(__path__);
./Python/import.c:1933:_Py_IDENTIFIER(__path__);

./Python/_warnings.c:487:_Py_IDENTIFIER(__name__);
./Python/_warnings.c:821:_Py_IDENTIFIER(__name__);
./Python/_warnings.c:972:_Py_IDENTIFIER(__name__);

./Python/errors.c:1012:_Py_IDENTIFIER(__module__);
./Python/errors.c:1238:_Py_IDENTIFIER(__module__);

./Objects/bytesobject.c:546:_Py_IDENTIFIER(__bytes__);
./Objects/bytesobject.c:2488:_Py_IDENTIFIER(__bytes__);

./Objects/moduleobject.c:61:_Py_IDENTIFIER(__name__);
./Objects/moduleobject.c:488:_Py_IDENTIFIER(__name__);
./Objects/moduleobject.c:741:_Py_IDENTIFIER(__name__);

./Objects/moduleobject.c:62:_Py_IDENTIFIER(__doc__);
./Objects/moduleobject.c:461:_Py_IDENTIFIER(__doc__);

./Objects/moduleobject.c:65:_Py_IDENTIFIER(__spec__);
./Objects/moduleobject.c:744:_Py_IDENTIFIER(__spec__);

./Objects/iterobject.c:107:_Py_IDENTIFIER(iter);
./Objects/iterobject.c:247:_Py_IDENTIFIER(iter);

./Objects/rangeobject.c:760:_Py_IDENTIFIER(iter);
./Objects/rangeobject.c:918:_Py_IDENTIFIER(iter);

./Objects/descrobject.c:574:_Py_IDENTIFIER(getattr);
./Objects/descrobject.c:1243:_Py_IDENTIFIER(getattr);

./Objects/odictobject.c:899:_Py_IDENTIFIER(items);
./Objects/odictobject.c:1378:_Py_IDENTIFIER(items);
./Objects/odictobject.c:2198:_Py_IDENTIFIER(items);

./Objects/fileobject.c:35:_Py_IDENTIFIER(open);
./Objects/fileobject.c:550:_Py_IDENTIFIER(open);


./Objects/typeobject.c:312:_Py_IDENTIFIER(mro);
./Objects/typeobject.c:1893:_Py_IDENTIFIER(mro);

--
components: Interpreter Core
messages: 360966
nosy: shihai1991
priority: normal
severity: normal
status: open
title: Merge duplicated _Py_IDENTIFIER identifiers in C code
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



[issue39486] bug in %-formatting in Python, related to escaped %-characters

2020-01-29 Thread Carl Friedrich Bolz-Tereick


New submission from Carl Friedrich Bolz-Tereick :

The following behaviour of %-formatting changed between Python3.6 and 
Python3.7, and is in my opinion a bug that was introduced.

So far, it has been possible to add conversion flags to a conversion specifier 
in %-formatting, even if the conversion is '%' (meaning a literal % is emitted 
and no argument consumed).

Eg this works in Python3.6:

 "%+%abc% %" % ()
'%abc%'

The conversion flags '+' and ' ' are ignored.

Was it discussed and documented anywhere that this is now an error? Because 
Python3.7 has the following strange behaviour instead:

>>> "%+%abc% %" % ()
Traceback (most recent call last):
  File "", line 1, in 
TypeError: not enough arguments for format string

That error message is just confusing, because the amount of arguments is not 
the problem here. If I pass a dict (thus making the number of arguments 
irrelevant) I get instead:

>>> "%+%abc% %" % {}
Traceback (most recent call last):
  File "", line 1, in 
ValueError: unsupported format character '%' (0x25) at index 2

(also a confusing message, because '%' is a perfectly fine format character)

In my opinion this behaviour should either be reverted to how Python3.6 worked, 
or the new restrictions should be documented and the error messages improved.

--
messages: 360965
nosy: Carl.Friedrich.Bolz
priority: normal
severity: normal
status: open
title: bug in %-formatting in Python, related to escaped %-characters
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



  1   2   >