[issue35993] incorrect use of released memory in Python/pystate.c line 284

2019-02-13 Thread Stéphane Wirtel

Change by Stéphane Wirtel :


--
assignee:  -> matrixise
nosy: +matrixise

___
Python tracker 

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



[issue35991] potential double free in Modules/_randommodule.c line 295 and line 317

2019-02-13 Thread miss-islington


Change by miss-islington :


--
pull_requests: +11883

___
Python tracker 

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



[issue35991] potential double free in Modules/_randommodule.c line 295 and line 317

2019-02-13 Thread Benjamin Peterson


Benjamin Peterson  added the comment:


New changeset bb3c05d7efca8d23bf39bc2640297ba2598899f3 by Benjamin Peterson 
(Zackery Spytz) in branch 'master':
closes bpo-35991: Fix a potential double free in Modules/_randommodule.c. 
(GH-11849)
https://github.com/python/cpython/commit/bb3c05d7efca8d23bf39bc2640297ba2598899f3


--
nosy: +benjamin.peterson
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



[issue35994] In WalkTests of test_os.py, sub2_tree missed the dir "SUB21" if symlink can't be supported.

2019-02-13 Thread Peixing Xin


New submission from Peixing Xin :

Looking into the setUp method of WalkTests class in test_os.py, sub2_tree 
missed "SUB21" in its directory list if support.can_symlink() returns False.

--
components: Tests
messages: 335505
nosy: pxinwr
priority: normal
severity: normal
status: open
title: In WalkTests of test_os.py, sub2_tree missed the dir "SUB21" if symlink 
can't be supported.
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



[issue35155] Clarify Protocol Handlers in urllib.request Docs

2019-02-13 Thread Denton Liu


Denton Liu  added the comment:

Unfortunately, inline markup can't be combined with roles. Using asterisks, it 
shows up as `**_open()` and using braces, `{}_open`.

I'm not sure how this works but it _might_ be possible to change how :meth: 
role is interpreted but I believe that's outside the scope of this change.

--

___
Python tracker 

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



[issue23460] Decimals do not obey ':g' exponential notation formatting rules

2019-02-13 Thread Brennan D Baraban


Brennan D Baraban <3...@holbertonschool.com> added the comment:

I submitted a PR just now. I only pushed the change to `string.rst`, as per 
Stefan Krah's suggestion.

--

___
Python tracker 

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



Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread ast

Le 13/02/2019 à 14:21, ast a écrit :

Hello

 >>> float('Nan') == float('Nan')
False

Why ?

Regards



Thank you for answers.

If you wonder how I was trapped with it, here
is the failing program.


r = float('Nan')

while r==float('Nan'):
inp = input("Enter a number\n")
try:
r = float(inp)
except ValueError:
r = float('Nan')
--
https://mail.python.org/mailman/listinfo/python-list


[issue23460] Decimals do not obey ':g' exponential notation formatting rules

2019-02-13 Thread Brennan D Baraban


Change by Brennan D Baraban <3...@holbertonschool.com>:


--
pull_requests: +11881
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



[issue35991] potential double free in Modules/_randommodule.c line 295 and line 317

2019-02-13 Thread Zackery Spytz


Change by Zackery Spytz :


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

___
Python tracker 

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



[issue35993] incorrect use of released memory in Python/pystate.c line 284

2019-02-13 Thread wangjiangqiang


New submission from wangjiangqiang <767563...@qq.com>:

the code is trying to visit a link list in a loop, it tries to visit the next 
node in line 284 "interp = interp->next" while the current node is freed in 
line 296 "PyMem_RawFree(interp);"

--

___
Python tracker 

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



[issue35899] '_is_sunder' function in 'enum' module fails on empty string

2019-02-13 Thread Brennan D Baraban

Brennan D Baraban <3...@holbertonschool.com> added the comment:

Thank you, Stéphane. I submitted a change request to your PR just now.

--

___
Python tracker 

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



[issue35991] potential double free in Modules/_randommodule.c line 295 and line 317

2019-02-13 Thread wangjiangqiang


wangjiangqiang <767563...@qq.com> added the comment:

line 295 calls PyMem_Free(key),then "key" was freed again in line 317 which 
causes the bug.

--

___
Python tracker 

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



[issue35992] Metaclasses interfere with __class_getitem__

2019-02-13 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +levkivskyi

___
Python tracker 

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



[issue35993] incorrect use of released memory in Python/pystate.c line 284

2019-02-13 Thread wangjiangqiang


Change by wangjiangqiang <767563...@qq.com>:


--
nosy: wjq-security
priority: normal
severity: normal
status: open
title: incorrect use of released memory in Python/pystate.c line 284
type: security

___
Python tracker 

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



[issue35991] potential double free in Modules/_randommodule.c line 295 and line 317

2019-02-13 Thread Karthikeyan Singaravelan


New submission from Karthikeyan Singaravelan :

Though random module doesn't receive frequent changes can you please add the 
relevant lines in the description or the relevant commit with the corresponding 
line number in the report with a description. 

On master with commit [0] line 295 calls PyMem_Free(key); and then calls goto 
Done where PyMem_Free(key); is again executed which I assume is the report.

[0] 
https://github.com/python/cpython/blob/d73ac0eba992a33992210915739d73250bf6d38d/Modules/_randommodule.c#L295

--
nosy: +mark.dickinson, rhettinger, xtreak

___
Python tracker 

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



[issue35992] Metaclasses interfere with __class_getitem__

2019-02-13 Thread Caleb Donovick


New submission from Caleb Donovick :

OS:
Debian testing

python3 -VV:
Python 3.7.2+ (default, Feb  2 2019, 14:31:48)
[gcc 8.2.0]


The following:
```
class Meta(type): pass

class X(metaclass=Meta):
def __class_getitem__(cls, key):
return key

X[10]
```
Results in 
```
TypeError: 'Meta' object does not support indexing
```

However, PEP 560 specifically states that __class_getitem__ should be used as 
fall back for when a metaclass does not implement __getitem__.

--
assignee: docs@python
components: Documentation, Interpreter Core
messages: 335497
nosy: Donovick, docs@python
priority: normal
severity: normal
status: open
title: Metaclasses interfere with __class_getitem__
type: behavior
versions: Python 3.7

___
Python tracker 

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



[issue35991] potential double free in Modules/_randommodule.c line 295 and line 317

2019-02-13 Thread wangjiangqiang


Change by wangjiangqiang <767563...@qq.com>:


--
nosy: wjq-security
priority: normal
severity: normal
status: open
title: potential double free in Modules/_randommodule.c line 295 and line 317
type: security

___
Python tracker 

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



[issue21150] Add quick links table to argparse docs

2019-02-13 Thread Susan Su


Susan Su  added the comment:

I'm available to start working on this bug. Please let me know if any 
suggestions, concerns or comments come up! Thank you.

--
nosy: +suhearsawho

___
Python tracker 

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



[issue33043] Add a 'Contributing to Docs' link at the bottom of docs.python.org

2019-02-13 Thread Susan Su


Susan Su  added the comment:

I am available to start working on this bug. Please let me know if any issues, 
concerns, or suggestions come up! Thank you.

--
nosy: +suhearsawho

___
Python tracker 

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



[issue29466] pickle does not serialize Exception __cause__ field

2019-02-13 Thread Tim Burgess


Change by Tim Burgess :


--
nosy: +tjb900

___
Python tracker 

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



[issue35155] Clarify Protocol Handlers in urllib.request Docs

2019-02-13 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

For file names, the result is  in italics.  Looking at 
https://devguide.python.org/exploring/, that seems to work well.  Can we just 
use **?

--

___
Python tracker 

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



[issue35132] python-gdb error: Python Exception Type does not have a target

2019-02-13 Thread Lisa Roach


Change by Lisa Roach :


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

___
Python tracker 

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



[issue35962] Slight error in words in [ 2.4.1. String and Bytes literals ]

2019-02-13 Thread Lisa Roach


Lisa Roach  added the comment:

The updated line sounds good to me, please make a PR.

--
nosy: +lisroach

___
Python tracker 

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



[issue21150] Add quick links table to argparse docs

2019-02-13 Thread Lisa Roach


Lisa Roach  added the comment:

It looks like @louielu might not be around anymore to finish this PR? If there 
are no objections I'd like to give a new contributor @suhearsawho a shot at 
this.

--
nosy: +lisroach

___
Python tracker 

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



[issue35500] Align expected and actual calls on mock.assert_called_with error message

2019-02-13 Thread Lisa Roach


Lisa Roach  added the comment:


New changeset 2bdd5858e3f89555c8de73a0f307d63536129dbd by Lisa Roach (Susan Su) 
in branch 'master':
bpo-35500: align expected and actual calls on mock.assert_called_with error 
message. (GH-11804)
https://github.com/python/cpython/commit/2bdd5858e3f89555c8de73a0f307d63536129dbd


--
nosy: +lisroach

___
Python tracker 

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



[issue35155] Clarify Protocol Handlers in urllib.request Docs

2019-02-13 Thread Denton Liu


Denton Liu  added the comment:

I gave that a try but it seems like it just outputs the {} literally in the
case of the method role.

--

___
Python tracker 

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



[issue35920] Windows 10 ARM32 platform support

2019-02-13 Thread Steve Dower


Steve Dower  added the comment:

Issue35976 was broken out for the more mechanical changes.

--

___
Python tracker 

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



Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Joe Pfeiffer
u...@speedy.net writes:

> There are more integers than odd numbers, and more odd numbers than prime
> numbers. An infinite set may be a subset of another infinite set although
> they may both have the same cardinality. Or in other words, the number of
> elements in each set is not equal. One has more elements than the other.
> AND, by induction you can also prove that the other one has more elements
> than the first one. So the number of elements in two infinite sets can't be
> equal. Even, if you compare the same set to itself.

You would expect that to be true, but it is not.  There are in fact the
same number of odd integers as integers, and the same number of primes
as integers.  Counterintuitive but true.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue1054041] Python doesn't exit with proper resultcode on SIGINT

2019-02-13 Thread Eryk Sun


Eryk Sun  added the comment:

For Windows, the default console control handler calls 
ExitProcess(STATUS_CONTROL_C_EXIT). If CMD is waiting on an application that 
exits with STATUS_CONTROL_C_EXIT, it prints "^C" to indicate the process was 
killed by Ctrl+C. For example:

>>> STATUS_CONTROL_C_EXIT = 0xC13A - 2**32
>>> STATUS_CONTROL_C_EXIT
-1073741510
>>> sys.exit(STATUS_CONTROL_C_EXIT)
^C

C:\>echo %errorlevel%
-1073741510

Note that switching to SIG_DFL with raise(SIGINT) does not invoke the default 
console control handler in Windows. It just invokes the default raise() 
behavior, which is to call _exit(3). This exit status value of 3 is arbitrary 
and meaningless.

--
nosy: +eryksun

___
Python tracker 

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



Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Joe Pfeiffer
songbird  writes:

> Chris Angelico wrote:
>> On Thu, Feb 14, 2019 at 7:12 AM Test Bot  wrote:
>>>
>>> This definition of NaN is much better in mentally visualizing all the so
>>> called bizarreness of IEEE. This also makes intuitive that no 2 NaN will be
>>> equal just as no 2 infinities would be equal. I believe in a hypothesis(of
>>> my own creation) that any arithmetic on a data type of NaN would be similar
>>> to any set of operations on the set of Infinities.
>>>
>>
>> Why would no two infinities be equal? In mathematics, there's one
>> best-known infinity (aleph null, aka the number of counting numbers),
>> and many many infinities are provably equal to it. (Others are
>> provably NOT equal to it, like the number of real numbers.) There's
>> nothing wrong with saying "there are as many prime numbers as there
>> are odd numbers", or equivalently that "the size/cardinality of the
>> set of primes is equal to the size of the set of odd numbers" [1]. And
>> both Python and IEEE agree:
> ...
>> [1] I'm sure someone will point out something pedantically wrong in
>> what I said, but certainly the sets have the same cardinality.
>
>   all such proofs i have ever seen are based upon the 
> assumptions that there are infinite numbers of such
> things like primes.
>
>   this only makes sense in theory.
>
>   alas, we don't really know if the universe is infinitely
> subdivisible (as the reals seem to represent) or infinitely
> large (even if it isn't infinitely subdivisible)...  so to
> me every one of those proofs is conditional upon assumptions
> (which also drags the p = np question into such assumptions).
>
>   it's fun to think about.  :)

It doesn't depend upon assumptions, it depends on definitions and
logic.  You don't need to assume there are an infinite number of primes,
it's been proven.  It doesn't matter whether the universe is infinitely
subdivisible or infinitely large, the set of real number is (assuming
I'm interpreting your "subdivisible" correctly).  I've got no idea what
P and NP have to do with this.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue35155] Clarify Protocol Handlers in urllib.request Docs

2019-02-13 Thread Cheryl Sabella


Cheryl Sabella  added the comment:

I found this issue that Serhiy did on the devguide where he added {} around the 
placeholder:
https://github.com/python/devguide/pull/444

I think that might be the correct way to do it.

--

___
Python tracker 

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



[issue35899] '_is_sunder' function in 'enum' module fails on empty string

2019-02-13 Thread Cheryl Sabella


Change by Cheryl Sabella :


--
Removed message: https://bugs.python.org/msg335483

___
Python tracker 

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



[issue35927] Intra-package References Documentation Incomplete

2019-02-13 Thread ADataGman


ADataGman  added the comment:

Terry, thank you for the detailed list of alternatives on how to approach
this, that's helpful in how to tackle this issue in my current development.

Nick, for the relative imports of relative imports I think the error
message is fine. It makes sense. It doesn't necessarily give you a lot of
hints on where to go next unfortunately, but it does explain why it doesn't
work.

For the absolute imports, a hint like, the module must be discoverable in
sys.path or the like if you wanted to make this clearer.

My biggest concern was just that the way the documentation is written for
https://docs.python.org/3.6/tutorial/modules.html#intra-package-references
. It implies that the code will run without any hint of needing to be
either run from a higher level, or a work around used like Terry suggested.
Now that I've spent a few days researching and reading more on my own, and
with help from you and Terry, I understand what's happening and have
options. But for others just reading the docs and not already familiar,
it's not clear why the current example wouldn't work when run from the
sibling level.

I'd like to see the documentation for intra-package references updated to
clearly state that the code is being run from a level above. "For example,
if the module sound.filters.vocoder needs to use the echo module in the
sound.effects package, it can use from sound.effects import echo." only
works if you run it from the sound module. Which is fine! It's just not
clear to a newb that it's being executed from the sound package rather than
the filters package. Perhaps modify
https://docs.python.org/3.6/tutorial/modules.html#packages to include a
"sound.py" at the top level folder, and in the explanation for the
intra-package reference, just mention that the example quoted above runs
from that new file.

If there is a optimal way to modify the path for adding in a sibling level
package, please include that. Otherwise just clarify that the example
relies on the code being run from something from another level up.

On Tue, Feb 12, 2019 at 11:35 PM Terry J. Reedy 
wrote:

>
> Terry J. Reedy  added the comment:
>
> AData> You log and output show that you problem is as described: package
> 'sound' is in directory "C:/" and "C:/" is not is sys.path.  Possible
> remedies:
> 1. Add "C:/" to sys.path at the top of each module that imports sound.
> This is a nuisance.
> 2. Move the sound package to
> 'C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages'.
> This can also a nuisance.
> 3. Add a file named 'C.pth' and containing "C:/" to the site-packages.
> ('pth' abbreviates 'path'.)  This makes C:/ an extension of site-packages.
> But all the non-python stuff in C: likely makes this a bad idea.
> 4 (3 improved). Add a directory such as "C:/pyprojects", make the contents
> of the .pth file "C:/pyprojects", and move sound to pyprojects.
> This is what I have done.  When I install a new version of Python, I copy
> the .pth file to the new site-packeges directory.  Works great.
>
> --
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Chris Angelico
On Thu, Feb 14, 2019 at 11:01 AM songbird  wrote:
>   all such proofs i have ever seen are based upon the
> assumptions that there are infinite numbers of such
> things like primes.

I posted an abbreviated proof of that in a footnote. It's a proof by
contradiction. First, assume that there are, in fact, a finite number
of primes. If that's the case, then all primes must be integers
between 2 and some number p, the highest prime. Take the product of
all primes - call it x. When you take the product of positive
integers, the result must always be at least as large as any of the
factors, so x >= p. Also, x must be a multiple of every prime, which
in turn means that x+1 cannot possibly be a multiple of any such
prime. Thus the value x+1 must either be prime, or be the product of
prime numbers that aren't in your collection of primes; therefore the
collection of primes cannot possibly be complete. Therefore there are
indeed an infinite number of primes.

So it's not an assumption; it's a proven point.

The subdividability of the universe is actually irrelevant. Perhaps
the universe, at some level, becomes indivisible; but numbers don't.
For any two non-equal real numbers, it is always possible to find
another number in between them. (This is NOT true of floating-point
numbers or any other fixed-size representation.) Numbers are actually
extremely convenient like that.

This is largely off-topic for Python, but do consider: thanks to
bignum integers and the Fraction type, we can represent any rational
number, assuming we have enough storage space. Or do we.

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


Re: Best way to remove unused pip installed modules/module dependencies from a virtual env?

2019-02-13 Thread Malcolm Greene
[Reformatted as original post got mangled]

Looking for advice on the best way to remove unused modules from a Python 
virtual environment. My setup is Python 3.6.6 running on macOS although I 
believe my use case is OS independent.

Background: Long running project that, over the course of time, pip installed 
modules that are no longer used by the code. I'm looking for a way to identity 
unused modules and remove them. 

Here's my back-of-napkin strategy to do this. Wondering if there are holes in 
this approach or if there's an off-the-shelf solution for
my use case?

1. pip freeze > modules.txt

2. build a list of all import statements, extract out module names

3. remove these module names from modules.txt and add to used-modules.txt

4. modules that remain in modules.txt are either module dependencies of 
directly imported modules or no longer used

5. remove my virtual env and recreate it again to start with a fresh env

6. reinstall each directly imported module (from list in used-modules.txt); 
this will pull in dependencies again

7. pip freeze > requirements.txt <--- this should be the exact modules used by 
our code

Thank you,
Malcolm
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue1054041] Python doesn't exit with proper resultcode on SIGINT

2019-02-13 Thread Gregory P. Smith


Gregory P. Smith  added the comment:

I expect that'll work as desired and avoids the re-raising of the signal.

Unless told otherwise I assume this should be a POSIX specific platform 
behavior.  ie: no return value alteration due to an uncaught KeyboardInterrupt 
on the Windows API build.

--

___
Python tracker 

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



[issue22213] Make pyvenv style virtual environments easier to configure when embedding Python

2019-02-13 Thread Steve Dower


Steve Dower  added the comment:

Thanks, Victor, that's great information.

> Memory allocator, context, different structures for configuration... it's 
> really not an easy topic :-( There are so many constraints put into a single 
> API!

This is why I'm keen to design the ideal *user* API first (that is, write the 
examples of how you would use it) and then figure out how we can make it fit. 
It's kind of the opposite approach from what you've been doing to adapt the 
existing code to suit particular needs.

For example, imagine instead of all the PySet*() functions followed by 
Py_Initialize() you could do this:

PyObject *runtime = PyRuntime_Create();
/* optional calls */
PyRuntime_SetAllocators(runtime, _malloc, _realloc, _free);
PyRuntime_SetHashSeed(runtime, 12345);

/* sets this as the current runtime via a thread local */
auto old_runtime = PyRuntime_Activate(runtime);
assert(old_runtime == NULL)

/* pretend triple quoting works in C for a minute ;) */
const char *init = """
import os.path
import sys

sys.executable = argv0
sys.prefix = os.path.dirname(argv0)
sys.path = [os.getcwd(), sys.prefix, os.path.join(sys.prefix, "Lib")]

pyvenv = os.path.join(sys.prefix, "pyvenv.cfg")
try:
with open(pyvenv, "r", encoding="utf-8") as f:  # *only* utf-8 support 
at this stage
for line in f:
if line.startswith("home"):
sys.path.append(line.partition("=")[2].strip())
break
except FileNotFoundError:
pass

if sys.platform == "win32":
sys.stdout = open("CONOUT$", "w", encoding="utf-8")
else:
# no idea if this is right, but you get the idea
sys.stdout = open("/dev/tty", "w", encoding="utf-8")
""";

PyObject *globals = PyDict_New();
/* only UTF-8 support at this stage */
PyDict_SetItemString(globals, "argv0", PyUnicode_FromString(argv[0]));
PyRuntime_Initialize(runtime, init_code, globals);
Py_DECREF(globals);

/* now we've initialised, loading codecs will succeed if we can find them 
or fail if not,
 * so we'd have to do cleanup to avoid depending on them without the user 
being able to
 * avoid it... */

PyEval_EvalString("open('file.txt', 'w', encoding='gb18030').close()");

/* may as well reuse DECREF for consistency */
Py_DECREF(runtime);

Maybe it's a terrible idea? Honestly I'd be inclined to do other big changes at 
the same time (make PyObject opaque and interface driven, for example).

My point is that if the goal is to "move the existing internals around" then 
that's all we'll ever achieve. If we can say "the goal is to make this example 
work" then we'll be able to do much more.

--

___
Python tracker 

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



[issue35899] '_is_sunder' function in 'enum' module fails on empty string

2019-02-13 Thread Cheryl Sabella


Cheryl Sabella  added the comment:

I found this issue that Serhiy did on the devguide where he added {} around the 
placeholder:
https://github.com/python/devguide/pull/444

I think that might be the correct way to do it.

--

___
Python tracker 

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



[issue1054041] Python doesn't exit with proper resultcode on SIGINT

2019-02-13 Thread STINNER Victor


STINNER Victor  added the comment:

> A question that leads to is what _is_ the correct value.

What do you think of using a short test program (ex: uses raise(SIGINT)) in 
./configure to get the "default exit code" to define a constant, and then use 
the constant for exit() in Python?

I dislike the idea of raising signals in general. The exact behavior of signals 
depends too much on the OS, it's hard to get it right. But having a 
configurable exit code looks safe and simple enough.

--

___
Python tracker 

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



[issue1054041] Python doesn't exit with proper resultcode on SIGINT

2019-02-13 Thread Gregory P. Smith


Change by Gregory P. Smith :


--
stage: patch review -> needs patch

___
Python tracker 

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



Best way to remove unused pip installed modules/module dependencies from a virtual env?

2019-02-13 Thread Malcolm Greene
Looking for advice on the best way to remove unused modules from a
Python virtual environment. My setup is Python 3.6.6 running on macOS
although I believe my use case is OS independent.
Background: Long running project that, over the course of time, pip installed 
modules that are no longer used by the code. I'm looking for a way to identity 
unused modules and remove them. 
Here's my back-of-napkin strategy to do this. Wondering if there are
holes in this approach or if there's an off-the-shelf solution for
my use case?
1. pip freeze > modules.txt
2. build a list of all import statements, extract out module names
3. remove these module names from modules.txt and add to used-
   modules.txt4. modules that remain in modules.txt are either module 
dependencies of
   directly imported modules or no longer used5. remove my virtual env and 
recreate it again to start with a fresh env6. reinstall each directly imported 
module (from list in used-
   modules.txt); this will pull in dependencies again7. pip freeze > 
requirements.txt <--- this should be the exact modules
   used by our code
Thank you,
Malcolm
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread songbird
Chris Angelico wrote:
> On Thu, Feb 14, 2019 at 7:12 AM Test Bot  wrote:
>>
>> This definition of NaN is much better in mentally visualizing all the so
>> called bizarreness of IEEE. This also makes intuitive that no 2 NaN will be
>> equal just as no 2 infinities would be equal. I believe in a hypothesis(of
>> my own creation) that any arithmetic on a data type of NaN would be similar
>> to any set of operations on the set of Infinities.
>>
>
> Why would no two infinities be equal? In mathematics, there's one
> best-known infinity (aleph null, aka the number of counting numbers),
> and many many infinities are provably equal to it. (Others are
> provably NOT equal to it, like the number of real numbers.) There's
> nothing wrong with saying "there are as many prime numbers as there
> are odd numbers", or equivalently that "the size/cardinality of the
> set of primes is equal to the size of the set of odd numbers" [1]. And
> both Python and IEEE agree:
...
> [1] I'm sure someone will point out something pedantically wrong in
> what I said, but certainly the sets have the same cardinality.

  all such proofs i have ever seen are based upon the 
assumptions that there are infinite numbers of such
things like primes.

  this only makes sense in theory.

  alas, we don't really know if the universe is infinitely
subdivisible (as the reals seem to represent) or infinitely
large (even if it isn't infinitely subdivisible)...  so to
me every one of those proofs is conditional upon assumptions
(which also drags the p = np question into such assumptions).

  it's fun to think about.  :)


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


[issue1054041] Python doesn't exit with proper resultcode on SIGINT

2019-02-13 Thread Gregory P. Smith


Gregory P. Smith  added the comment:

Taking a renewed look at this 8 years later... I agree, re-triggering the 
signal with the SIG_DFL handler would prevent us from doing the existing 
interpreter shutdown cleanup if we did it too early which would be a behavior 
change other than the exit value correction.

So we should delay the re-signaling kill(getpid(), SIGINT) call until we've 
completed that and are about to exit anyways.

The code has moved around a lot since i generated this patch on a 3.2-ish tree 
so it'll take me a while to untangle what would need to go where to create a PR.

Instead of kill(getpid(), SIGINT) or raise(SIGINT), we could just checking the 
_UnhandledKeyboardInterrupt flag we return our exit valye adjusting it to be 
the one a calling shell may be expecting to indicate a SIGINT.  That goes 
against the advice of https://www.cons.org/cracauer/sigint.html but is likely 
to work.

A question that leads to is what _is_ the correct value.  On Linux the magic 
130 happens to be (SIGINT + 128).  Triggering the libc or kernel supplied 
SIG_DFL handler as a final act avoids us ever needing to know what possible 
mechanisms to indicate this to the parent process are preferred on a platform.  
(if we know it is merely an exit value we could capture that in to a #define 
with a configure.ac check if the + 128 trick were deemed too magical despite 
being what everyone likely implements, standardized or not)

--

___
Python tracker 

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



[issue1054041] Python doesn't exit with proper resultcode on SIGINT

2019-02-13 Thread Gregory P. Smith


Change by Gregory P. Smith :


--
versions: +Python 3.8 -Python 3.3

___
Python tracker 

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



[issue35887] Doc string for updating the frozen version of importlib in _bootstrap.py incorrect

2019-02-13 Thread Brett Cannon


Brett Cannon  added the comment:


New changeset 1dc5cb9cb3447211069a7788208254b1cfa8ec98 by Brett Cannon (Nina 
Zakharenko) in branch 'master':
bpo-35887: Add make regen-importlib step to importlib._bootstrap docstring 
(GH-11777)
https://github.com/python/cpython/commit/1dc5cb9cb3447211069a7788208254b1cfa8ec98


--
nosy: +brett.cannon

___
Python tracker 

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



What's up with Activestate Python?

2019-02-13 Thread Grant Edwards
For many, many years I've always installed ActiveState's ActivePython
Community edition when forced to use Windows.  It has always included
all of the "extra" libraries that I didn't wan't to install (or
couldn't because I didn't have a C compiler for Windows).

I recently decided to upgrade my Win7 machine from ActivePython 3.5.4
to 3.6.

... and all of apps stopped working.  ActivePython 3.6 appears to be a
minimal install that includes nothing but CPython.  Comparing the
download sizes makes this obvious:

-rw-r--r-- 1 grante users 223056832 Mar 26  2018 
ActivePython-2.7.14.2717-win64-x64-404905.exe
-rw-r--r-- 1 grante users 225065576 May 29  2018 
ActivePython-3.5.4.3504-win64-x64-404899.exe
-rw-r--r-- 1 grante users  30297136 Feb 13 16:28 
ActivePython-3.6.0.3600-win64-x64-401834.exe

I've searched the ActiveState web site, and the fact that they've
stopped including "extra" libraries doesn't seem to be documented
anywhere.

I guess it's time to switch to Anaconda or ???

-- 
Grant Edwards   grant.b.edwardsYow! Is this going to
  at   involve RAW human ecstasy?
  gmail.com

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


[issue22213] Make pyvenv style virtual environments easier to configure when embedding Python

2019-02-13 Thread STINNER Victor


STINNER Victor  added the comment:

> It seems that the disagreement about the design is fundamentally a 
> disagreement between a "quick, painful but complete fix" and "slow, careful 
> improvements with a transition period". Both are valid approaches, and since 
> Victor is putting actual effort in right now he gets to "win", but I do think 
> we can afford to move faster.

Technically, the API already exists and is exposed as a private API:

* "_PyCoreConfig" structure
* "_PyInitError _Py_InitializeFromConfig(const _PyCoreConfig *config)" function
* "void _Py_FatalInitError(_PyInitError err)" function (should be called on 
failure)

I'm not really sure of the benefit compared to the current initialization API 
using Py_xxx global configuration variables (ex: Py_IgnoreEnvironmentFlag) and 
Py_Initialize().

_PyCoreConfig basically exposed *all* input parameters used to initialize 
Python, much more than jsut global configuration variables and the few function 
that can be called before Py_Initialize():
https://docs.python.org/dev/c-api/init.html


> Currently PEP 432 is the best description we have, and it looks like Victor 
> has been heading in that direction too (deliberately? I don't know :) ).

Well, it's a strange story. At the beginning, I had a very simple use case... 
it took me more or less one year to implement it :-) My use case was to add... 
a new -X utf8 command line option:

* parsing the command line requires to decode bytes using an encoding
* the encoding depends on the locale, environment variable and options on the 
command line
* environment variables depend on the command line (-E option)

If the utf8 mode is enabled (PEP 540), the encoding must be set to UTF-8, all 
configuration must be removed and the whole configuration (env vars, cmdline, 
etc.) must be read again from scratch :-)

To be able to do that, I had to collect *every single* thing which has an 
impact on the Python initialization: all things that I moved into _PyCoreConfig.

... but I didn't want to break the backward compatibility, so I had to keep 
support for Py_xxx global configuration variables... and also the few 
initialization functions like Py_SetPath() or Py_SetStandardStreamEncoding().

Later it becomes very dark, my goal became very unclear and I looked at the PEP 
432 :-)

Well, I wanted to expose _PyCoreConfig somehow, so I looked at the PEP 432 to 
see how it can be exposed.


> By necessity, it touches a lot of people's contributions to Python, but it 
> also has the potential to seriously improve even more people's ability to 
> _use_ Python (for example, I know an app that you all would recognize the 
> name of who is working on embedding Python right now and would _love_ certain 
> parts of this side of things to be improved).

_PyCoreConfig "API" makes some things way simpler. Maybe it was already 
possible to do them previously but it was really hard, or maybe it was just not 
possible.

If a _PyCoreConfig field is set: it has the priority over any other way to 
initialize the field. _PyCoreConfig has the highest prioririty.

For example, _PyCoreConfig allows to completely ignore the code which computes 
sys.path (and related variables) by setting directly the "path configuration":

* nmodule_search_path, module_search_paths: list of sys.path paths
* executable: sys.executable */
* prefix: sys.prefix
* base_prefix: sys.base_prefix
* exec_prefix: sys.exec_prefix
* base_exec_prefix sys.base_exec_prefix
* (Windows only) dll_path: Windows DLL path

The code which initializes these fields is really complex. Without 
_PyCoreConfig, it's hard to make sure that these fields are properly 
initialized as an embedder would like.




> Nick, Victor, Eric, (others?) - are you interested in having a virtual 
> whiteboard session to brainstorm how the "perfect" initialization looks? And 
> probably a follow-up to brainstorm how to get there without breaking the 
> world? I don't think we're going to get to be in the same room anytime before 
> the language summit, and it would be awesome to have something concrete to 
> discuss there.

Sorry, I'm not sure of the API / structures, but when I discussed with Eric 
Snow at the latest sprint, we identified different steps in the Python 
initialization:

* only use bytes (no encoding), no access to the filesystem (not needed at this 
point)
* encoding defined, can use Unicode
* use the filesystem
* configuration converted as Python objects
* Python is fully initialized

--

Once I experimented to reorganize _PyCoreConfig and _PyMainInterpreterConfig to 
avoid redundancy: add a _PyPreConfig which contains only fields which are 
needed before _PyMainInterpreterConfig. With that change, 
_PyMainInterpreterConfig (and _PyPreConfig) *contained* _PyCoreConfig.

But it the change became very large, I wasn't sure that it was a good idea, I 
abandonned my change.

* https://github.com/python/cpython/pull/10575
* https://bugs.python.org/issue35266
* I have a more advanced 

[issue20523] global .pdbrc on windows 7 not reachable out of the box

2019-02-13 Thread Roundup Robot


Change by Roundup Robot :


--
pull_requests: +11878

___
Python tracker 

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



Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Chris Angelico
On Thu, Feb 14, 2019 at 9:07 AM Avi Gross  wrote:
> But that means that normal mathematics is warped.

Well yes. Yes, it is. That's why people think "Alice's Adventures
in Wonderland" is the result of a drug-induced dream - in actual fact,
it's the result of the Dean of Mathematics telling stories to young
children. Of course mathematics is warped.

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


Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Avi Gross

I think we should realize that Nan and NA and so on are human constructs people 
Define in programming languages. Some have subdivisions as in not an int as 
compared to not a float.

Python also has an Inf as well as a -Inf that are abstractions and not a real, 
so to speak. Number.

Mathematics is arguably a human discovery when it comes to infinities since 
Cantor but the rules are not the same. CARDINALITY is not a number. It is a 
logical range of partitions. There obviously are more integers than prime 
numbers as you count upwards to a thousand or a billion. BUT in the context of 
infinity, at the Aleph Null level, they sort of map into the same category. So 
the primes or squares or odd numbers are not equal but in the limit as you 
approach whatever infinity means, they seem effectively equal as there is 
always another.  You can sort of make a 1:1 correspondence or mapping. 

But that means that normal mathematics is warped. Double it and/or add a 
quadrillion and it remains in the same bucket.  But there are other buckets and 
everything in them is not so much the same as in some sense larger than the 
previous bucket but smaller than the next higher bucket.

The continuum hypothesis remains open as to whether there is an intermediate 
bucket you can describe between Aleph Null and Aleph one. Meaning there is no 
reasonable definition of a bucket the new infinite construct fits in while not 
fitting existing ones.

Back to python. Or is it IEEE? In type int the number can be arbitrarily large 
as long as you have enough computer memory and resources. Yet the special 
concepts of Inf and negative Inf can be compared with other ints but not 
fruitfully with Nan, right? There are helper functions you can call to ask if a 
variable is an Inf or a Nan. Doubles have size limits so anything big enough 
might as well be an Inf. I note some things like numpy use a fixed size int as 
well.

Some of the confusion may come when a language uses a concept in many ways. In 
R all an NA can mean is Not Available. Some data structures, just like a numpy 
array in python, insist on holding objects of one unified type and NA normally 
matches any such type as a placeholder. Sort of a NULL. You normally do not 
want to include an NA in calculations as it infects everything. So you often 
filter it out implicitly or explicitly. It is not necessarily an error but if 
you use it in calculating a mean, then the result is sort of an error.

You can ask if a variable is an NA as in is.na(x) which returns a Boolean. So 
to test if x and y are both NA or have the same status by both not being NA, 
use the functions. Python has similar functionality. Just don't compare the 
naked singularities to each other!


Sent from AOL Mobile Mail
On Wednesday, February 13, 2019 Chris Angelico  wrote:
On Thu, Feb 14, 2019 at 7:12 AM Test Bot  wrote:
>
> This definition of NaN is much better in mentally visualizing all the so
> called bizarreness of IEEE. This also makes intuitive that no 2 NaN will be
> equal just as no 2 infinities would be equal. I believe in a hypothesis(of
> my own creation) that any arithmetic on a data type of NaN would be similar
> to any set of operations on the set of Infinities.
>

Why would no two infinities be equal? In mathematics, there's one
best-known infinity (aleph null, aka the number of counting numbers),
and many many infinities are provably equal to it. (Others are
provably NOT equal to it, like the number of real numbers.) There's
nothing wrong with saying "there are as many prime numbers as there
are odd numbers", or equivalently that "the size/cardinality of the
set of primes is equal to the size of the set of odd numbers" [1]. And
both Python and IEEE agree:

>>> float("inf") == float("inf")
True

NaN and infinity are quite different concepts, and they behave very differently.

ChrisA

[1] I'm sure someone will point out something pedantically wrong in
what I said, but certainly the sets have the same cardinality.
-- 
https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue20523] global .pdbrc on windows 7 not reachable out of the box

2019-02-13 Thread Roundup Robot


Change by Roundup Robot :


--
pull_requests: +11877
stage:  -> patch review

___
Python tracker 

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



Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Chris Angelico
‪On Thu, Feb 14, 2019 at 8:24 AM ‫אורי‬‎  wrote:‬
> On Wed, Feb 13, 2019 at 10:20 PM Chris Angelico  wrote:
>>
>> Why would no two infinities be equal? In mathematics, there's one
>> best-known infinity (aleph null, aka the number of counting numbers),
>> and many many infinities are provably equal to it. (Others are
>> provably NOT equal to it, like the number of real numbers.) There's
>> nothing wrong with saying "there are as many prime numbers as there
>> are odd numbers", or equivalently that "the size/cardinality of the
>> set of primes is equal to the size of the set of odd numbers" [1]. And
>> both Python and IEEE agree:
>
>
> There are more integers than odd numbers, and more odd numbers than prime 
> numbers. An infinite set may be a subset of another infinite set although 
> they may both have the same cardinality. Or in other words, the number of 
> elements in each set is not equal. One has more elements than the other. AND, 
> by induction you can also prove that the other one has more elements than the 
> first one. So the number of elements in two infinite sets can't be equal. 
> Even, if you compare the same set to itself.
>

You can enumerate the odd numbers easily. The first odd number is 1,
the second odd number is 3, the third is 5, the fourth is 7, etc, etc.
Or if you want to include negative odd numbers, the first is 1, the
second is -1, the third is 3, the fourth is -3, the fifth is 5, the
sixth is -5, etc. Thus there is a clear and easy bijection between odd
numbers and counting numbers. You aren't going to run out of counting
numbers before you run out of odd numbers or vice versa.

The same is true of prime numbers. The first prime number is 2, the
second is 3, the third is 5, the fourth 7, the fifth 11, the sixth 13.
You can never "run out" of prime numbers [1], so you can enumerate
them all. Thus there's the same bijection between prime numbers and
counting numbers, and thus there are equally many.

Therefore, since you can take any odd number and find its position in
the list, and then find the same position in the list of primes, it
would be possible (albeit computationally impractical) to find the
corresponding prime number for any odd number. There are just as many
prime numbers as odd numbers.

ChrisA

[1] Proof by contradiction: if there were finitely many primes, you
could multiply them all together and add one. The result is greater
than any number on your list, and can't be a multiple of any of the
primes, ergo it's either prime, or a product of primes not on your
list. QED.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue17703] Trashcan mechanism segfault during interpreter finalization in Python 2.7.4

2019-02-13 Thread Jeroen Demeyer


Jeroen Demeyer  added the comment:

See also https://bugs.python.org/issue35983 for another trashcan-related issue.

--
nosy: +jdemeyer

___
Python tracker 

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



Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread אורי
אורי
u...@speedy.net


On Wed, Feb 13, 2019 at 10:20 PM Chris Angelico  wrote:

> On Thu, Feb 14, 2019 at 7:12 AM Test Bot  wrote:
> >
> > This definition of NaN is much better in mentally visualizing all the so
> > called bizarreness of IEEE. This also makes intuitive that no 2 NaN will
> be
> > equal just as no 2 infinities would be equal. I believe in a
> hypothesis(of
> > my own creation) that any arithmetic on a data type of NaN would be
> similar
> > to any set of operations on the set of Infinities.
> >
>
> Why would no two infinities be equal? In mathematics, there's one
> best-known infinity (aleph null, aka the number of counting numbers),
> and many many infinities are provably equal to it. (Others are
> provably NOT equal to it, like the number of real numbers.) There's
> nothing wrong with saying "there are as many prime numbers as there
> are odd numbers", or equivalently that "the size/cardinality of the
> set of primes is equal to the size of the set of odd numbers" [1]. And
> both Python and IEEE agree:
>

There are more integers than odd numbers, and more odd numbers than prime
numbers. An infinite set may be a subset of another infinite set although
they may both have the same cardinality. Or in other words, the number of
elements in each set is not equal. One has more elements than the other.
AND, by induction you can also prove that the other one has more elements
than the first one. So the number of elements in two infinite sets can't be
equal. Even, if you compare the same set to itself.


>
> >>> float("inf") == float("inf")
> True
>
> NaN and infinity are quite different concepts, and they behave very
> differently.
>
> ChrisA
>
> [1] I'm sure someone will point out something pedantically wrong in
> what I said, but certainly the sets have the same cardinality.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


How do/can I generate a PKCS#12 file the cryptography module?

2019-02-13 Thread Travis Griggs
I’m using the cryptography module (https://cryptography.io/en/latest/) to try 
and generate some cert/key/identities.

It's pretty easy using said module to generate the contents of .pem file for a 
private key:

keyPEMBytes = privateKey.private_bytes( 
encoding=serialization.Encoding.PEM,
format=serialization.PrivateFormat.TraditionalOpenSSL,
encryption_algorithm=serialization.NoEncryption())

It’s also easy to generate the contents of a .cer/.pem file for an associated 
cert:

certBytes = certificate.public_bytes(encoding=serialization.Encoding.PEM)

But I need them (and their chain) balled up on a single .p12 (PKCS12) file. 
Said module documents how to parse/consume PKCS12 formats, but nothing (that I 
can find) about how one can generate them.

My understanding of PKI stuff is hit and miss though, so maybe I'm just not 
searching the right keyword in the documentation?

I can create the .p12 file at the command line on Linux using

openssl pkcs12 -export -out myIdentity.p12 -inkey myPrivKey.pem -in 
myCert.crt -certfile myCertChain.crt

So I could just wrap calls like this with subprocess/cmd and mess with 
tempfiles/pipes. I was hoping to keep it all in memory/python though.

Is there a different python TLS library that I should be considering, that can 
do this?

(stack overflow version if you’re into the points and all that: 
https://stackoverflow.com/questions/54677841/how-do-can-i-generate-a-pkcs12-file-using-python-and-the-cryptography-module)


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


[issue35984] test__xxsubinterpreters leaked [3, 4, 3] memory blocks, sum=1

2019-02-13 Thread Alexey Izbyshev


Alexey Izbyshev  added the comment:

Thank you for your introduction about _xxsubinterpreters, Eric.

This particular leak is easy: it's right in _channel_send(). I've submitted a 
PR.

I've also done a quick scan of neighboring code, and it seems there are other 
leaks as well, e.g.:

* PyThread_free_lock() is not called at 
https://github.com/python/cpython/blob/dcb68f47f74b0cc8a1896d4a4c5a6b83c0bbeeae/Modules/_xxsubinterpretersmodule.c#L761
 (and below)

* data is not released and freed at 
https://github.com/python/cpython/blob/dcb68f47f74b0cc8a1896d4a4c5a6b83c0bbeeae/Modules/_xxsubinterpretersmodule.c#L1387

Do you think it'd make sense to go through the module to find and fix leaks? Or 
is this code in an early stage for such cleanup?

As a side note, such leaks should be easily found by static analyzers such as 
Coverity (assuming it understands CPython allocation functions like PyMem_NEW), 
so it might make sense to check out its reports on the module.

--

___
Python tracker 

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



Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Rob Gaddi

On 2/13/19 12:32 PM, Marko Rauhamaa wrote:

"Avi Gross" :


A NaN is a bit like a black hole. Anything thrown in disappears and
that is about all we know about it. No two black holes are the same
even if they seem to have the same mass, spin and charge. All they
share is that we don't know what is in them.


Then, how do you explain:

>>> float("nan") != float("nan")
True

Why's that not False?


Marko



Because IEEE-754 decided that it was non-optional that (x != y) was 
equal to not (x == y).  Which is not the case for the ordering 
operators, since ordering is inherently undefined.


In part, these decisions were made to make it possible to detect a NaN 
in C in the absence of an isnan() function.  If (x != x), then x must be 
a NaN.


--
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.
--
https://mail.python.org/mailman/listinfo/python-list


[issue35984] test__xxsubinterpreters leaked [3, 4, 3] memory blocks, sum=1

2019-02-13 Thread Alexey Izbyshev


Change by Alexey Izbyshev :


--
keywords: +patch
pull_requests: +11876
stage: test needed -> patch review

___
Python tracker 

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



[issue35983] tp_dealloc trashcan shouldn't be called for subclasses

2019-02-13 Thread Jeroen Demeyer


Jeroen Demeyer  added the comment:

NOTE: also OrderedDict currently uses trashcan hacking to work around this 
problem:

/* Call the base tp_dealloc().  Since it too uses the trashcan mechanism,
 * temporarily decrement trash_delete_nesting to prevent triggering it
 * and putting the partially deallocated object on the trashcan's
 * to-be-deleted-later list.
 */
--tstate->trash_delete_nesting;
assert(_tstate->trash_delete_nesting < PyTrash_UNWIND_LEVEL);
PyDict_Type.tp_dealloc((PyObject *)self);
++tstate->trash_delete_nesting;

So this seems to be a known problem which deserves to be fixed properly.

--

___
Python tracker 

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



[issue35989] ipaddress.IPv4Network allows prefix > 32

2019-02-13 Thread Stéphane Wirtel

Stéphane Wirtel  added the comment:

I proposed my PR but I prefer a review because in the code of ipaddress, there 
is a function for the validation of an address with the netmask. Maybe we could 
use this function and try to refactor/improve the current code.

--
nosy: +matrixise

___
Python tracker 

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



[issue35989] ipaddress.IPv4Network allows prefix > 32

2019-02-13 Thread Stéphane Wirtel

Change by Stéphane Wirtel :


--
keywords: +patch
pull_requests: +11875
stage: test needed -> patch review

___
Python tracker 

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



Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Marko Rauhamaa
"Avi Gross" :

> A NaN is a bit like a black hole. Anything thrown in disappears and
> that is about all we know about it. No two black holes are the same
> even if they seem to have the same mass, spin and charge. All they
> share is that we don't know what is in them.

Then, how do you explain:

   >>> float("nan") != float("nan")
   True

Why's that not False?


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


Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Chris Angelico
On Thu, Feb 14, 2019 at 7:12 AM Test Bot  wrote:
>
> This definition of NaN is much better in mentally visualizing all the so
> called bizarreness of IEEE. This also makes intuitive that no 2 NaN will be
> equal just as no 2 infinities would be equal. I believe in a hypothesis(of
> my own creation) that any arithmetic on a data type of NaN would be similar
> to any set of operations on the set of Infinities.
>

Why would no two infinities be equal? In mathematics, there's one
best-known infinity (aleph null, aka the number of counting numbers),
and many many infinities are provably equal to it. (Others are
provably NOT equal to it, like the number of real numbers.) There's
nothing wrong with saying "there are as many prime numbers as there
are odd numbers", or equivalently that "the size/cardinality of the
set of primes is equal to the size of the set of odd numbers" [1]. And
both Python and IEEE agree:

>>> float("inf") == float("inf")
True

NaN and infinity are quite different concepts, and they behave very differently.

ChrisA

[1] I'm sure someone will point out something pedantically wrong in
what I said, but certainly the sets have the same cardinality.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Test Bot
This definition of NaN is much better in mentally visualizing all the so
called bizarreness of IEEE. This also makes intuitive that no 2 NaN will be
equal just as no 2 infinities would be equal. I believe in a hypothesis(of
my own creation) that any arithmetic on a data type of NaN would be similar
to any set of operations on the set of Infinities.

On Thu, Feb 14, 2019, 12:33 AM Avi Gross  I won't speak for the IEEE but NOT A NUMBER does not tell you what
> something
> IS.
>
> If "Hello, World!" is not a number as in an int or a float and we throw
> away
> the content and simply call it a NaN or something and then we notice that
> an
> object that is a list of fruits is also not a number so we call it a NaN
> too, then should  they be equal?
>
> A NaN is a bit like a black hole. Anything thrown in disappears and that is
> about all we know about it. No two black holes are the same even if they
> seem to have the same mass, spin and charge. All they share is that we
> don't
> know what is in them.
>
> When variable "a" is a Nan then it is sort of a pointer to a concept. The
> pointer IS itself but the concepts may not be.
>
> -Original Message-
> From: Python-list  On
> Behalf Of Grant Edwards
> Sent: Wednesday, February 13, 2019 1:03 PM
> To: python-list@python.org
> Subject: Re: Why float('Nan') == float('Nan') is False
>
> On 2019-02-13, ast  wrote:
> > Hello
> >
> > >>> float('Nan') == float('Nan')
> > False
>
> If you think that's odd, how about this?
>
> >>> n = float('nan')
> >>> n
> nan
> >>> n is n
> True
> >>> n == n
> False
> >>>
>
> > Why ?
>
> IEEE says so.
>
> --
> Grant Edwards   grant.b.edwardsYow! Like I always say
>   at   -- nothing can beat
>   gmail.comthe BRATWURST here in
>DUSSELDORF!!
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Dan Sommers

On 2/13/19 1:53 PM, Grant Edwards wrote:


Floating point is sort of the quantum mechanics of computer science.
At first glance, it seems sort of weird.  But after you work with it a
while, it gets even worse.


Yep!  :-)
--
https://mail.python.org/mailman/listinfo/python-list


Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Chris Angelico
On Thu, Feb 14, 2019 at 6:55 AM Grant Edwards  wrote:
>
> On 2019-02-13, Schachner, Joseph  wrote:
>
> > This makes some sense because NAN is Not A Number, so any comparison
> > to a number fails.
>
> Ah, but you now seem to be conflating "comparison fails" with
> "comparison has a boolean value of False".
>
> The alternative to (nan == nan) => False is probably not (nan == nan)
> => True: it's (nan == nan) => exception.

Or (nan == nan) => nan, which is what "infections nan" would be like.
(Compare NULL.)

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


Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Chris Angelico
On Thu, Feb 14, 2019 at 6:40 AM Schachner, Joseph
 wrote:
>
> Because all comparisons with NAN return false, that's the spec.

Apart from !=, because it would be insane (I mean, even more insane
than it is) to have nan == nan be false AND nan != nan.

IEEE NAN has several purposes, including representing the concept of
"could be any number but we have no idea what", and also the concept
of "there is truly no value here". And sometimes both at once -
imagine getting per-capita statistics partitioned by age group and
postal code, and having nobody in a particular age/postcode, so you
end up with both "there is no value here" and "what do you get when
you divide zero by zero" (zero whatevers divided by zero people). So
there ARE some operations involving nan that produce real results:

>>> 1 ** nan
1.0

but as a general rule, you have to assume that nan truly isn't a number.

Oh, and if you want TRULY mind-melty fun, look into the SQL "NULL"
value, which is a value, except when it isn't. Comparisons with NULL
don't return false, they return NULL. Most of the time, if you take a
column function over a nullable column (say, taking the sum or average
of the values in a field), you just ignore any rows that are NULL; but
if *every* value is NULL, the sum is not 0, but NULL.

Now try mapping SQL's NULL to Python's float("nan"), and performing
operations on both sides.

Endless fun.

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


Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Grant Edwards
On 2019-02-13, Schachner, Joseph  wrote:

> This makes some sense because NAN is Not A Number, so any comparison
> to a number fails.

Ah, but you now seem to be conflating "comparison fails" with
"comparison has a boolean value of False".

The alternative to (nan == nan) => False is probably not (nan == nan)
=> True: it's (nan == nan) => exception.  Towards that end, the IEEE
standard provides for something called a "signalling NaN".  I'm not
aware of any Python implementations that support signalling NaNs.

Floating point is sort of the quantum mechanics of computer science.
At first glance, it seems sort of weird.  But after you work with it a
while, it gets even worse.

-- 
Grant Edwards   grant.b.edwardsYow! Jesuit priests are
  at   DATING CAREER DIPLOMATS!!
  gmail.com

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


RE: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Schachner, Joseph
Because all comparisons with NAN return false, that's the spec.  is NAN > 0? 
False.  Is NAN< 0?   False.  Is NAN == 0?  False.  Is NAN == ? False. 
So: Is NAN == NAN? False. And one more:  Is NAN < 1.0e18? False

This makes some sense because NAN is Not A Number, so any comparison to a 
number fails.

--- Joseph S. 
-Original Message-
From: ast  
Sent: Wednesday, February 13, 2019 8:21 AM
To: python-list@python.org
Subject: Why float('Nan') == float('Nan') is False

Hello

 >>> float('Nan') == float('Nan')
False

Why ?

Regards


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


Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Joe Pfeiffer
ast  writes:

> Hello
>
 float('Nan') == float('Nan')
> False
>
> Why ?
>
> Regards

Others have given the real answer -- IEEE says so, and the people who
wrote the standard are smarter than me.  All the same, this is my take
on the reason for it:  NaN is specifically a representation for "this
has no value".  The == operator compares the values of its operands;
something that has no value can't == anything, including itself.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue35990] ipaddress.IPv4Interface won't accept 2-tuple (address, mask)

2019-02-13 Thread John Florian


New submission from John Florian :

The docs say """The meaning of address is as in the constructor of IPv4Network, 
except that arbitrary host addresses are always accepted."""

However, that doesn't seem to be entirely true:

>>> tup1 = ('192.168.123.234', 24)
>>> tup2 = ('192.168.123.234', '255.255.255.0')
>>> IPv4Network(tup1, strict=False)
IPv4Network('192.168.123.0/24')
>>> IPv4Network(tup2, strict=False)
IPv4Network('192.168.123.0/24')
>>> IPv4Interface(tup1)
IPv4Interface('192.168.123.234/24')
>>> IPv4Interface(tup2)
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib64/python3.7/ipaddress.py", line 1391, in __init__
self._prefixlen = int(address[1])
ValueError: invalid literal for int() with base 10: '255.255.255.0'

--
messages: 335474
nosy: John Florian
priority: normal
severity: normal
status: open
title: ipaddress.IPv4Interface won't accept 2-tuple (address, mask)
versions: Python 3.7

___
Python tracker 

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



RE: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Avi Gross
I won't speak for the IEEE but NOT A NUMBER does not tell you what something
IS.

If "Hello, World!" is not a number as in an int or a float and we throw away
the content and simply call it a NaN or something and then we notice that an
object that is a list of fruits is also not a number so we call it a NaN
too, then should  they be equal?

A NaN is a bit like a black hole. Anything thrown in disappears and that is
about all we know about it. No two black holes are the same even if they
seem to have the same mass, spin and charge. All they share is that we don't
know what is in them.

When variable "a" is a Nan then it is sort of a pointer to a concept. The
pointer IS itself but the concepts may not be.

-Original Message-
From: Python-list  On
Behalf Of Grant Edwards
Sent: Wednesday, February 13, 2019 1:03 PM
To: python-list@python.org
Subject: Re: Why float('Nan') == float('Nan') is False

On 2019-02-13, ast  wrote:
> Hello
>
> >>> float('Nan') == float('Nan')
> False

If you think that's odd, how about this?

>>> n = float('nan')
>>> n
nan
>>> n is n
True
>>> n == n
False
>>>

> Why ?

IEEE says so.

-- 
Grant Edwards   grant.b.edwardsYow! Like I always say
  at   -- nothing can beat
  gmail.comthe BRATWURST here in
   DUSSELDORF!!

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

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


[issue15753] No-argument super in method with variable arguments raises SystemError

2019-02-13 Thread Rémi Lapeyre

Change by Rémi Lapeyre :


--
nosy: +remi.lapeyre

___
Python tracker 

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



[issue15753] No-argument super in method with variable arguments raises SystemError

2019-02-13 Thread Josh Rosenberg


Josh Rosenberg  added the comment:

Moving from pending back to open (not sure what was "pending" about it?).

The workaround is viable (and used by Python implemented dict subclasses in the 
standard library since they must accept **kwargs with arbitrary strings, 
including self), but it does seem a little silly that it's required. Leaving it 
as low priority since the workaround exists.

Still, would be nice to make super() seamless, pulling the first argument if 
the function accepts it as non-varargs, and the first element of the first 
argument if it's varargs. If someone reassigns self/args, that's on them; it's 
fine to raise a RuntimeError if they use no-arg super(), requiring them to use 
two-arg super explicitly in that case.

--
priority: normal -> low
status: pending -> open
versions: +Python 3.8 -Python 3.2, Python 3.3, Python 3.4

___
Python tracker 

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



[issue5038] urrlib2/httplib doesn't reset file position between requests

2019-02-13 Thread Roundup Robot


Change by Roundup Robot :


--
keywords: +patch
pull_requests: +11873
stage: test needed -> patch review

___
Python tracker 

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



[issue35988] Python interpreter segfault

2019-02-13 Thread Josh Rosenberg


Josh Rosenberg  added the comment:

"your application is using more memory than what is available in the system." 

Well, it alone may not be using more memory, but the cumulative usage on the 
system is "too high" by whatever metric the OOM killer is using (IIRC the 
default rule is that actual committed memory must be less than swap size + 50% 
of RAM). The OOM killer is a strange and terrible beast, and the behavior 
varies based on configuration, relative memory usage of each process grouping, 
minimizing number of processes killed, etc.

You can find deep implementation details on it (including how to disable a 
given process for consideration) here: https://linux-mm.org/OOM_Killer

The real solution to problems like this usually amounts to:

1. Install more RAM.

2. Increase the size of your swap partition. Doesn't "fix" being shy of memory 
if you're actually using more memory than you have RAM, but allows you to 
handle overcommit (particularly for fork+exec scenarios where the forked 
process's memory will be freed momentarily) without the OOM killer getting 
involved, and to limp along slowly, without actually failing, if you actually 
allocate and use more memory than you have RAM.

3. Tweak the overcommit heuristics to allow more overcommit before invoking the 
OOM killer.

4. Disable overcommit entirely, so memory allocations fail immediately if 
sufficient backing storage is not available, rather than succeeding, only to 
invoke the OOM killer when the allocated memory gets used and the shortage is 
discovered. This is a good solution if the program(s) in question aren't poorly 
designed such that they try to allocate many GBs of memory up front even when 
they're unlikely to need it; unfortunately, there are commonly used programs 
that overallocate like this and render this solution non-viable if they're part 
of your setup.

Regardless, this isn't a bug in Python itself. Any process that uses a lot of 
memory (Apache, MySQL) and hasn't explicitly removed itself from OOM killer 
consideration is going to look tasty when an OOM scenario occurs.

--
nosy: +josh.r
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



Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Grant Edwards
On 2019-02-13, ast  wrote:
> Hello
>
> >>> float('Nan') == float('Nan')
> False

If you think that's odd, how about this?

>>> n = float('nan')
>>> n
nan
>>> n is n
True
>>> n == n
False
>>>

> Why ?

IEEE says so.

-- 
Grant Edwards   grant.b.edwardsYow! Like I always say
  at   -- nothing can beat
  gmail.comthe BRATWURST here in
   DUSSELDORF!!

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


[issue22213] Make pyvenv style virtual environments easier to configure when embedding Python

2019-02-13 Thread Steve Dower


Steve Dower  added the comment:

I just closed 35706 as a duplicate of this one (the titles are basically 
identical, which feels like a good hint ;) )

It seems that the disagreement about the design is fundamentally a disagreement 
between a "quick, painful but complete fix" and "slow, careful improvements 
with a transition period". Both are valid approaches, and since Victor is 
putting actual effort in right now he gets to "win", but I do think we can 
afford to move faster.

It seems the main people who will suffer from the pain here are embedders (who 
are already suffering pain) and the core developers (who explicitly signed up 
for pain!). But without knowing the end goal, we can't accelerate.

Currently PEP 432 is the best description we have, and it looks like Victor has 
been heading in that direction too (deliberately? I don't know :) ). But it 
seems like a good time to review it, replace the "here's the current state of 
things" with "here's an imaginary ideal state of things" and fill the rest with 
"here are the steps to get there without breaking the world".

By necessity, it touches a lot of people's contributions to Python, but it also 
has the potential to seriously improve even more people's ability to _use_ 
Python (for example, I know an app that you all would recognize the name of who 
is working on embedding Python right now and would _love_ certain parts of this 
side of things to be improved).

Nick - has the steering council been thinking about ways to promote 
collaborative development of ideas like this? I'm thinking an Etherpad style 
environment for the brainstorm period (in lieu of an in-person whiteboard 
session) that's easy for us all to add our concerns to, that can then be turned 
into something more formal.

Nick, Victor, Eric, (others?) - are you interested in having a virtual 
whiteboard session to brainstorm how the "perfect" initialization looks? And 
probably a follow-up to brainstorm how to get there without breaking the world? 
I don't think we're going to get to be in the same room anytime before the 
language summit, and it would be awesome to have something concrete to discuss 
there.

--

___
Python tracker 

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



[issue35706] Make it easier to use a venv with an embedded Python interpreter

2019-02-13 Thread Steve Dower


Steve Dower  added the comment:

That's not a "see also" - it's just a duplicate :) I'll close this one as the 
other one has been around longer.

--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Make pyvenv style virtual environments easier to configure when 
embedding Python

___
Python tracker 

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



[issue35706] Make it easier to use a venv with an embedded Python interpreter

2019-02-13 Thread STINNER Victor


STINNER Victor  added the comment:

PEP 432 will allow to give with fine control on parameters used to initialize 
Python. Sadly, I failed to agree with Nick Coghlan and Eric Snow on the API. 
The current implementation (_PyCoreConfig and _PyMainInterpreterConfig) has 
some flaw (don't separate clearly the early initialization and Unicode-ready 
state, the interpreter contains main and core config whereas some options are 
duplicated in both configs, etc.).

--

___
Python tracker 

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



[issue22213] Make pyvenv style virtual environments easier to configure when embedding Python

2019-02-13 Thread STINNER Victor


STINNER Victor  added the comment:

PEP 432 will allow to give with fine control on parameters used to initialize 
Python. Sadly, I failed to agree with Nick Coghlan and Eric Snow on the API. 
The current implementation (_PyCoreConfig and _PyMainInterpreterConfig) has 
some flaw (don't separate clearly the early initialization and Unicode-ready 
state, the interpreter contains main and core config whereas some options are 
duplicated in both configs, etc.).

See also bpo-35706.

--

___
Python tracker 

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



[issue35706] Make it easier to use a venv with an embedded Python interpreter

2019-02-13 Thread STINNER Victor


STINNER Victor  added the comment:

See also bpo-22213.

--

___
Python tracker 

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



[issue35907] Unnecessary URL scheme exists to allow file:// reading file in urllib

2019-02-13 Thread Sihoon Lee


Change by Sihoon Lee :


--
keywords: +patch
pull_requests: +11872
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



[issue35949] Move PyThreadState into Include/internal/pycore_pystate.h

2019-02-13 Thread STINNER Victor


STINNER Victor  added the comment:

Same ratione than for PyInterpreterState: 
https://bugs.python.org/issue35886#msg335464

Except that I expect that a few more projects rely on PyThreadState fields. 
Maybe not. It's hard to guess :-(

I mean that I'm ok-ish with the change but it should be carefully prepared and 
announced.

--

___
Python tracker 

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



[issue35989] ipaddress.IPv4Network allows prefix > 32

2019-02-13 Thread SilentGhost


Change by SilentGhost :


--
components: +Library (Lib)
nosy: +pitrou
stage:  -> test needed
type:  -> behavior

___
Python tracker 

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



[issue35886] Move PyInterpreterState into Include/internal/pycore_pystate.h

2019-02-13 Thread STINNER Victor


STINNER Victor  added the comment:

> @Victor, do you see any problems with doing this?  It will help simplify 
> other changes I'm working on.

I'm quite sure that they are users of the PyInterpreterState structure outside 
CPython internals and stdlib, but I expect that the number is quite low.

Since internal headers are now installed (I modified "make install" for that) 
(but need to define Py_BUILD_CORE), it might be acceptable to force users of 
this structure to opt-in for internal headers.

Just make sure that we properly communicate on such backward incompatible 
changes:

* "C API Changes" section of 
https://docs.python.org/dev/whatsnew/3.8.html#porting-to-python-3-8
* mail to python-dev

The bpo-35810 also proposes a subtle backward incompatible change which makes 
me unhappy, but Stefan Behnel seems less scared than me, so maybe it will be 
fine.

Maybe we need to organize a collective effort to better communicate on our 
backward incompatible C API changes. The capi-sig mailing list may be a good 
channel for that. I asked to test some popular C extensions to check that they 
are not broken. If it's the case, we should help them to be prepared for the 
new C API.

--

___
Python tracker 

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



[issue35983] tp_dealloc trashcan shouldn't be called for subclasses

2019-02-13 Thread Eric Snow


Eric Snow  added the comment:

On Wed, Feb 13, 2019 at 8:42 AM Antoine Pitrou  wrote:
> Antoine Pitrou  added the comment:
>
> By "relatively new thing", you mean less than 20 years old? :-)

Yeah, looks like it was in the 2.2 release (Dec 2001) for PEP 253.
Anyway, I know of several core devs who are still opposed to
subclassing builtin types. :)

--

___
Python tracker 

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



[issue35984] test__xxsubinterpreters leaked [3, 4, 3] memory blocks, sum=1

2019-02-13 Thread Eric Snow


Eric Snow  added the comment:

FYI, the _xxsubinterpreters module serves several purposes.  First, it allows 
us to more thoroughly test the subinterpreter functionality of CPython (doing 
so via _testembed and _testcapi is messy), effectively in 
test__xxsubinterpreters.  Second, it is the foundation for helpers (which I 
intend on adding to test.support in the 3.8 time frame) for easily using 
subinterpreters in the test suite in lieu of subprocesses.  Third, ultimately 
it will be the low-level implementation of PEP 554.

--

___
Python tracker 

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



[issue35984] test__xxsubinterpreters leaked [3, 4, 3] memory blocks, sum=1

2019-02-13 Thread Eric Snow


Eric Snow  added the comment:

Alexey, even though the refleak does not appear to be related to your earlier 
PR, you are welcome to keep working on this issue. :)  If you do then please 
add me as a reviewer on whatever PR you make.  Also, I'd be glad to answer any 
questions you have about the _xxsubinterpreters module.  The more folks that 
understand that code, the better. :)

On the other hand, if you decide at this point that you'd rather do something 
else than track down refleaks I introduced then I'd totally understand. :)  In 
that case feel free to assign this issue to me at that time.

--
stage:  -> test needed
type:  -> resource usage

___
Python tracker 

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



[issue35989] ipaddress.IPv4Network allows prefix > 32

2019-02-13 Thread Rémi Lapeyre

Change by Rémi Lapeyre :


--
nosy: +remi.lapeyre

___
Python tracker 

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



[issue35989] ipaddress.IPv4Network allows prefix > 32

2019-02-13 Thread John Florian


New submission from John Florian :

I wanted a simple is_valid_ipv4_network() function, so I wrote one and a bunch 
of unit tests where I discovered that I can legally:

>>> n = IPv4Network(('192.168.123.234', 12345678))
>>> n
IPv4Network('192.168.123.234/12345678')
>>> n.prefixlen
12345678
>>> n.max_prefixlen
32

I assume this is a bug.

--
messages: 335460
nosy: John Florian
priority: normal
severity: normal
status: open
title: ipaddress.IPv4Network allows prefix > 32
versions: Python 3.7

___
Python tracker 

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



[issue35983] tp_dealloc trashcan shouldn't be called for subclasses

2019-02-13 Thread Jeroen Demeyer


Change by Jeroen Demeyer :


--
keywords: +patch
pull_requests: +11871
stage: test needed -> patch review

___
Python tracker 

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



[issue35972] _xxsubinterpreters: channel_send() may truncate ints on 32-bit platforms

2019-02-13 Thread Eric Snow


Eric Snow  added the comment:

ack

--

___
Python tracker 

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



[issue35988] Python interpreter segfault

2019-02-13 Thread Hinko Kocevar


Hinko Kocevar  added the comment:

Using python3.6 now.
I've also used the 'handle SIGPIPE nostop noprint' to skip SIGPIPE.

Now the interpreter is killed instead:

INF  2019-02-13 15:42:19,131 web:2162 log_request - 200 GET /NPM.html 
(10.0.6.209) 1.10ms

[Thread 0x7fffe76eb700 (LWP 8411) exited]
[Thread 0x7fffe78ec700 (LWP 8410) exited]
[Thread 0x7fffe7a2d700 (LWP 8409) exited]
[Thread 0x7fffe7d41700 (LWP 8408) exited]
[Thread 0x7fffe8542700 (LWP 8407) exited]

Program terminated with signal SIGKILL, Killed.
The program no longer exists.
(gdb) bt
No stack.
(gdb) 


And the dmesg shows, what I think is the real reason, for python3.5/3.6 dying 
on me (out of memory):

[26194250.313676] vmtoolsd invoked oom-killer: gfp_mask=0x201da, order=0, 
oom_score_adj=0
[26194250.313691] vmtoolsd cpuset=/ mems_allowed=0
[26194250.313696] CPU: 0 PID: 29876 Comm: vmtoolsd Not tainted 
3.10.0-693.21.1.el7.x86_64 #1
[26194250.313697] Hardware name: VMware, Inc. VMware Virtual Platform/440BX 
Desktop Reference Platform, BIOS 6.00 04/05/2016
[26194250.313698] Call Trace:
[26194250.313714]  [] dump_stack+0x19/0x1b
[26194250.313717]  [] dump_header+0x90/0x229
[26194250.313725]  [] ? ktime_get_ts64+0x52/0xf0
[26194250.313733]  [] ? delayacct_end+0x8f/0xb0
[26194250.313737]  [] oom_kill_process+0x254/0x3d0
[26194250.313739]  [] ? oom_unkillable_task+0xcd/0x120
[26194250.313740]  [] ? find_lock_task_mm+0x56/0xc0
[26194250.313742]  [] out_of_memory+0x4b6/0x4f0
[26194250.313744]  [] __alloc_pages_slowpath+0x5d6/0x724
[26194250.313747]  [] __alloc_pages_nodemask+0x405/0x420
[26194250.313752]  [] alloc_pages_current+0x98/0x110
[26194250.313757]  [] __page_cache_alloc+0x97/0xb0
[26194250.313759]  [] filemap_fault+0x170/0x420
[26194250.313869]  [] ext4_filemap_fault+0x36/0x50 [ext4]
[26194250.313875]  [] __do_fault+0x58/0xe0
[26194250.313876]  [] do_read_fault.isra.44+0x4b/0x130
[26194250.313880]  [] handle_mm_fault+0x691/0xfa0
[26194250.313888]  [] ? cputime_adjust+0x94/0x150
[26194250.313893]  [] __do_page_fault+0x154/0x450
[26194250.313894]  [] do_page_fault+0x35/0x90
[26194250.313898]  [] page_fault+0x28/0x30
[26194250.313912] Mem-Info:
[26194250.313915] active_anon:317608 inactive_anon:106541 isolated_anon:0
 active_file:836 inactive_file:1338 isolated_file:0
 unevictable:0 dirty:0 writeback:0 unstable:0
 slab_reclaimable:5892 slab_unreclaimable:7233
 mapped:394 shmem:334 pagetables:5322 bounce:0
 free:12861 free_pcp:12 free_cma:0
[26194250.313920] Node 0 DMA free:7624kB min:380kB low:472kB high:568kB 
active_anon:3680kB inactive_anon:3828kB active_file:4kB inactive_file:96kB 
unevictable:0kB isolated(anon):0kB isolated(file):0kB present:15992kB 
managed:15908kB mlocked:0kB dirty:0kB writeback:0kB mapped:4kB shmem:4kB 
slab_reclaimable:96kB slab_unreclaimable:52kB kernel_stack:32kB 
pagetables:160kB unstable:0kB bounce:0kB free_pcp:0kB local_pcp:0kB 
free_cma:0kB writeback_tmp:0kB pages_scanned:492 all_unreclaimable? yes
[26194250.313925] lowmem_reserve[]: 0 1822 1822 1822
[26194250.313927] Node 0 DMA32 free:43820kB min:44672kB low:55840kB 
high:67008kB active_anon:1266752kB inactive_anon:422336kB active_file:3340kB 
inactive_file:5256kB unevictable:0kB isolated(anon):0kB isolated(file):0kB 
present:2080704kB managed:1867756kB mlocked:0kB dirty:0kB writeback:0kB 
mapped:1572kB shmem:1332kB slab_reclaimable:23472kB slab_unreclaimable:28880kB 
kernel_stack:3200kB pagetables:21128kB unstable:0kB bounce:0kB free_pcp:48kB 
local_pcp:0kB free_cma:0kB writeback_tmp:0kB pages_scanned:11345 
all_unreclaimable? yes
[26194250.313930] lowmem_reserve[]: 0 0 0 0
[26194250.313932] Node 0 DMA: 4*4kB (UEM) 9*8kB (UEM) 9*16kB (UEM) 3*32kB (E) 
2*64kB (UE) 2*128kB (UE) 3*256kB (UM) 4*512kB (UEM) 4*1024kB (EM) 0*2048kB 
0*4096kB = 7624kB
[26194250.313939] Node 0 DMA32: 386*4kB (E) 482*8kB (UE) 324*16kB (UEM) 
247*32kB (UEM) 157*64kB (UEM) 56*128kB (UEM) 18*256kB (UEM) 7*512kB (UEM) 
0*1024kB 0*2048kB 0*4096kB = 43896kB
[26194250.313945] Node 0 hugepages_total=0 hugepages_free=0 hugepages_surp=0 
hugepages_size=2048kB
[26194250.313946] 3429 total pagecache pages
[26194250.313947] 890 pages in swap cache
[26194250.313950] Swap cache stats: add 52552391, delete 52551501, find 
24707502/29312733
[26194250.313951] Free swap  = 0kB
[26194250.313951] Total swap = 2047996kB
[26194250.313952] 524174 pages RAM
[26194250.313953] 0 pages HighMem/MovableOnly
[26194250.313953] 53258 pages reserved
[26194250.313954] [ pid ]   uid  tgid total_vm  rss nr_ptes swapents 
oom_score_adj name
[26194250.313963] [  564] 0   564 9307  371  23   46
 0 systemd-journal
[26194250.313965] [  751]81   751 9244  104  21   89
  -900 dbus-daemon
[26194250.313967] [  783] 0   783   138064   94 101 9333
 0 NetworkManager
[26194250.313968] [  849] 0   849283430  58 3123
 0 dhclient
[26194250.313970] [ 1016] 0  1016 8818   35  19  236  

[issue35224] PEP 572: Assignment Expressions

2019-02-13 Thread STINNER Victor


STINNER Victor  added the comment:

> If anyone has another area they think the documentation should be updated, 
> please let me know!

If we forget something, it's not an issue: it can be added later!

--

___
Python tracker 

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



[issue35988] Python interpreter segfault

2019-02-13 Thread STINNER Victor


STINNER Victor  added the comment:

> [26194250.314042] Out of memory: Kill process 8399 (python3.6) score 574 or 
> sacrifice child

That's not a bug in Python: your application is using more memory than what is 
available in the system.

--

___
Python tracker 

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



[issue35983] tp_dealloc trashcan shouldn't be called for subclasses

2019-02-13 Thread Antoine Pitrou


Antoine Pitrou  added the comment:

By "relatively new thing", you mean less than 20 years old? :-)

--

___
Python tracker 

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



[issue35988] Python interpreter segfault

2019-02-13 Thread Hinko Kocevar


Hinko Kocevar  added the comment:

> Are you able to reproduce the crash on Python 3.6 or 3.7?

I'm running it under python3.6 as we speak.

--

___
Python tracker 

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



[issue35983] tp_dealloc trashcan shouldn't be called for subclasses

2019-02-13 Thread Eric Snow


Eric Snow  added the comment:

FWIW, subclassing builtin types is a relatively new thing.  There are still a 
number of lingering (older) implementation details throughout CPython that were 
written assuming no subclassing.  I'd guess that this is one of them.

--
nosy: +eric.snow
stage:  -> test needed
type:  -> behavior

___
Python tracker 

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



[issue35224] PEP 572: Assignment Expressions

2019-02-13 Thread Emily Morehouse


Emily Morehouse  added the comment:

I have a work-in-progress (WIP) documentation branch I've been working on that 
I'll push up this week to address the following:

- Add summary to What's New in Doc/whatsnew/3.8.rst
- Add to list of delimiters in Doc/reference/lexical_analysis.rst
- Add usage documentation in Doc/reference/expressions.rst
- Update FAQ in Doc/faq/design.rst (https://bugs.python.org/issue35666)

If anyone has another area they think the documentation should be updated, 
please let me know!

--

___
Python tracker 

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



  1   2   >