[issue38893] broken container/selinux integration

2019-11-29 Thread Leif Middelschulte


Leif Middelschulte  added the comment:

@Christian Heimes: is there anything else you need from me? Is this the wrong 
forum?

As discussed in the referenced GitHub issue, some SELinux people suggest it 
might be a fault in how Python determines (?) it's running within a container 
environment and how to act upon it.

Does it determine it at all? Does it use libselinux[0]?

Background: I came across this issue by building a Linux distribution using 
Yocto in a Fedora:30 podman managed container with host volumes bound in. I 
guess that it is a fairly common scenario in the near future.

[0] https://danwalsh.livejournal.com/73099.html

--

___
Python tracker 

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



[issue38939] Using Python as a Calculator

2019-11-29 Thread dongjs


New submission from dongjs :

>>> 17 / 3  # classic division returns a float
5.667

this example is error 

what i test is below

>>> 17.0 / 3
5.667
>>> 17 / 3
5

--
messages: 357637
nosy: dongjs
priority: normal
severity: normal
status: open
title: Using Python as a Calculator
type: behavior
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



[issue30988] Exception parsing invalid email address headers starting or ending with dot

2019-11-29 Thread Cyril Nicodème

Cyril Nicodème  added the comment:

Hi!

I confirm this problem too, also with the SMTPUTF8 policy.

I was able to reproduce this error on my end (Python v3.7.5).

Note that when calling `message_from_bytes` without policy, there is no errors.

--
nosy: +cnicodeme

___
Python tracker 

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



[issue38939] Using Python as a Calculator

2019-11-29 Thread Karthikeyan Singaravelan

Karthikeyan Singaravelan  added the comment:

Maybe you are looking for floor division?

https://docs.python.org/3.3/reference/expressions.html#binary-arithmetic-operations

> The / (division) and // (floor division) operators yield the quotient of 
> their arguments. The numeric arguments are first converted to a common type. 
> Division of integers yields a float, while floor division of integers results 
> in an integer; the result is that of mathematical division with the ‘floor’ 
> function applied to the result. Division by zero raises the ZeroDivisionError 
> exception.

Python 3.8 

>>> 17 / 3
5.667
>>> 17.0 / 3
5.667
>>> 17 // 3
5

--
nosy: +xtreak

___
Python tracker 

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



[issue38940] Add a new functools.cast() function

2019-11-29 Thread Ugra Dániel

New submission from Ugra Dániel :

In some cases it would be really helpful to have a decorator which 
automagically casts returned value to a different type.

Particularly, instead of writing something like this:

def example():
result = []

for ...:
result.append(item)

return result

...this would do the magic:

@functools.cast(list)
def example():
for ...:
yield item

On the positive side (apart from its compactness) when an implementation 
changes from list to set, .append() does not need to be changed to .add().

Of course on the caller side one can always write list(example()) but sometimes 
this transformation needs to be done on implementation side for architectural 
reasons.

Pseudocode for proposed functools.cast():

def cast(type):
def wrapper(func):
@wraps(func)
def newfunc(*args, **keywords):
return type(func(*args, **keywords))

return newfunc

return wrapper

--
components: Library (Lib)
messages: 357640
nosy: daniel.ugra
priority: normal
severity: normal
status: open
title: Add a new functools.cast() function
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



[issue38940] Add a new functools.cast() function

2019-11-29 Thread Ugra Dániel

Ugra Dániel  added the comment:

Currently, the closest functionality I can think of (using standard library 
functions only):

@functools.partial(lambda func: functools.wraps(func)(lambda *args, **keywords: 
list(func(*args, **keywords

Or without proper wrapping:

@functools.partial(lambda func: lambda *args, **keywords: list(func(*args, 
**keywords)))

--

___
Python tracker 

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



[issue38941] xml.etree.ElementTree.Element inconsistent warning for bool

2019-11-29 Thread Philip Rowlands


New submission from Philip Rowlands :

Steps to reproduce:

$ python3.7
Python 3.7.2 (default, May 13 2019, 13:52:56)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import xml.etree.ElementTree as ET
>>> bool(ET.fromstring("").find(".//c"))
False


$ python3.7
Python 3.7.2 (default, May 13 2019, 13:52:56)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.modules['_elementtree'] = None
>>> import xml.etree.ElementTree as ET
>>> bool(ET.fromstring("").find(".//c"))
__main__:1: FutureWarning: The behavior of this method will change in future 
versions.  Use specific 'len(elem)' or 'elem is not None' test instead.


This is (almost) the smallest test case, but in real code what I was trying to 
write was:
```
# check the result code is ok
if response.find("./result[@code='ok']"):
return True
```

The unintuitive bool() behaviour was surprising, compared to other typical True 
/ False determinations on objects, and I think what the FutureWarning is trying 
to avoid.

Please implement the same warning for bool(Element) in _elementtree.c as exists 
in ElementTree.py. bpo29204 was making similar alignments between the versions, 
but didn't consider this FutureWarning.

--
components: Library (Lib)
messages: 357642
nosy: philiprowlands
priority: normal
severity: normal
status: open
title: xml.etree.ElementTree.Element inconsistent warning for bool
type: behavior

___
Python tracker 

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



[issue38941] xml.etree.ElementTree.Element inconsistent warning for bool

2019-11-29 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
components: +XML
nosy: +scoder

___
Python tracker 

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



[issue38937] NameError in list comprehension within .pth file

2019-11-29 Thread Chris Billington


Chris Billington  added the comment:

Sorry for the spamming, realised I misunderstood further.

The original behaviour isn't because the exec'd code can't create new local 
variables - it can - it's because of the documented behaviour of exec when it 
gets different dicts for globals and locals:

"If exec gets two separate objects as globals and locals, the code will be 
executed as if it were embedded in a class definition"

So the new scope made by the list comprehension can't access the enclosing 
scope in which the new variable was defined, because that's how scoping works 
in class definitions.

--

___
Python tracker 

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



[issue38940] Add a new functools.cast() function

2019-11-29 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
nosy: +rhettinger

___
Python tracker 

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



[issue38941] xml.etree.ElementTree.Element inconsistent warning for bool

2019-11-29 Thread Stefan Behnel

Stefan Behnel  added the comment:

Agreed that both should behave the same.

And, we should finally decide whether this should really be changed or not. The 
current behaviour is counter-intuitive, but it's been like that forever and 
lots of code depends on it in one way or another, so …

--
stage:  -> needs patch
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



[issue38941] xml.etree.ElementTree.Element inconsistent warning for bool

2019-11-29 Thread Philip Rowlands


Philip Rowlands  added the comment:

It's easier to justify a change in behaviour if the warning is emitted. With no 
legacy concerns, I would be happy for bool() to change, but I'm not the one who 
would receive the grumbly tickets.

How about emitting the warning in the next release, then assessing the 
behaviour change for version n+2?

--

___
Python tracker 

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



[issue38936] fatal error during installation 0x80070643 during python installation

2019-11-29 Thread Steve Dower


Steve Dower  added the comment:

It looks like you had a previous install that wasn't cleaned up properly (all 
the packages are still registered). Any idea what may have caused that?

The easiest workaround will be to use Programs and Features to find and repair 
the previous install ("Modify" in P&F and then "Repair" in the Python 
installer). You might be able to skip straight to Uninstall here, but sometimes 
that won't work without repairing first. After you've repaired it, your 
install/upgrade should be okay.

--

___
Python tracker 

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



[issue38939] Using Python as a Calculator

2019-11-29 Thread Brett Cannon


Brett Cannon  added the comment:

If you're using Python 2.7 then that would explain what you're seeing. You can 
either upgrade to Python 3 or use `from __future__ import division` to get the 
result you're after.

--
nosy: +brett.cannon
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



[issue38940] Add a new functools.cast() function

2019-11-29 Thread Brett Cannon


Brett Cannon  added the comment:

First off, thanks for the suggestion!

But there are two things to say about this. One, that isn't actually casting as 
Python doesn't have the concept of casting like in statically typed languages 
since everything is dynamically typed.

Two, the solution is so short and simple but not widely needed enough that I 
don't think this warrants addition in the stdlib. And since you're changing 
what the function returns you probably need a new docstring anyway, which means 
having to do a normal wrapping of the function.

So thanks for the idea but I don't think we will be adding this to the stdlib 
(obviously feel free to put this up on PyPI or as a gist somewhere and share it 
in a blog post or something.

--
nosy: +brett.cannon
resolution:  -> rejected
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



[issue35003] Provide an option to venv to put files in a bin/ directory on Windows

2019-11-29 Thread Brett Cannon

Brett Cannon  added the comment:

> Surely "on native Windows you run venv-path\Scripts\activate[.ps1], on POSIX 
> you use source venv-path/bin/activate" isn't *that* hard for new users to 
> grok, and would cover the vast majority of users?

Sure, but how many times do we need to make people type, write, or say that 
exact line instead of a single line of "you activate by doing "?

> So venv’s setup is consistent with the rest of Python.

Right, it's a Python-on-Windows thing, not a Windows thing itself to my 
knowledge.

> I think Brett is thinking about eliminating the manual activate part entirely

I'm actually after a single command to handle activation of a virtual 
environment. It's a point of friction on your first day of learning Python and 
I have seen it solved multiple times at this point by multiple tools. This 
seemed like a potential simple way to solve it to me, but apparently not 
everyone agrees. ;)

Now I realize that if we don't worry about the prompt changing it's actually 
very straight-forward, and so maybe proposing a simple `venv --activate ` 
that does nothing more than set those key environment variables and prints out 
a message about what is happening is enough to do the trick (and if people want 
the prompt to change they can tweak their shell configs to detect something 
like `__VENV_PROMPT__` being set and use it appropriately).

> Of course, scripts installed in venvs never need activation to run

Sure, but then that doesn't mean activation isn't convenient. :) Otherwise what 
is the point of having the activation scripts?

--

___
Python tracker 

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



[issue38924] pathlib paths .normalize()

2019-11-29 Thread Brett Cannon


Brett Cannon  added the comment:

> From my experience in the past the intention has been to keep the API minimal

Correct, all of os.path and shutils does not need to end up in pathlib. :) 
Hence why the request to add things is always tough as we have to try and 
strike a balance of useful but not overwhelming/overdone (and what is "useful" 
varies from person to person).

> It is nice that normpath _accepts_ pathlike objects, but it should then not 
> return a generic str. It should try to return an object of the same type.

It's an interesting idea, but it's also difficult to get right, even with 
assumptions as things that represent a path are nowhere near as unified as 
dates. There would also be a ton of converting back and forth in os.path as 
functions call other functions to get the path, manipulate it, and then wrap it 
back up.

But if someone can come up with a concrete proposal with some example 
implementation and brings it to python-ideas it could be discussed.

--

___
Python tracker 

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



[issue17068] peephole optimization for constant strings

2019-11-29 Thread Batuhan


Batuhan  added the comment:

I think this operation is more suitable for AST optimizer then peephole but i'm 
still not sure if such a conversion gains anything compared to usage of old 
type string formattings.

--
nosy: +BTaskaya

___
Python tracker 

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



[issue38942] Possible assertion failures in csv.Dialect()

2019-11-29 Thread Zackery Spytz


New submission from Zackery Spytz :

dialect_new() in Modules/_csv.c calls PyObject_GetAttrString() repeatedly 
without
checking if an error occurred. If an exception (like MemoryError) is raised 
during one of the
PyObject_GetAttrString() calls, an assertion failure will occur during the next 
call.

--
components: Extension Modules
messages: 357652
nosy: ZackerySpytz
priority: normal
severity: normal
status: open
title: Possible assertion failures in csv.Dialect()
type: crash
versions: Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



[issue38942] Possible assertion failures in csv.Dialect()

2019-11-29 Thread Zackery Spytz


Change by Zackery Spytz :


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

___
Python tracker 

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



[issue38924] pathlib paths .normalize()

2019-11-29 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

There were reasons why something like PurePath.normalize() was not added at 
first place. os.path.normpath() is broken by design. It does not work as you 
expect in case when the .. component is preceeded by a symlink. Its behvior can 
lead to bugs and maybe even security issues. We did not want to add something 
so dubious in the pathlib module. Path.resolve() is the correct way.

So I suggest to close this issue.

--

___
Python tracker 

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



[issue38943] Idle autocomplete window doesn't show up

2019-11-29 Thread JohnnyNajera


New submission from JohnnyNajera :

In Ubuntu 19.10 and probably earlier versions of Ubuntu, the autocomplete 
window  doesn't show up when expected. This is probably due to wm_geometry 
called in a context in which it has no effect.

--
assignee: terry.reedy
components: IDLE
messages: 357654
nosy: JohnnyNajera, terry.reedy
priority: normal
severity: normal
status: open
title: Idle autocomplete window doesn't show up
type: behavior
versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



[issue38943] Idle autocomplete window doesn't show up

2019-11-29 Thread JohnnyNajera


Change by JohnnyNajera :


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

___
Python tracker 

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



[issue38902] image/webp support in mimetypes

2019-11-29 Thread Florian Dahlitz


Change by Florian Dahlitz :


--
nosy: +DahlitzFlorian

___
Python tracker 

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



[issue35003] Provide an option to venv to put files in a bin/ directory on Windows

2019-11-29 Thread Vinay Sajip


Vinay Sajip  added the comment:

> so maybe proposing a simple `venv --activate ` that does nothing more 
> than set those key environment variables

If venv is run in a child process of the shell, how does it set those variables 
in the parent shell? I thought that wasn't possible (on POSIX, anyway), which 
is why e.g. pew spawns a subshell.

> Sure, but then that doesn't mean activation isn't convenient

Indeed it is. But many less experienced users think that it's always a 
necessary step, when it isn't always so.

--

___
Python tracker 

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



[issue38943] Idle autocomplete window doesn't show up

2019-11-29 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

IDLE completes global names, attributes, and file names with various invocation 
methods.  The main problem users have in editor windows is not running the 
module to update namespaces.  But the claim here (and in the PR) is that there 
is a timing problem. 

JN,  please post at least one minimal, specific, sometimes reproducible 
example, with code and user actions, that misbehaves.  Do you have any idea why 
a 1 millesecond delay helps?

(3.5 and 3.6 only get security fixes.)

--
nosy: +taleinat
versions:  -Python 3.5, Python 3.6

___
Python tracker 

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



[issue17068] peephole optimization for constant strings

2019-11-29 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
priority: normal -> low
versions: +Python 3.9 -Python 3.4

___
Python tracker 

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