[issue30878] The staticmethod doesn't properly reject keyword arguments

2017-07-08 Thread Kay Hayen

New submission from Kay Hayen:

Check out this:

python3.6 -c "staticmethod(function=1)"
Traceback (most recent call last):
  File "", line 1, in 
TypeError: staticmethod expected 1 arguments, got 0

python3.6 -c "staticmethod()"
Traceback (most recent call last):
  File "", line 1, in 
TypeError: staticmethod expected 1 arguments, got 0

python3.6 -c "staticmethod(f=1)"
Traceback (most recent call last):
  File "", line 1, in 
TypeError: staticmethod expected 1 arguments, got 0

I believe Python 2.7 behaves the same.

What should happen is more like this:

python3.6 -c "range(f=1)"
Traceback (most recent call last):
  File "", line 1, in 
TypeError: range() does not take keyword arguments

While statically optimizing, I came across this as a first. At least 
"classmethod" behaves the same. I suppose it is because these are not intended 
for manual use anymore.

I would recommend to fix up the argument parsing to either indicate its 
rejection of keyword arguments, or to accept "function = " for input 
(preferred).

Thanks,
Kay Hayen

--
components: Interpreter Core
messages: 297946
nosy: kayhayen
priority: normal
severity: normal
status: open
title: The staticmethod doesn't properly reject keyword arguments
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



[issue30876] SystemError on import

2017-07-08 Thread Nick Coghlan

Nick Coghlan added the comment:

If there are intermittent concurrent problems associated with this behaviour, I 
think that may be a sign that the current management of the per-module import 
locks is inadequate, since it isn't adequately accounting for direct 
manipulation of sys.modules in user code.

Fully resolving that would probably mean ensuring that:

1. For submodule imports, we always acquire the parent module locks in a 
consistent order, and then hang onto them until the submodule import is 
complete rather than letting them go as soon as the parent module import is 
complete
2. We move the current sys.modules to sys._modules, and make sys.modules a 
proxy mapping that acquires the relevant import locks in the same consistent 
order for set and delete operations before mutating sys._modules

If we did that, then we should consistently get one of the following two orders:

1. Thread A imports package, package.module1, package.module2; Thread B then 
unloads (and maybe reloads) package; or
2. Thread B then unloads (and maybe reloads) package; Thread A imports package, 
package.module1, package.module2

By contrast, at the moment there's a window where the following can happen:

- Thread A finishes importing "package" and starts importing "package.module1"
- Thread B unloads "package"
- Thread A hits SystemError through no fault of its own when it hits the "from 
. import module2" line

That said, formulating the problem that way does suggest another potential 
resolution: in this scenario, we could treat "from . import module2" *exactly* 
the same way we would handle "import package.module2", which would be to just 
import "package" again, rather than complaining that it "should" already be 
imported.

In addition to being vastly simpler to implement, that approach would have the 
virtue of also fixing the "del sys.modules(__package__)" case, not just the 
potential race condition.

--

___
Python tracker 

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



[issue30878] The staticmethod doesn't properly reject keyword arguments

2017-07-08 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

This is similar to recently fixed issue30534 and issue30627. The solution is 
simple as for issue30627.

--
keywords: +easy (C)
nosy: +SylvainDe, serhiy.storchaka
stage:  -> needs patch
type:  -> enhancement
versions: +Python 3.7 -Python 3.6

___
Python tracker 

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



[issue30877] possibe typo in json/scanner.py

2017-07-08 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Good catch c-fos!

The scan_once() wrapper was introduced in issue7451, but py_make_scanner() 
still returns unwrapped _scan_once().

Is it possible to write a test that catches this bug?

--
nosy: +pitrou, serhiy.storchaka
stage:  -> patch review
versions: +Python 3.5, Python 3.6

___
Python tracker 

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



[issue10438] list an example for calling static methods from WITHIN classes

2017-07-08 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
status: open -> pending

___
Python tracker 

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



[issue26528] NameError for built in function open when re-raising stored exception from yielded function

2017-07-08 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The interpreter makes a copy of the builtins module dict at startup and 
restores it at shutdown. open() is imported from the io module after making the 
copy, and therefore it is absent in restored module.

--
nosy: +haypo, pitrou, serhiy.storchaka

___
Python tracker 

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



[issue30877] possibe typo in json/scanner.py

2017-07-08 Thread c-fos

c-fos added the comment:

The possible test:

import unittest
from json.decoder import JSONDecoder

class Memo_Test(unittest.TestCase):
def test_for_empty_memo(self):
json_str = '{"a": 1}'
decoder = JSONDecoder()
decoder.decode(json_str)
self.assertEqual(decoder.memo, {})

suite = unittest.TestSuite()
suite.addTest(Memo_Test("test_for_empty_memo"))
runner = unittest.TextTestRunner()
runner.run(suite)

But it works only when _json import fails

--

___
Python tracker 

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



[issue30877] possibe typo in json/scanner.py

2017-07-08 Thread c-fos

c-fos added the comment:

Test independent from _json library:

import unittest
from json.decoder import JSONDecoder
from json.scanner import py_make_scanner

class Memo_Test(unittest.TestCase):
def test_for_empty_memo(self):
json_str = '{"a": 1}'
decoder = JSONDecoder()
decoder.scan_once = py_make_scanner(decoder)
result = decoder.decode(json_str)
self.assertEqual(result, {"a":1})
self.assertEqual(decoder.memo, {})

suite = unittest.TestSuite()
suite.addTest(Memo_Test("test_for_empty_memo"))
runner = unittest.TextTestRunner()
runner.run(suite)

--

___
Python tracker 

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



[issue30873] `SystemError: returned NULL without setting an error` from importing _pickle

2017-07-08 Thread ppperry

ppperry added the comment:

Interesting. For you, `_pickle` seems to be an extension module, which is thus 
trying to call `imp.create_dynamic`, whereas for me it is a builtin module. 
Perhaps that explains why you get a KeyError and I get a SystemError (my 
traceback ends with):
  File "C:\Program Files\Python36\lib\importlib\_bootstrap.py", line 560, in 
module_from_spec
module = spec.loader.create_module(spec)
  File "C:\Program Files\Python36\lib\importlib\_bootstrap.py", line 725, in 
create_module
return _call_with_frames_removed(_imp.create_builtin, spec)
  File "C:\Program Files\Python36\lib\importlib\_bootstrap.py", line 205, in 
_call_with_frames_removed
return f(*args, **kwds)
SystemError:  returned NULL without setting 
an error
(and is the same as your 3.6 traceback up to that point)

--

___
Python tracker 

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



[issue30873] `SystemError: returned NULL without setting an error` from importing _pickle

2017-07-08 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Ah, this is Windows-only _imp.create_builtin().

--
components: +Windows
nosy: +paul.moore, steve.dower, tim.golden, zach.ware

___
Python tracker 

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



[issue30873] `SystemError: returned NULL without setting an error` from importing _pickle on Windows

2017-07-08 Thread ppperry

Changes by ppperry :


--
title: `SystemError:  returned NULL without 
setting an  error` from importing _pickle -> `SystemError:  returned NULL without setting an  error` from importing _pickle 
on Windows

___
Python tracker 

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



[issue29854] Segfault when readline history is more then 2 * history size

2017-07-08 Thread Berker Peksag

Berker Peksag added the comment:


New changeset aa6a4d6ed881f79c51fb91dd928ed9496737b420 by Berker Peksag (Nir 
Soffer) in branch 'master':
bpo-29854: Skip history-size test on older readline (GH-2621)
https://github.com/python/cpython/commit/aa6a4d6ed881f79c51fb91dd928ed9496737b420


--

___
Python tracker 

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



[issue30444] Add ability to change "-- more --" text in pager module

2017-07-08 Thread Gautam krishna.R

Gautam krishna.R added the comment:

Thank you! closing this due to inncativity..

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



[issue30522] Allow replacing a logging.StreamHandler's stream

2017-07-08 Thread Vinay Sajip

Vinay Sajip added the comment:

How about this as an API?

def setStream(self, stream):
"""
Sets the StreamHandler's stream to the specified value,
if it is different.

Returns the old stream, if the stream was changed, or None
if it wasn't.
"""

--

___
Python tracker 

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



[issue30522] Allow replacing a logging.StreamHandler's stream

2017-07-08 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Vinay, yes, that sounds fine to me.

--

___
Python tracker 

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



[issue30875] round(number[, digits]) does not return value with >12 decimal places

2017-07-08 Thread Mark Dickinson

Changes by Mark Dickinson :


--
nosy: +mark.dickinson

___
Python tracker 

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



[issue29854] Segfault when readline history is more then 2 * history size

2017-07-08 Thread Nir Soffer

Changes by Nir Soffer :


--
pull_requests: +2698

___
Python tracker 

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



[issue30875] round(number[, digits]) does not return value with >12 decimal places

2017-07-08 Thread john Forgue

john Forgue added the comment:

I found a programming issue that circumvented the round function.  As for the 
terminal "verification" I reported I'm not sure what I did and cannot 
repeat.

Sorry for the false alarm.

John

--
resolution:  -> works for me
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



[issue30879] os.listdir(bytes) gives a list of bytes, but os.listdir(buffer) gives a list of unicodes

2017-07-08 Thread Armin Rigo

New submission from Armin Rigo:

The ``os`` functions generally accept any buffer-supporting object as file 
names, and interpret it as if ``bytes()`` had been called on it.  However, 
``os.listdir(x)`` uses the type of ``x`` to know if it should return a list of 
bytes or a list of unicodes---and the condition seems to be ``isinstance(x, 
bytes)``.  So we get this kind of inconsistent behaviour:

>>> os.listdir(b".")
[b'python', b'Include', b'python-config.py', ...]

>>> os.listdir(bytearray(b"."))
['python', 'Include', 'python-config.py', ...]

--
components: Library (Lib)
messages: 297960
nosy: arigo
priority: normal
severity: normal
status: open
title: os.listdir(bytes) gives a list of bytes, but os.listdir(buffer) gives a 
list of unicodes
type: behavior
versions: Python 3.5, Python 3.7

___
Python tracker 

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



[issue30879] os.listdir(bytes) gives a list of bytes, but os.listdir(buffer) gives a list of unicodes

2017-07-08 Thread Alex Gaynor

Changes by Alex Gaynor :


--
nosy: +alex

___
Python tracker 

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



[issue30880] PCG random number generator

2017-07-08 Thread Evelyn Mitchell

New submission from Evelyn Mitchell:

John Cook tested the quality of the PCG Random Number generator 
(http://www.pcg-random.org/index.html) and it appears to have good performance. 

His report is at: 
https://www.johndcook.com/blog/2017/07/07/testing-the-pcg-random-number-generator/

This is a suggestion to add a PCG implementation.

--
messages: 297961
nosy: Evelyn Mitchell
priority: normal
severity: normal
status: open
title: PCG random number generator
type: enhancement

___
Python tracker 

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



[issue30879] os.listdir(bytes) gives a list of bytes, but os.listdir(buffer) gives a list of unicodes

2017-07-08 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
pull_requests: +2699

___
Python tracker 

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



[issue30879] os.listdir(bytes) gives a list of bytes, but os.listdir(buffer) gives a list of unicodes

2017-07-08 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Good catch Armin! PR 2634 fixes this inconsistency.

Maybe it is worth to deprecate support of other bytes-like object except bytes. 
open(), os.fspath() and os.path functions don't support them.

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



[issue30880] PCG random number generator

2017-07-08 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
components: +Extension Modules
nosy: +mark.dickinson, rhettinger
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



[issue30879] os.listdir(bytes) gives a list of bytes, but os.listdir(buffer) gives a list of unicodes

2017-07-08 Thread Armin Rigo

Armin Rigo added the comment:

I've also been pointed to https://bugs.python.org/issue26800 .

--

___
Python tracker 

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



[issue30876] SystemError on import

2017-07-08 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I concur with Serhiy: SystemError is a smell that C code isn't taking 
appropriate precautions before dealing with user code or data.

--
nosy: +pitrou

___
Python tracker 

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



[issue30876] SystemError on import

2017-07-08 Thread Brett Cannon

Brett Cannon added the comment:

So this is very old semantics from the Python 2 days. I think Nick's idea of 
transforming the import to `import pkg.mod` when pkg isn't in sys.modules is 
probably the simplest, cleanest solution if we're going to change this.

--

___
Python tracker 

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



[issue30841] A shadowing variable naming emitted for Python-ast.c

2017-07-08 Thread Brett Cannon

Changes by Brett Cannon :


--
priority: normal -> low

___
Python tracker 

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



[issue30841] A shadowing variable naming emitted for Python-ast.c

2017-07-08 Thread Brett Cannon

Changes by Brett Cannon :


--
type: compile error -> enhancement

___
Python tracker 

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



[issue30814] Import dotted name as alias breaks with concurrency

2017-07-08 Thread Brett Cannon

Brett Cannon added the comment:

I just wanted to say thanks to everyone who helped to fix this bug. The locking 
situation in import is probably the trickiest part of it and has also been 
tweaked the most as of late and so solving these kinds of issues is tricky.

--

___
Python tracker 

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



[issue29854] Segfault when readline history is more then 2 * history size

2017-07-08 Thread Berker Peksag

Berker Peksag added the comment:


New changeset 04f77d4677e7508b6ec8de9d0331fdabbcd11d30 by Berker Peksag (Nir 
Soffer) in branch '3.6':
[3.6] bpo-29854: Fix segfault in call_readline() (GH-728)
https://github.com/python/cpython/commit/04f77d4677e7508b6ec8de9d0331fdabbcd11d30


--

___
Python tracker 

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



[issue30870] IDLE: configdialog/fonts: change font when select by key up/down

2017-07-08 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
stage:  -> patch review
type:  -> enhancement
versions: +Python 3.6

___
Python tracker 

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



[issue30880] PCG random number generator

2017-07-08 Thread Mark Dickinson

Mark Dickinson added the comment:

Some previous discussions: "Time for a change of random number generator": 
https://mail.python.org/pipermail/python-dev/2016-February/143268.html

"Should our default random number generator be secure?": (warning: long) 
https://mail.python.org/pipermail/python-ideas/2015-September/035820.html

--

___
Python tracker 

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



[issue30878] The staticmethod doesn't properly reject keyword arguments

2017-07-08 Thread SylvainDe

SylvainDe added the comment:

I have a fix ready but I'll look if other functions using _PyArg_NoKeywords may 
have the same defect before submitting it.

--

___
Python tracker 

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



[issue30868] IDLE: Improve configuration tests with mock Save.

2017-07-08 Thread Cheryl Sabella

Cheryl Sabella added the comment:

If it's helpful, here's some history on Save and save_as in configdialog.

--
Item: Code change which added the lines to always save 'highlight' and 'keys'.

November 16, 2004, commit 5acdf9308191b6356fb3ed4ba691ba5cd391f202

commit message:
 Saving a Keyset w/o making changes (by using the "Save as New Custom …

…Key Set"

button) caused IDLE to fail on restart (no new keyset was created in
config-keys.cfg).  Also true for Theme/highlights.  Python Bug 1064535.
--

Item: Code change to always save 'main' first.  Not much information, but seems 
to be part of the handling of the help source changes.

March 26, 2002  commit 0c5bc8c9518fd18d41aedede536c4a9aa8dfa619 

Commit message:  further work on new config system;

user defined help items
--

--
nosy: +csabella

___
Python tracker 

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



[issue30880] PCG random number generator

2017-07-08 Thread Evelyn Mitchell

Evelyn Mitchell added the comment:

Mark, thanks for the background links.

My suggestion is much more constrained than the territory covered by those 
links.

--

___
Python tracker 

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



[issue30876] SystemError on importing module that deletes itself from sys.modules

2017-07-08 Thread ppperry

Changes by ppperry :


--
title: SystemError on import -> SystemError on importing module that deletes 
itself from sys.modules

___
Python tracker 

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



[issue30878] The staticmethod doesn't properly reject keyword arguments

2017-07-08 Thread SylvainDe

Changes by SylvainDe :


--
pull_requests: +2700

___
Python tracker 

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



[issue27068] Add a detach() method to subprocess.Popen

2017-07-08 Thread Martin Panter

Martin Panter added the comment:

Personally, I haven’t needed this feature. But I still think it may be a decent 
solution for the “webbrowser” module, potentially your “asyncio” problem, and 
other cases that could now trigger an unwanted ResourceWarning.

--

___
Python tracker 

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



[issue29854] Segfault when readline history is more then 2 * history size

2017-07-08 Thread Nir Soffer

Changes by Nir Soffer :


--
pull_requests: +2701

___
Python tracker 

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



[issue29854] Segfault when readline history is more then 2 * history size

2017-07-08 Thread Nir Soffer

Changes by Nir Soffer :


--
pull_requests: +2702

___
Python tracker 

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



[issue30881] IDLE: add docstrings to browser.py

2017-07-08 Thread Cheryl Sabella

New submission from Cheryl Sabella:

Add docstrings to browser.py to aid to unit test creation.

--
assignee: terry.reedy
components: IDLE
messages: 297973
nosy: csabella, terry.reedy
priority: normal
severity: normal
status: open
title: IDLE: add docstrings to browser.py
type: enhancement
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



[issue30881] IDLE: add docstrings to browser.py

2017-07-08 Thread Cheryl Sabella

Changes by Cheryl Sabella :


--
pull_requests: +2703

___
Python tracker 

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



[issue1612262] Class Browser doesn't show internal classes

2017-07-08 Thread Cheryl Sabella

Cheryl Sabella added the comment:

I created issue 30881 to add docstrings to browser.py to make creating user 
tests easier.

--

___
Python tracker 

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



[issue30868] IDLE: Improve configuration tests with mock Save.

2017-07-08 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Very helpful.  Is there a git equivalent to hg annotate, or did you have to 
trudge through the commit log?

--

___
Python tracker 

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



[issue8231] Unable to run IDLE without write-access to home directory

2017-07-08 Thread Terry J. Reedy

Terry J. Reedy added the comment:

#27534 is about reducing the imports into the user runcode process. Without 
rechecking the reason for each import, I think it possible that this might 
result in config not being indirectly imported.

--
dependencies: +IDLE: Reduce number and time for user process imports

___
Python tracker 

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



[issue30880] PCG random number generator

2017-07-08 Thread Raymond Hettinger

Raymond Hettinger added the comment:

FWIW, the previous discussions on the MersenneTwister have all resulted in a 
decision to stick with it.

The PCG family of PRNG is relatively new.  IIRC, the paper for it was never 
accepted for publication and some of its bolder claims haven't been proven.  It 
is far being standard or widely adopted.  In addition, there is not a single 
"the PCG RNG".  Instead, it is a collection of ideas and patterns for creating 
RNGs without recommending a single one that the "here use this one".

Tim reminded us that any issues for the MersenneTwister didn't surface for many 
years after its initial publication and wide-spread acceptance.  That is a 
cautionary note for adopting something too soon.

FWIW, I reviewed the PCG work a good while ago and discussed it with Guido.  
The decision was to stick with the current safe choice.

That said, if someone wants to add this to PyPi, it is a really easy coding 
task.  There isn't much to the PCG code and the Python random module was 
designed to be "pluggable" so that other RNGs can easily be substituted by user.

--
assignee:  -> rhettinger
resolution:  -> rejected
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue10438] list an example for calling static methods from WITHIN classes

2017-07-08 Thread Raymond Hettinger

Raymond Hettinger added the comment:

I also don't think this is worth it.  The extra wording will likely cause more 
confusion that it clears up.

Also, calling a staticmethod from within a class isn't a common thing to do.  
The principal use case for Python's static methods is to attach a function to a 
class for the sole purpose of making it findable by someone using that class.

--
nosy: +rhettinger
status: pending -> open

___
Python tracker 

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



[issue30821] unittest.mock.Mocks with specs aren't aware of default arguments

2017-07-08 Thread Raymond Hettinger

Raymond Hettinger added the comment:

No need to spend time making a PR until there is a decision about whether this 
is something we want to do.

--
assignee:  -> michael.foord
nosy: +rhettinger

___
Python tracker 

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



[issue30880] PCG random number generator

2017-07-08 Thread Tim Peters

Tim Peters added the comment:

I agree closing was appropriate at this time.  I quite like PCG, but as Raymond 
said it's more a template for creating PRNGs than a specific generator.  So 
even if a compelling case could be made, there's still a long way to having 
specific code in mind.

In the Python world, the only non-trivial (i.e., not just a pure-Python toy 
demo program) PCG work I'm aware of is Robert Kern's (numpy's PRNG specialist) 
experiment with wrapping it:

https://github.com/rkern/pcg-python

But it hasn't been touched since late 2015.  It's also a bit concerning that 
Prof. O'Neill hasn't posted to her PCG blog in over 2 years:

http://www.pcg-random.org/blog/

I'm not concerned that the paper still hasn't been published - papers can sit a 
lng time in review queues, and I'm afraid her paper is far too 
down-to-earth, readable, entertaining, and long for the TOMS editors' tastes 
<0.3 wink>.

--
nosy: +tim.peters

___
Python tracker 

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



[issue30876] SystemError on importing module from unloaded package

2017-07-08 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
title: SystemError on importing module that deletes itself from sys.modules -> 
SystemError on importing module from unloaded package

___
Python tracker 

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



[issue30878] The staticmethod doesn't properly reject keyword arguments

2017-07-08 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:


New changeset 9648088e6ccd6d0cc04f450f55628fd8eda3784c by Serhiy Storchaka 
(Sylvain) in branch 'master':
bpo-30878: Fix error message when keyword arguments are passed (#2635)
https://github.com/python/cpython/commit/9648088e6ccd6d0cc04f450f55628fd8eda3784c


--

___
Python tracker 

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



[issue30878] The staticmethod doesn't properly reject keyword arguments

2017-07-08 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you for your report Kay and thank you for your patch SylvainDe.

--
resolution:  -> fixed
stage: needs patch -> resolved
status: open -> closed

___
Python tracker 

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



[issue30868] IDLE: Improve configuration tests with mock Save.

2017-07-08 Thread Terry J. Reedy

Terry J. Reedy added the comment:

This issue began with #27173 which added test_config with CurrentColorKeysTest 
to test the new IdleConf.current_colors_and_keys.  Those tests never called any 
user parser.Save, but I knew I had to remove the possibility that any future 
test would touch anyone's working .idlerc.  I thought of at least some of the 
following:

1. Directly replace config.IdleUserConfParser.Save.  Since 4 instances are 
created during import, this would require recreating idleCong.userCfg after 
import.  Restore the status quo by saving the original userCfg and restoring it 
after tests.  The same applies to 3. and 4.

2. Give instances a Save function, as Cheryl did in PR2610, 
test_config.ConfigChangesTest.test_save_all, to mask the instance method.
idleConf.userCfg['main'].Save = Func()
Restore the status quo by removing the instance function.

3. Subclass IdleUserConfigParser with a new Save and recreate userCfg, as 
Cheryl did in configdialog_tests_v1.py on #30868.  But instead of a dummy 
function, the replacement should be a mock.
class DummyUserConfParser(config.IdleUserConfParser):
Save = Func()  # or other Mock.
This is essentially 1. with subclassing being an alternate way to replace the 
original Save.

4. It turns out the initializing IdleUserConfParser with file name '' works to 
disable both Load and Save without raising an exception.  (Plain open('') gives 
me FileNotFoundError.)  So, recreate userCfg with instances initialized with ''.

When I opened this issue, I forgot about the no load part.  But it is in the  
comment near the top of test_config, and it is essential.  This suggests 
combining 3. and 4. by initializing a subclass with ''.

A. Testing ConfigChanges.save_all requires a count of calls.  Func can easily 
be upgraded to do that.

B. The real save function does not just save a page.  Instead, it removes empty 
sections and if the result is an empty page, the corresponding file is deleted, 
not just emptied. Testing the function requires a fairly functional substitute. 
 I am not sure yet how the solution for this should relate to A and its 
solution.

In #8231, I tried and failed to get IDLE to run with a temporary directory as 
the home directory, so people without a writeable home directory can still run 
IDLE.  Having to run with 2.7 is no more, for me, an issue.  Running in 2 
processes, and having config indirectly inported into the run process is.  As I 
noted there, #27534 could result in this issue going away.

I also want to look into a simulated in-memory 'directory', class IdleRC, 
contains StringIO instances, with a simulated open and any needed os functions. 
 (For instance, mock-open('.idlerc/config-main.cfg') returns the StringIO for 
'main'.)  This would be fast and instrumented for testing as we please.

C. 'Other tests' at the top of this post include both other tests in 
test_config and other test files.  If Solutions 1. to 4. have to include 
restoration, then they should be repeated in every test_file that imports 
config.  So why bother restoring, only to repatch?  This suggests that when 
testing, usefCfg should be created in an alternate state.

However, ... the current mechanism is that test.test_idle sets 
idlelib.__init__.testing to True.  This is fine for buildbots, which only run 
idle test by running test_idle.  So an IdelConf.set_testing, called from 
test_xyz would be needed.

D. Other modules write other configuration files into .idlerc. When a file is 
opened, it is added or moved to the top of recent-files.lst.  When the debugger 
is on and a file with breakpoints is run, the filename and breakpoint lines are 
supposed to be saved to breakpoints.lst.  (Withoug tests, this could have stop 
working without me noticing.)

So disabling parser saves during tests is not enough.  The other .idlerc saves 
must also be blocked.  Some sort of temporary directory is needed.

E. On the next issue after this, #30869, Victor Stinner requested that IDLE not 
even create $HOME/.idlerc on buildbots.

F. There systems on which IDLE does not find a place to write .idlerc.  IDLE 
now quits.  Any temporary directory would be better, at least as a choice.  See 
#8231 and #15862.

--

___
Python tracker 

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



[issue30879] os.listdir(bytes) gives a list of bytes, but os.listdir(buffer) gives a list of unicodes

2017-07-08 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Oh, I forgot that this feature already is deprecated!

--

___
Python tracker 

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



[issue30869] regrtest: Add .idlerc to saved_test_environment

2017-07-08 Thread Terry J. Reedy

Terry J. Reedy added the comment:

#27534 is about reducing run's imports.  I believe that the current patch may 
remove one path by which config is indirectly imported.  While writing 
msg297983 of #30868, I remembered that config files are not the only files put 
in .idlerc.  So a solution to block writing config files while testing is not 
enough.  An in-memory .idlerc with StringIOs for files, both for testing and 
for user systems without a place to write it, is looking more inviting to me 
than it did yesterday.

--

___
Python tracker 

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



[issue29464] Specialize FASTCALL for functions with positional-only parameters

2017-07-08 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


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

___
Python tracker 

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



[issue30876] SystemError on importing module from unloaded package

2017-07-08 Thread Nick Coghlan

Nick Coghlan added the comment:

OK, so at least for 3.7, we'll replace the SystemError with a recursive import 
of the missing parent package, just as we'd expect to see with an absolute 
import.

I'm classing this as "Won't fix" for the native import system in 2.7 - folks 
wanting the fix there will need to switch to using importlib2 (assuming that 
gets updated to include the fix at some point).

That leaves 3.5 and 3.6, and I'd suggest we defer making a decision about 
whether or not to backport the fix to the maintenance branches until after we 
see how complex the patch for 3.7 ends up being.

--
versions:  -Python 2.7

___
Python tracker 

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



[issue24845] IDLE functional/integration testing

2017-07-08 Thread Terry J. Reedy

Terry J. Reedy added the comment:

A different take on the proposal: A functional integration test for IDLE should 
open IDLE, rename .idlerc, open a new file, insert some text, and, for 
instance, at some point open the options dialog for testing.  As part this, the 
font face change would simulate button clicks and then check that the the font 
had changed in the editor *and* in .idlerc/config-main.cfg.  I have done this 
manually.  A complete functional test would do what I also occasionally do.  
Exercise at least once every menu function, all dialog widgets, and a few 
invisible functions.  Unless suppressed, even the print function should be 
included, verified by the user affirming that the printed page appeared.

Such a test should be separate from the unittest test suite, just as is the 
htest module.  Only a few buildbots run gui tests anyway, but some core devs 
run the suite regularly, some with gui enabled.  I don't want to impose on them 
in any way, neither another minute or two of test time, nor flickers and bells. 
 Running such a test suite should be strictly voluntary.

A few files could go in idle_test, like htest.py.  A large number might justify 
a separate func_test directory.

I don't want the mode of invocation and operation and the code style to be 
limited to that of unittest.

I envision IDLE and the functest code running in one process, with one Tk 
instance.  Which starts first is to be decided.  But if IDLE starts first, then 
Run Func Test can be a menu item.  I have already though of adding Run Unit 
Tests (in a subprocess) and Run Visual Tests (in the same process) to the Help 
Menu. 

The main use of setup and teardown in IDLE unit tests is to create and destroy 
Tk roots;  with one permanent root, these functionsgo away.

If test_xyz functions are defined at module scope, they are easy to collect and 
run.  This is the function I use in my own project.

def main(namespace):
for name, obj in namespace.items():
if name.startswith('test_') and hasattr(obj, '__call__'):
print(name)
obj()

The obj() call could be wrapped with

 try: obj()
 except Exception as e: print(e, file=output_window)

where output_window is an instance of IDLE's OutputWindow.  A helper equal(x,y) 
function could send an error message to the same place.

--

___
Python tracker 

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