[issue35187] a bug about np.arrange

2018-11-07 Thread xiyunlong


New submission from xiyunlong :

when I use np.arange as follows:
np.arange(1,2.2,0.2)
I got the array as [1. , 1.2, 1.4, 1.6, 1.8, 2. , 2.2],we know, the maxvalue 
2.2 of the array should not be included in the array. Is this a bug?

--
components: Library (Lib)
messages: 329460
nosy: xyl123
priority: normal
severity: normal
status: open
title: a bug about np.arrange
versions: Python 3.5

___
Python tracker 

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



[issue34966] Pydoc: better support of method aliases

2018-11-07 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
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



[issue34966] Pydoc: better support of method aliases

2018-11-07 Thread miss-islington


miss-islington  added the comment:


New changeset 11a33e171b89ea9267672b0664d739ca06e459ca by Miss Islington (bot) 
in branch '3.6':
bpo-34966: Improve support of method aliases in pydoc. (GH-9823)
https://github.com/python/cpython/commit/11a33e171b89ea9267672b0664d739ca06e459ca


--

___
Python tracker 

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



[issue34966] Pydoc: better support of method aliases

2018-11-07 Thread miss-islington


miss-islington  added the comment:


New changeset 9d3658147b56e24e96e174510b6ee91c8141e530 by Miss Islington (bot) 
in branch '3.7':
bpo-34966: Improve support of method aliases in pydoc. (GH-9823)
https://github.com/python/cpython/commit/9d3658147b56e24e96e174510b6ee91c8141e530


--
nosy: +miss-islington

___
Python tracker 

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



[issue24905] Allow incremental I/O to blobs in sqlite3

2018-11-07 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
versions: +Python 3.8 -Python 3.7

___
Python tracker 

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



[issue24905] Allow incremental I/O to blobs in sqlite3

2018-11-07 Thread Holger Waldmann


Holger Waldmann  added the comment:

I am looking forward for this to be included.

My main use case is on restricted IoT devices, where I need to handle BLOBs of 
2MB size.
As this is larger than my available RAM, I store need to store them in the 
filesystem today.

This is ugly because it is not part of the atomic commit of the database.

I would very much appreciate if I could get a file-like API for BLOBs in sqlite.

--
nosy: +waldhol

___
Python tracker 

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



[issue34966] Pydoc: better support of method aliases

2018-11-07 Thread miss-islington


Change by miss-islington :


--
pull_requests: +9692

___
Python tracker 

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



[issue34966] Pydoc: better support of method aliases

2018-11-07 Thread miss-islington


Change by miss-islington :


--
pull_requests: +9691

___
Python tracker 

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



[issue34966] Pydoc: better support of method aliases

2018-11-07 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset a44d34e17908a49d584f86c4f8642a50707b7150 by Serhiy Storchaka in 
branch 'master':
bpo-34966: Improve support of method aliases in pydoc. (GH-9823)
https://github.com/python/cpython/commit/a44d34e17908a49d584f86c4f8642a50707b7150


--

___
Python tracker 

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



[issue25451] tkinter: PhotoImage transparency methods

2018-11-07 Thread Zackery Spytz


Zackery Spytz  added the comment:

I've created a PR for this issue.

--
nosy: +ZackerySpytz
versions: +Python 3.8 -Python 3.6

___
Python tracker 

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



[issue25451] tkinter: PhotoImage transparency methods

2018-11-07 Thread Zackery Spytz


Change by Zackery Spytz :


--
keywords: +patch
pull_requests: +9690
stage: needs patch -> patch review

___
Python tracker 

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



Re: Overwhelmed by the Simplicity of Python. Any Recommendation?

2018-11-07 Thread Michael Torrie
On 11/07/2018 01:31 PM, MRAB wrote:
> On 2018-11-07 09:20, Thomas Jollans wrote:
>> I'll just take this opportunity to point out (for those that don't know)
>> that Visual Studio Code (an open source cross-platform programmer's text
>> editor of the same calibre as Sublime or Atom, not an IDE) has great
>> support for (graphical) debugging of Python code. Not tedious to set up,
>> particularly. Obviously there are plugins for other editors, but they're
>> usually not this well-integrated.
>>
> I find that the code does run more slowly, though.

Why?  Python is python, isn't it?  Usually code runs slower in a
debugger.  Isn't VS code using pdb under the hood?
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27602] Enable py launcher to launch repository Python.

2018-11-07 Thread Franklin Yu


Franklin Yu  added the comment:

Any updates? I would like to switch between versions of PyPy.

--
nosy: +Franklin Yu

___
Python tracker 

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



[issue35186] distutils.command.upload uses deprecated platform.dist with bdist_rpm

2018-11-07 Thread Paul Ganssle


New submission from Paul Ganssle :

It seems that in issue #1322, `platform.dist` was deprecated, and is slated for 
removal in Python 3.8, but it is currently used in 
distutils.command.upload.upload_file: 
https://github.com/python/cpython/blob/6843ffe4533e9f2cde036296fd932fef6f059687/Lib/distutils/command/upload.py#L126

As far as I can tell, this line is hit only when you run `python setup.py 
bdist_rpm upload`, as far as I can tell.

Using the `upload` command is *itself* very deprecated, and is dangerously 
broken in many ways. See, for example, this setuptools issue: 
https://github.com/pypa/setuptools/issues/1381

So I see three possible options (two realistic):

1. Remove the whole "comment" field from the upload, both for bdist_rpm and 
bdist_dumb. I'm not sure if PyPI uses this for anything, but I highly doubt it.

2. Have both bdist_rpm and bdist_dumb send a comment based on 
`platform.platform(terse=1)`

3. Remove the upload command functionality entirely for Python 3.8 with no 
deprecation warning.

Obviously #3 is the unrealistic one, but it's very tempting. That said, I think 
we should go with #1 and maybe open a separate issue to actually deprecate the 
`upload` command in distutils (though to be honest we'll probably monkey-patch 
it out of existence in setuptools within a year and everyone uses `setuptools` 
anyway, so maybe #3 is less unrealistic than it seems).

--
components: Distutils
messages: 329453
nosy: dstufft, eric.araujo, p-ganssle
priority: normal
severity: normal
status: open
title: distutils.command.upload uses deprecated platform.dist with bdist_rpm
versions: Python 3.6, 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



Re: Does this behavior have a better design pattern?

2018-11-07 Thread lampahome
>
>
> The rest is just cruft ;)
> >
> > *Is there better design pattern for me?*
>
> If A does B to C, is that a crime?
>
No


> Your problem description suffers from overgeneralisation.
>
> Generally speaking you get better solutions when you ask yourself
> "How can I solve this problem efficiently?"
>
>
In another hand, how can I solve this problem efficiently?
or any pythonic way to solve this?
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue32485] Multiprocessing dict sharing between forked processes

2018-11-07 Thread Gus Goulart

Gus Goulart  added the comment:

This is probably a bug that was fixed sometime in Python 3x.
Testing on 3.7.1, Python gracefully errors out:

```
➜  cpython git:(bpo-32485) ✗ python issue_32485.py
Same manager, same mux
Starting test_sameProcessSameThread
Traceback (most recent call last):
  File "issue_32485.py", line 130, in 
test_sameProcessSameThread(inst1, inst2, nRuns)
  File "issue_32485.py", line 48, in test_sameProcessSameThread
run(inst1, nRuns)
  File "issue_32485.py", line 30, in run
inst.run()
  File "issue_32485.py", line 19, in run
if (self.d.has_key(self.key)):
  File "", line 2, in has_key
  File 
"/home/gus/.pyenv/versions/3.7.1/lib/python3.7/multiprocessing/managers.py", 
line 811, in _callmethod
raise convert_to_error(kind, result)
multiprocessing.managers.RemoteError: 
---
Traceback (most recent call last):
  File 
"/home/gus/.pyenv/versions/3.7.1/lib/python3.7/multiprocessing/managers.py", 
line 251, in serve_client
function = getattr(obj, methodname)
AttributeError: 'dict' object has no attribute 'has_key'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File 
"/home/gus/.pyenv/versions/3.7.1/lib/python3.7/multiprocessing/managers.py", 
line 271, in serve_client
fallback_func = self.fallback_mapping[methodname]
KeyError: 'has_key'
---

```

--
nosy: +gus.goulart, taleinat

___
Python tracker 

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



[issue32409] venv activate.bat is UTF-8 encoded but uses current console codepage

2018-11-07 Thread miss-islington


miss-islington  added the comment:


New changeset 3ba5e253de1a52e9692aa645c95072705f08b7bb by Miss Islington (bot) 
in branch '3.7':
Revert "bpo-32409: Fix regression in activate.bat on international Windows 
(GH-10295)" (GH-10403)
https://github.com/python/cpython/commit/3ba5e253de1a52e9692aa645c95072705f08b7bb


--
nosy: +miss-islington

___
Python tracker 

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



[issue32409] venv activate.bat is UTF-8 encoded but uses current console codepage

2018-11-07 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset 6843ffe4533e9f2cde036296fd932fef6f059687 by Pablo Galindo in 
branch 'master':
Revert "bpo-32409: Fix regression in activate.bat on international Windows 
(GH-10295)" (GH-10403)
https://github.com/python/cpython/commit/6843ffe4533e9f2cde036296fd932fef6f059687


--

___
Python tracker 

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



[issue32409] venv activate.bat is UTF-8 encoded but uses current console codepage

2018-11-07 Thread miss-islington


Change by miss-islington :


--
pull_requests: +9689

___
Python tracker 

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



[issue31670] Associate .wasm with application/wasm

2018-11-07 Thread Runping Wang


Runping Wang  added the comment:

We're also depending on this MIME type for WebAssembly. It will be great if we 
can get this wasm MIME type in.

--
nosy: +runpiw

___
Python tracker 

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



[issue32409] venv activate.bat is UTF-8 encoded but uses current console codepage

2018-11-07 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
pull_requests: +9688
stage: resolved -> patch review

___
Python tracker 

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



[issue34805] Explicitly specify `MyClass.__subclasses__()` returns classes in definition order

2018-11-07 Thread Guido van Rossum


Guido van Rossum  added the comment:

OK, I don't have time to keep arguing, and I doubt any other core devs
care. We should probably just close it as Won't Fix, since it's not
important enough to keep deliberating.

Luna, I recommend that you pick another project.

--

___
Python tracker 

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



Re: Overwhelmed by the Simplicity of Python. Any Recommendation?

2018-11-07 Thread Thomas Jollans
On 07/11/2018 21:31, MRAB wrote:
> On 2018-11-07 09:20, Thomas Jollans wrote:
>> On 06/11/2018 22:51, Lie Ryan wrote:
 I like to step through my code line by line,
 it's impossible to do it with
 object-oriented programming language.
>>>
>>> I suggest pudb, it's a curses based debugger, which is nicer than
>>> pdb, but doesn't require tedious IDE setup.
>>
>> I'll just take this opportunity to point out (for those that don't know)
>> that Visual Studio Code (an open source cross-platform programmer's text
>> editor of the same calibre as Sublime or Atom, not an IDE) has great
>> support for (graphical) debugging of Python code. Not tedious to set up,
>> particularly. Obviously there are plugins for other editors, but they're
>> usually not this well-integrated.
>>
> I find that the code does run more slowly, though.

Can't argue with that.

I'm not totally sold on vscode, either. But I enjoy the debugger!


> 
>>>
 Also, there's no good REPL IDE. 
>>>
>>> Not quite sure what you meant by REPL IDE, but did you try IPython
>>>
>>
>> If you find yourself wanting a debugger in an IPython/Jupyter notebook,
>> ipdb is pretty nice.
>>

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


[issue34011] Default preference not given to venv DLL's

2018-11-07 Thread miss-islington


Change by miss-islington :


--
pull_requests: +9686

___
Python tracker 

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



[issue34011] Default preference not given to venv DLL's

2018-11-07 Thread miss-islington


Change by miss-islington :


--
pull_requests: +9687

___
Python tracker 

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



[issue32409] venv activate.bat is UTF-8 encoded but uses current console codepage

2018-11-07 Thread Martin Bijl-Schwab


Martin Bijl-Schwab  added the comment:

I will have a look.

--

___
Python tracker 

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



[issue34805] Explicitly specify `MyClass.__subclasses__()` returns classes in definition order

2018-11-07 Thread Josh Rosenberg


Josh Rosenberg  added the comment:

Keep in mind, had this guarantee been in place in 3.4, the improvement in 3.5 
couldn't have been made, and issue17936 might have been closed and never 
addressed, even once dicts were ordered, simply because we never rechecked it. 
It makes the whole "potential downside" more obvious, because we would have 
paid that price not so long ago. Knowing that 3.5 improved by breaking this 
guarantee was part of what made me cautious here.

--

___
Python tracker 

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



[issue34805] Explicitly specify `MyClass.__subclasses__()` returns classes in definition order

2018-11-07 Thread Josh Rosenberg


Josh Rosenberg  added the comment:

I wrote the response to the OP's use case before I saw your response; it wasn't 
really intended as an additional critique of the proposed change or a 
counterargument to your post, just a note that the required behavior could be 
obtained on all versions of Python via metaclasses, including on 3.5.

I have no specific plans to rewrite the typeobject.c, nor make a C implemented 
WeakSet. I'm just leery of adding language guarantees that limit future 
development when they:

1. Provide very little benefit (I doubt one package in 10,000 even uses 
__subclasses__, let alone relies on its ordering)

2. The benefit is achievable without herculean efforts with existing tools 
(metaclasses can provide the desired behavior with minimal effort at the 
trivial cost of an additional side-band dict on the root class)

If the guarantee never limits a proposed change, then our best case scenario is 
we provided a guarantee that benefits almost no one (guaranteed upside 
minimal). But if it limits a proposed change, we might lose out on a 
significant improvement in performance, code maintainability, what have you 
(much larger potential downside). I'm just not seeing enough of a benefit to 
justify the potential cost.

--

___
Python tracker 

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



[issue31354] Fixing a bug related to LTO only build

2018-11-07 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset f6b9459996f5166300982d0427119eb326e74dac by Victor Stinner 
(stratakis) in branch '3.6':
[3.6] bpo-31354: Let configure --with-lto work on all builds (GH-10261)
https://github.com/python/cpython/commit/f6b9459996f5166300982d0427119eb326e74dac


--

___
Python tracker 

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



[issue34011] Default preference not given to venv DLL's

2018-11-07 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
pull_requests: +9685
stage: resolved -> patch review

___
Python tracker 

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



[issue33694] test_asyncio: test_start_tls_server_1() fails on Python on x86 Windows7 3.7 and 3.x

2018-11-07 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests:  -9681

___
Python tracker 

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



[issue35015] availability directive breaks po files

2018-11-07 Thread Julien Palard


Change by Julien Palard :


--
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



[issue35015] availability directive breaks po files

2018-11-07 Thread miss-islington


miss-islington  added the comment:


New changeset 363839caf9dac796783c74b682a70680a15fa8a7 by Miss Islington (bot) 
in branch '3.7':
bpo-35015: Doc: Fix internationalisation of the availability directive. 
(GH-10360)
https://github.com/python/cpython/commit/363839caf9dac796783c74b682a70680a15fa8a7


--
nosy: +miss-islington

___
Python tracker 

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



[issue35015] availability directive breaks po files

2018-11-07 Thread miss-islington


Change by miss-islington :


--
pull_requests: +9684

___
Python tracker 

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



[issue35015] availability directive breaks po files

2018-11-07 Thread Julien Palard


Julien Palard  added the comment:


New changeset beed84ca5e0f2784d758478d4e7c81c9c1088c4e by Julien Palard in 
branch 'master':
bpo-35015: Doc: Fix internationalisation of the availability directive. 
(GH-10360)
https://github.com/python/cpython/commit/beed84ca5e0f2784d758478d4e7c81c9c1088c4e


--

___
Python tracker 

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



[issue34805] Explicitly specify `MyClass.__subclasses__()` returns classes in definition order

2018-11-07 Thread Guido van Rossum


Guido van Rossum  added the comment:

Josh, I have to ask -- do you have plans to rewrite the __subclasses__
implementation? Because at this point I don't really feel like arguing over
the OP's use case. It looks like you have a strong objection over the
requested feature that's quite independent from the validity of any use
cases, and I'm curious why. The argument "but then we couldn't change the
implementation in some future version" feels pretty weak.

--

___
Python tracker 

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



[issue32409] venv activate.bat is UTF-8 encoded but uses current console codepage

2018-11-07 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

This commit broke a lot of the Windows buildbots:

https://buildbot.python.org/all/#/builders/32/builds/1707
https://buildbot.python.org/all/#/builders/113/builds/733
https://buildbot.python.org/all/#/builders/40/builds/1137
https://buildbot.python.org/all/#/builders/130/builds/420
https://buildbot.python.org/all/#/builders/3/builds/1634

Can someone work on a patch soon? If not we need to revert the commits in all 
the branches that are failed to build :(

--
nosy: +pablogsal
status: closed -> open

___
Python tracker 

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



[issue34805] Explicitly specify `MyClass.__subclasses__()` returns classes in definition order

2018-11-07 Thread Josh Rosenberg


Josh Rosenberg  added the comment:

I'm also a little skeptical of the OP's proposed use case for other reasons. In 
any circumstance other than "all classes are defined in the same module", you 
can't really make useful guarantees about subclass definition order, because:

1. If the converters are defined in multiple modules in a single package, the 
module with IntConverter could be imported first explicitly, and now 
BoolConverter will come second.

2. If all the provided converters occur in a single monolithic module, and some 
other package tries to make a converter for their own int subclass, well, 
IntConverter is already first in the list of subclasses, so the other package's 
converter will never be called (unless it's for the direct subclass of int, 
rather than a grandchild of int, but that's an implementation detail of the 
OP's project).

Essentially, to write such a class hierarchy properly, you'd need to rejigger 
the ordering each time a class was registered such that any converter for a 
parent class was pushed until after the converter for all of its descendant 
classes (and if there is multiple inheritance involved, you're doomed).

Even ignoring all that, their use case doesn't require explicit registration if 
they don't want it to. By making a simple metaclass for the root class, the 
metaclass's __new__ can perform registration on the descendant class's behalf, 
either with the definition time ordering of the current design, or with a more 
complicated rejiggering I described that would be necessary to ensure parent 
classes are considered after child classes (assuming no multiple inheritance).

--

___
Python tracker 

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



[issue34805] Explicitly specify `MyClass.__subclasses__()` returns classes in definition order

2018-11-07 Thread Guido van Rossum


Guido van Rossum  added the comment:

Thanks for the long post! Clearly there is more here than the eye can easily 
see.

Nevertheless, I feel that, *in this case*, it's not likely that such a 
re-implementation will ever happen, so I think it is okay to constrain the 
future so we can guarantee (the ordering aspect of) the current behavior. The 
current behavior also *feels* natural, regardless of the validity of the OP's 
use case.

The edge case of assignment to __bases__ is a good one to call out (in the docs 
and in the test) but I don't think the current behavior there is sufficiently 
dicey to change it or to exclude it from the guarantee.

--

___
Python tracker 

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



[issue34805] Explicitly specify `MyClass.__subclasses__()` returns classes in definition order

2018-11-07 Thread Josh Rosenberg


Josh Rosenberg  added the comment:

First off, the OP's original case seems like a use case for 
functools.singledispatch. Not really related to the problem, just thought I'd 
mention it.

Secondly, are we sure we want to make such a guarantee? That restricts the 
underlying storage to ordered types (list/dict; possibly tuple at the cost of 
making modifications slightly more expensive), or an unordered type with 
additional ordering layered on it (like old-school OrderedDict).

That does tie our hands in the future. For example, it seems like it would be a 
perfectly reasonable approach for the internal collection of subclasses to be 
implemented as a weakref.WeakSet (some future version of it implemented in C, 
rather than the current Python layer version) so as to reduce code duplication 
and improve handling when a subclass disappears. Right now, tp_subclasses is a 
dict keyed by the raw memory address of the subclass (understandable, but eww), 
with a value of a weakref to the subclass itself. There is tons of custom code 
involved in handling this (e.g. the dict only self-cleans because the dealloc 
for classes explicitly removes the subclass from the parent classes, but every 
use of the dict still has to assume weakrefs have gone dead anyway, because of 
reentrancy issues; these are solved problems in WeakSet which hides all the 
complexity from the user). Being able to use WeakSets would mean a huge amount 
of special purpose code in typeobject.c could go away,
  but guaranteeing ordering would make that more difficult (it would require 
providing an ordering guarantee for WeakSet, which, being built on set, would 
likely require ordering guarantees for sets in general, or changing WeakSet to 
be built on dicts).

There is also (at least) one edge case that would need to be fixed (based on a 
brief skim of the code). type_set_bases (which handles assignment to __bases__ 
AFAICT, admittedly a niche use case) simplified its own implementation by 
making the process of changing __bases__ be to remove itself as a subclass of 
all of its original bases, then add itself as a subclass of the new bases. This 
is done even if there are overlaps in the bases, and even if the new bases are 
the same.

Minimal repro:

>>> class A: pass
>>> class B(A): pass
>>> class C(A): pass
>>> A.__subclasses__()  # Appear in definition order
[__main__.B, __main__.C]

>>> B.__bases__ = B.__bases__# Should be no-op...
>>> A.__subclasses__()   # But oops, order changed
[__main__.C, __main__.B]

I'm not going to claim this is common or useful (I've done something like this 
exactly once, interactively, while making an OrderedCounter from OrderedDict 
and Counter back before dicts were ordered; I got the inheritance order wrong 
and reversed it after the fact), but making the guarantee would be more than 
just stating it; we'd either have to complicate the code to back it up, or 
qualify the guarantee with some weird, possibly CPython-specific details.

--
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: Overwhelmed by the Simplicity of Python. Any Recommendation?

2018-11-07 Thread MRAB

On 2018-11-07 09:20, Thomas Jollans wrote:

On 06/11/2018 22:51, Lie Ryan wrote:

I like to step through my code line by line,
it's impossible to do it with
object-oriented programming language.


I suggest pudb, it's a curses based debugger, which is nicer than pdb, but 
doesn't require tedious IDE setup.


I'll just take this opportunity to point out (for those that don't know)
that Visual Studio Code (an open source cross-platform programmer's text
editor of the same calibre as Sublime or Atom, not an IDE) has great
support for (graphical) debugging of Python code. Not tedious to set up,
particularly. Obviously there are plugins for other editors, but they're
usually not this well-integrated.


I find that the code does run more slowly, though.



Also, there's no good REPL IDE. 


Not quite sure what you meant by REPL IDE, but did you try IPython



If you find yourself wanting a debugger in an IPython/Jupyter notebook,
ipdb is pretty nice.


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


[issue35182] Popen.communicate() breaks when child closes its side of pipe but not exits

2018-11-07 Thread Josh Rosenberg


Josh Rosenberg  added the comment:

Hmm... Correction to my previous post. communicate itself has a test for:

"if self._communication_started and input:"

that raises an error if it passes, so the second call to communicate can only 
be passed None/empty input. And _communicate only explicitly closes self.stdin 
when input is falsy and _communication_started is False, so the required 
behavior right now is:

1. First call *may* pass input
2. Second call must not pass (non-empty) input under any circumstance

So I think we're actually okay on the code for stdin, but it would be a good 
idea to document that input *must* be None on all but the first call, and that 
the input passed to the first call is cached such that as long as at least one 
call to communicate completes without a TimeoutError (and the stdin isn't 
explicitly closed), it will all be sent.

Sorry for the noise; I should have rechecked communicate itself, not just 
_communicate.

--

___
Python tracker 

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



[issue35182] Popen.communicate() breaks when child closes its side of pipe but not exits

2018-11-07 Thread Josh Rosenberg


Josh Rosenberg  added the comment:

Sounds like the solution you'd want here is to just change each if check in 
_communicate, so instead of:

if self.stdout:
selector.register(self.stdout, selectors.EVENT_READ)
if self.stderr:
selector.register(self.stderr, selectors.EVENT_READ)

it does:

if self.stdout and not self.stdout.closed:
selector.register(self.stdout, selectors.EVENT_READ)
if self.stderr and not self.stderr.closed:
selector.register(self.stderr, selectors.EVENT_READ)

The `if self.stdin and input:` would also have to change. Right now it's buggy 
in a related, but far more complex way. Specifically if you call it with input 
the first time:

1. If some of the input is sent but not all, and the second time you call 
communicate you rely on the (undocumented, but necessary for consistency) input 
caching and don't pass input at all, it won't register the stdin handle for 
read (and in fact, will explicitly close the stdin handle), and the remaining 
cached data won't be sent. If you try to pass some other non-empty input, it 
just ignores it and sends whatever remains in the cache (and fails out as in 
the stdout/stderr case if the data in the cache was sent completely before the 
timeout).

2. If all of the input was sent on the first call, you *must* pass input=None, 
or you'll die trying to register self.stdin with the selector

The fix for this would be to either:

1. Follow the pattern for self.stdout/stderr (adding "and not 
self.stdin.closed"), and explicitly document that repeated calls to communicate 
must pass the exact same input each time (and optionally validate this in the 
_save_input function, which as of right now just ignores the input if a cache 
already exists); if input is passed the first time, incompletely transmitted, 
and not passed the second time, the code will error as in the OP's case, but it 
will have violated the documented requirements (ideally the error would be a 
little more clear though)

or

2. Change the code so populating the cache (if not already populated) is the 
first step, and replace all subsequent references to input with references to 
self._input (for setup tests, also checking if self._input_offset >= 
len(self._input), so it doesn't register for notifications on self.stdin if all 
the input has been sent), so it becomes legal to pass input=None on a second 
call and rely on the first call to communicate caching it. It would still 
ignore new input values on the subsequent calls, but at least it would behave 
in a sane way (not closing sys.stdin despite having unsent cached data, then 
producing a confusing error that is several steps removed from the actual 
problem)

Either way, the caching behavior for input should be properly documented; we 
clearly specify that output is preserved after a timeout and retrying 
communicate ("If the process does not terminate after timeout seconds, a 
TimeoutExpired exception will be raised. Catching this exception and retrying 
communication will not lose any output."), but we don't say anything about 
input, and right now, the behavior is the somewhat odd and hard to express:

"Retrying a call to communicate when the original call was passed 
non-None/non-empty input requires subsequent call(s) to pass non-None, 
non-empty input. The input on said subsequent calls is otherwise ignored; only 
the unsent remainder of the original input is sent. Also, it will just fail 
completely if you pass non-empty input and it turns out the original input was 
sent completely on the previous call, in which case you *must* call it with 
input=None."

It might also be worth changing the selectors module to raise a more obvious 
exception when register is passed a closed file-like object, but given it only 
requires non-integer fileobjs to have a .fileno() method, adding a requirement 
for a "closed" attribute/property could break other code.

--
nosy: +josh.r
stage:  -> needs patch

___
Python tracker 

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



[issue32281] bdist_rpm v.s. the Macintosh

2018-11-07 Thread Ben Hyde


Ben Hyde  added the comment:

ping

--

___
Python tracker 

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



[issue32153] mock.create_autospec fails if an attribute is a partial function

2018-11-07 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

@berker.peksag I have created a unit test PR and verified that the test fails 
in 3.6 and passes on master.

# 3.6 branch

   cpython git:(25bd107399)   ./python.exe
Python 3.6.7+ (remotes/upstream/3.6:25bd107399, Nov  8 2018, 00:50:43)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> ^D
   cpython git:(25bd107399)   ./python.exe -m unittest -v 
unittest.test.testmock.testhelpers.SpecSignatureTest.test_autospec_getattr_partial_function
test_autospec_getattr_partial_function 
(unittest.test.testmock.testhelpers.SpecSignatureTest) ... ERROR

==
ERROR: test_autospec_getattr_partial_function 
(unittest.test.testmock.testhelpers.SpecSignatureTest)
--
Traceback (most recent call last):
  File 
"/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/unittest/test/testmock/testhelpers.py",
 line 884, in test_autospec_getattr_partial_function
autospec = create_autospec(proxy)
  File 
"/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/unittest/mock.py", 
line 2182, in create_autospec
_check_signature(spec, mock, is_type, instance)
  File 
"/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/unittest/mock.py", 
line 102, in _check_signature
_copy_func_details(func, checksig)
  File 
"/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/unittest/mock.py", 
line 107, in _copy_func_details
funcopy.__name__ = func.__name__
AttributeError: 'functools.partial' object has no attribute '__name__'

--
Ran 1 test in 0.007s

FAILED (errors=1)

# Master

   cpython git:(bpo32153) ./python.exe
Python 3.8.0a0 (heads/bpo32153:3e9cd8d982, Nov  8 2018, 00:53:46)
[Clang 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> ^D
   cpython git:(bpo32153) ./python.exe -m unittest -v 
unittest.test.testmock.testhelpers.SpecSignatureTest.test_autospec_getattr_partial_function
test_autospec_getattr_partial_function 
(unittest.test.testmock.testhelpers.SpecSignatureTest) ... ok

--
Ran 1 test in 0.005s

OK

--

___
Python tracker 

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



[issue32513] dataclasses: make it easier to use user-supplied special methods

2018-11-07 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
pull_requests:  -9682

___
Python tracker 

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



[issue32513] dataclasses: make it easier to use user-supplied special methods

2018-11-07 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
pull_requests: +9682

___
Python tracker 

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



[issue32153] mock.create_autospec fails if an attribute is a partial function

2018-11-07 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
keywords: +patch
pull_requests: +9683
stage: needs patch -> patch review

___
Python tracker 

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



[issue35148] cannot activate a venv environment on a Swiss German windows

2018-11-07 Thread Vinay Sajip


Vinay Sajip  added the comment:

Fixed, see bpo-32409 for commit information.

--
resolution:  -> fixed
stage:  -> resolved
status: open -> closed
versions:  -Python 3.6

___
Python tracker 

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



[issue32409] venv activate.bat is UTF-8 encoded but uses current console codepage

2018-11-07 Thread Vinay Sajip


Vinay Sajip  added the comment:


New changeset 881e273c795f2f5154b8afebfa299f0e830f3712 by Vinay Sajip (Miss 
Islington (bot)) in branch '3.7':
bpo-32409: Fix regression in activate.bat on international Windows (GH-10295) 
(GH-10377)
https://github.com/python/cpython/commit/881e273c795f2f5154b8afebfa299f0e830f3712


--

___
Python tracker 

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



[issue34726] Add support of checked hash-based pycs in zipimport

2018-11-07 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
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



[issue34726] Add support of checked hash-based pycs in zipimport

2018-11-07 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset a6e956bcb0edbfe7f18af9be2215a5326ea6bf05 by Serhiy Storchaka 
(Elvis Pranskevichus) in branch 'master':
bpo-34726: Fix handling of hash-based pycs in zipimport. (GH-10327)
https://github.com/python/cpython/commit/a6e956bcb0edbfe7f18af9be2215a5326ea6bf05


--

___
Python tracker 

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



[issue35185] Logger race condition - loses lines if removeHandler called from another thread while logging

2018-11-07 Thread Ned Deily


Change by Ned Deily :


--
nosy: +vinay.sajip

___
Python tracker 

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



[issue35185] Logger race condition - loses lines if removeHandler called from another thread while logging

2018-11-07 Thread Ben Spiller


New submission from Ben Spiller :

I just came across a fairly serious thread-safety / race condition bug in the 
logging.Loggers class, which causes random log lines to be lost i.e. not get 
passed to some of the registered handlers, if (other, unrelated) handlers are 
being added/removed using add/removeHandler from another thread during logging. 
This potentially affects all log handler classes, though for timing reasons 
I've found it easiest to reproduce with the logging.FileHandler. 

See attached test program that reproduces this. 

I did some debugging and looks like although add/removeHandler are protected by 
_acquireLock(), they modify the self.handlers list in-place, and the 
callHandlers method iterates over self.handlers with no locking - so if you're 
unlucky you can end up with some of your handlers not being called. 

A trivial way to fix the bug is by editing callHandlers and copying the list 
before iterating over it:
- for hdlr in c.handlers:
+ for hdlr in list(c.handlers):

However since that could affect the performance of routine log statements a 
better fix is probably to change the implementation of add/removeHandler to 
avoid in-place modification of self.handlers so that (as a result of the GIL) 
it'll be safe to iterate over the list in callHandlers, e.g. change 
removeHandler like this:

- self.handlers.remove(hdlr)
+ newhandlers = list(self.handlers)
+ newhandlers.remove(hdlr)
+ self.handlers = hdlr

(and the equivalent in addHandler)

--
components: Library (Lib)
files: logger-race.py
messages: 329429
nosy: benspiller
priority: normal
severity: normal
status: open
title: Logger race condition - loses lines if removeHandler called from another 
thread while logging
type: behavior
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7
Added file: https://bugs.python.org/file47914/logger-race.py

___
Python tracker 

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



[issue34011] Default preference not given to venv DLL's

2018-11-07 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

This buildbot is failing when raising when creating 
subprocess.CalledProcessError:

https://buildbot.python.org/all/#/builders/40/builds/1135/steps/3/logs/stdio

test_defaults (test.test_venv.BasicTest) ... ok
test_executable (test.test_venv.BasicTest) ... ok
test_executable_symlinks (test.test_venv.BasicTest) ... skipped 'Needs symlinks'
test_isolation (test.test_venv.BasicTest) ... ok
test_overwrite_existing (test.test_venv.BasicTest) ... ok
test_prefixes (test.test_venv.BasicTest) ... ok
test_prompt (test.test_venv.BasicTest) ... ok
test_symlinking (test.test_venv.BasicTest) ... skipped 'Needs symlinks'
test_unicode_in_batch_file (test.test_venv.BasicTest) ... ERROR
test_unoverwritable_fails (test.test_venv.BasicTest) ... ok
test_upgrade (test.test_venv.BasicTest) ... ok
test_devnull (test.test_venv.EnsurePipTest) ... ok
test_explicit_no_pip (test.test_venv.EnsurePipTest) ... ok
test_no_pip_by_default (test.test_venv.EnsurePipTest) ... ok
test_with_pip (test.test_venv.EnsurePipTest) ... ok
==
ERROR: test_unicode_in_batch_file (test.test_venv.BasicTest)
--
Traceback (most recent call last):
  File "C:\buildbot.python.org\3.x.kloth-win64\build\lib\test\test_venv.py", 
line 302, in test_unicode_in_batch_file
out, err = check_output(
  File "C:\buildbot.python.org\3.x.kloth-win64\build\lib\test\test_venv.py", 
line 37, in check_output
raise subprocess.CalledProcessError(
TypeError: __init__() takes from 3 to 5 positional arguments but 6 were given
--
I will prepare a PR fixing this

--
nosy: +pablogsal
status: closed -> open

___
Python tracker 

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



[issue35180] Ctypes segfault or TypeError tested for python2.7 and 3

2018-11-07 Thread Eryk Sun


Eryk Sun  added the comment:

Assign an errcheck function to check the return value and raise an OSError 
exception on failure. Load the C library with use_errno=True to get the value 
of C errno. Make sure to properly handle encoding Unicode strings for the 
file-system encoding, including conversion of __fspath__ paths (e.g. 3.x 
pathlib). Finally, don't load libraries and define prototypes in API functions. 
It's redundant and inefficient. You're just needlessly increasing the loaders 
reference count on the shared library and needlessly redefining prototypes that 
never change. Load it once at module or class level.

For example:

import os
import sys
import ctypes
import ctypes.util
import contextlib

libc = ctypes.CDLL(ctypes.util.find_library("c"), use_errno=True)

class DIR(ctypes.Structure):
"""Opaque type for directory entries""" 

PDIR = ctypes.POINTER(DIR)

class c_fschar_p(ctypes.c_char_p):
if sys.version_info[0] >= 3:
@classmethod
def from_param(cls, param):
if isinstance(param, (str, bytes, os.PathLike)):
param = os.fsencode(param)
return super().from_param(param)
else:
@classmethod
def from_param(cls, param):
if isinstance(param, unicode):
param = param.encode(sys.getfilesystemencoding())
return super(c_fschar_p, cls).from_param(param)

def check_bool(result, func, args):
if not result:
err = ctypes.get_errno()
raise OSError(err, os.strerror(err))
return args

def check_int(result, func, args):
if result == -1:
err = ctypes.get_errno()
raise OSError(err, os.strerror(err))
return args

libc.opendir.errcheck = check_bool
libc.opendir.argtypes = (c_fschar_p,)
libc.opendir.restype = PDIR
libc.dirfd.errcheck = check_int
libc.dirfd.argtypes = (PDIR,)
libc.closedir.errcheck = check_int
libc.closedir.argtypes = (PDIR,)

@contextlib.contextmanager
def get_directory_file_descriptor(directory):
dir_p = libc.opendir(directory)
try:
if __debug__:
print("dir_p = %s:%r" % (directory, dir_p))
dir_fd = libc.dirfd(dir_p)
if __debug__:
print("dir_fd = %r" % dir_fd)
yield dir_fd
finally:
libc.closedir(dir_p)
if __debug__:
print("closed %r" % dir_p)

--
nosy: +eryksun

___
Python tracker 

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



[issue5166] ElementTree and minidom don't prevent creation of not well-formed XML

2018-11-07 Thread Ben Spiller


Change by Ben Spiller :


--
nosy: +Ben Spiller

___
Python tracker 

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



[issue33694] test_asyncio: test_start_tls_server_1() fails on Python on x86 Windows7 3.7 and 3.x

2018-11-07 Thread Martin Bijl-Schwab


Change by Martin Bijl-Schwab :


--
pull_requests: +9681

___
Python tracker 

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



[issue11492] email.header.Header doesn't fold headers correctly

2018-11-07 Thread STINNER Victor


STINNER Victor  added the comment:

I wrote PR 10378 to show that I don't think that this bug must be fixed in 
Python 2: it would break any application relying on the current folding 
algorithm.

--
nosy: +vstinner

___
Python tracker 

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



[issue11492] email.header.Header doesn't fold headers correctly

2018-11-07 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +9680

___
Python tracker 

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



[issue32409] venv activate.bat is UTF-8 encoded but uses current console codepage

2018-11-07 Thread miss-islington


Change by miss-islington :


--
pull_requests: +9679

___
Python tracker 

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



[issue32409] venv activate.bat is UTF-8 encoded but uses current console codepage

2018-11-07 Thread Vinay Sajip


Vinay Sajip  added the comment:


New changeset c64583b6d3e8516a8cd2b5f84fc1e300bfac2206 by Vinay Sajip 
(samstagern) in branch 'master':
bpo-32409: Fix regression in activate.bat on international Windows (GH-10295)
https://github.com/python/cpython/commit/c64583b6d3e8516a8cd2b5f84fc1e300bfac2206


--
nosy: +vinay.sajip

___
Python tracker 

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



[issue35184] Makefile is not correctly generated when compiling pyextat with DXML_POOR_ENTROPY=1

2018-11-07 Thread Marta Gómez

New submission from Marta Gómez :

Hello,

I was getting this same error (https://bugs.python.org/issue35139) when 
compiling pyextat so I added these changes 
(https://github.com/python/cpython/pull/10291/files) to my Setup.dist. 

After running ./configure, the generated Makefile throws the following error:

$ make
Makefile:264: *** missing separator.  Stop.

I have tried this in both Python 3.7 and 3.6 and I get the error in both (the 
line numbers are different but the error is the same). I have tested this in 
both Ubuntu 16/18 and CentOS 7.

Any hints in how could I fix this?

Best regards,
Marta

--
components: Build
messages: 329424
nosy: mgmacias95
priority: normal
severity: normal
status: open
title: Makefile is not correctly generated when compiling pyextat with 
DXML_POOR_ENTROPY=1
type: compile error
versions: Python 3.6, Python 3.7

___
Python tracker 

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



[issue35168] shlex punctuation_chars inconsistency

2018-11-07 Thread Vinay Sajip


Vinay Sajip  added the comment:

> a better run time error message which clarifies that shlex.punctuation_chars 
> is read-only

That it can be set only via the __init__(), yes.

--

___
Python tracker 

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



[issue34971] add support for tls/ssl sessions in asyncio

2018-11-07 Thread Rémi Cardona

Rémi Cardona  added the comment:

So, IOW, the ssl module needs a good shakeup wrt TLS 1.3 sessions before any 
asyncio work can be merged.  Am I getting this right?

In which case, a whole other issue/PR is needed and possibly better folks than 
me.  I try to stay clear of low-level crypto APIs because I don't trust myself 
to get things right.  Well… I certainly can look at it, but I fear I may be 
punching above my weight with this.

--

___
Python tracker 

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



Re: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-07 Thread srinivasan
Many Thanks a lot , I can use for reliably "lsblk %s -n -o FSTYPE"  in the
reused code of mine as below

cmd = "lsblk %s -n -o FSTYPE" % partition_path
return self._helper.execute_cmd_output_string(cmd)

I really appreciate for all your support w.r.t this..

I feel I have kick started my learning in python :)

Have a great day ahead!


On Wed, Nov 7, 2018 at 3:11 PM Ben Bacarisse  wrote:

> srinivasan  writes:
>
> > Even after changing as per the below
> > "blkid -o export %s | grep 'TYPE' | cut -d'=' -f3"
> > or:
> > 'blkid -o export %s | grep "TYPE" | cut -d"=" -f3'
> > or:
> > "blkid -o export %s | grep \"TYPE\" | cut -d\"=\" -f3"
> >
> > Still my output is:
> > */dev/mmcblk1p1: LABEL="efi" UUID="1084-AA42" TYPE="vfat"*
> >
> > My expected output should be only:
> > *vfat*
> >
> > Could you guys please do the needful?
>
> Why not
>
>   blkid %s -o value --match-tag TYPE
>
> ?  Or, better still,
>
>   lsblk %s -n -o FSTYPE
>
> It's not easy to answer your question about fixing the line you have,
> because the output you are getting it not consistent with what you are
> showing.  (And I can't find the original post that presumably has Python
> code I could run myself.)
>
> The format I get with -o export is:
>
> DEVNAME=/dev/sda1
> UUID=2726bf5f-2655-4986-815d-e4532374f218
> TYPE=ext3
> PARTUUID=000453d3-01
>
> for which
>
>   "blkid %s -o export | grep TYPE | cut -c6-"
>
> would work.  Alternatively I get the result you want from
>
>   "blkid %s -o export | grep TYPE | cut -d= -f2"
>
> Note that "TYPE" and "=" don't really need to be quoted at all.
>
> Someone suggested sed, and that too can be used like this:
>
>   blkid %s -o export | sed -ne '/TYPE=/s///p'
>
> --
> Ben.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28015] configure --with-lto builds fail when CC=clang on Linux, requires gold linker

2018-11-07 Thread Charalampos Stratakis


Charalampos Stratakis  added the comment:

The workaround indeed works.

--

___
Python tracker 

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



[issue34982] re.sub() different behavior in 3.7

2018-11-07 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Yes, it is.

--

___
Python tracker 

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



[issue35181] Doc: Namespace Packages: Inconsistent documentation of __loader__ being None

2018-11-07 Thread Géry

Géry  added the comment:

It looks like Barry Warsaw has not been fully updated the documentation after 
making the __spec__.loader attribute match with the __loader__ attribute, and 
the __spec__.file attribute match with the __file__ attribute for namespace 
packages.

Here is a pull request to update the library documentation of importlib (your 
first link [1]) with the current Barry's implementation:
https://github.com/python/cpython/pull/10016

Here is another pull request to update the reference documentation of the 
import system (your second link [2], but for a different paragraph, as I think 
the "To indicate to the import machinery that the spec represents a namespace 
portion the path entry finder sets “loader” on the spec to None" sentence is 
correct, since the `_bootstrap.ModuleSpec.loader` attribute of a namespace 
package remains `None` until the call to the 
`importlib._bootstrap._init_module_attrs` function):
https://github.com/python/cpython/pull/10376

--
nosy: +brett.cannon, eric.snow, maggyero, ncoghlan

___
Python tracker 

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



[issue34982] re.sub() different behavior in 3.7

2018-11-07 Thread Stephan Bergmann


Stephan Bergmann  added the comment:

So, just to make sure, that also means that

  re.sub('a*$', 'b', 'a')

returning 'bb' instead of 'b' is intended behavior?

--
nosy: +Stephan Bergmann

___
Python tracker 

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



[issue35181] Doc: Namespace Packages: Inconsistent documentation of __loader__ being None

2018-11-07 Thread Géry

Change by Géry :


--
pull_requests: +9678

___
Python tracker 

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



[issue35181] Doc: Namespace Packages: Inconsistent documentation of __loader__ being None

2018-11-07 Thread Géry

Change by Géry :


--
keywords: +patch
pull_requests: +9677
stage:  -> patch review

___
Python tracker 

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



[issue2504] Add gettext.pgettext() and variants support

2018-11-07 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
resolution:  -> fixed
stage: needs patch -> 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: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-07 Thread Ben Bacarisse
srinivasan  writes:

> Even after changing as per the below
> "blkid -o export %s | grep 'TYPE' | cut -d'=' -f3"
> or:
> 'blkid -o export %s | grep "TYPE" | cut -d"=" -f3'
> or:
> "blkid -o export %s | grep \"TYPE\" | cut -d\"=\" -f3"
>
> Still my output is:
> */dev/mmcblk1p1: LABEL="efi" UUID="1084-AA42" TYPE="vfat"*
>
> My expected output should be only:
> *vfat*
>
> Could you guys please do the needful?

Why not

  blkid %s -o value --match-tag TYPE

?  Or, better still,

  lsblk %s -n -o FSTYPE

It's not easy to answer your question about fixing the line you have,
because the output you are getting it not consistent with what you are
showing.  (And I can't find the original post that presumably has Python
code I could run myself.)

The format I get with -o export is:

DEVNAME=/dev/sda1
UUID=2726bf5f-2655-4986-815d-e4532374f218
TYPE=ext3
PARTUUID=000453d3-01

for which

  "blkid %s -o export | grep TYPE | cut -c6-"

would work.  Alternatively I get the result you want from

  "blkid %s -o export | grep TYPE | cut -d= -f2"

Note that "TYPE" and "=" don't really need to be quoted at all.

Someone suggested sed, and that too can be used like this:

  blkid %s -o export | sed -ne '/TYPE=/s///p'

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


[issue2504] Add gettext.pgettext() and variants support

2018-11-07 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 637a33b99685fd5d1032670fbe29c7c8a8f0ff63 by Serhiy Storchaka 
(Cheryl Sabella) in branch 'master':
bpo-2504: Add pgettext() and variants to gettext. (GH-7253)
https://github.com/python/cpython/commit/637a33b99685fd5d1032670fbe29c7c8a8f0ff63


--

___
Python tracker 

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



[issue34160] ElementTree not preserving attribute order

2018-11-07 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 5598cc90c745dab827e55fadded42dbe85e31d33 by Serhiy Storchaka 
(Diego Rojas) in branch 'master':
bpo-34160: Preserve order of attributes in minidom. (GH-10219)
https://github.com/python/cpython/commit/5598cc90c745dab827e55fadded42dbe85e31d33


--

___
Python tracker 

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



Re: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-07 Thread Chris Angelico
On Wed, Nov 7, 2018 at 11:42 PM srinivasan  wrote:
>
> Some I managed to fix temporarily as below, might be useful for others. Also 
> please correct me if anything wrong or for any improvements in the below
>
> cmd = "blkid -o export %s" % partition_path
> out = self._helper.execute_cmd_output_string(cmd)
> var = out.split("TYPE=", 1)[1]
> quoted = re.compile('(?<=^\")[^"]*')
> for string in quoted.findall(var):
> return string

Leaving aside the fact that MS Comic Sans is known to the State of
California to cause cancer, this code is probably okay if you don't
mind it being overengineered. Here's a much simpler version, albeit
untested:

out = subprocess.check_output(["blkid", "-o", "export", partition_path])
for line in out.split("\n"):
item, value = line.split("=")
if item == "TYPE": return value

No helper needed. Safe against command injection. Uses the known
format of the command's output; if you want other information as well
as the type, you could get that too.

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


Re: Unable to remove python from my computer.

2018-11-07 Thread Rhodri James
I assume "on a PC" actually means "on Windows".  Redirected back to the 
list since I neither know nor care about wrangling Python on Windows.


On 07/11/2018 12:27, Jack Gilbert wrote:

on a PC:

click start, (click on the window, lower left hand corner)[ in 8.1]
Control Panel
Programs and Features

you will see a list of programs installed on your machine in alphabetical
order
look for Python x.x.x(32 bit)  click to highlight
click uninstall  near the top of the screen
wait
wait
wait
the machine might ask you,, are you sure you want to uninstall this
program?  click ok or yes
wait
wait
wait
wait some more

you might see the status bar move to the right as the machine clears the
program

wait
wait

the machine will say,, this progam has been uninstalled

you should see or rather not see the program in the list and any python
icon that you have on your desktop will also be removed.

I have  Python 3.6.4(32-bit) on a 64bit PC with 5TB HDD, Dell machine,
running 8.1




Virus-free.
www.avg.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Tue, Nov 6, 2018 at 5:42 AM Rhodri James  wrote:


On 06/11/2018 09:25, Thomas Jollans wrote:

On 2018-11-06 10:05, Varshit Jain wrote:

Hi Python Support Team,


I just want to remove python 3.6.6 from my computer. I am unable to do
it. Please find attached video that describe my problem.


Use your words, friend!

(this list is text-only)


More exactly, I'm afraid the mailing list has stripped off the video you
attached, so we can't watch it.  I'm afraid I wouldn't in any case; I
learned long ago not to open attachments from people I don't already know.

Could you please describe to us your problem?  Are you using Windows,
Linux, Mac or something else?  Copy any error messages the uninstaller
might have given you, preferably cutting and pasting rather than just
retyping them (it's easy to mistype something critical!).  Please don't
send us screen shots, those will just get stripped off by the mailing
list as well.

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






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


[issue10536] Enhancements to gettext docs

2018-11-07 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
stage: resolved -> 
status: closed -> open
versions: +Python 3.6, Python 3.7 -Python 3.4, Python 3.5

___
Python tracker 

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



Re: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-07 Thread srinivasan
Some I managed to fix temporarily as below, might be useful for others.
Also please correct me if anything wrong or for any improvements in the
below

cmd = "blkid -o export %s" % partition_path
out = self._helper.execute_cmd_output_string(cmd)
var = out.split("TYPE=", 1)[1]
quoted = re.compile('(?<=^\")[^"]*')
for string in quoted.findall(var):
return string

On Wed, Nov 7, 2018 at 1:39 PM Chris Angelico  wrote:

> On Wed, Nov 7, 2018 at 11:36 PM Qian Cai  wrote:
> >
> > srinivasan  wrote:
> > > Even after changing as per the below
> > > "blkid -o export %s | grep 'TYPE' | cut -d'=' -f3"
> > > or:
> > > 'blkid -o export %s | grep "TYPE" | cut -d"=" -f3'
> > > or:
> > > "blkid -o export %s | grep \"TYPE\" | cut -d\"=\" -f3"
> > >
> > > Still my output is:
> > > */dev/mmcblk1p1: LABEL="efi" UUID="1084-AA42" TYPE="vfat"*
> > >
> > > My expected output should be only:
> > > *vfat*
> > >
> > > Could you guys please do the needful?
> > >
> > >
> > Perfect place to use sed instead of grep/cut.
>
> ... or to use subprocess.check_output() to run just the blkid command,
> and then do the parsing in Python.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-07 Thread Chris Angelico
On Wed, Nov 7, 2018 at 11:36 PM Qian Cai  wrote:
>
> srinivasan  wrote:
> > Even after changing as per the below
> > "blkid -o export %s | grep 'TYPE' | cut -d'=' -f3"
> > or:
> > 'blkid -o export %s | grep "TYPE" | cut -d"=" -f3'
> > or:
> > "blkid -o export %s | grep \"TYPE\" | cut -d\"=\" -f3"
> >
> > Still my output is:
> > */dev/mmcblk1p1: LABEL="efi" UUID="1084-AA42" TYPE="vfat"*
> >
> > My expected output should be only:
> > *vfat*
> >
> > Could you guys please do the needful?
> >
> >
> Perfect place to use sed instead of grep/cut.

... or to use subprocess.check_output() to run just the blkid command,
and then do the parsing in Python.

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


Re: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-07 Thread Qian Cai
srinivasan  wrote:
> Even after changing as per the below
> "blkid -o export %s | grep 'TYPE' | cut -d'=' -f3"
> or:
> 'blkid -o export %s | grep "TYPE" | cut -d"=" -f3'
> or:
> "blkid -o export %s | grep \"TYPE\" | cut -d\"=\" -f3"
> 
> Still my output is:
> */dev/mmcblk1p1: LABEL="efi" UUID="1084-AA42" TYPE="vfat"*
> 
> My expected output should be only:
> *vfat*
> 
> Could you guys please do the needful?
> 
> 
Perfect place to use sed instead of grep/cut.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue35182] Popen.communicate() breaks when child closes its side of pipe but not exits

2018-11-07 Thread Andriy Maletsky


Change by Andriy Maletsky :


--
components: +Library (Lib)

___
Python tracker 

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



[issue35123] Add style guide for sentinel usage

2018-11-07 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I agree that there are not any problems that need solving.

--
nosy: +serhiy.storchaka
resolution:  -> not a bug
stage:  -> 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



[issue35183] os.path.splitext documentation needs typical example

2018-11-07 Thread Shaun Griffith


New submission from Shaun Griffith :

As with many entries on the os.path doc page, splitext needs a typical example. 
Not grokking the bare minimum text, I had to actually try it in the interpreter 
to see what it did.

The one example that *is* there is an edge case, and does nothing to explain 
the normal behavior, or why this is the correct behavior for the edge case.

Here is where I tripped up:

Split the pathname path into a pair (root, ext) such that root + ext == path, 
and ext is empty or begins with a period and contains at most one period.

One interpretation of this is that ext is either empty, or has a period, _and 
nothing else_. 

Here are 2 examples for typical use:

>>> splitext('readme.txt')
('readme', '.txt')
>>> splitext('/some/long/pathname/warble.csv')
('/some/long/pathname/warble', '.csv')

--
assignee: docs@python
components: Documentation
messages: 329414
nosy: docs@python, shaungriffith
priority: normal
severity: normal
status: open
title: os.path.splitext documentation needs typical example
type: enhancement
versions: Python 3.6

___
Python tracker 

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



[issue35123] Add style guide for sentinel usage

2018-11-07 Thread Robert Wright


Robert Wright  added the comment:

Perhaps there's confusion over what I mean by "style guide". I'd happily take 
Steven's message *as* the style guide. Or, at the very least, the clarification 
that sentinels are to be thought of as constants.

It's one of those things that's obvious once mentioned, but might not be 
thought of when you're using them.

Though Eric does raise an interesting point about C sentinels. Something like:

kwargs = {}

if mode is not _MISSING:
  kwargs.update(mode=mode)

return open(name, "foo", **kwargs)

would work a bit better with multiple arguments, but it's still not great.

--

___
Python tracker 

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



Re: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-07 Thread srinivasan
Even after changing as per the below
"blkid -o export %s | grep 'TYPE' | cut -d'=' -f3"
or:
'blkid -o export %s | grep "TYPE" | cut -d"=" -f3'
or:
"blkid -o export %s | grep \"TYPE\" | cut -d\"=\" -f3"

Still my output is:
*/dev/mmcblk1p1: LABEL="efi" UUID="1084-AA42" TYPE="vfat"*

My expected output should be only:
*vfat*

Could you guys please do the needful?


On Wed, Nov 7, 2018 at 11:10 AM Brian J. Oney 
wrote:

> On Wed, 2018-11-07 at 10:22 +0100, srinivasan wrote:
> > blkid -o export %s | grep \'TYPE\' | cut -d\"=\" -f3
>
> You don't need to escape the single quotes.
> Try either:
>
> "blkid -o export %s | grep 'TYPE' | cut -d'=' -f3"
> or:
> 'blkid -o export %s | grep "TYPE" | cut -d"=" -f3'
> or:
> "blkid -o export %s | grep \"TYPE\" | cut -d\"=\" -f3"
>
> HTH
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Does this behavior have a better design pattern?

2018-11-07 Thread Peter Otten
lampahome wrote:

> Above is I thought to make code clear, and this pattern is called simple
> factory?

This is a factory function:

> def get_class(obj):
> if obj == 'A1' or obj == 'A2':
> return A(obj)
>  else:
> return B(obj)

The rest is just cruft ;)
> 
> *Is there better design pattern for me?*

If A does B to C, is that a crime?

Your problem description suffers from overgeneralisation.

Generally speaking you get better solutions when you ask yourself
"How can I solve this problem efficiently?"
rather than
"What fancy design patterns can I use while solving this problem?"

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


[issue35182] Popen.communicate() breaks when child closes its side of pipe but not exits

2018-11-07 Thread Andriy Maletsky


Change by Andriy Maletsky :


--
type: crash -> behavior

___
Python tracker 

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



[issue31553] Extend json.tool to handle jsonlines (with a flag)

2018-11-07 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.8 -Python 3.7

___
Python tracker 

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



[issue35182] Popen.communicate() breaks when child closes its side of pipe but not exits

2018-11-07 Thread Andriy Maletsky


New submission from Andriy Maletsky :

When communicate() is called in a loop, it crashes when the child process has 
already closed any piped standard stream, but still continues to be running.

How this happens:
1) the parent waits for the child events inside communicate() call
2) the child closes its side of any attached pipes long before exiting (in my 
case there is some complex c++ application which had messed with its 
termination)
3) communicate() receives an epoll event, tries to read/write, receives SIGPIPE 
(for stdin) or EOF (for stdout), decides to close corresponding file 
descriptors from its side
4) communicate() waits for the death of the child, but a timeout is fired
5) parent handles timeout exception and calls communicate() again
6) an exception is raised when communicate() tries to register closed file in 
epoll

I think there may be a simple solution: before registering file descriptors in 
epoll, we may check whether any of them is already closed, and don't register 
it in that case.

Here is a simple reproducible example, ran on Linux 4.15.0-1021-aws x86_64:


import subprocess

child = subprocess.Popen(
['/usr/local/bin/python3.7', '-c', 'import os, time; os.close(1), 
time.sleep(30)'],
stdout=subprocess.PIPE,
)

while True:
try:
child.communicate(timeout=3)
break
except subprocess.TimeoutExpired:
# do something useful here
pass


Here is a stacktrace:

Traceback (most recent call last):
  File "test.py", line 10, in 
child.communicate(timeout=3)
  File "/usr/local/lib/python3.7/subprocess.py", line 933, in communicate
stdout, stderr = self._communicate(input, endtime, timeout)
  File "/usr/local/lib/python3.7/subprocess.py", line 1666, in _communicate
selector.register(self.stdout, selectors.EVENT_READ)
  File "/usr/local/lib/python3.7/selectors.py", line 352, in register
key = super().register(fileobj, events, data)
  File "/usr/local/lib/python3.7/selectors.py", line 238, in register
key = SelectorKey(fileobj, self._fileobj_lookup(fileobj), events, data)
  File "/usr/local/lib/python3.7/selectors.py", line 225, in _fileobj_lookup
return _fileobj_to_fd(fileobj)
  File "/usr/local/lib/python3.7/selectors.py", line 40, in _fileobj_to_fd
"{!r}".format(fileobj)) from None
ValueError: Invalid file object: <_io.BufferedReader name=3>

--
messages: 329412
nosy: and800
priority: normal
severity: normal
status: open
title: Popen.communicate() breaks when child closes its side of pipe but not 
exits
type: crash
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6, 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



Re: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-07 Thread Brian J. Oney via Python-list
On Wed, 2018-11-07 at 10:22 +0100, srinivasan wrote:
> blkid -o export %s | grep \'TYPE\' | cut -d\"=\" -f3

You don't need to escape the single quotes.
Try either:

"blkid -o export %s | grep 'TYPE' | cut -d'=' -f3"
or:
'blkid -o export %s | grep "TYPE" | cut -d"=" -f3'
or:
"blkid -o export %s | grep \"TYPE\" | cut -d\"=\" -f3"

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


[issue31553] Extend json.tool to handle jsonlines (with a flag)

2018-11-07 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset f19447994983902aa88362d8fffe645f1ea2f2aa by Serhiy Storchaka 
(HongWeipeng) in branch 'master':
bpo-31553: add --json-lines option to json.tool (#10051)
https://github.com/python/cpython/commit/f19447994983902aa88362d8fffe645f1ea2f2aa


--

___
Python tracker 

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



[issue34971] add support for tls/ssl sessions in asyncio

2018-11-07 Thread Christian Heimes


Christian Heimes  added the comment:

The session code of the ssl is not compatible with TLS 1.3. Actually the whole 
API doesn't work with TLS 1.3. In TLS 1.2 and before, sessions had multiple 
security implications. For example they break PFS.

TLS 1.3 changed when sessions are exchanged and how session are resumed. 
Session data is no longer part of the handshake. Instead the server can send 
session tickets at any point after the handshake. A server can send multiple 
tickets (usually two) and tickets must only be reused once.

--

___
Python tracker 

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



Re: Overwhelmed by the Simplicity of Python. Any Recommendation?

2018-11-07 Thread Thomas Jollans
On 06/11/2018 22:51, Lie Ryan wrote:
>> I like to step through my code line by line,
>> it's impossible to do it with
>> object-oriented programming language.
> 
> I suggest pudb, it's a curses based debugger, which is nicer than pdb, but 
> doesn't require tedious IDE setup.

I'll just take this opportunity to point out (for those that don't know)
that Visual Studio Code (an open source cross-platform programmer's text
editor of the same calibre as Sublime or Atom, not an IDE) has great
support for (graphical) debugging of Python code. Not tedious to set up,
particularly. Obviously there are plugins for other editors, but they're
usually not this well-integrated.

> 
>> Also, there's no good REPL IDE. 
> 
> Not quite sure what you meant by REPL IDE, but did you try IPython
> 

If you find yourself wanting a debugger in an IPython/Jupyter notebook,
ipdb is pretty nice.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue34898] add mtime argument to gzip.compress

2018-11-07 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Thank you for your contribution!

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
type:  -> enhancement
versions:  -Python 3.6, Python 3.7

___
Python tracker 

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



[issue34898] add mtime argument to gzip.compress

2018-11-07 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 0e7497cb469b003a45a4abe4105b81ef6d0c4002 by Serhiy Storchaka 
(guoci) in branch 'master':
bpo-34898: Add mtime parameter to gzip.compress(). (GH-9704)
https://github.com/python/cpython/commit/0e7497cb469b003a45a4abe4105b81ef6d0c4002


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue34971] add support for tls/ssl sessions in asyncio

2018-11-07 Thread Rémi Cardona

Rémi Cardona  added the comment:

Hi Christian,

Could you tell me more about this new openssl API? Right now my patch works 
with whatever the ssl module provides. Are you suggesting the ssl module is in 
some way incomplete? Would supporting TLS 1.3 sessions be incompatible with the 
current session API?

I'd like to help wherever possible, but I'm probably missing some context 
and/or knowledge around all things TLS in cpython.

Thanks

--

___
Python tracker 

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



Does this behavior have a better design pattern?

2018-11-07 Thread lampahome
I have two categories A,B, and A has 2 items A1,A2
B have 2 items B1, B2.

I have two class A and B, and A will handle A1,A2, B handle B1,B2.

I want to parse one of A1,A2,B1,B2 to script and generate the corresponding
class(object).

Ex: Both in class A and B, all have func1(), func2().
What I thought to design is below:
-
class Data(object):
def __Init__():
...
 def func1(self):
pass

def func2(self):
 pass

class A(Data):
def __Init__():
...
 def func1(self):
A_do()

def func2(self):
 A_does()

class B(Data):
def __Init__():
...
 def func1(self):
B_do()

def func2(self):
 B_does()

def get_class(obj):
if obj == 'A1' or obj == 'A2':
return A(obj)
 else:
return B(obj)

# A = get_class(A1)
# B = get_class(B2)

-

Above is I thought to make code clear, and this pattern is called simple
factory?

*Is there better design pattern for me?*

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


Re: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-07 Thread srinivasan
After changing the line to *"cmd = "blkid -o export %s | grep \'TYPE\' |
cut -d\"=\" -f3" % fs"*, Now I dont see the error "SyntaxError: can't
assign to literal"
This is not returning exactly "*vfat*" instead of this, it is returning as "*
/dev/mmcblk1p1: LABEL="efi" UUID="1084-AA42" TYPE="vfat"* "

Could you please help me  as it seems to be like grep and cut commands are
not working in the above line ie., on *cmd = "blkid -o export %s | grep
\'TYPE\' | cut -d\"=\" -f3" % fs*?

On Wed, Nov 7, 2018 at 9:41 AM Avi Gross  wrote:

> I may be missing something but it looks like the embedded double quotes
> may be a problem in this:
>
> cmd = "blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % ...
>
> if you use single quotes as in:
>
> cut -d"="
>
> becomes
>
> cut -d'='
>
> or escape the double quotes with \" and so on ...
>
> The above seems to be seen as:
>
> cmd=ALPHA=BETA % ...
>
> where ALPHA="blkid -o export %s | grep 'TYPE' | cut -d"
> and BETA=" -f3"
>
> Other issues may also be there.
> -Original Message-
> From: Tutor  On Behalf Of
> Alan Gauld via Tutor
> Sent: Tuesday, November 6, 2018 7:37 PM
> To: tu...@python.org
> Cc: python-...@python.org
> Subject: Re: [Tutor] SyntaxError: can't assign to literal while using
> ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using
> subprocess module in Python
>
> On 06/11/2018 18:07, srinivasan wrote:
>
> > bash command in python using subprocess module, I ma seeing the below
> > *cmd = "blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" %
> > (fs)*
>
> In general you should try to do as little as possible using bash and
> subprocess. Especially try to avoid long pipelines since you are starting a
> new OS process for every element in the pipeline. That means, in your case,
> you are running 4 processes to get your result - Python, blkid, grep and cut
>
> Python is designed to do much of what the shell command can do almost as
> easily and much more efficiently (no new processes being started).
>
> In this case just execute the blkid bit in bash because its too difficult
> to replicate simply in Python. Then use Python to search for the TYPE lines
> and slice them to size.
>
> That will, in turn, simplify your command string and remove the issue of
> multiple quotes.
>
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
> ___
> Tutor maillist  -  tu...@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
> ___
> Tutor maillist  -  tu...@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
-- 
https://mail.python.org/mailman/listinfo/python-list


  1   2   >