[issue19108] Benchmark runner tries to execute external Python command and fails on error reporting

2016-09-02 Thread Stefan Behnel

Stefan Behnel added the comment:

Let's close this as outdated. New bugs for the new project should be reported 
in github anyway.

--
resolution:  -> out of date
status: open -> closed

___
Python tracker 

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



[issue19489] move quick search box above TOC

2016-09-02 Thread Zachary Ware

Zachary Ware added the comment:

Berker, would you mind giving this another look?  If you give it the OK, I can 
get it committed if you don't beat me to it.

--
assignee: docs@python -> berker.peksag

___
Python tracker 

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



[issue27883] Update sqlite version for Windows build

2016-09-02 Thread Zachary Ware

Zachary Ware added the comment:

I agree, we should update our sqlite version.  I'll try to get to this next 
week, but it shouldn't be a big deal if it misses beta 1 since it's not a new 
feature.

--
stage:  -> needs patch
title: sqlite-3.14.1 for Python_3.6.0b1 ? -> Update sqlite version for Windows 
build

___
Python tracker 

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



[issue27947] Trailing backslash in raw string format causes EOL

2016-09-02 Thread cfgbd

cfgbd added the comment:

Thanks for comment. Here I got my answer from string docs.

Even in a raw literal, quotes can be escaped with a backslash, but the 
backslash remains in the result; for example, r"\"" is a valid string literal 
consisting of two characters: a backslash and a double quote; r"\" is not a 
valid string literal (even a raw string cannot end in an odd number of 
backslashes). Specifically, a raw literal cannot end in a single backslash 
(since the backslash would escape the following quote character). Note also 
that a single backslash followed by a newline is interpreted as those two 
characters as part of the literal, not as a line continuation.

--

___
Python tracker 

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



[issue27947] Trailing backslash in raw string format causes EOL

2016-09-02 Thread Tim Peters

Changes by Tim Peters :


--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed
versions: +Python 3.2 -Python 3.4

___
Python tracker 

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



[issue27947] Trailing backslash in raw string format causes EOL

2016-09-02 Thread Ammar Askar

Ammar Askar added the comment:

This isn't a bug, in fact this very behavior is documented within the string 
docs, please read the last paragraph here:

https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals

--
nosy: +ammar2
title: Bug of python interpreter -> Trailing backslash in raw string format 
causes EOL

___
Python tracker 

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



[issue27947] Bug of python interpreter

2016-09-02 Thread cfgbd

New submission from cfgbd:

In python shell, I typed words and got result as follows. It seems that the use 
of 'r' before a literal string may cause an error that the an odd '\' at the 
end of literal string blocked the quote.

>>> rb'abc\\\'
SyntaxError: EOL while scanning string literal
>>> rb'abc\\'
b'abc'
>>> br'abc\\\ '
b'abc\\ '
>>> br'abc\\\'
SyntaxError: EOL while scanning string literal
>>> r'\\'
''
>>> r'\\\'
SyntaxError: EOL while scanning string literal

--
messages: 274282
nosy: cfgbd
priority: normal
severity: normal
status: open
title: Bug of python interpreter
type: behavior
versions: Python 3.4

___
Python tracker 

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



[issue27939] Tkinter mainloop raises when setting the value of ttk.LabeledScale

2016-09-02 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
nosy: +serhiy.storchaka
stage:  -> needs patch
type: crash -> behavior
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



[issue27928] Add hashlib.scrypt

2016-09-02 Thread Alex Gaynor

Alex Gaynor added the comment:

Bug in the error message "n must be a multiple of 2." it should say "n must be 
a power of 2."

--
nosy: +alex

___
Python tracker 

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



[issue23591] enum: Add Flags and IntFlags

2016-09-02 Thread Roundup Robot

Roundup Robot added the comment:

New changeset f33fc2117bb2 by Ethan Furman in branch 'default':
issue23591: bool(empty_flags) == False; more docs & tests
https://hg.python.org/cpython/rev/f33fc2117bb2

--

___
Python tracker 

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



[issue23591] enum: Add Flags and IntFlags

2016-09-02 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 31586a2f01b6 by Ethan Furman in branch 'default':
issue23591: optimize _high_bit()
https://hg.python.org/cpython/rev/31586a2f01b6

--

___
Python tracker 

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



[issue21122] CPython fails to build modules with LLVM LTO on Mac OS X

2016-09-02 Thread Brett Cannon

Brett Cannon added the comment:

Here is a patch to turn on `-Wl,-export_dynamic` when building with LTO. 
Unfortunately I have a bunch of tests that fail when running with LTO+PGO of 
the form of:

[ 95/398] test_bytes
Traceback (most recent call last):
  File "/Users/brettcannon/Repositories/python/cpython/3.5/Lib/runpy.py", line 
193, in _run_module_as_main
"__main__", mod_spec)
  File "/Users/brettcannon/Repositories/python/cpython/3.5/Lib/runpy.py", line 
85, in _run_code
exec(code, run_globals)
  File 
"/Users/brettcannon/Repositories/python/cpython/3.5/Lib/test/__main__.py", line 
3, in 
regrtest.main_in_temp_cwd()
  File 
"/Users/brettcannon/Repositories/python/cpython/3.5/Lib/test/regrtest.py", line 
1593, in main_in_temp_cwd
main()
  File 
"/Users/brettcannon/Repositories/python/cpython/3.5/Lib/test/regrtest.py", line 
756, in main
raise Exception("Child error on {}: {}".format(test, result[1]))
Exception: Child error on test_bytes: Exit code -6

--
keywords: +patch
resolution: fixed -> 
status: closed -> open
Added file: http://bugs.python.org/file44352/issue21122.diff

___
Python tracker 

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



[issue21122] CPython fails to build modules with LLVM LTO on Mac OS X

2016-09-02 Thread Brett Cannon

Changes by Brett Cannon :


--
components: +Macintosh

___
Python tracker 

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



[issue26359] CPython build options for out-of-the box performance

2016-09-02 Thread Brett Cannon

Brett Cannon added the comment:

So if I enable this manually, I get various test failures from modules on OS X 
El Capitan with the same type of failure:

[ 95/398] test_bytes
Traceback (most recent call last):
  File "/Users/brettcannon/Repositories/python/cpython/3.5/Lib/runpy.py", line 
193, in _run_module_as_main
"__main__", mod_spec)
  File "/Users/brettcannon/Repositories/python/cpython/3.5/Lib/runpy.py", line 
85, in _run_code
exec(code, run_globals)
  File 
"/Users/brettcannon/Repositories/python/cpython/3.5/Lib/test/__main__.py", line 
3, in 
regrtest.main_in_temp_cwd()
  File 
"/Users/brettcannon/Repositories/python/cpython/3.5/Lib/test/regrtest.py", line 
1593, in main_in_temp_cwd
main()
  File 
"/Users/brettcannon/Repositories/python/cpython/3.5/Lib/test/regrtest.py", line 
756, in main
raise Exception("Child error on {}: {}".format(test, result[1]))
Exception: Child error on test_bytes: Exit code -6

Since I can't get the test suite to pass with PGO+LTO I'm not comfortable 
committing this patch and promoting people turn them on.

--

___
Python tracker 

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



[issue27945] Various segfaults with dict

2016-09-02 Thread Christian Heimes

Changes by Christian Heimes :


--
nosy: +christian.heimes

___
Python tracker 

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



[issue26359] CPython build options for out-of-the box performance

2016-09-02 Thread Brett Cannon

Changes by Brett Cannon :


--
assignee: brett.cannon -> 
dependencies: +CPython fails to build modules with LLVM LTO on Mac OS X

___
Python tracker 

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



[issue27946] issues in elementtree and elsewhere due to PyDict_GetItem

2016-09-02 Thread tehybel

New submission from tehybel:

I would like to describe an issue in the _elementtree module, and then
propose a fix which would prevent this type of bug everywhere in the
codebase.

The issue exists in _elementtree_Element_get_impl in
/Modules/_elementtree.c. Here is the code:

static PyObject *
_elementtree_Element_get_impl(ElementObject *self, PyObject *key,
  PyObject *default_value)
{
PyObject* value;

if (...)
value = default_value;
else {
value = PyDict_GetItem(self->extra->attrib, key);
...
}
...
}

We look up "key" in the dictionary, that is, in self->extra->attrib. This is 
done with the call to PyDict_GetItem(self->extra->attrib, key).

We need to hash the "key" object in order to find it in the dictionary. This
sometimes requires calling the key's __hash__ function, i.e., it might call on
to python code.

What happens if the python code gets the dictionary (self->extra->attrib) freed?
Then PyDict_GetItem will use it after it has been freed.

I've attached a proof-of-concept script which causes a use-after-free through
_elementtree_Element_get_impl due to this issue.

We could fix this by calling Py_INCREF on self->extra->attrib before calling
PyDict_GetItem. But grepping for "PyDict_GetItem.*\->" shows that there are many
places in the codebase where this situation occurs. Some of these may not have
much impact, but some of them likely will.

All these bugs could be fixed at once by changing PyDict_GetItem to call 
Py_INCREF on the dictionary before it hashes the key.



Here's a PoC for the _elementtree module.

--- begin script ---

import _elementtree as et

state = {
"tag": "tag",
"_children": [],
"attrib": "attr",
"tail": "tail",
"text": "text",
}

class X:
def __hash__(self):
e.__setstate__(state) # this frees e->extra->attrib
return 13

e = et.Element("elem", {1: 2})
e.get(X())

--- end script ---

Running it (64-bits Python 3.5.2, --with-pydebug) causes a use-after-free with
control of the program counter:

(gdb) r ./poc13.py
Starting program: /home/xx/Python-3.5.2/python ./poc13.py

Program received signal SIGSEGV, Segmentation fault.
0x004939af in PyDict_GetItem (op=0x76d5b1a8, key=0x76d528e0) at 
Objects/dictobject.c:1079
1079ep = (mp->ma_keys->dk_lookup)(mp, key, hash, _addr);
(gdb) p mp->ma_keys->dk_lookup
$8 = (dict_lookup_func) 0x7b7b7b7b7b7b7b7b

--
components: Extension Modules
messages: 274276
nosy: tehybel
priority: normal
severity: normal
status: open
title: issues in elementtree and elsewhere due to PyDict_GetItem
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



[issue27945] Various segfaults with dict

2016-09-02 Thread Emanuel Barry

Changes by Emanuel Barry :


--
nosy: +ebarry, larry, ned.deily, rhettinger, serhiy.storchaka
priority: normal -> critical
stage:  -> needs patch
title: five dictobject issues -> Various segfaults with dict
type:  -> crash

___
Python tracker 

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



[issue27945] five dictobject issues

2016-09-02 Thread tehybel

Changes by tehybel :


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



[issue27945] five dictobject issues

2016-09-02 Thread tehybel

New submission from tehybel:

Here I'll describe five distinct issues I found. Common to them all is that they
reside in the built-in dictionary object. 

Four of them are use-after-frees and one is an array-out-of-bounds indexing bug.


All of the described functions reside in /Objects/dictobject.c.


Issue 1: use-after-free when initializing a dictionary

Initialization of a dictionary happens via the function dict_init which calls
dict_update_common. From there, PyDict_MergeFromSeq2 may be called, and that is
where this issue resides.

In PyDict_MergeFromSeq2 we retrieve a sequence of size 2 with this line:

fast = PySequence_Fast(item, "");

After checking its size, we take out a key and value:

key = PySequence_Fast_GET_ITEM(fast, 0);
value = PySequence_Fast_GET_ITEM(fast, 1);

Then we call PyDict_GetItem. This calls back to Python code if the key has a
__hash__ function. From there the "item" sequence could get modified, resulting
in "key" or "value" getting used after having been freed.

Here's a PoC:

---

class X:
def __hash__(self):
pair[:] = []
return 13

pair = [X(), 123]
dict([pair])

---

It crashes while trying to use freed memory as a PyObject:

(gdb) run ./poc24.py 
Program received signal SIGSEGV, Segmentation fault.
0x0048fe25 in insertdict (mp=mp@entry=0x76d5c4b8, 
key=key@entry=0x76d52538, hash=0xd, 
value=value@entry=0x8d1ac0 ) at Objects/dictobject.c:831
831 MAINTAIN_TRACKING(mp, key, value);
(gdb) print *key
$26 = {_ob_next = 0xdbdbdbdbdbdbdbdb, _ob_prev = 0xdbdbdbdbdbdbdbdb, ob_refcnt 
= 0xdbdbdbdbdbdbdbdb, 
  ob_type = 0xdbdbdbdbdbdbdbdb}




Issue 2: use-after-free in dictitems_contains

In the function dictitems_contains we call PyDict_GetItem to look up a value in
the dictionary:

found = PyDict_GetItem((PyObject *)dv->dv_dict, key);

However this "found" variable is borrowed. We then go ahead and compare it:

return PyObject_RichCompareBool(value, found, Py_EQ);

But PyObject_RichCompareBool could call back into Python code and e.g. release
the GIL. As a result, the dictionary may be mutated. Thus "found" could get
freed. 

Then, inside PyObject_RichCompareBool (actually in do_richcompare), the "found"
variable gets used after being freed.

PoC:

---

class X:
def __eq__(self, other):
d.clear()
return NotImplemented

d = {0: set()}
(0, X()) in d.items()

---

Result:

(gdb) run ./poc25.py 
Program received signal SIGSEGV, Segmentation fault.
0x004a03b6 in do_richcompare (v=v@entry=0x76d52468, 
w=w@entry=0x76ddf7c8, op=op@entry=0x2)
at Objects/object.c:673
673 if (!checked_reverse_op && (f = w->ob_type->tp_richcompare) != 
NULL) {
(gdb) print w->ob_type
$26 = (struct _typeobject *) 0xdbdbdbdbdbdbdbdb




Issue 3: use-after-free in dict_equal

In the function dict_equal, we call the "lookdict" function via
b->ma_keys->dk_lookup to look up a value:

if ((b->ma_keys->dk_lookup)(b, key, ep->me_hash, ) == NULL)

This value's address is stored into the "vaddr" variable and the value is
fetched into the "bval" variable:

bval = *vaddr;

Then we call Py_DECREF(key) which can call back into Python code. This could
release the GIL and mutate dictionary b. Therefore "bval" could become freed at
this point. We then proceed to use "bval":

cmp = PyObject_RichCompareBool(aval, bval, Py_EQ);

This results in a use-after-free.

PoC:

---

class X():
def __del__(self): 
dict_b.clear()
def __eq__(self, other):
dict_a.clear()
return True
def __hash__(self): 
return 13

dict_a = {X(): 0}
dict_b = {X(): X()}
dict_a == dict_b

---

Result:

(gdb) run ./poc26.py 
Program received signal SIGSEGV, Segmentation fault.
PyType_IsSubtype (a=0xdbdbdbdbdbdbdbdb, b=0x87ec60 )
at Objects/typeobject.c:1343
1343mro = a->tp_mro;
(gdb) print a
$59 = (PyTypeObject *) 0xdbdbdbdbdbdbdbdb



Issue 4: use-after-free in _PyDict_FromKeys

The function _PyDict_FromKeys takes an iterable as argument. If the iterable is
a dict, _PyDict_FromKeys loops over it like this:

while (_PyDict_Next(iterable, , , , )) {
if (insertdict(mp, key, hash, value)) {
...
}
}

However if we look at the comment for PyDict_Next, we see this:

 * CAUTION:  In general, it isn't safe to use PyDict_Next in a loop that
 * mutates the dict.

But insertdict can call on to Python code which might mutate the dict. In that
case we perform a use-after-free of the "key" variable.

Here's a PoC:

---

class X(int):
def __hash__(self):
return 13 
def __eq__(self, other):
if len(d) > 1:
d.clear()
return False

d = {}
d = {X(1): 1, X(2): 2}
x = {}.fromkeys(d)

---

And the result:

(gdb) run ./poc27.py 
Program received signal SIGSEGV, Segmentation fault.
0x00435122 in visit_decref 

[issue27944] two hotshot module issues

2016-09-02 Thread tehybel

New submission from tehybel:

Here I'll describe two issues in the "hotshot" module which can be found in
/Modules/_hotshot.c. Note that this module is for Python 2.7 only.

The issues are (1) an uninitialized variable use and (2) a double free.


Issue 1: uninitialized variable usage in unpack_add_info

In the function unpack_add_info we have this code:

static int
unpack_add_info(LogReaderObject *self)
{
PyObject *key;
...
err = unpack_string(self, );
if (!err) {
...
}
 finally:
Py_XDECREF(key);
Py_XDECREF(value);
return err;
}

The variable "key" is not initialized to NULL. If the call to unpack_string
fails, the code will directly call Py_XDECREF on key which is an uninitialized
variable.

To fix this we could initialize "key" to NULL.

Here's a PoC:
---

import hotshot.log

WHAT_ADD_INFO = 0x13
open("./tmp", "w").write(chr(WHAT_ADD_INFO))
logreader = hotshot.log.LogReader("./tmp")

---

It segfaults here:

(gdb) run poc_27_1.py

Program received signal SIGSEGV, Segmentation fault.
0x7696e585 in unpack_add_info (self=0x76b82098)
at /home/xx/Python-2.7.12/Modules/_hotshot.c:370
370 Py_XDECREF(key);
(gdb) p *key
$3 = {_ob_next = 0x438b480f74fff883, _ob_prev = 0x53894801508d4808,
  ob_refcnt = 0x9066c35b00b60f08, ob_type = 0x841f0f2e66}



Issue 2: double free (Py_DECREF) in unpack_add_info

This is a separate issue from the one described above, but it exists in the same
function, unpack_add_info:

static int
unpack_add_info(LogReaderObject *self)
{
PyObject *key;
PyObject *value = NULL;
int err;

err = unpack_string(self, );
if (!err) {
err = unpack_string(self, );
if (err)
Py_DECREF(key);
else {
...
}
}
 finally:
Py_XDECREF(key);
Py_XDECREF(value);
return err;
}

If the second call to unpack_string fails, we call Py_DECREF(key). Then we reach
the "finally" block and again call Py_XDECREF(key). So key is getting its
refcount dropped twice.

To fix this we could simply remove the "if (err)" clause and turn the "else"
into "if (!err)". Then we would only have the single call to Py_XDECREF(key) in
the "finally" block.

Here's a PoC:

---

import hotshot.log

content  = "\x13\x20"
content += "A"*0x20
open("./tmp", "w").write(content)
logreader = hotshot.log.LogReader("./tmp")

---

When run, python dies with SIGABRT here (because it's a debug build with
Py_REF_DEBUG defined; otherwise memory would silently be corrupted):

(gdb) r ./poc_27_2.py
Fatal Python error: /home/xx/Python-2.7.12/Modules/_hotshot.c:370 object at 
0x76b7e220 has negative ref count -2604246222170760230

Program received signal SIGABRT, Aborted.
0x77143295 in raise () from /usr/lib/libc.so.6

--
components: Extension Modules
messages: 274274
nosy: tehybel
priority: normal
severity: normal
status: open
title: two hotshot module issues
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



[issue27943] pstats.Stats: missing the source OS setting argument in strip_dirs() method

2016-09-02 Thread Jaroslav

New submission from Jaroslav:

Forked from Issue 27902.

The method cannot process the paths from different OS correctly. The optional 
argument will help, default = host OS settings as it is now.

--
components: Windows
messages: 274273
nosy: Jaroslav, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: pstats.Stats: missing the source OS setting argument in strip_dirs() 
method
type: enhancement
versions: 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



[issue27902] pstats.Stats: strip_dirs() method cannot handle file paths from different OS

2016-09-02 Thread Jaroslav

Jaroslav added the comment:

The paragraph is ok.

I'll open. Thanks a lot.

--

___
Python tracker 

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



[issue27928] Add hashlib.scrypt

2016-09-02 Thread Christian Heimes

Christian Heimes added the comment:

It's not a limitation of the argument clinic. PyArg_Parse*() does not support 
required, keyword-only arguments without a default value. I'm using None as 
default value, require PyLong_Type and added some extra checks.

--
Added file: http://bugs.python.org/file44351/Add-hashlib.scrypt-3.patch

___
Python tracker 

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



[issue27905] Add documentation for typing.Type

2016-09-02 Thread Ivan Levkivskyi

Ivan Levkivskyi added the comment:

Michael, thank you for helping with this!
Please take a look at my comments on the patch.

--
nosy: +levkivskyi

___
Python tracker 

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



[issue27919] Deprecate and remove extra_path distribution kwarg

2016-09-02 Thread Jason R. Coombs

Jason R. Coombs added the comment:

Doing a quick search on Github, it seems there are [537 
projects](https://github.com/search?utf8=%E2%9C%93=extra_path+filename%3Asetup.py=Code=searchresults)
 indicating `extra_path` in their setup.py. Many (most?) of those are using the 
feature to group packages into a namespace (Numeric, pygoogle, aeosa) in the 
filesystem. For each of these groups, it's probably worth contacting someone in 
the group to reference this ticket and get feedback.

Some of those projects just reference the value but set it to the default 
(disabled) or it's commented out.

At least one is using the feature for a load-time behavior injection 
(https://github.com/jwasinger/mailman_cas/blob/2ad0631001cb57366bb2a3b9d5f8eeddf5472c4e/mailman-2.1.12/misc/KoreanCodecs-2.0.5/setup.py).
 In that case, I don't think distutils should remain complicit in the hack, but 
the hack should be owned entirely by the project.

--

___
Python tracker 

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



[issue22458] Add fractions benchmark

2016-09-02 Thread Stefan Krah

Stefan Krah added the comment:

Which Stefan? :)


Anyway, the first half of this issue was centered around the
proposition that fractions are a "better decimal", and the
latest pull request still has the "decimal backend" in it. :)


Fast fractions have been around for a long time (Lisp/sbcl),
but apparently they have never been widely used.


A fraction-only benchmark is okay, but comparing fractions/decimals
in one particular "official" benchmark is a bit strange.

--

___
Python tracker 

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



[issue27934] json float encoding incorrect for dbus.Double

2016-09-02 Thread Mark Dickinson

Mark Dickinson added the comment:

Note that this will also change the results for JSON output of NumPy float64 
values, so at the very least I'd expect this change to break (admittedly poorly 
written) unit tests / doctests.

Python 2.7.12 (default, Jul 10 2016, 18:28:23) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> import json
>>> x = np.float64(3.3)
>>> json.dumps(x)
'3.2998'
>>> repr(x)
'3.2998'
>>> float.__repr__(x)
'3.3'

--

___
Python tracker 

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



[issue26208] decimal C module's exceptions don't match the Python version

2016-09-02 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



[issue27869] test failures under Bash on Windows

2016-09-02 Thread Brett Cannon

Brett Cannon added the comment:

And with the latest patches applied, same hanging tests, but one less failure:

test_asyncio test_asyncore test_epoll test_faulthandler test_fcntl
test_ftplib test_httpservers test_import test_mmap
test_multiprocessing_fork test_multiprocessing_forkserver
test_multiprocessing_main_handling test_multiprocessing_spawn
test_os test_posix test_resource test_signal test_socketserver
test_subprocess test_time test_unicode_file test_wsgiref

--

___
Python tracker 

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



[issue27936] Inconsistent round behavior between float and int

2016-09-02 Thread Mark Dickinson

Mark Dickinson added the comment:

For the record, the float behaviour was changed (for Python 3.5) in 
http://bugs.python.org/issue19933. There didn't seem to be any particularly 
strong motivation for that change, but it's done now.

--

___
Python tracker 

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



[issue22458] Add fractions benchmark

2016-09-02 Thread STINNER Victor

STINNER Victor added the comment:

Stefan Krah added the comment:
> Fractions will shine in most benchmarks where decimal is exact anyway.

According to Stefan's latest message, the purpose of the benchmark is
not the compare decimal to fractions, but measure the performance of
fractions for one Python implementation. For example, it can be used
to check that fractions is faster in Python 3.6 than Python 3.4
fractions.

--

___
Python tracker 

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



[issue27942] Default value identity regression

2016-09-02 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

This likely is an interference of issue27095 with issue26148. I consider this 
as a regression. This causes not only a waste of memory, but can affect a 
performance, since comparing non-identical strings is slower than comparing 
identical strings.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue27942] Default value identity regression

2016-09-02 Thread Steven D'Aprano

Steven D'Aprano added the comment:

Can confirm the expected behaviour (printing True) in Python 2.4 through 2.7, 
3.3, Jython 2.5, and even venerable old Python 1.5 (where it prints 1).

But *not* IronPython 2.6, where it prints False.

In 3.6, the difference seems to be here:

py> f = defaultKeepsIdentity
py> f.__defaults__[0] is f.__code__.co_consts[1]
False
py> f.__defaults__[0] == f.__code__.co_consts[1]
True

This behaviour is not specified by the language. Caching and re-use of strings 
has always been subject to change. Nevertheless, perhaps it is time for this to 
be make a language feature: inside a function, any use of the same string 
literal should use the same object?

--
nosy: +steven.daprano

___
Python tracker 

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



[issue27934] json float encoding incorrect for dbus.Double

2016-09-02 Thread Mark Dickinson

Mark Dickinson added the comment:

Yes. I'm fairly convinced about the bug part; it's the gratuitous breakage part 
that worries me. It wouldn't surprise me at all to find that there's someone 
out there who wants all their numbers to be written out to JSON with exactly 6 
places after the point, and subclasses float just for that purpose. (I'm not 
for a moment suggesting that this is a good idea, but there's a big difference 
between the set of Python code that *should* have been written and the set of 
Python code that *has* been written. :-)

>>> class MyFloat(float):
... def __repr__(self):
... return '{:.6f}'.format(self)
... 
>>> import math, json
>>> json.dumps(MyFloat(math.pi))
'3.141593'

--

___
Python tracker 

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



[issue27931] Email parse IndexError <""@wiarcom.com>

2016-09-02 Thread Xiang Zhang

Xiang Zhang added the comment:

It should be. If there is anything wrong I'd like to hear and fix.

--

___
Python tracker 

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



[issue27928] Add hashlib.scrypt

2016-09-02 Thread Xiang Zhang

Xiang Zhang added the comment:

It looks good. But Christian, may I ask how do you generate the argument 
clinic? It looks from me that the declaration cannot give you such a format 
"y*|$y*O!O!O!ll:scrypt". I rerun clinic.py and the .c.h file is altered. Maybe 
it's better to abandon AC for right now?

--

___
Python tracker 

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



[issue27941] Bad error message from Decimal('garbage') across the py3 range

2016-09-02 Thread Stefan Krah

Stefan Krah added the comment:

Hardly a bad error message, but see #26208.

--
nosy: +skrah
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> decimal C module's exceptions don't match the Python version
type: behavior -> enhancement

___
Python tracker 

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



[issue27942] Default value identity regression

2016-09-02 Thread Kay Hayen

New submission from Kay Hayen:

Consider this:

def defaultKeepsIdentity(arg = "str_value"):
print(arg is "str_value")

defaultKeepsIdentity()

This has been outputing "True" on every Python release I have seen so far, but 
not so on 3.6.0a4. Normally string values come from a "co_const" and will be 
"is" identical if used as literals in a module, but no longer in this case.

This seems wasteful at best, needlessly increasing the number of strings in 
usage. 

Yours,
Kay

--
components: Interpreter Core
messages: 274257
nosy: Kay.Hayen
priority: normal
severity: normal
status: open
title: Default value identity regression
type: resource usage
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



[issue22458] Add fractions benchmark

2016-09-02 Thread Stefan Krah

Stefan Krah added the comment:

The reason is that the benchmark is a softball for fractions. Using the fastest 
fraction implementation (gmpy.mpq) and the best printing method for both types, 
gmpy.mpq seems to be about 2.5 to 3 times slower than decimal.

It is however easy to generate benchmarks where mpq is 3000 times slower, 
depending on how many prime factors accumulate in the denominator.


Fractions will shine in most benchmarks where decimal is exact anyway.

--

___
Python tracker 

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



[issue27869] test failures under Bash on Windows

2016-09-02 Thread Brett Cannon

Brett Cannon added the comment:

I re-ran the test suite in a directory not under /mnt/c to see if having a 
different file owner would change things and it did. test_logging and 
test_socket still hang, but the failures go down to 23:

test_asyncio test_asyncore test_eintr test_epoll test_faulthandler
test_fcntl test_ftplib test_httpservers test_import test_mmap
test_multiprocessing_fork test_multiprocessing_forkserver
test_multiprocessing_main_handling test_multiprocessing_spawn
test_os test_posix test_resource test_signal test_socketserver
test_subprocess test_time test_unicode_file test_wsgiref

--
title: test failures on Bash on Windows -> test failures under Bash on Windows

___
Python tracker 

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



[issue27941] Bad error message from Decimal('garbage') across the py3 range

2016-09-02 Thread Samuele Santi

New submission from Samuele Santi:

Looks like, on some occasions, running ``Decimal('garbage')`` on Python 3.x 
decimal raises this error:

decimal.InvalidOperation: []

instead of the usual:

decimal.InvalidOperation: Invalid literal for Decimal: 'garbage'


This seems to be caused by the built-in decimal module on 3.x, while it's just 
fine with decimal.py / _pydecimal.py (eg. the system Python on Archlinux).

I'm attaching the output from a few tests I made against different interpreters.

--
files: test-decimal-error-output.txt
messages: 274254
nosy: Samuele Santi
priority: normal
severity: normal
status: open
title: Bad error message from Decimal('garbage') across the py3 range
type: behavior
versions: Python 3.4, Python 3.5
Added file: http://bugs.python.org/file44350/test-decimal-error-output.txt

___
Python tracker 

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



[issue27928] Add hashlib.scrypt

2016-09-02 Thread Christian Heimes

Christian Heimes added the comment:

You are right. Let's try this again. How do you like:

>>> hashlib.scrypt(b'', n=2, r=2, p=3)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: salt is required
>>> hashlib.scrypt(b'', salt=b'')
Traceback (most recent call last):
  File "", line 1, in 
TypeError: n is required and must be an unsigned int
>>> hashlib.scrypt(b'', n=None, r=2, p=3)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: scrypt() argument 3 must be int, not None

--

___
Python tracker 

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



[issue27934] json float encoding incorrect for dbus.Double

2016-09-02 Thread Eddie James

Changes by Eddie James :


Added file: http://bugs.python.org/file44349/json-float-repr-2.7.patch

___
Python tracker 

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



[issue27934] json float encoding incorrect for dbus.Double

2016-09-02 Thread Eddie James

Eddie James added the comment:

Python 2.7 also already behaves correctly for other dbus types:

Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import dbus
>>> import json
>>> x = dbus.Int32(3)
>>> x
dbus.Int32(3)
>>> json.dumps(x)
'3'
>>> repr(x)
'dbus.Int32(3)'

--

___
Python tracker 

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



[issue27456] asyncio: set TCP_NODELAY flag by default

2016-09-02 Thread Марк Коренберг

Марк Коренберг added the comment:

vote +10 for that

--
nosy: +mmarkk

___
Python tracker 

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



[issue27940] xml.etree: Avoid XML declaration for the "ascii" encoding

2016-09-02 Thread Stefan Behnel

Stefan Behnel added the comment:

> By the way, I'm surprised that the special encoding "unicode" relies on the 
> *current* locale encoding when the XML declaration is requested.

That seems a weird choice. Since it serialises to a Unicode string, it 
shouldn't have any XML declaration at all, if only to make it easy for users to 
add one themselves if they feel like it.

I guess it's too late to change that now, though...

--
nosy: +scoder

___
Python tracker 

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



[issue27934] json float encoding incorrect for dbus.Double

2016-09-02 Thread Mark Dickinson

Mark Dickinson added the comment:

> That's still using PyObject_Repr() which will call tp_repr for dbus.Double... 
> Any suggestions?

Right, you'll want to replace that with a call to `PyFloat_Type.tp_repr(obj)`, 
as in the Python 3 code.

We're in a bit of a grey area here: making this change to the 2.7 branch does 
require making a case that it's a bugfix rather than a new feature (which isn't 
permitted in 2.7), *and* that it's not going to cause gratuitous breakage in 
existing json-using applications. I think there *is* a reasonable case there, 
but others may disagree. One point in its favour is that we're *already* 
behaving like a regular float for special values:

Python 2.7.12 (default, Jun 29 2016, 12:46:54) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import dbus, json
>>> x = dbus.Double(float('inf'))
>>> json.dumps(x)  # not using repr(x) here
'Infinity'
>>> repr(x)
'dbus.Double(inf)'
>>> x = dbus.Double(2.3)
>>> json.dumps(x)  # using repr(x) here
'dbus.Double(2.3)'
>>> repr(x)
'dbus.Double(2.3)'

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



[issue27934] json float encoding incorrect for dbus.Double

2016-09-02 Thread R. David Murray

Changes by R. David Murray :


--
resolution: third party -> 
stage: resolved -> needs patch
status: closed -> open

___
Python tracker 

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



[issue27934] json float encoding incorrect for dbus.Double

2016-09-02 Thread Eddie James

Eddie James added the comment:

Wait what about the json C code for 2.7? That's still using PyObject_Repr() 
which will call tp_repr for dbus.Double... Any suggestions?

--

___
Python tracker 

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



[issue27937] logging.getLevelName microoptimization

2016-09-02 Thread R. David Murray

R. David Murray added the comment:

Parens do not cause lazy evaluation unless what is parenthesized is a generator 
comprehension.  An expanded if solution is the correct one.  

If Vinay prefers a one liner, I think you could also write:

   _levelToName.get(level) or _nameToLevel.get(level) or ("Level %s" % level)

Because we know we get back either a True string or None, I don't think there's 
any ambiguity there.

--
nosy: +r.david.murray, vinay.sajip

___
Python tracker 

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



[issue27934] json float encoding incorrect for dbus.Double

2016-09-02 Thread Eddie James

Eddie James added the comment:

Thanks Mark, yes you installed the right package.

OK I didn't dig deep enough in the sub class. And yea, there shouldn't be any 
difference between float.__repr__ and float.__str__. Obviously repr calls the 
object's tp_repr method, while float.__repr__ calls the base float method, 
which is the one we want.

I didn't do any testing for python 3.x as I couldn't figure out how to import 
dbus into a local build of 3.x. My mistake here.

> For 2.7, we may want to consider processing float instances using 
> `float.__repr__` instead of plain old `repr`

That should work! I'll upload a new patch for 2.7

--

___
Python tracker 

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



[issue27931] Email parse IndexError <""@wiarcom.com>

2016-09-02 Thread R. David Murray

R. David Murray added the comment:

You are correct, it is technically a valid angleaddr.  I'll review this next 
week, the patch looks good (thanks) but I need to double check a couple things 
before I commit.

--
assignee:  -> r.david.murray
stage: needs patch -> commit review

___
Python tracker 

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



[issue22458] Add fractions benchmark

2016-09-02 Thread Stefan Behnel

Stefan Behnel added the comment:

> So this benchmark cannot be used to show the superiority of exact fractions.

I don't see how a benchmark would be a way to show that. It's certainly not the 
goal of this benchmark to show that one is computationally better than the 
other. But if a benchmark for one part of Python allows a direct, reasonable 
speed comparison with another, why would you object to make use of that?


> is the purpose of this benchmark to show that fractions are slow and generate 
> interest in changing the situation?

There have been a couple of attempts to make them faster already. The speed 
improvements in Py3.5 and 3.6 directly result from those changes. Thus, making 
these improvements visible and comparable across Python versions and different 
implementations is one of the goals of this benchmark.

--

___
Python tracker 

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



[issue27934] json float encoding incorrect for dbus.Double

2016-09-02 Thread Mark Dickinson

Mark Dickinson added the comment:

> Nothing that can/should be done on the stdlib side, then.

I think there's nothing to do for 3.x: as far as I can tell, everything should 
be working exactly as desired there.

For 2.7, we may want to consider processing float instances using 
`float.__repr__` instead of plain old `repr`. I believe that would fix the OP's 
problem, and also bring the 2.7 behaviour more in line with the 3.x behaviour. 
It's a backwards incompatible behaviour change, but probably not a particularly 
disruptive one.

--

___
Python tracker 

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



[issue27934] json float encoding incorrect for dbus.Double

2016-09-02 Thread Mark Dickinson

Mark Dickinson added the comment:

> Dbus.Double is not a subclass of float unfortunately.

Okay, now I'm *really* confused. :-)

If it's not a subclass of `float`, then how do you end up in the `floatstr` 
code? Every path to that code that I can see in the source is via an 
`isinstance(, float`) check.

I don't know dbus at all, but I just tried installing it under Macports (on OS 
X 10.9). Here's the package description, so you can tell me whether I'm 
actually installing the right thing, or something totally unrelated:

dbus-python35 @1.2.0_2 (devel, python)
Python bindings for the dbus message bus system.

Once I've done that, I get the following behaviour in Python:

Python 3.5.2 (default, Aug 16 2016, 08:43:53) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import dbus
>>> dbus.Double

>>> dbus.Double.__mro__
(, , , 
)

So it looks as though at least for this version of dbus, we do have a subclass 
of `float`. Looking at an instance, I see the following:

>>> x = dbus.Double(4.3)
>>> isinstance(x, float)
True
>>> repr(x)
'dbus.Double(4.3)'
>>> str(x)
'4.3'
>>> float.__repr__(x)
'4.3'
>>> float.__str__(x)
'4.3'
>>> import json
>>> json.dumps(x)
'4.3'

So I'm still struggling to see what difference swapping out float.__repr__ for 
float.__str__ would make.

--

___
Python tracker 

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



[issue23591] enum: Add Flags and IntFlags

2016-09-02 Thread Ethan Furman

Ethan Furman added the comment:

> Yes, you're correct here, but what about output? Do all relevant bits have
> to be named separately?

No.

> And will the output always talk about separate
> bits?

No.

> We have talked about this.

Indeed.  Here's my previous reply. ;)

>> The algorithm is simple: start with the biggest Flag and mask off
>> matching bits until all bits are are matched.

When I said "biggest flag" I meant the flag with the highest value (so a flag 
of 5 would get matched before a flag of four).

>> If any unmatched bits remain an error is raised.

This part is specifically for Flag; IntFlag will just show the values of any 
unmatched bits.

> If I give meaningful name to 1, 3, 4 and
> 6, but not to 2, is it supported?

Depends.  Not having 2 named has different consequences for Flag vs IntFlag 
(although neither is an error):

- Flag: no combination of flags will ever have the 2 bit set
- IntFlag: '2' will show in the name portion if the 2 bit is set

> And is the repr of 7 an implementation detail, or is it specified?

I should specify it in the docs, thanks.

> One more question: in the docs, you say 
>>
>> otherwise, all members evaluate as :data:`True`.
>
>I would like you to reconsider the case of `.0` (.NONE in my
> terminology). Many other things in the interface (e.g. `in` operator)
> are modelled as if flags instance were just a container (set, in fact)
> of bits. In that case, empty set _should_ be false. Otherwise, this will
> be a weird exception to the usual container semantics.

Very good point.  Unless I can think of a good reason not to, I'll make that 
change in the next couple days.

Thanks.

--

___
Python tracker 

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



[issue27934] json float encoding incorrect for dbus.Double

2016-09-02 Thread R. David Murray

R. David Murray added the comment:

Nothing that can/should be done on the stdlib side, then.

--
nosy: +r.david.murray
resolution:  -> third party
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



[issue16334] Faster unicode-escape and raw-unicode-escape codecs

2016-09-02 Thread STINNER Victor

STINNER Victor added the comment:

> Did you benchmark this change? I afraid that this inflates execution code 
> size and can have negative impact on the performance.

I consider that readability (maintainability) matters more than such micro 
optimization.

--

___
Python tracker 

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



[issue16334] Faster unicode-escape and raw-unicode-escape codecs

2016-09-02 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

> Unicode escape encodecs were modified by the issue #25353 to use the
> _PyBytesWriter API. Sadly, I didn't benchmark my change before pushing it
> :-/

You can benchmark it now by checking out revisions with your patch and just 
before. But AFAIK the performance was not changed since 3.3 and the effect of 
your patch is the difference between columns 3.3 and 3.6 (very good).

I used scripts from https://bitbucket.org/storchaka/cpython-stuff/src/default/
bench/ .

> Your patch basically reverts my change.
> 
> > Py3.2Py3.3Py3.6Py3.6+patch
> > 195 (+136%)  109 (+323%)  258 (+79%)   461encode  unicode-escape 
> > 'A'*1 391 (+1310%) 333 (+1556%) 575 (+859%)  5514   encode 
> > raw-unicode-escape  'A'*1

> I'm surprised that the revert makes raw-unicode-escape encoder so much
> faster. Does it mean that the _PyBytesWriter API is so inefficient?

I don't remember all details, but it seems that after applying all 
optimizations _PyBytesWriter became just not needed (unlike to 
_PyUnicodeWriter that is used for widening a buffer).

The awesome difference in encoding for ascii-only data is not related to using 
_PyBytesWriter. It is caused by reordering checks in the inner loop.

> * Rename WRITECHAR macro to WRITE_ASCII_CHAR()

This is not correct name. This macro is used for writing non-ascii characters 
too.

> * Add WRITE_CHAR() macro to avoid "goto writechar;"
> * Drop the "store" label: use WRITE_CHAR() macro instead,

Did you benchmark this change? I afraid that this inflates execution code size 
and can have negative impact on the performance.

--

___
Python tracker 

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



[issue27934] json float encoding incorrect for dbus.Double

2016-09-02 Thread Eddie James

Eddie James added the comment:

Understood on 2.7, I wasn't aware it would cause any issues.

Dbus.Double is not a subclass of float unfortunately. Problem is that all Dbus 
types seem to have a custom tp_repr method that returns that strange formatting 
I mentioned. So repr won't be the same as str, in any version of python.

--

___
Python tracker 

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



[issue27898] regexp performance degradation between 2.7.6 and 2.7.12

2016-09-02 Thread Steve Newcomb

Steve Newcomb added the comment:

On 08/30/2016 12:46 PM, Raymond Hettinger wrote:
> Raymond Hettinger added the comment:
>
> It would be helpful if you ... make a small set of regular expressions that 
> demonstrate the performance regression.
>
Done.  Attachments:

test.py : Code that exercises re.sub() and outputs a profile report.

test_output_2.7.6.txt : Output of test.py under Python 2.7.6.

test_output_2.7.12.txt : Output of test.py under Python 2.7.12.

p17.188.htm -- test data: public information from the U.S. Internal 
Revenue Service.

Equivalent hardware was used in both cases.

The outputs show that 2.7.12's re.sub() takes 1.2 times as long as 
2.7.6's.  It's a significant difference, but...

...it was not the dramatic degradation I expected to find in this 
exercise.  Therefore I attempted to tease what I was looking for out of 
the profile stats I already uploaded to this site, made from actual 
production runs.  My attempts are all found in an hg repository that can 
be downloaded from 
sftp://s...@coolheads.com//files/py-re-perform-276-2712 using password 
bysIe20H .

I do not feel the latter work took me where I wanted to go, and I think 
the reason is that, at least for purposes of our application, Python 
2.7.12 has been so extensively refactored since Python 2.7.6.  So it's 
an apples-to-oranges comparison, apparently.  Still, the performance 
difference for re.sub() is quite dramatic , and re.sub() is the only 
comparable function whose performance dramatically worsened: in our 
application, 2.7.12's re.sub() takes 3.04 times as long as 2.7.6's.

The good news, of course, is that by and large the performance of the 
other *comparable* functions largely improved, often dramatically.  But 
at least in our application, it doesn't come close to making up for the 
degradation in re.sub().

My by-the-gut bottom line: somebody who really knows the re module 
should take a deep look at re.sub().  Why would re.sub(), unlike all 
others, take so much longer to run, while *every* other function in the 
re module get (often much) faster?  It feels like there's a bug 
somewhere in re.sub().

Steve Newcomb

--
Added file: http://bugs.python.org/file44335/test.py
Added file: http://bugs.python.org/file44336/test_output_2.7.6.txt
Added file: http://bugs.python.org/file44337/p17-188.htm
Added file: http://bugs.python.org/file44338/test_output_2.7.12.txt

___
Python tracker 

___#!/usr/bin/env python2

import codecs, profile, os, re, sys

hrefRE = re.compile(
''.join(
[
r'href=',
r'(?P["\'])',
r'(?P',
r'.*?',
r')',
r'(?=quote)',
],
),
)
###
onePathSegmentMS = ''.join(
[
r'(?P<_pathSeg>',
r'(',
r'/?',
r'(',
r'(?!',
r'[ \t\r\n]+',
r'$',
r')',
u'[^%s]' % ( re.escape( r'/?#')),
r')+',
r'|',
r'/',
r')',
r')',
],
)
onePathSegmentRE = re.compile( onePathSegmentMS)

###
uriMS = r''.join(
(
r'(?P',  ## leading whitespace is OK and ignorable; 
see http://dev.w3.org/html5/spec-LC/urls.html
r'[ \t\r\n]+',
r')?',
r'(',
r'(?P',
r'https?',  
r')',
r':\/{0,2}',   ## accounts for encountered error: only 0 or 1 slash 
instead of 2
r')?',
r'(?P',
r'(?P',
r'(',
r'(?P<_userinfo>',
r'[^%s]+' % ( re.escape( r'@/[:?#')),
r')',
re.escape( '@'),
r')?',
r')',
r'(?P',
r'(?P',
re.escape( r'['),
r')?',
r'(',
r'(?P',
r'(',
r'[0-9]{1,3}%s' % ( re.escape( r'.')),
r'){3}',
r'[0-9]{1,3}',
r')',
r'|',
r'(?P',
r'(',
r'[0-9A-Fa-f]{0,4}%s' % ( re.escape( ':')),
r'){1,7}',
r'[0-9A-Fa-f]{0,4}',
r')',
r'|',
r'(?P',
r'(',
r'[^%s]+?' % ( re.escape( r']:/?#')),  ## this may 
have dots
r'\.',
r')+',
r'(?P',  ## top-level domain, e.g. "com", "gov" 
etc.
r'(',

[issue27934] json float encoding incorrect for dbus.Double

2016-09-02 Thread Eric V. Smith

Changes by Eric V. Smith :


--
nosy: +eric.smith

___
Python tracker 

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



[issue16334] Faster unicode-escape and raw-unicode-escape codecs

2016-09-02 Thread STINNER Victor

STINNER Victor added the comment:

I rebased faster_unicode_escape_4.patch and made tiny changes:

* Rename WRITECHAR macro to WRITE_ASCII_CHAR()
* Add WRITE_CHAR() macro to avoid "goto writechar;"
* Drop the "store" label: use WRITE_CHAR() macro instead, expect that getcode() 
only returns valid unicode characters (<= MAX_UNICODE)
* For \U format: since MAX_UNICODE is 0x10, hardcode the first two 
digits as 0, and add an assertion on MAX_UNICODE value
* PEP 7: add {...} on if/else blocks

--
Added file: http://bugs.python.org/file44348/faster_unicode_escape_5.patch

___
Python tracker 

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



[issue27921] f-strings: do not allow backslashes

2016-09-02 Thread Eric V. Smith

Eric V. Smith added the comment:

> This looks a little ugly.

True. My goal is to get the simplest possible thing working now, and then 
before beta 2 fix it so that backslashes again work in the text portions of an 
f-string. After that, I'll fix this particular piece of code (and the others, 
plus the tests that can be made to work).

Here's an updated patch. I'm planning on committing it today.

--
Added file: http://bugs.python.org/file44347/27921-1.patch

___
Python tracker 

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



[issue22458] Add fractions benchmark

2016-09-02 Thread Stefan Krah

Stefan Krah added the comment:

I've left comments on GitHub.


[scoder] 
> As I said, where ever exact calculations are needed..

Even if the formatting comment is addressed, the main problem with
this benchmark is that *both* fraction and decimal calculations
are in fact exact here.

You can check that by printing out the values for "t" in the loop
like I suggested on GitHub.


This is of course one of the main features of Decimal: If you're
willing to take the penalty of a large precision, calculations
can often be exact; similar to taking the penalty of potentially
huge numerators and denominators in fractions.


So this benchmark cannot be used to show the superiority of exact
fractions.

--

___
Python tracker 

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



[issue16334] Faster unicode-escape and raw-unicode-escape codecs

2016-09-02 Thread STINNER Victor

STINNER Victor added the comment:

Unicode escape encodecs were modified by the issue #25353 to use the 
_PyBytesWriter API. Sadly, I didn't benchmark my change before pushing it :-/

Your patch basically reverts my change.

> Py3.2Py3.3Py3.6Py3.6+patch
> 195 (+136%)  109 (+323%)  258 (+79%)   461encode  unicode-escape  
> 'A'*1
> 391 (+1310%) 333 (+1556%) 575 (+859%)  5514   encode  raw-unicode-escape  
> 'A'*1

I'm surprised that the revert makes raw-unicode-escape encoder so much faster. 
Does it mean that the _PyBytesWriter API is so inefficient?

The most efficient case for _PyBytesWriter is when you only call 
_PyBytesWriter_Alloc() and _PyBytesWriter_Finish() and the output string has 
exactly the allocated length. It should be the case when 'A'*1 is encoded, 
no?

--

___
Python tracker 

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



[issue27938] PyUnicode_AsEncodedString, PyUnicode_Decode: add fast-path for "us-ascii" encoding

2016-09-02 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

See also get_standard_encoding() in Python/codecs.c. I suppose it is faster.

UTF-32 is rarely used as external encoding, but it is still used as internal 
encoding in some programming languages and libraries (e.g. wchar_t* in C and 
std::wstring in C++ on Linux). The codec itself is very fast. I would add fast 
path all utf encodings (except utf-7).

--

___
Python tracker 

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



[issue27940] xml.etree: Avoid XML declaration for the "ascii" encoding

2016-09-02 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

> By the way, I'm surprised that the special encoding "unicode" relies on the 
> *current* locale encoding when the XML declaration is requested. Why not 
> alway susing UTF-8 for *unicode* instead of the locale encoding?

Because it is usually outputs to sys.stdout or a file opened with default 
encoding. Agreed, the current locale encoding is not the best choice. It would 
be better to look at the encoding attribute of the file and fallback to utf-8 
or ascii.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue23591] enum: Add Flags and IntFlags

2016-09-02 Thread Vedran Čačić

Vedran Čačić added the comment:

> Nope.  You are welcome to give more meaningful names to different 
> combinations of powers of two.

Yes, you're correct here, but what about output? Do all relevant bits have to 
be named separately? And will the output always talk about separate bits? We 
have talked about this. If I give meaningful name to 1, 3, 4 and 6, but not to 
2, is it supported? And is the repr of 7 an implementation detail, or is it 
specified?

One more question: in the docs, you say 

> otherwise, all members evaluate as :data:`True`.

I would like you to reconsider the case of `.0` (.NONE in my terminology). Many 
other things in the interface (e.g. `in` operator) are modelled as if flags 
instance were just a container (set, in fact) of bits. In that case, empty set 
_should_ be false. Otherwise, this will be a weird exception to the usual 
container semantics.

--

___
Python tracker 

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



[issue27456] asyncio: set TCP_NODELAY flag by default

2016-09-02 Thread STINNER Victor

Changes by STINNER Victor :


--
title: TCP_NODELAY -> asyncio: set TCP_NODELAY flag by default

___
Python tracker 

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



[issue24648] Allocation of values array in split dicts should use small object allocator.

2016-09-02 Thread STINNER Victor

Changes by STINNER Victor :


--
resolution:  -> fixed
status: open -> closed

___
Python tracker 

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



[issue27915] Use 'ascii' instead of 'us-ascii' to bypass lookup machinery

2016-09-02 Thread STINNER Victor

STINNER Victor added the comment:

It looks like the email module has a special usage of the "us-ascii" encoding 
name. It's not just an alias to "ascii". So I proposed a patch implementing the 
fast-path differently in the Python builtin codecs: see my issue #27938.

The xml.etree module has special cases for the "us-ascii" encoding name, but 
not for "ascii". See the ElementTree.write() method. I proposed to also skip 
the XML declaration by default when "ascii" encoding is used: issue #27940.

--
nosy: +haypo

___
Python tracker 

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



[issue27940] xml.etree: Avoid XML declaration for the "ascii" encoding

2016-09-02 Thread STINNER Victor

STINNER Victor added the comment:

Note: I found the "us-ascii" special case when reviewing the issue #27915 which 
proposed to replace "us-ascii" with "ascii" in the xml.etree module to use the 
Python fast-path for performance.

--

___
Python tracker 

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



[issue27940] xml.etree: Avoid XML declaration for the "ascii" encoding

2016-09-02 Thread STINNER Victor

New submission from STINNER Victor:

The ElementTree module (xml.etree) avoids the XML declaration for "utf-8" and 
"us-ascii" codecs, but not for the "ascii" encoding.

Attached patch avoids the XML declaration for the "ascii" codec since it's a 
subset of UTF-8 and UTF-8 is the default encoding of XML.

The patch also normalizes the encoding name to handle aliases like "utf8" 
(UTF-8) or "us_ascii" (ASCII).

The patch adds unit tests.

--

By the way, I'm surprised that the special encoding "unicode" relies on the 
*current* locale encoding when the XML declaration is requested. Why not alway 
susing UTF-8 for *unicode* instead of the locale encoding?

My unit test tests different locale encodings.

--
components: XML
files: etree_xml_declaration.patch
keywords: patch
messages: 274227
nosy: haypo
priority: normal
severity: normal
status: open
title: xml.etree: Avoid XML declaration for the "ascii" encoding
type: enhancement
versions: Python 3.6
Added file: http://bugs.python.org/file44346/etree_xml_declaration.patch

___
Python tracker 

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



[issue27934] json float encoding incorrect for dbus.Double

2016-09-02 Thread Mark Dickinson

Mark Dickinson added the comment:

> I propose a change to use str() for float objects as well. This could be 
> ported back to 2.7 as well

That would be a behaviour change for 2.7, and an undesirable one. `str` loses 
precision in Python 2, so e.g., `json.loads(json.dumps(pi)) == pi` would no 
longer be true. (Indeed, the json library was changed to use `repr` rather than 
`str` for floats at some point in the past, for exactly this reason.)

I assume that dbus.Double is a subclass of float. Is that correct? If that's 
the case, I'm a bit confused: `float.__repr__` behaves identically to 
`float.__str__` in Python versions >= 3.2, so I don't see what your suggested 
change would achieve.

>>> class MyFloat(float):
... def __repr__(self): return "MyFloat(something_or_other)"
... def __str__(self): return "1729.0"
... 
>>> x = MyFloat(2.3)
>>> import json
>>> json.dumps(x)
'2.3'

--
nosy: +mark.dickinson

___
Python tracker 

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



[issue27928] Add hashlib.scrypt

2016-09-02 Thread Xiang Zhang

Xiang Zhang added the comment:

It looks that new patch when used like this hashlib.scrypt(b'password') will 
generate a "an integer is required" exception message which is misleading. I 
don't test it since I don't get openssl 1.1.

And the phrase "interpreted as buffers of bytes" in the doc may better be 
"bytes-like objects".

--
nosy: +xiang.zhang

___
Python tracker 

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



[issue26470] Make OpenSSL module compatible with OpenSSL 1.1.0

2016-09-02 Thread Bernard Spil

Bernard Spil added the comment:

Sorry for the noise Christian, I thought the former EGD handling was still in 
place. That was fixed with 
https://github.com/python/cpython/commit/968ec1d29b44ca7a600df5984adff00a78392368
 on 07 Jul 2016

--

___
Python tracker 

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



[issue27939] Tkinter mainloop raises when setting the value of ttk.LabeledScale

2016-09-02 Thread Goyo

New submission from Goyo:

Calling mainloop after setting the value of a ttk.LabeledScale raises an error. 
The same happens if the value is set after entering the mainloop.

Does not affect python 3.4.3. Does not affect ttk.Scale. No error is raised if 
you do not call mainloop.


import tkinter as tk
import tkinter.ttk as ttk
root = tk.Tk()
w = ttk.LabeledScale(root)
w.pack()
w.scale.set(1)
root.mainloop()

Traceback (most recent call last):
  File 
"d:\users\u938001\AppData\Local\Programs\Python\Python35-32\lib\tkinter\__init__.py",
 line 1550, in __call__
return self.func(*args)
  File 
"d:\users\u938001\AppData\Local\Programs\Python\Python35-32\lib\tkinter\ttk.py",
 line 1540, in _adjust
newval = self._variable.get()
  File 
"d:\users\u938001\AppData\Local\Programs\Python\Python35-32\lib\tkinter\__init__.py",
 line 355, in get
return self._tk.getint(self._tk.globalgetvar(self._name))
TypeError: getint() argument must be str, not float

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "itcomp.py", line 8, in 
root.mainloop()
  File 
"d:\users\u938001\AppData\Local\Programs\Python\Python35-32\lib\tkinter\__init__.py",
 line 1131, in mainloop
self.tk.mainloop(n)
  File 
"d:\users\u938001\AppData\Local\Programs\Python\Python35-32\lib\tkinter\__init__.py",
 line 1554, in __call__
self.widget._report_exception()
AttributeError: 'IntVar' object has no attribute '_report_exception'

--
components: Tkinter
messages: 274223
nosy: goyodiaz
priority: normal
severity: normal
status: open
title: Tkinter mainloop raises when setting the value of ttk.LabeledScale
type: crash
versions: Python 3.5

___
Python tracker 

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



[issue27938] PyUnicode_AsEncodedString, PyUnicode_Decode: add fast-path for "us-ascii" encoding

2016-09-02 Thread STINNER Victor

New submission from STINNER Victor:

The "us-ascii" encoding is an alias to the Python ASCII encoding. 
PyUnicode_AsEncodedString() and PyUnicode_Decode() functions have a fast-path 
for the "ascii" string, but not for "us-ascii".

Attached patch uses also the fast-path for "us-ascii". It's a more generic 
change than the issue #27915. The "us-ascii" name is common in the email and 
xml.etree modules.

Other changes of the patch:

* Rewrite _Py_normalize_encoding() as a C implementation of 
encodings.normalize_encoding(). For example, " utf-8 " is now normalized to 
"utf_8". So the fast path is now used for more name variants of the same 
encoding.
* Avoid strcpy() when encoding is NULL: call directly the UTF-8 codec
* Reorder encodings: UTF-8, ASCII, MBCS, Latin1, UTF-16
* Remove fast-path for UTF-32: seriously, nobody uses this codec. Latin9 is 
much faster but has no fast-path.

--
components: Interpreter Core, Unicode
files: normalize_encoding.patch
keywords: patch
messages: 274222
nosy: ezio.melotti, haypo, scop, serhiy.storchaka
priority: normal
severity: normal
status: open
title: PyUnicode_AsEncodedString, PyUnicode_Decode: add fast-path for 
"us-ascii" encoding
type: performance
versions: Python 3.6
Added file: http://bugs.python.org/file44345/normalize_encoding.patch

___
Python tracker 

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



[issue27779] Sync-up docstrings in C version of the the decimal module

2016-09-02 Thread Stefan Krah

Stefan Krah added the comment:

"hand written signatures" refers to the signatures that Argument Clinic would 
generate if it were used (but I don't want that).

So this is an example of a hand written signature:

"is_infinite($self, /)\n--\n\n\"


I still wonder if people wouldn't be served better with concise docstrings, but 
then I'm generally in favor of a Unix manual page documentation style, so 
perhaps there's a cultural difference.

--

___
Python tracker 

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



[issue26470] Make OpenSSL module compatible with OpenSSL 1.1.0

2016-09-02 Thread Christian Heimes

Christian Heimes added the comment:

Yes, I plan to change this for Python 3.7 along with #27876.

--

___
Python tracker 

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



[issue26470] Make OpenSSL module compatible with OpenSSL 1.1.0

2016-09-02 Thread Christian Heimes

Christian Heimes added the comment:

Bernard, where do you see HAVE_RAND_EGD in my patch or in any recent version of 
_ssl.c? There is no reference to HAVE_RAND_EGD. The patches use OPENSSL_NO_EGD.

--

___
Python tracker 

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



[issue27937] logging.getLevelName microoptimization

2016-09-02 Thread Ondřej Medek

Ondřej Medek added the comment:

That's probably my lack of Python knowledge. I have though that parentheses in 
("Level %s" % level) cause lazy evaluation. If not, then this code has to be 
optimized by if-then, too.

--

___
Python tracker 

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



[issue27928] Add hashlib.scrypt

2016-09-02 Thread Christian Heimes

Christian Heimes added the comment:

Here is a new patch with argument clinic, more tests and required keyword 
arguments.

--
Added file: http://bugs.python.org/file44344/Add-hashlib.scrypt-2.patch

___
Python tracker 

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



[issue27937] logging.getLevelName microoptimization

2016-09-02 Thread Xiang Zhang

Xiang Zhang added the comment:

No, I mean this method you propose:

return _levelToName.get(level, (_nameToLevel.get(level, ("Level %s" % level

I cannot see any difference with the original code, except parentheses.

--

___
Python tracker 

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



[issue27937] logging.getLevelName microoptimization

2016-09-02 Thread Ondřej Medek

Ondřej Medek added the comment:

Which 'first' method do you mean?

logging.getLevelName() converts level (int) to level name (str). But due to the 
backward compatibility is also converts level name (str) to level (int).

--

___
Python tracker 

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



[issue27936] Inconsistent round behavior between float and int

2016-09-02 Thread Mark Dickinson

Mark Dickinson added the comment:

The test could be strengthened to add a check that the types of `round(x)` and 
`round(x, None)` match.

--

___
Python tracker 

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



[issue27936] Inconsistent round behavior between float and int

2016-09-02 Thread Mark Dickinson

Mark Dickinson added the comment:

Ah, sorry; now that I've looked at the patch, I see I misunderstood. You're not 
replacing None with zero; you're replacing it with NULL.

Patch LGTM.

--

___
Python tracker 

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



[issue27936] Inconsistent round behavior between float and int

2016-09-02 Thread Mark Dickinson

Mark Dickinson added the comment:

> I think the round() function should explicitly check for None and replace it 
> with zero

That would be a change in behaviour: `round(x)` is not the same as `round(x, 
0)`. For most types, `round(x)` returns an `int`, while `round(x, 0)` returns 
something of the same type as `x`. Instead, I think we should add the check for 
`None` to `int`s `__round__` implementation.

>>> round(1.3, 0)
1.0
>>> round(1.3)
1
>>> round(1.3, None)
1

--
nosy: +mark.dickinson

___
Python tracker 

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



[issue27937] logging.getLevelName microoptimization

2016-09-02 Thread Xiang Zhang

Xiang Zhang added the comment:

What's the meaning of the first method?

--
nosy: +xiang.zhang

___
Python tracker 

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



[issue27937] logging.getLevelName microoptimization

2016-09-02 Thread Ondřej Medek

New submission from Ondřej Medek:

The logging.getLevelName contains code:

return _levelToName.get(level, _nameToLevel.get(level, ("Level %s" % level)))

I am still a Python beginner, but I think the most of the times the 
_nameToLevel.get is called unnecessarily. IMHO the code should be

return _levelToName.get(level, (_nameToLevel.get(level, ("Level %s" % level

or maybe better a classic if then style:
result = _levelToName.get(level)
if result is None:
   result = _nameToLevel.get(level, ("Level %s" % level))
return result

Since this function is called every time the LogRecord is created, I think it 
should be microoptimized.

--
components: Library (Lib)
messages: 274210
nosy: Ondřej Medek
priority: normal
severity: normal
status: open
title: logging.getLevelName microoptimization
type: performance
versions: Python 3.5

___
Python tracker 

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



[issue27935] logging level FATAL missing in _nameToLevel

2016-09-02 Thread Xiang Zhang

Xiang Zhang added the comment:

Though FATAL is not mentioned in the doc, but I think it should be added to 
getLevelName, just like how WARN is handled now:

>>> logging.getLevelName("WARN")
30

--
keywords: +patch
nosy: +xiang.zhang
Added file: http://bugs.python.org/file44343/issue27935.patch

___
Python tracker 

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



[issue27936] Inconsistent round behavior between float and int

2016-09-02 Thread Raymond Hettinger

Changes by Raymond Hettinger :


Added file: 
http://bugs.python.org/file44342/fix_round_default_none_with_test.diff

___
Python tracker 

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



[issue27936] Inconsistent round behavior between float and int

2016-09-02 Thread Raymond Hettinger

Changes by Raymond Hettinger :


Removed file: http://bugs.python.org/file44341/fix_round_default_none.diff

___
Python tracker 

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



[issue27936] Inconsistent round behavior between float and int

2016-09-02 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
keywords: +patch
Added file: http://bugs.python.org/file44341/fix_round_default_none.diff

___
Python tracker 

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



[issue27936] Inconsistent round behavior between float and int

2016-09-02 Thread Raymond Hettinger

Raymond Hettinger added the comment:

The different data types make different choices:

>>> from decimal import Decimal
>>> from fractions import Fraction
>>> (1).__round__(None)
Traceback (most recent call last):
  File "", line 1, in 
(1).__round__(None)
TypeError: 'NoneType' object cannot be interpreted as an integer
>>> (1.0).__round__(None)
1
>>> Decimal(1).__round__(None)
Traceback (most recent call last):
  File "", line 1, in 
Decimal(1).__round__(None)
TypeError: optional arg must be an integer
>>> Fraction(1, 1).__round__(None)
1
>>> from _pydecimal import Decimal
>>> Decimal(1).__round__(None)
1

For Fraction and _pydecimal, the behavior comes from using None as a 
placeholder (which is common and normal in pure python code).  For float there 
is explicit code to test for the None case.   For int, the None test was 
omitted (perhaps a mistake) and the error is raised by PyNumber_Index.

Looking through tests, only Lib/test/test_float.py tests for None being 
allowable.  Elsewhere, it seems to be an implementation detail.

The old Python 2 version of the round() function never let None be passed in 
(because it used PyArg_ParseTupleAndKeywords(args, kwds, "d|i:round").  That 
logic seems to get lost in the Python 3 version when __round__ was introduced.

To resolve the differences, I think the round() function should explicitly 
check for None and replace it with zero before calling the underling __round__ 
functions where we would allow variable according the needs of the 
implementation.

--
nosy: +rhettinger

___
Python tracker 

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



[issue27931] Email parse IndexError <""@wiarcom.com>

2016-09-02 Thread Xiang Zhang

Xiang Zhang added the comment:

Looking at the spec this is a valid angle addr. Not only 
et_angle_addr('<""@wiarcom.com> SIZE=28113')[0].addr_spec but also 
et_angle_addr('<""@wiarcom.com> SIZE=28113')[0].local_part fails for the same 
reason.

The problem exists in get_bare_quoted_string. When encounter bare '""', it 
returns a empty BareQuoteString. I write issue27931.patch to fix this.

--
keywords: +patch
nosy: +xiang.zhang
Added file: http://bugs.python.org/file44340/issue27931.patch

___
Python tracker 

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



[issue27935] logging level FATAL missing in _nameToLevel

2016-09-02 Thread SilentGhost

Changes by SilentGhost :


--
nosy: +vinay.sajip

___
Python tracker 

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



[issue27936] Inconsistent round behavior between float and int

2016-09-02 Thread Jonatan Skogsfors

New submission from Jonatan Skogsfors:

Theo error handling for round is different for float and int. 

Python 3.5.1 (default, Apr 18 2016, 11:46:32) 
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> round(1.0, None)
1
>>> round(1, None)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'NoneType' object cannot be interpreted as an integer

--
messages: 274205
nosy: Jonatan Skogsfors
priority: normal
severity: normal
status: open
title: Inconsistent round behavior between float and int
type: behavior
versions: Python 3.5

___
Python tracker 

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



  1   2   >