[issue30134] BytesWarning is missing from the documents

2019-04-08 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

This PR was not ready to merge. Please address my and Martin's comments.

--

___
Python tracker 

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



[issue24743] Make _PyTraceback_Add public

2019-04-08 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It looks like a hack and is used only three time in the CPython code. What is 
your use case? How do you use it?

--

___
Python tracker 

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



[issue36551] Optimize list comprehensions with preallocate size and protect against overflow

2019-04-08 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

> I was going to note that the algorithm Anthony has pursued here is the same 
> one we already use for the list constructor and list.extend(), but Inada-san 
> already pointed that out :)

And that optimization looks questionable to me. I tried to reduce an overhead 
for small lists, but this requires much more complex code and gives mixed 
results.

I am -1 for this optimization because it affects only one particular case 
(neither other kinds of comprehensions, nor generator expressions, nor list 
comprehensions with conditions) and even in this case it is small. It is 
possible to add a lot of other optimizations for other cases which will sped up 
them to 50% or 100%, but we do not do this, because every such optimization has 
a cost. It increases the amount of code which should be maintained and covered 
by tests, it adds small overhead in common cases to speed up an uncommon case, 
and increasing the code base can negatively affect surrounding code (just 
because the CPU cache and registers are used inappropriate and the compiler 
optimizes less important paths).

In addition, while this change speed up list comprehensions for long list, it 
slows down them for short lists. Short lists are more common.

--

___
Python tracker 

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



[issue24743] Make _PyTraceback_Add public

2019-04-08 Thread SilentGhost


Change by SilentGhost :


--
nosy: +serhiy.storchaka
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



[issue30134] BytesWarning is missing from the documents

2019-04-08 Thread Inada Naoki


Change by Inada Naoki :


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



[issue30134] BytesWarning is missing from the documents

2019-04-08 Thread Inada Naoki


Inada Naoki  added the comment:


New changeset d012d64b6a513e760abb6745f7f7ce5e6a31f274 by Inada Naoki 
(cocoatomo) in branch '2.7':
bpo-30134: add an explanation of BytesWarning (GH-1249)
https://github.com/python/cpython/commit/d012d64b6a513e760abb6745f7f7ce5e6a31f274


--
nosy: +inada.naoki

___
Python tracker 

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



[issue36569] @staticmethod seems to work with setUpClass, but docs say it shouldn't

2019-04-08 Thread Peter de Blanc


New submission from Peter de Blanc :

According to unittest docs: 
https://docs.python.org/3.7/library/unittest.html#module-unittest

`setUpClass is called with the class as the only argument and must be decorated 
as a classmethod()`

and:

`tearDownClass is called with the class as the only argument and must be 
decorated as a classmethod()`

However, I was able to create a passing test case where `setUpClass` and 
`tearDownClass` are decorated with `@staticmethod` instead of `@classmethod`:

I tested this with Python versions 3.6.4 and 3.7.1.

Please update the documentation to indicate that `@staticmethod` is allowed 
here, or else indicate why it's bad.

--
components: Library (Lib)
files: test_bar.py
messages: 339700
nosy: Peter de Blanc, ezio.melotti, michael.foord, rbcollins
priority: normal
severity: normal
status: open
title: @staticmethod seems to work with setUpClass, but docs say it shouldn't
type: behavior
versions: Python 3.6, Python 3.7
Added file: https://bugs.python.org/file48251/test_bar.py

___
Python tracker 

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



[issue36551] Optimize list comprehensions with preallocate size and protect against overflow

2019-04-08 Thread anthony shaw

anthony shaw  added the comment:

Have just optimized some of the code and pushed another change as 69dce1c552.

ran both master and 69dce1c552 using pyperformance with PGO:

➜  ~ python3.8 -m perf compare_to master.json 69dce1c552.json --table 
+-+-+-+
| Benchmark   | master  | 69dce1c552  |
+=+=+=+
| 2to3| 432 ms  | 426 ms: 1.02x faster (-2%)  |
+-+-+-+
| chaos   | 157 ms  | 155 ms: 1.01x faster (-1%)  |
+-+-+-+
| crypto_pyaes| 154 ms  | 153 ms: 1.00x faster (-0%)  |
+-+-+-+
| dulwich_log | 123 ms  | 124 ms: 1.00x slower (+0%)  |
+-+-+-+
| fannkuch| 603 ms  | 600 ms: 1.01x faster (-1%)  |
+-+-+-+
| float   | 153 ms  | 154 ms: 1.01x slower (+1%)  |
+-+-+-+
| go  | 323 ms  | 326 ms: 1.01x slower (+1%)  |
+-+-+-+
| hexiom  | 13.6 ms | 13.5 ms: 1.01x faster (-1%) |
+-+-+-+
| json_dumps  | 18.1 ms | 17.9 ms: 1.01x faster (-1%) |
+-+-+-+
| logging_format  | 13.2 us | 13.8 us: 1.05x slower (+5%) |
+-+-+-+
| logging_silent  | 266 ns  | 280 ns: 1.05x slower (+5%)  |
+-+-+-+
| logging_simple  | 12.4 us | 13.1 us: 1.06x slower (+6%) |
+-+-+-+
| meteor_contest  | 145 ms  | 132 ms: 1.10x faster (-9%)  |
+-+-+-+
| nbody   | 179 ms  | 172 ms: 1.04x faster (-4%)  |
+-+-+-+
| nqueens | 138 ms  | 134 ms: 1.03x faster (-3%)  |
+-+-+-+
| pathlib | 56.4 ms | 55.6 ms: 1.01x faster (-1%) |
+-+-+-+
| pickle  | 15.0 us | 15.4 us: 1.03x slower (+3%) |
+-+-+-+
| pickle_pure_python  | 620 us  | 617 us: 1.01x faster (-1%)  |
+-+-+-+
| raytrace| 696 ms  | 691 ms: 1.01x faster (-1%)  |
+-+-+-+
| regex_compile   | 242 ms  | 243 ms: 1.00x slower (+0%)  |
+-+-+-+
| scimark_monte_carlo | 140 ms  | 143 ms: 1.02x slower (+2%)  |
+-+-+-+
| scimark_sparse_mat_mult | 5.90 ms | 5.94 ms: 1.01x slower (+1%) |
+-+-+-+
| spectral_norm   | 194 ms  | 196 ms: 1.01x slower (+1%)  |
+-+-+-+
| sympy_str   | 246 ms  | 245 ms: 1.00x faster (-0%)  |
+-+-+-+
| telco   | 8.42 ms | 8.31 ms: 1.01x faster (-1%) |
+-+-+-+
| unpack_sequence | 59.2 ns | 59.7 ns: 1.01x slower (+1%) |
+-+-+-+
| unpickle| 21.2 us | 21.4 us: 1.01x slower (+1%) |
+-+-+-+
| unpickle_list   | 5.73 us | 5.81 us: 1.01x slower (+1%) |
+-+-+-+
| unpickle_pure_python| 471 us  | 467 us: 1.01x faster (-1%)  |
+-+-+-+
| xml_etree_iterparse | 142 ms  | 143 ms: 1.01x slower (+1%)  |
+-+-+-+
| xml_etree_generate  | 139 ms  | 137 ms: 1.02x faster (-2%)  |
+-+-+-+
| xml_etree_process   | 109 ms  | 108 ms: 1.01x faster (-1%)  |
+-+-+-+

Not significant (21): deltablue; django_template; html5lib; json_loads; mako; 
pickle_dict; pickle_list; pidigits; python_startup; python_startup_no_site; 
regex_dna; regex_effbot; regex_v8; 

[issue35848] readinto is not a method on io.TextIOBase

2019-04-08 Thread miss-islington


miss-islington  added the comment:


New changeset 0a16bb15afec28f355bc28203b6b10610293f026 by Miss Islington (bot) 
in branch '3.7':
closes bpo-35848: Move all documentation regarding the readinto out of IOBase. 
(GH-11893)
https://github.com/python/cpython/commit/0a16bb15afec28f355bc28203b6b10610293f026


--
nosy: +miss-islington

___
Python tracker 

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



[issue35848] readinto is not a method on io.TextIOBase

2019-04-08 Thread Benjamin Peterson


Benjamin Peterson  added the comment:


New changeset 7b97ab35b28b761ab1253df427ee674b1a90f465 by Benjamin Peterson 
(Steve Palmer) in branch 'master':
closes bpo-35848: Move all documentation regarding the readinto out of IOBase. 
(GH-11893)
https://github.com/python/cpython/commit/7b97ab35b28b761ab1253df427ee674b1a90f465


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



[issue35848] readinto is not a method on io.TextIOBase

2019-04-08 Thread miss-islington


Change by miss-islington :


--
pull_requests: +12659

___
Python tracker 

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



[issue31512] Add non-elevated symlink support for dev mode Windows 10

2019-04-08 Thread Eryk Sun


Eryk Sun  added the comment:

:ping: It seems this was ready to be merged a while ago.

--

___
Python tracker 

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



[issue1756] -m broken in trunk

2019-04-08 Thread Giampaolo Rodola'


Giampaolo Rodola'  added the comment:

Sorry, I accidentally referenced this BPO issue in my commit.

--

___
Python tracker 

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



[issue17561] Add socket.bind_socket() convenience function

2019-04-08 Thread Giampaolo Rodola'


Giampaolo Rodola'  added the comment:


New changeset 8702b67dad62a9084f6c1823dce10653743667c8 by Giampaolo Rodola in 
branch 'master':
BPO-17561: set create_server backlog default to None (GH-12735)
https://github.com/python/cpython/commit/8702b67dad62a9084f6c1823dce10653743667c8


--

___
Python tracker 

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



[issue1756] -m broken in trunk

2019-04-08 Thread Giampaolo Rodola'


Giampaolo Rodola'  added the comment:


New changeset 8702b67dad62a9084f6c1823dce10653743667c8 by Giampaolo Rodola in 
branch 'master':
BPO-17561: set create_server backlog default to None (GH-12735)
https://github.com/python/cpython/commit/8702b67dad62a9084f6c1823dce10653743667c8


--
nosy: +giampaolo.rodola

___
Python tracker 

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



[issue36568] Typo in socket.CAN_RAW_FD_FRAMES library documentation

2019-04-08 Thread Carl Cerecke


Carl Cerecke  added the comment:

See section 4.1.5 at https://www.kernel.org/doc/Documentation/networking/can.txt

--

___
Python tracker 

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



[issue36568] Typo in socket.CAN_RAW_FD_FRAMES library documentation

2019-04-08 Thread Carl Cerecke


New submission from Carl Cerecke :

https://docs.python.org/3/library/socket.html#socket.CAN_RAW_FD_FRAMES

The wording "...however, you one must accept..." doesn't make sense. I think 
the "you one" should be "your application", but I'm not sure.

--
assignee: docs@python
components: Documentation
messages: 339691
nosy: Carl Cerecke, docs@python
priority: normal
severity: normal
status: open
title: Typo in socket.CAN_RAW_FD_FRAMES library documentation
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



[issue17561] Add socket.bind_socket() convenience function

2019-04-08 Thread Giampaolo Rodola'


Change by Giampaolo Rodola' :


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

___
Python tracker 

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



[issue36559] "import random" should import hashlib on demand (nor load OpenSSL)

2019-04-08 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

One other thought. This code has been present for over a decade.  There is no 
evidence that anyone has ever wanted random to defer one of its imports. This 
seems like an invented problem.

--

___
Python tracker 

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



[issue36559] "import random" should import hashlib on demand (nor load OpenSSL)

2019-04-08 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

In general, deferred imports are code smell that should avoided unless really 
necessary. They create an on-going maintenance burden (there's a reason most 
modules don't do this and put their imports at the top).

FWIW, a broken hashlib is a localized bug, not an optimization problem. It 
doesn't affect any user with a build that passes the test suite.

Running "python -v" shows that "random" is not part of the normal startup, so 
deferring the import saves zero for normal startup. It only affects modules 
that specifically import random.

IIRC, Mercurial uses hashing extensively, so deferring the import doesn't help 
them at all.

This is minor change, so I suppose we could let it go through; however, it 
seems somewhat arbitrary and the reasons offered seem dubious. For the most 
part, it isn't a good practice.

--

___
Python tracker 

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



[issue36533] logging regression with threading + fork are mixed in 3.7.1rc2 (deadlock potential)

2019-04-08 Thread Gregory P. Smith


Gregory P. Smith  added the comment:

The logging library has never guaranteed that it wouldn't interleave or 
duplicate buffered io output when fork() in involved.  We should not start 
trying to claim that it does.  Too complicated and fragile.  It can't.  Users 
who want that should implement their own single logging handler that is well 
behaved in whatever regards they need.  there are a ton of options for them.

A basicConfig setting to switch the mode of operation to a single lock instead 
of per-handler locks could only happen in 3.8 (new feature).  I'll ponder if it 
is even feasible to add that after the re-init change goes in.  Even with such 
a feature, library user authored Handler subclasses would always be free to 
violate that.  We can't protect people from themselves.

--

___
Python tracker 

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



[issue17561] Add socket.bind_socket() convenience function

2019-04-08 Thread STINNER Victor


STINNER Victor  added the comment:

The change broke multiple buildbots. Example:

https://buildbot.python.org/all/#builders/16/builds/2625

Traceback (most recent call last):
  File 
"/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/test/_test_multiprocessing.py",
 line 4377, in test_wait_socket
self.assertEqual(b''.join(v), expected)
AssertionError: b'1\n2\n3\n4\n5\n6\n7\n8\n9\n' != 
b'0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n'

More logs:

https://github.com/python/cpython/pull/11784#issuecomment-481036369

--
nosy: +vstinner
resolution: fixed -> 
status: closed -> open

___
Python tracker 

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



[issue36565] Reference hunting (python3 -m test -R 3:3) doesn't work if the _abc module is missing

2019-04-08 Thread STINNER Victor


Change by STINNER Victor :


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



[issue36565] Reference hunting (python3 -m test -R 3:3) doesn't work if the _abc module is missing

2019-04-08 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 2368d86ed1249505b10561e005fc57f4884619c1 by Victor Stinner (Miss 
Islington (bot)) in branch '3.7':
bpo-36565: Fix libregrtest for Python without builtin _abc (GH-12733) (GH-12734)
https://github.com/python/cpython/commit/2368d86ed1249505b10561e005fc57f4884619c1


--

___
Python tracker 

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



[issue36565] Reference hunting (python3 -m test -R 3:3) doesn't work if the _abc module is missing

2019-04-08 Thread miss-islington


Change by miss-islington :


--
pull_requests: +12657

___
Python tracker 

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



[issue36565] Reference hunting (python3 -m test -R 3:3) doesn't work if the _abc module is missing

2019-04-08 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 79b5d29041bd85ea3baa050b3fa2481344ea35c9 by Victor Stinner in 
branch 'master':
bpo-36565: Fix libregrtest for Python without builtin _abc (GH-12733)
https://github.com/python/cpython/commit/79b5d29041bd85ea3baa050b3fa2481344ea35c9


--

___
Python tracker 

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



[issue36551] Optimize list comprehensions with preallocate size and protect against overflow

2019-04-08 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Here are the updated results for the benchmark suite. The previous results 
(unlinked from the issue to reduce noise)
were against an old version of the master branch.

2019-04-08_13-08-master-58721a903074.json.gz


Performance version: 0.7.0
Report on Linux-5.0.5-1-ARCH-x86_64-with-glibc2.28
Number of logical CPUs: 12
Start date: 2019-04-09 00:32:40.656576
End date: 2019-04-09 00:54:03.721798

12718-5f06333a4e49.json.gz
==

Performance version: 0.7.0
Report on Linux-5.0.5-1-ARCH-x86_64-with-glibc2.28
Number of logical CPUs: 12
Start date: 2019-04-09 00:07:53.433511
End date: 2019-04-09 00:29:32.603022

  
-- CURRENT MASTER --
-- PR12718 --
+-+--++--++
| Benchmark   | 2019-04-08_13-08-master-58721a903074.json.gz | 
12718-5f06333a4e49.json.gz | Change   | Significance   |
+=+==++==++
| 2to3| 455 ms   | 465 
ms | 1.02x slower | Significant (t=-2.27)  |
+-+--++--++
| chaos   | 171 ms   | 180 
ms | 1.05x slower | Significant (t=-5.92)  |
+-+--++--++
| crypto_pyaes| 169 ms   | 177 
ms | 1.05x slower | Significant (t=-6.06)  |
+-+--++--++
| deltablue   | 11.5 ms  | 11.9 
ms| 1.03x slower | Significant (t=-3.28)  |
+-+--++--++
| django_template | 175 ms   | 191 
ms | 1.09x slower | Significant (t=-13.00) |
+-+--++--++
| dulwich_log | 127 ms   | 131 
ms | 1.03x slower | Significant (t=-8.97)  |
+-+--++--++
| fannkuch| 646 ms   | 665 
ms | 1.03x slower | Significant (t=-12.37) |
+-+--++--++
| float   | 165 ms   | 165 
ms | 1.00x faster | Not significant|
+-+--++--++
| go  | 386 ms   | 381 
ms | 1.01x faster | Not significant|
+-+--++--++
| hexiom  | 15.4 ms  | 15.5 
ms| 1.00x slower | Not significant|
+-+--++--++
| html5lib| 130 ms   | 132 
ms | 1.01x slower | Not significant|
+-+--++--++
| json_dumps  | 18.4 ms  | 18.3 
ms| 1.00x faster | Not significant|
+-+--++--++
| json_loads  | 38.6 us  | 38.6 
us| 1.00x faster | Not significant|

[issue36551] Optimize list comprehensions with preallocate size and protect against overflow

2019-04-08 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


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

___
Python tracker 

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



[issue28351] statistics.geometric_mean can enter infinite loop for Decimal inputs

2019-04-08 Thread Cheryl Sabella


Cheryl Sabella  added the comment:

The new version of geometric_mean does not enter an infinite loop for this 
example, so I am going to close this issue as out of date.

--
nosy: +cheryl.sabella, rhettinger
resolution:  -> out of date
stage:  -> resolved
status: open -> closed
versions: +Python 3.8 -Python 3.7

___
Python tracker 

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



[issue25922] canceling a repair install breaks the ability to uninstall, repair, or re-install

2019-04-08 Thread Cheryl Sabella


Cheryl Sabella  added the comment:

Going to close this as the original OP didn't provide the additional 
information that was requested.  Feel free to reopen if additional info is 
provided.

--
nosy: +cheryl.sabella
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



[issue26389] Expand traceback module API to accept just an exception as an argument

2019-04-08 Thread Cheryl Sabella


Cheryl Sabella  added the comment:

The last comment on the original PR for this issue was to wait until an API was 
decided upon before proceeding with creating a new PR.  Bumping this issue to 
generate new discussion and hopefully reach concession on an API.

--
nosy: +cheryl.sabella
versions: +Python 3.8 -Python 3.7

___
Python tracker 

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



[issue24743] Make _PyTraceback_Add public

2019-04-08 Thread Cheryl Sabella


Change by Cheryl Sabella :


--
stage:  -> needs patch
versions: +Python 3.7, Python 3.8 -Python 3.4, Python 3.5, Python 3.6

___
Python tracker 

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



[issue36478] backport of pickle fixes to Python 3.5.7 uses C99 for loops

2019-04-08 Thread Alexander Mohr


Alexander Mohr  added the comment:

I hit this as well in debian:jessie, and if I enabled -std=c99 I hit this 
issue: https://github.com/dvarrazzo/py-setproctitle/issues/62

--
nosy: +thehesiod

___
Python tracker 

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



[issue28043] Sane defaults for SSLContext options and ciphers

2019-04-08 Thread Cheryl Sabella


Change by Cheryl Sabella :


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



[issue33601] [EASY DOC] Py_UTF8Mode is not documented

2019-04-08 Thread Cheryl Sabella


Change by Cheryl Sabella :


--
assignee: docs@python -> Mariatta
keywords:  -patch
nosy: +Mariatta
stage: patch review -> needs patch
type:  -> enhancement

___
Python tracker 

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



[issue19992] subprocess documentation not explicit about fileno()

2019-04-08 Thread Cheryl Sabella


Cheryl Sabella  added the comment:

Assigning to @Mariatta for the sprints.

--
assignee: docs@python -> Mariatta
nosy: +Mariatta, cheryl.sabella
type:  -> enhancement
versions: +Python 3.7, Python 3.8 -Python 2.7, Python 3.5, Python 3.6

___
Python tracker 

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



[issue17561] Add socket.bind_socket() convenience function

2019-04-08 Thread Giampaolo Rodola'


Giampaolo Rodola'  added the comment:

Patch committed as of:
https://github.com/python/cpython/commit/eb7e29f2a9d075accc1ab3faf3612ac44f5e2183
For posterity, since the API evolved since the original proposal (as per PR 
review/suggestions), this is the final incarnation:

# IPv4 only
>>> socket.create_server(addr)  
# IPv6 only
>>> socket.create_server(addr, family=socket.AF_INET6)
# IPv4 + IPv6
>>> socket.create_server(addr, family=socket.AF_INET6, dualstack_ipv6=True)
# IPv4/6 if possible and don't care about IPv4 mapped addresses, else IPv4
>>> if socket.has_dualstack_ipv6():
...s = socket.create_server(addr, family=socket.AF_INET6, 
dualstack_ipv6=True)
... else:
...s = socket.create_server(addr)

--

___
Python tracker 

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



[issue17561] Add socket.bind_socket() convenience function

2019-04-08 Thread Giampaolo Rodola'


Change by Giampaolo Rodola' :


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



[issue35934] Add socket.create_server() utility function

2019-04-08 Thread Giampaolo Rodola'


Giampaolo Rodola'  added the comment:


New changeset eb7e29f2a9d075accc1ab3faf3612ac44f5e2183 by Giampaolo Rodola in 
branch 'master':
bpo-35934: Add socket.create_server() utility function (GH-11784)
https://github.com/python/cpython/commit/eb7e29f2a9d075accc1ab3faf3612ac44f5e2183


--

___
Python tracker 

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



[issue33456] site.py: by default, a virtual environment is *not* isolated from the system-level site-packages directories

2019-04-08 Thread Cheryl Sabella


Change by Cheryl Sabella :


--
assignee:  -> docs@python
components: +Documentation -Library (Lib)
nosy: +cheryl.sabella, docs@python, vinay.sajip
versions:  -Python 3.6

___
Python tracker 

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



[issue36567] DOC: manpage directive doesn't create hyperlink

2019-04-08 Thread Cheryl Sabella


New submission from Cheryl Sabella :

The `manpage` directive in the docs is not creating a hyperlink to the Unix 
manual page.  As of Sphinx 1.7, the `manpage` directive needs to have a 
`manpages_url` defined in the conf.py file.

[1] 
http://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-manpage

--
assignee: docs@python
components: Documentation
messages: 339676
nosy: cheryl.sabella, docs@python, eric.araujo, ezio.melotti, mdk, willingc
priority: normal
severity: normal
stage: needs patch
status: open
title: DOC: manpage directive doesn't create hyperlink
type: enhancement
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



[issue36566] Support password masking in getpass.getpass()

2019-04-08 Thread Cheryl Sabella


Cheryl Sabella  added the comment:

Thank you for the suggestion.  I believe this is a duplicate of issue 32884.

--
nosy: +cheryl.sabella
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Adding the ability for getpass to print asterisks when passowrd 
is typed

___
Python tracker 

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



[issue36559] "import random" should import hashlib on demand (nor load OpenSSL)

2019-04-08 Thread STINNER Victor


STINNER Victor  added the comment:

Raymond:
> Why do we care about this particular import?  It doesn't see slow in any way.

I ran a benchmark:

$ ./python -m perf command -o ref.json -v -- ./python -c 'import random'
$ # apply patch
$ ./python -m perf command -o patch.json -v -- ./python -c 'import random'
$ ./python -m perf compare_to ref.json patch.json 
Mean +- std dev: [ref] 13.8 ms +- 0.2 ms -> [patch] 11.8 ms +- 0.2 ms: 1.18x 
faster (-15%)

My PR 12728 makes Python startup 2 ms faster which I consider as quite 
significant on 13.8 ms.

I know that some users are fighting to get a faster Python startup. Mercurial 
is just one example ;-)

--

___
Python tracker 

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



[issue36559] "import random" should import hashlib on demand (nor load OpenSSL)

2019-04-08 Thread STINNER Victor


STINNER Victor  added the comment:

Raymond:
> In general, we don't do deferred imports unless there is a compelling reason 
> (i.e. it is very slow or it is sometimes unavailable).

While I was working on adding OpenSSL 1.1.1 to Python 3.4, my _hashopenssl 
module was broken. In that case, "import random" fails with ImportError because 
of hashlib failures. I was surprised, since random doesn't need hashlib at 
startup.

I would like to be able to use "import random" even if hashlib is broken. For 
me, random is a key component, whereas I see hashlib more as optional. (Even if 
in practice, it should always be available).


Raymond:
> Otherwise, it is a false optimization.

Brett:
> Could you explain a bit more, Victor, about why you want to avoid importing 
> hashlib and OpenSSL so much?

Well, OpenSSL is not a random tiny library. For example, loading it increases 
Python RSS of around 2.7 MiB.

Example with script x.py:
---
import os
os.system(f"grep ^VmRSS /proc/{os.getpid()}/status")
import random
os.system(f"grep ^VmRSS /proc/{os.getpid()}/status")
---

Output without the change on Fedora 29:

VmRSS:  7396 kB
VmRSS: 11796 kB  # +4.4 MiB

With the change:

VmRSS:  7272 kB
VmRSS:  8988 kB  # +1.7 MiB


Another example is that OpenSSL loads the libz.so dynamic library by dependency.

I would prefer to minimize Python footprint if possible.

--

___
Python tracker 

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



[issue22377] %Z in strptime doesn't match EST and others

2019-04-08 Thread Alex LordThorsen


Alex LordThorsen  added the comment:

This behavior is currently unchanged and the docs still state that `EST` is an 
acceptable value.

```
>>> datetime.strptime("2019-01-28 18:54:45 EST", "%Y-%m-%d %H:%M:%S %Z")
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python3.7/_strptime.py", line 577, in _strptime_datetime
tt, fraction, gmtoff_fraction = _strptime(data_string, format)
  File "/usr/local/lib/python3.7/_strptime.py", line 359, in _strptime
(data_string, format))
ValueError: time data '2019-01-28 18:54:45 EST' does not match format '%Y-%m-%d 
%H:%M:%S %Z'
```

--
nosy: +Alex.LordThorsen

___
Python tracker 

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



[issue36566] Support password masking in getpass.getpass()

2019-04-08 Thread Steven Vascellaro


New submission from Steven Vascellaro :

Support password masking in getpass.getpass()

Currently, getpass.getpass() hides all user input when entering a password. 
This can throw off non-Unix users who are used to passwords being masked with 
asterisks *. This has led some users to write their own libraries for this 
functionality.

Proposal:

- Add an optional argument to `getpass.getpass()` for a character to mask user 
input

Usage Example:

> import getpass
> password = getpass.getpass(mask='*')
Password: **
> password = getpass.getpass()
Password:

--
components: Library (Lib)
messages: 339671
nosy: stevoisiak
priority: normal
severity: normal
status: open
title: Support password masking in getpass.getpass()
type: enhancement
versions: Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



[issue36562] Can't call a method from a module built in Python C API

2019-04-08 Thread Joao Paulo


Joao Paulo  added the comment:

The following modifications solved the problem:

static PyMethodDef pyModuleMethods[] = {
{ "runTester", (PyCFunction)runTesterFunc, METH_VARARGS | METH_KEYWORDS, 
"Foo Boo." },
{ NULL, NULL, 0, NULL }
};

static struct PyModuleDef MyModule = {
PyModuleDef_HEAD_INIT,
"my_module",
"Foo Boo.",
-1,
pyModuleMethods,
NULL
};

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



[issue36541] Make lib2to3 grammar more closely match Python

2019-04-08 Thread Tim Hatch


Tim Hatch  added the comment:

jreese reminded me of pep570, which will make more grammar changes.  I'm open 
to the idea of replacing the grammar with the live one, plus porting the 2isms 
forward like print, eval, except with comma.

My sincere hope is that everyone that depends on this structure will have tests 
(mine and lib2to3 do); the only big user I'm aware of is probably libfuturize.  
Definitely worth a changelog entry if this is the way forward.

--

___
Python tracker 

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



[issue24565] the f_lineno getter is broken

2019-04-08 Thread Xavier de Gaye


Xavier de Gaye  added the comment:

Fixed a bug in the implementation of PR 12419 while running the coverage.py 
test suite: f_lineno must be valid upon 'call' trace events. The confusion 
stems from the reason why until now we have prevented line jumps from 'call' 
trace events, see below.

Summary:
  * Full coverage.py tests OK (including the C tracer).
  * Fixes issues #7238, #16482, #17277 and #17697.
  * We could now remove the restriction that prevents jumps from a call trace 
event. The restriction was based on the fact that f->f_trace is NULL until 
after the first return from call_trampoline() and setting f_lineno from within 
this first call to call_trampoline() would have had the f_lineno getter still 
return the value returned by PyCode_Addr2Line(), very confusing for the user !
  * A trace function may be set in an extension modules by PyEval_SetTrace() 
and the extension module may not use f->f_trace and still make jumps using 
f_lineno.
  * Fixes _PyTraceback_Add() at 
https://github.com/python/cpython/blob/58721a903074d28151d008d8990c98fc31d1e798/Python/traceback.c#L272

--

___
Python tracker 

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



[issue13947] gdbm reorganize() leaves hanging file descriptor

2019-04-08 Thread sds


sds  added the comment:

Upstream claims that this is fixed by 
http://git.gnu.org.ua/cgit/gdbm.git/commit/?id=a0d6c1a8

--

___
Python tracker 

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



[issue36559] "import random" should import hashlib on demand (nor load OpenSSL)

2019-04-08 Thread Brett Cannon


Brett Cannon  added the comment:

Could you explain a bit more, Victor, about why you want to avoid importing 
hashlib and OpenSSL so much?

--
nosy: +brett.cannon

___
Python tracker 

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



[issue36551] Optimize list comprehensions with preallocate size and protect against overflow

2019-04-08 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

12718-5f06333a4e49.json.gz
==

Performance version: 0.7.0
Report on macOS-10.14.4-x86_64-i386-64bit
Number of logical CPUs: 8
Start date: 2019-04-08 19:40:57.104845
End date: 2019-04-08 20:02:37.392894

+-+--++--++
| Benchmark   | 2019-01-18_22-05-master-2cf1ddaff4c8.json.gz |  
PR12718   | Change   | Significance   |
+=+==++==++
| 2to3| 522 ms   | 512 
ms | 1.02x faster | Not significant|
+-+--++--++
| chaos   | 184 ms   | 195 
ms | 1.06x slower | Significant (t=-7.09)  |
+-+--++--++
| crypto_pyaes| 169 ms   | 177 
ms | 1.05x slower | Significant (t=-8.85)  |
+-+--++--++
| deltablue   | 11.9 ms  | 12.8 
ms| 1.07x slower | Significant (t=-11.53) |
+-+--++--++
| django_template | 186 ms   | 194 
ms | 1.04x slower | Significant (t=-7.94)  |
+-+--++--++
| dulwich_log | 137 ms   | 151 
ms | 1.11x slower | Significant (t=-11.70) |
+-+--++--++
| fannkuch| 642 ms   | 676 
ms | 1.05x slower | Significant (t=-7.55)  |
+-+--++--++
| float   | 165 ms   | 180 
ms | 1.09x slower | Significant (t=-13.23) |
+-+--++--++
| go  | 394 ms   | 418 
ms | 1.06x slower | Significant (t=-9.24)  |
+-+--++--++
| hexiom  | 15.6 ms  | 15.8 
ms| 1.01x slower | Not significant|
+-+--++--++
| html5lib| 136 ms   | 137 
ms | 1.01x slower | Not significant|
+-+--++--++
| json_dumps  | 19.6 ms  | 20.7 
ms| 1.06x slower | Significant (t=-7.41)  |
+-+--++--++
| json_loads  | 39.8 us  | 42.7 
us| 1.07x slower | Significant (t=-9.45)  |
+-+--++--++
| logging_format  | 16.0 us  | 16.7 
us| 1.05x slower | Significant (t=-5.70)  |
+-+--++--++
| logging_silent  | 318 ns   | 315 
ns | 1.01x faster | Not significant|

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

2019-04-08 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

This issue seems to have been assigned CVE-2019-9948 
(https://nvd.nist.gov/vuln/detail/CVE-2019-9948) as noted in 
https://github.com/python/cpython/pull/11842#issuecomment-480930608

--
nosy: +xtreak

___
Python tracker 

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



[issue36560] test_functools leaks randomly 1 memory block

2019-04-08 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue36560] test_functools leaks randomly 1 memory block

2019-04-08 Thread STINNER Victor


STINNER Victor  added the comment:

The issue comes maybe from the complex code in Lib/test/libregrtest/refleak.py 
to handle the ABC cache:

abcs = {}
for abc in [getattr(collections.abc, a) for a in collections.abc.__all__]:
if not isabstract(abc):
continue
for obj in abc.__subclasses__() + [abc]:
abcs[obj] = _get_dump(obj)[0]

...

# clear type cache
sys._clear_type_cache()

# Clear ABC registries, restoring previously saved ABC registries.
abs_classes = [getattr(collections.abc, a) for a in collections.abc.__all__]
abs_classes = filter(isabstract, abs_classes)
for abc in abs_classes:
for obj in abc.__subclasses__() + [abc]:
for ref in abcs.get(obj, set()):
if ref() is not None:
obj.register(ref())
obj._abc_caches_clear()

clear_caches()

--

___
Python tracker 

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



[issue36560] test_functools leaks randomly 1 memory block

2019-04-08 Thread STINNER Victor


STINNER Victor  added the comment:

Some progress.

I'm now able to reproduce the issue with attached test_functools2.py (103 
lines, a single test method):

$ cp (...)test_functools2.py Lib/test/
$ ./configure -C --with-pydebug CFLAGS=-O0
$ make
$ ./python -m test -F -j5 -R 3:3 test_functools2
(...)
0:00:02 load avg: 0.95 [ 19/1] test_functools failed
beginning 6 repetitions
123456
..
test_functools leaked [1, 1, 1] memory blocks, sum=3
(...)
Tests result: FAILURE

I disabled the C accelerator _functools.

I'm now trying to disable the C accelerator of abc, but I had a small issue: 
bpo-36565.

--
Added file: https://bugs.python.org/file48250/test_functools2.py

___
Python tracker 

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



[issue36564] Infinite loop with short maximum line lengths in EmailPolicy

2019-04-08 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +xtreak

___
Python tracker 

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



[issue36565] Reference hunting (python3 -m test -R 3:3) doesn't work if the _abc module is missing

2019-04-08 Thread STINNER Victor


Change by STINNER Victor :


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

___
Python tracker 

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



[issue36565] Reference hunting (python3 -m test -R 3:3) doesn't work if the _abc module is missing

2019-04-08 Thread STINNER Victor


New submission from STINNER Victor :

Disable the compilation of the built-in _abc module. For example, on Python 3.7 
apply the following patch:

diff --git a/Modules/Setup.dist b/Modules/Setup.dist
index 8cc6bf0540..4015527b32 100644
--- a/Modules/Setup.dist
+++ b/Modules/Setup.dist
@@ -114,7 +114,7 @@ _weakref _weakref.c # weak references
 _functools -DPy_BUILD_CORE _functoolsmodule.c   # Tools for working with 
functions and callable objects
 _operator _operator.c  # operator.add() and similar goodies
 _collections _collectionsmodule.c  # Container types
-_abc _abc.c# Abstract base classes
+#_abc _abc.c   # Abstract base classes
 itertools itertoolsmodule.c# Functions creating iterators for 
efficient looping
 atexit atexitmodule.c  # Register functions to be run at 
interpreter-shutdown
 _signal -DPy_BUILD_CORE signalmodule.c
@@ -363,7 +363,8 @@ xxsubtype xxsubtype.c
 # Uncommenting the following line tells makesetup that all following modules
 # are not built (see above for more detail).
 #
-#*disabled*
+*disabled*
 #
 #_sqlite3 _tkinter _curses pyexpat
 #_codecs_jp _codecs_kr _codecs_tw unicodedata
+_abc


Recompile Python, check:

$ ./python -c 'import _abc'
ModuleNotFoundError: No module named '_abc'

Run:

$ ./python -u -m test -R 3:3 test_functools -m test_mro_conflicts 

Error without _abc:

test test_functools crashed -- Traceback (most recent call last):
  File "/home/vstinner/prog/python/3.7/Lib/test/libregrtest/runtest.py", line 
180, in runtest_inner
refleak = dash_R(the_module, test, test_runner, ns.huntrleaks)
  File "/home/vstinner/prog/python/3.7/Lib/test/libregrtest/refleak.py", line 
71, in dash_R
abcs)
  File "/home/vstinner/prog/python/3.7/Lib/test/libregrtest/refleak.py", line 
148, in dash_R_cleanup
obj.register(ref())
  File "/home/vstinner/prog/python/3.7/Lib/_py_abc.py", line 60, in register
raise TypeError("Can only register classes")
TypeError: Can only register classes

With built-in _abc module, regrtest is fine.

The problem comes from pure-Python reimplementation of abc._get_dump() in 
Lib/test/libregrtest/refleak.py:

def _get_dump(cls):
# For legacy Python version
return (cls._abc_registry, cls._abc_cache,
cls._abc_negative_cache, cls._abc_negative_cache_version)

The first item tuple must be a set of weak references. Currently, it's a weak 
set of strong references.

Attached PR fix the issue.

--
components: Library (Lib)
messages: 339661
nosy: vstinner
priority: normal
severity: normal
status: open
title: Reference hunting (python3 -m test -R 3:3) doesn't work if the _abc 
module is missing
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



[issue36564] Infinite loop with short maximum line lengths in EmailPolicy

2019-04-08 Thread Paul Ganssle


Change by Paul Ganssle :


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

___
Python tracker 

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



[issue36564] Infinite loop with short maximum line lengths in EmailPolicy

2019-04-08 Thread Paul Ganssle


New submission from Paul Ganssle :

When reviewing PR 12020 fixing an infinite loop in the e-mail module, I noticed 
that a *different* infinite loop is documented with a "# XXX" comment on line 
2724:

https://github.com/python/cpython/blob/58721a903074d28151d008d8990c98fc31d1e798/Lib/email/_header_value_parser.py#L2724

This is triggered when the policy's `max_line_length` is set to be shorter than 
minimum line length required by the "RFC 2047 chrome". It can be reproduced 
with:

from email.policy import default

policy = default.clone(max_line_length=7) # max_line_length = 78
policy.fold("Subject", "12345678")

I could not find an entry on the tracker for this bug, but it is documented in 
the source code itself, so maybe I just didn't try hard enough.

Related but distinct bugs: #33529, #33524

I will submit a patch to fix this.

--
messages: 339660
nosy: barry, p-ganssle, r.david.murray
priority: normal
severity: normal
status: open
title: Infinite loop with short maximum line lengths in EmailPolicy
versions: Python 3.7, Python 3.8

___
Python tracker 

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



[issue36554] unittest.TestCase: "subTest" cannot be used together with "debug"

2019-04-08 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
resolution:  -> duplicate
superseder:  -> unittest subTests() fails when called from debug()

___
Python tracker 

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



[issue36554] unittest.TestCase: "subTest" cannot be used together with "debug"

2019-04-08 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Thanks, just confirmed the commit fix with the given file.

--

___
Python tracker 

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



[issue36554] unittest.TestCase: "subTest" cannot be used together with "debug"

2019-04-08 Thread Dieter Maurer


Dieter Maurer  added the comment:

This is a duplicate of issue34900

--
stage:  -> resolved
status: open -> closed
Added file: https://bugs.python.org/file48249/utest.py

___
Python tracker 

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



[issue36563] pdbrc is read twice if current directory is the home directory

2019-04-08 Thread daniel hahler


Change by daniel hahler :


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

___
Python tracker 

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



[issue36563] pdbrc is read twice if current directory is the home directory

2019-04-08 Thread daniel hahler


New submission from daniel hahler :

If $HOME is $PWD, .pdbrc is read twice.

This confused me when seeing intentional errors from there twice during tests.

It should be only read once.

--
components: +Library (Lib)
title: pdbrc home twice -> pdbrc is read twice if current directory is the home 
directory
versions: +Python 3.9

___
Python tracker 

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



[issue36563] pdbrc home twice

2019-04-08 Thread daniel hahler


Change by daniel hahler :


--
nosy: blueyed
priority: normal
severity: normal
status: open
title: pdbrc home twice

___
Python tracker 

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



[issue36554] unittest.TestCase: "subTest" cannot be used together with "debug"

2019-04-08 Thread Dieter Maurer


Change by Dieter Maurer :


Added file: https://bugs.python.org/file48248/utest.py

___
Python tracker 

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



[issue35422] misleading error message from ssl.get_server_certificate() when bad port

2019-04-08 Thread Ruluk


Ruluk  added the comment:

I would still validate the error somewhere, maybe before reaching the OpenSSL 
library, because that same error is also shown for other cases. E.g:

http_connection = HTTPSConnection("localhost")
http_connection.request("POST", my_url, my_body, my_headers)

The use of an HTTPS connection for localhost effectively produces the same 
"SSL: WRONG VERSION NUMBER" error.

--
nosy: +ruluk

___
Python tracker 

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



[issue36561] Python argparse doesn't work in the presence of my custom module

2019-04-08 Thread Peter Otten


Peter Otten <__pete...@web.de> added the comment:

That's a bug in your code. You create another ArgumentParser in the toplevel 
code of preprocess.py. When this module is imported directly or indirectly your 
script will us this parser to parse the command line first. Minimal example:

$ cat preprocess.py
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--foo")
print(parser.parse_args())
$ cat test.py
import argparse
import preprocess

parser = argparse.ArgumentParser()
parser.add_argument("--bar")
print(parser.parse_args())
$ python3 test.py --bar 42
usage: test.py [-h] [--foo FOO]
test.py: error: unrecognized arguments: --bar 42
$ 

Fix: Protect toplevel code in preprocess.py with

if __name__ == "__main__":
parser = ...
...

--
nosy: +peter.otten

___
Python tracker 

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



[issue36561] Python argparse doesn't work in the presence of my custom module

2019-04-08 Thread Karthikeyan Singaravelan

Karthikeyan Singaravelan  added the comment:

test.py shown in msg339649 accepts only --data_type DATA_TYPE. Running test.py 
without import and the non-existent flag would show all the options present 
like the below I am using from the repo you have shared. You might 


./python.exe ../backups/bpo36561.py --non-existent 100
usage: bpo36561.py [-h] [--mode MODE] [--data_type DATA_TYPE] [--model-path 
MODEL_PATH]
   [--data-path DATA_PATH] [--data-shuffle DATA_SHUFFLE] 
[--batch-size BATCH_SIZE]
   [--num_epochs NUM_EPOCHS] [--val-step VAL_STEP] 
[--test-epoch TEST_EPOCH]
   [--start-epoch START_EPOCH] [--neg-cnt NEG_CNT] [--lr LR] 
[--beta1 BETA1]
   [--beta2 BETA2] [--dropout DROPOUT] [--n_critic N_CRITIC] 
[--emb-dim EMB_DIM]
   [--hidden HIDDEN] [--nb NB] [--train_path TRAIN_PATH] 
[--val_path VAL_PATH]
   [--test_path TEST_PATH]
bpo36561.py: error: unrecognized arguments: --non-existent 100

Looking further the problem might be that importing data_loader imports 
preprocess module and it has the below code. So this argparse code is executed 
and not the one from tests.py. Python executes all the top level code while 
importing. Maybe you can have this inside if __name__ == "__main__" so that 
this is not used while importing,

parser = argparse.ArgumentParser()
# data
parser.add_argument('--data_type', type=str, default="ml_100k")
args = parser.parse_args()
download_dataset(args.data_type)
preprocess(args.data_type)

Can help so that this is not executed.

if __name__ == "__main__":
parser = argparse.ArgumentParser()
# data
parser.add_argument('--data_type', type=str, default="ml_100k")
args = parser.parse_args()
download_dataset(args.data_type)
preprocess(args.data_type)

This is reproducible like this where you expect foo to be printed but due to 
import bar's argument parser is used : 

➜  gc-mc-pytorch git:(master) ✗ cat /tmp/foo.py
import bar
import argparse

parser = argparse.ArgumentParser()
parser.add_argument('--foo', required=True)
parser.parse_args()

➜  gc-mc-pytorch git:(master) ✗ cat /tmp/bar.py
import argparse

parser = argparse.ArgumentParser()
parser.add_argument('--bar', required=True)
parser.parse_args()

➜  gc-mc-pytorch git:(master) ✗ python3 /tmp/foo.py
usage: foo.py [-h] --bar BAR
foo.py: error: the following arguments are required: --bar


Either way it's not a bug in Python and it's a side effect of top level code 
being executed during importing the module. I am closing this as not a bug.

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



[issue36562] Can't call a method from a module built in Python C API

2019-04-08 Thread Joao Paulo


New submission from Joao Paulo :

I'm trying to build a python module in C++ using the Python C API and the code 
is attached.

The problem is when I run my_module.runTester() in PyRun_SimpleString. I get 
the following error message:

SystemError: Bad call flags in PyCFunction_Call. METH_OLDARGS is no longer 
supported!

I'm not using METH_OLDARGS. As you can see, I'm using METH_VARARGS | 
METH_KEYWORDS. What I could be missing here?

I'm using Windows 7 x64.

--
files: module.cpp
messages: 339653
nosy: jjppof
priority: normal
severity: normal
status: open
title: Can't call a method from a module built in Python C API
type: behavior
versions: Python 3.6
Added file: https://bugs.python.org/file48247/module.cpp

___
Python tracker 

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



[issue36559] "import random" should import hashlib on demand (nor load OpenSSL)

2019-04-08 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Why do we care about this particular import?  It doesn't see slow in any way.  
In general, we don't do deferred imports unless there is a compelling reason 
(i.e. it is very slow or it is sometimes unavailable).  Otherwise, it is a 
false optimization.

--
nosy: +rhettinger

___
Python tracker 

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



[issue36560] test_functools leaks randomly 1 memory block

2019-04-08 Thread STINNER Victor


STINNER Victor  added the comment:

Current bisection progress: I'm able to reproduce a failure with attached 
test_functools.py (211 lines) using:

./python -m test -F -j5 -R 3:3 test_functools  

It takes between 4 and 200 runs to reproduce the failure, I don't understand 
what triggers the bug.

I failed to identify if the bug is more likely when the system is idle or when 
the system is busy. It looks purely random.

--
Added file: https://bugs.python.org/file48246/test_functools.py

___
Python tracker 

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



[issue36533] logging regression with threading + fork are mixed in 3.7.1rc2 (deadlock potential)

2019-04-08 Thread cagney


cagney  added the comment:

I think the only pragmatic solution here is to add an optional parameter to 
logging.basicConfig() that specifies that the logger should use a single global 
lock; and then start documenting that thread locks and fork() don't work well 
together.

And note that this solution is pragmatic, not correct (@dhr, when we discussed 
this off line, pointed out that since python's using threads then a "correct" 
solution would be to use some sort of inter-process lock).

For instance, if I were to implement emit() as something contrived like:

with lock:
s = record.to-string()
for i in 1 .. s'length:
b[i] = s[i]
for i in 1 .. b'length:
stdout.write(b[i]).flush()
b = []

then when fork() breaks 'lock' the guarantee that the code is atomic is also 
broken:

- when the child enters the code 'b' is undefined
- the guarantee that log records don't interleave is lost

while a global lock would help mitigate the first case it really isn't a 
"correct" fix.

--

___
Python tracker 

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



[issue36561] Python argparse doesn't work in the presence of my custom module

2019-04-08 Thread JP Zhang


JP Zhang  added the comment:

>>>python test.py --num_epochs 200
usage: test.py [-h] [--data_type DATA_TYPE]
test.py: error: unrecognized arguments: --num_epochs 200

I have a created a colab share link. You can check: 
https://colab.research.google.com/drive/1TUvt4CCv2d43GD1ccmuRNBJlkbUPXN8Z

--

___
Python tracker 

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



[issue33632] undefined behaviour: signed integer overflow in threadmodule.c

2019-04-08 Thread Paul Ganssle


Change by Paul Ganssle :


--
nosy: +p-ganssle

___
Python tracker 

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



[issue36558] Change time.mktime() return type from float to int?

2019-04-08 Thread Paul Ganssle


Paul Ganssle  added the comment:

I would say that the natural output of mktime is indeed an integer, but I can't 
say off the top of my head what "compatibility" refers to here, so per the 
principle of Chesterton's fence, without more research or historical context 
I'd say the default should be *not* to make this change.

At the moment, I'm -0 on this, because "we should have designed the API this 
way in the first place" doesn't seem like a good enough reason to change the 
return type. I doubt it would be *terribly* onerous to the users to change 
this, so if there's some compelling reason for making it an integer I'm willing 
to be persuaded, but as it stands I don't think this is causing a huge amount 
of confusion or problems.

One other possible reason to mildly prefer no change is that if we were to 
change `struct_time` to accept a float for `tm_sec` (which I imagine might have 
more widespread consequences, admittedly), it wouldn't require a change to 
`mktime` to support sub-second offsets. Again, a compelling use case for an 
`int` return value could pretty easily overwhelm this objection.

> mktime() will not start losing precision before year 285,422,891 (which is 
> quite far in the future ;-)).

I think we're witnessing the birth of the Y285M422K891 bug! winking face emoji

--

___
Python tracker 

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



[issue36561] Python argparse doesn't work in the presence of my custom module

2019-04-08 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Can you please post the traceback you are getting and how you are running the 
script from command line? The custom module has third party dependencies like 
numpy so it will be helpful if you can attach a reproducer without dependencies 
to see if it's a problem with CPython or something with custom loader.

--
nosy: +xtreak

___
Python tracker 

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



[issue36561] Python argparse doesn't work in the presence of my custom module

2019-04-08 Thread JP Zhang


New submission from JP Zhang :

Github repo for reproducing: https://github.com/zjplab/gc-mc-pytorch/tree/bug, 
test.py. 

In the presence of my custom data_loader, it will error as unrecognized 
argument. But without importing it(comment it out) everything is just fine.

--
components: Library (Lib)
messages: 339646
nosy: JP Zhang
priority: normal
severity: normal
status: open
title: Python argparse doesn't work in the presence of my custom module
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-04-08 Thread Jeroen Demeyer


Change by Jeroen Demeyer :


--
pull_requests: +12653

___
Python tracker 

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



[issue36557] Python (Launcher)3.7.3 CMDLine install/uninstall

2019-04-08 Thread Steve Dower


Steve Dower  added the comment:

Pass /passive to have it automatically close at the end, or /quiet to avoid 
popping up a window at all.

Can you clarify what you mean by launcher? There are a couple different things 
you could be talking about and I don't want to give you the wrong answer.

--

___
Python tracker 

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



[issue33632] undefined behaviour: signed integer overflow in threadmodule.c

2019-04-08 Thread Zackery Spytz


Zackery Spytz  added the comment:

I've created a PR based on Martin Panter's patch.

--
components: +Extension Modules -Library (Lib)
nosy: +ZackerySpytz
versions:  -Python 3.6

___
Python tracker 

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



[issue33632] undefined behaviour: signed integer overflow in threadmodule.c

2019-04-08 Thread Zackery Spytz


Change by Zackery Spytz :


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

___
Python tracker 

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



[issue36560] test_functools leaks randomly 1 memory block

2019-04-08 Thread STINNER Victor


New submission from STINNER Victor :

Sometimes, each run of test_functools leaks exactly 1 memory block, even when 
the whole test is "re-run in verbose mode". Sometimes, it doesn't leak.

https://buildbot.python.org/all/#/builders/80/builds/550

test_functools leaked [1, 1, 1] memory blocks, sum=3
Re-running test 'test_functools' in verbose mode
test_functools leaked [1, 1, 1] memory blocks, sum=3

Maybe the problem comes from 

Example on Linux:

$ ./python -m test -F -r -j1 -R 3:3 test_functools  
Using random seed 3891892
Run tests in parallel using 1 child processes
0:00:01 load avg: 2.38 [  1] test_functools passed
beginning 6 repetitions
123456
..
(...)
0:00:06 load avg: 2.27 [  6] test_functools passed
beginning 6 repetitions
123456
..
0:00:07 load avg: 2.27 [  7/1] test_functools failed
beginning 6 repetitions
123456
..
test_functools leaked [1, 2, 1] memory blocks, sum=4
0:00:08 load avg: 2.27 [  8/1] test_functools passed
beginning 6 repetitions
123456
..

== Tests result: FAILURE ==

7 tests OK.

1 test failed:
test_functools

Total duration: 8 sec 333 ms
Tests result: FAILURE

--
components: Tests
messages: 339643
nosy: vstinner
priority: normal
severity: normal
status: open
title: test_functools leaks randomly 1 memory block
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



[issue18372] _Pickler_New() doesn't call PyObject_GC_Track(self)

2019-04-08 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Tracking objects that do not need this will just add work to the garbage 
collector. Not all instances of trackable types should be tracked, for example 
the empty tuple and some dicts are not tracked.

>>> gc.is_tracked(())
False
>>> gc.is_tracked((1, 2))
True
>>> gc.is_tracked({1: None})
False
>>> gc.is_tracked({1: []})
True

--

___
Python tracker 

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



[issue36414] Multiple test failures in GCC and Clang optional builds on Travis CI

2019-04-08 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

https://github.com/python/cpython/pull/12708 that seems to fix similar issue 
(issue36544) for Ubuntu that helps in making Mac OS build green again. 

Successful build : https://travis-ci.org/python/cpython/jobs/516821454

--
nosy: +xdegaye

___
Python tracker 

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



[issue36551] Optimize list comprehensions with preallocate size and protect against overflow

2019-04-08 Thread Nick Coghlan


Nick Coghlan  added the comment:

I was going to note that the algorithm Anthony has pursued here is the same one 
we already use for the list constructor and list.extend(), but Inada-san 
already pointed that out :)

While length_hint is allowed to be somewhat inaccurate, we do expect it to be 
at least *vaguely* accurate (otherwise it isn't very useful, and if it can be 
inaccurate enough to trigger OverflowError or MemoryError in cases that would 
otherwise work reasonably well, it would be better for a type not to implement 
it at all).

While it would be nice to be able to avoid adding a new opcode, the problem is 
that the existing candidate opcodes (BUILD_LIST, BUILD_LIST_UNPACK) are both 
inflexible in what they do:

- BUILD_LIST requires that the final list length be known at compile time
- BUILD_LIST_UNPACK infers the final length from an object reference, but calls 
_PyList_Extend directly, so it combines the preallocation and the iterator 
consumption into a single step, and hence can't be used outside of iterable 
unpacking into a list

At the same time, attempting to generalise either of them isn't desirable, 
since it would slow them down for their existing use cases, and be slower than 
a new opcode for this use case.

The proposed BUILD_LIST_PREALLOC opcode splits the difference: it lets the 
compiler provide the interpreter with a *hint* as to how big the resulting list 
is expected to be.

That said, you'd want to run the result through the benchmark suite rather than 
relying solely on microbenchmarks, as even though unfiltered 
"[some_operation_on_x for x in y]" comprehensions without nested loops or 
filter clauses are pretty common (more common than the relatively new "[*itr]" 
syntax), it's far less clear what the typical distribution in input lengths 
actually is, and how many memory allocations need to be avoided in order to 
offset the cost of the initial _PyObject_LengthHint call (as Pablo's small 
scale results show).

(Note that in the _PyList_Extend code, there are preceding special cases for 
builtin lists and tuples that take those down a much faster path that avoids 
the _PyObject_LengthHint call entirely)

--

___
Python tracker 

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



[issue36478] backport of pickle fixes to Python 3.5.7 uses C99 for loops

2019-04-08 Thread Anthony Sottile


Anthony Sottile  added the comment:

It's a rather oldish gcc in this case. (4.8.4 + whatever ubuntu patches). 
Here's a full (successful) build log (including the combinations of flags) 
after patching: 
https://launchpadlibrarian.net/416985438/buildlog_ubuntu-trusty-amd64.python3.5_3.5.7-1+trusty1_BUILDING.txt.gz

iirc this version of gcc defaults to "gnu89" as the standard c target

--

___
Python tracker 

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



[issue35416] Fix potential resource warnings in distutils

2019-04-08 Thread Inada Naoki


Change by Inada Naoki :


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



[issue36559] "import random" should import hashlib on demand (nor load OpenSSL)

2019-04-08 Thread STINNER Victor


STINNER Victor  added the comment:

In the past, some developers complained when an import has been removed in a 
stdlib module. I vaguely recall code using "import os" to get the "errno" 
module from "os.errno". That's "What's New in Python 3.7" contains:

"Several undocumented internal imports were removed. One example is that 
os.errno is no longer available; use import errno directly instead. Note that 
such undocumented internal imports may be removed any time without notice, even 
in micro version releases."

For this reason, I don't think that stable versions (2.7 and 3.7) should be 
modified.

--

___
Python tracker 

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



[issue36559] "import random" should import hashlib on demand (nor load OpenSSL)

2019-04-08 Thread STINNER Victor


Change by STINNER Victor :


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

___
Python tracker 

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



[issue36559] "import random" should import hashlib on demand (nor load OpenSSL)

2019-04-08 Thread STINNER Victor


New submission from STINNER Victor :

Currently, when the random module is imported, the hashlib module is always 
imported which loads the OpenSSL library, whereas hashlib is only needed when a 
Random() instance is created with a string seed.

For example, "rnd = random.Random()" and "rnd = random.Random(12345)" don't 
need hashlib.

Example on Linux:

$ python3
Python 3.7.2 (default, Mar 21 2019, 10:09:12) 
>>> import os, sys

>>> 'hashlib' in sys.modules
False
>>> res=os.system(f"grep ssl /proc/{os.getpid()}/maps")

>>> import random
>>> 'hashlib' in sys.modules
True
>>> res=os.system(f"grep ssl /proc/{os.getpid()}/maps")
7f463ec38000-7f463ec55000 r--p  00:2a 5791335
/usr/lib64/libssl.so.1.1.1b
7f463ec55000-7f463eca5000 r-xp 0001d000 00:2a 5791335
/usr/lib64/libssl.so.1.1.1b
...


Attached PR only imports hashlib on demand.

Note: I noticed this issue while working on adding OpenSSL 1.1.1 support to 
Python 3.4 :-)

--
components: Library (Lib)
messages: 339637
nosy: vstinner
priority: normal
severity: normal
status: open
title: "import random" should import hashlib on demand (nor load OpenSSL)
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



[issue36551] Optimize list comprehensions with preallocate size and protect against overflow

2019-04-08 Thread Pablo Galindo Salgado

Pablo Galindo Salgado  added the comment:

> That is a one-off cost for the __length_hint__ of the range object 
> specifically.
Objects with a known length (lists, sets, tuples) would not have that overhead.

That seems incorrect. This is not unique of range objects as it affects also 
objects with known lengths (like a list):

import perf

runner = perf.Runner()
runner.timeit("list_comp",
   stmt="[x*2 for x in k]",
   setup="k=list(range(10))")


Current master:
❯ ./python.exe ../check.py -n 10
.
list_comp: Mean +- std dev: 3.82 us +- 0.13 us

PR 12718:
❯ ./python.exe ../check.py -n 10
.
list_comp: Mean +- std dev: 4.38 us +- 0.16 us


Check also my other benchmark with a list iterator ( iter(list(range(10))) ) or 
this one with a generator comp:

import perf

runner = perf.Runner()
runner.timeit("list_comp",
   stmt="[x*2 for x in it]",
   setup="k=list(range(10));it=(x for x in k)")


Current master:
❯ ./python.exe ../check.py -n 10
.
list_comp: Mean +- std dev: 945 ns +- 27 ns


PR 12718:
❯ ./python.exe ../check.py -n 10
.
list_comp: Mean +- std dev: 1.33 us +- 0.05 us

--

___
Python tracker 

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



[issue35416] Fix potential resource warnings in distutils

2019-04-08 Thread Inada Naoki

Inada Naoki  added the comment:


New changeset 58721a903074d28151d008d8990c98fc31d1e798 by Inada Naoki (Mickaël 
Schoentgen) in branch 'master':
bpo-35416: fix potential resource warnings in distutils (GH-10918)
https://github.com/python/cpython/commit/58721a903074d28151d008d8990c98fc31d1e798


--
nosy: +inada.naoki

___
Python tracker 

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



[issue36551] Optimize list comprehensions with preallocate size and protect against overflow

2019-04-08 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


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

___
Python tracker 

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



[issue15903] Make rawiobase_read() read directly to bytes object

2019-04-08 Thread Mark Lawrence


Change by Mark Lawrence :


--
nosy:  -BreamoreBoy

___
Python tracker 

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



[issue36551] Optimize list comprehensions with preallocate size and protect against overflow

2019-04-08 Thread Pablo Galindo Salgado

Pablo Galindo Salgado  added the comment:

> That is a one-off cost for the __length_hint__ of the range object 
> specifically.
Objects with a known length (lists, sets, tuples) would not have that overhead.

That seems incorrect. This is not unique of range objects as it affects also 
objects with known lengths (like a list):

import perf

runner = perf.Runner()
runner.timeit("list_comp",
   stmt="[x*2 for x in k]",
   setup="k=list(range(10))")


Current master:
❯ ./python.exe ../check.py -n 10
.
list_comp: Mean +- std dev: 3.82 us +- 0.13 us

PR 12718:
❯ ./python.exe ../check.py -n 10
.
list_comp: Mean +- std dev: 4.38 us +- 0.16 us


Check also my other benchmark with a list iterator ( iter(list(range(10))) ) or 
this one with a generator comp:

import perf

runner = perf.Runner()
runner.timeit("list_comp",
   stmt="[x*2 for x in it]",
   setup="k=list(range(10));it=(x for x in k)")


Current master:
❯ ./python.exe ../check.py -n 10
.
list_comp: Mean +- std dev: 967 ns +- 27 ns


PR 12718:
❯ ./python.exe ../check.py -n 10
.
list_comp: Mean +- std dev: 1.22 us +- 0.04 us

--
nosy: +pablogsal

___
Python tracker 

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



[issue36558] Change time.mktime() return type from float to int?

2019-04-08 Thread STINNER Victor


Change by STINNER Victor :


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

___
Python tracker 

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



[issue15994] memoryview to freed memory can cause segfault

2019-04-08 Thread Inada Naoki


Change by Inada Naoki :


--
nosy: +inada.naoki

___
Python tracker 

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



  1   2   >