[issue22486] Speed up fractions.gcd()

2014-09-25 Thread Mark Dickinson

Mark Dickinson added the comment:

In case it's useful, see issue #1682 for my earlier Lehmer gcd implementation.  
 At the time, that approach was dropped as being premature optimisation.

--
nosy: +mark.dickinson

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



[issue22491] Support Unicode line boundaries in regular expression

2014-09-25 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

Currently regular expressions support on '\n' as line boundary. To meet Unicode 
standard requirement RL1.6 [1] all Unicode line separators should be supported: 
'\n', '\r', '\v', '\f', '\x85', '\u2028', '\u2029' and two-character '\r\n'. 
Also it is recommended that '.' in dotall mode matches '\r\n'. Also strongly 
recommended to support the '\R' pattern which matches all line separators 
(equivalent to '(?:\\r\n|(?!\r\n)[\n\v\f\r\x85\u2028\u2029]').

 [m.start() for m in re.finditer('$', '\r\n\n\r', re.M)]
[1, 2, 4]  # should be [0, 2, 3, 4]
 [m.start() for m in re.finditer('^', '\r\n\n\r', re.M)]
[0, 2, 3]  # should be [0, 2, 3, 4]
 [m.group() for m in re.finditer('.', '\r\n\n\r', re.M|re.S)]
['\r', '\n', '\n', '\r']  # should be ['\r\n', '\n', '\r']
 [m.group() for m in re.finditer(r'\R', '\r\n\n\r')]
[]  # should be ['\r\n', '\n', '\r']

[1] http://www.unicode.org/reports/tr18/#RL1.6

--
components: Extension Modules, Regular Expressions
messages: 227508
nosy: ezio.melotti, mrabarnett, pitrou, serhiy.storchaka
priority: normal
severity: normal
stage: needs patch
status: open
title: Support Unicode line boundaries in regular expression
type: enhancement
versions: Python 3.5

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



[issue22492] small addition to print() docs: no binary streams.

2014-09-25 Thread Georg Brandl

New submission from Georg Brandl:

This is implicit in the converts arguments to strings, but people might 
reasonably expect that print(x, file=y) is the same as y.write(x) for strings 
and bytes.  This paragraph makes it clear.

--
files: print_binary.diff
keywords: patch
messages: 227509
nosy: georg.brandl
priority: normal
severity: normal
status: open
title: small addition to print() docs: no binary streams.
Added file: http://bugs.python.org/file36719/print_binary.diff

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



[issue22264] Add wsgiref.util.dump_wsgistr load_wsgistr

2014-09-25 Thread Robert Collins

Robert Collins added the comment:

So this looks like its going to instantly create bugs in programs that use it. 
HTTP/1.1 headers are one of:
latin1
MIME encoded (RFC2047)
invalid and working only by accident

HTTP/2 doesn't change this.

An API that encourages folk to encode into utf8 and then put that in their 
headers is problematic.

Consider:

def dump_wsgistr(data, encoding, errors='strict'):
data.encode(encoding, errors).decode('iso-8859-1')

This takes a string that one wants to put into a header value, encodes it with 
a *user specified encoding*, then decodes that into iso-8859-1 [at which point 
it can be encoded back to octets by the wsgi server before putting on the wire].

But this is fundamentally wrong in the common case: either 'data' is itself 
suitable as a header value (e.g. it is ASCII - recommended per RFC7230 section 
3.2.4) or 'data' needs encoding via RFC 2047 encoding not via utf8.

There are a few special cases where folk have incorrectly shoved utf8 into 
header values and we need to make it possible for folk working within WSGI to 
do that - which is why the API is the way it is - but we shouldn't make it 
*easier* for them to do the wrong thing.

I'd support an API that DTRT here by taking a string, tries US_ASCII, with 
fallback to MIME encoded with utf8 as the encoding parameter.

--
nosy: +rbcollins

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



[issue12946] PyModule_GetDict() claims it can never fail, but it can

2014-09-25 Thread theme

Changes by theme theemat...@gmail.com:


--
versions: +Python 3.4, Python 3.5

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



[issue22264] Add wsgiref.util.dump_wsgistr load_wsgistr

2014-09-25 Thread Nick Coghlan

Nick Coghlan added the comment:

I'm not wedded to the specific algorithm - I definitely don't consider myself 
an HTTP or WSGI expert.

I do like the general idea of treating wsgistr as a serialisation format 
though, as that's effectively what it is at this point.

--

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



[issue12946] PyModule_GetDict() claims it can never fail, but it can

2014-09-25 Thread STINNER Victor

STINNER Victor added the comment:

 I gave two reasons why this function can fail, and one turns out to be 
 assumed-to-be-dead code. 

If the call to PyDict_New() is never called, the test can be replaced with an 
assertion.

--

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



[issue18093] Move main functions to a separate Programs directory

2014-09-25 Thread STINNER Victor

STINNER Victor added the comment:

_testembed was moved from Modules to Programs but test_capi was not updated: it 
still looks for test_embed in Modules.

$ ./configure --with-pydebug
$ make
$ ./python -m test -v test_capi
...
test_forced_io_encoding (test.test_capi.EmbeddingTests) ... skipped 
'/home/haypo/prog/python/default/Modules/_testembed' doesn't exist
test_subinterps (test.test_capi.EmbeddingTests) ... skipped 
'/home/haypo/prog/python/default/Modules/_testembed' doesn't exist
...

--
nosy: +haypo
resolution: fixed - 
status: closed - open

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



[issue18093] Move main functions to a separate Programs directory

2014-09-25 Thread STINNER Victor

STINNER Victor added the comment:

test_capi.patch fixes test_capi to be able to run _testembed in test_capi.

--
Added file: http://bugs.python.org/file36720/test_capi.patch

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



[issue22490] Using realpath for __PYVENV_LAUNCHER__ makes Homebrew installs fragile

2014-09-25 Thread Ned Deily

Ned Deily added the comment:

From the initial description of the problem, it's not clear to me that there 
is a problem here needing resolution in the stub launcher.  I've asked for 
clarification on the pip issue tracker.

--

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



[issue22490] Using realpath for __PYVENV_LAUNCHER__ makes Homebrew installs fragile

2014-09-25 Thread Ned Deily

Ned Deily added the comment:

Also, the patch causes a test failure with a framework build:

==
FAIL: test_defaults (test.test_venv.BasicTest)
--
Traceback (most recent call last):
  File 
/py/dev/3x/root/fwd/Library/Frameworks/pytest_10.9.framework/Versions/3.5/lib/python3.5/test/test_venv.py,
 line 106, in test_defaults
self.assertIn('home = %s' % path, data)
AssertionError: 'home = /py/dev/3x/root/fwd/./bin' not found in 'home = 
/py/dev/3x/root/fwd/bin\ninclude-system-site-packages = false\nversion = 
3.5.0\n'

--

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



[issue17835] test_io broken on PPC64 Linux

2014-09-25 Thread James Spurin

James Spurin added the comment:

fcntl doesnt seem to like the parameter you mentioned -

# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.5 (Santiago)
# /local/0/opt/python-3.4.1/bin/python
Python 3.4.1 (default, Sep 24 2014, 12:23:21)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux
Type help, copyright, credits or license for more information.
 import fcntl, os
 r, w = os.pipe()
 fcntl.fcntl(w, 1032)
Traceback (most recent call last):
  File stdin, line 1, in module
OSError: [Errno 22] Invalid argument


--

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



[issue18093] Move main functions to a separate Programs directory

2014-09-25 Thread Roundup Robot

Roundup Robot added the comment:

New changeset c87e00a6258d by Nick Coghlan in branch 'default':
Issue #18093: fix test_capi test skip due to _testembed move
https://hg.python.org/cpython/rev/c87e00a6258d

--

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



[issue18093] Move main functions to a separate Programs directory

2014-09-25 Thread Nick Coghlan

Nick Coghlan added the comment:

Thanks for spotting that Victor - should be fixed by that last commit with your 
change.

--
resolution:  - fixed
status: open - closed

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



[issue19717] resolve() fails when the path doesn't exist

2014-09-25 Thread July Tikhonov

Changes by July Tikhonov july.t...@gmail.com:


--
nosy: +july

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



[issue22493] Deprecate the use of flags not at the start of regular expression

2014-09-25 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

The meaning of inline flags not at the start of regular expression is 
ambiguous. Current re implementation and regex in the V0 mode enlarge the scope 
to all expression. In V1 mode in regex they affect only the end of the 
expression.

I propose to deprecate (and then forbid in 3.7) the use of inline flags not at 
the start of regular expression. This will help to change the meaning of inline 
flags in the middle of the expression in future (in 3.8 or later).

--
components: Library (Lib), Regular Expressions
files: re_deprecate_nonstart_flags.patch
keywords: patch
messages: 227520
nosy: ezio.melotti, mrabarnett, pitrou, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Deprecate the use of flags not at the start of regular expression
type: enhancement
versions: Python 3.5
Added file: http://bugs.python.org/file36721/re_deprecate_nonstart_flags.patch

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



[issue22494] default logging time string is not localized

2014-09-25 Thread Sean Dague

New submission from Sean Dague:

The default time string is not localized for using locale specific formatting, 
but is instead hardcoded to a ','. 

https://hg.python.org/cpython/file/c87e00a6258d/Lib/logging/__init__.py#l483 
demonstrates this.

Instead I think we should set that to the value of: 
locale.localeconv()['decimal_point']

While this clearly a very minor issue, I stare at enough logging output data 
that falls back to default formats (due to testing environments) that would 
love for this to be locale aware.

--
components: Library (Lib)
messages: 227521
nosy: sdague
priority: normal
severity: normal
status: open
title: default logging time string is not localized
type: behavior
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5

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



[issue22486] Speed up fractions.gcd()

2014-09-25 Thread Antoine Pitrou

Antoine Pitrou added the comment:

If Python grows an optimized implementation, how about exposing it in the math 
module?

--
nosy: +pitrou

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



[issue22491] Support Unicode line boundaries in regular expression

2014-09-25 Thread Matthew Barnett

Matthew Barnett added the comment:

For reference, the regex module normally considers the line ending to be '\n', 
but it has a WORD flag ('(?w)') that turns on the Unicode definition of a 
'word' character as well as Unicode line separator.

--

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



[issue22486] Speed up fractions.gcd()

2014-09-25 Thread Mark Dickinson

Mark Dickinson added the comment:

 If Python grows an optimized implementation, how about exposing it in the 
 math module?

+1.

--

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



[issue22486] Speed up fractions.gcd()

2014-09-25 Thread Stefan Behnel

Stefan Behnel added the comment:

That's what the patch does anyway. +1

--

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



[issue22477] GCD in Fractions

2014-09-25 Thread Stefan Behnel

Stefan Behnel added the comment:

Also see issue 22486. There is an unmerged C implementation in the old issue 
1682 that would go into the math module.

--

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



[issue22486] Speed up fractions.gcd()

2014-09-25 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Hmm... which patch?

--

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



[issue22486] Speed up fractions.gcd()

2014-09-25 Thread Stefan Behnel

Stefan Behnel added the comment:

http://bugs.python.org/file9486/lehmer_gcd.patch

(see #1682)

--

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



[issue22486] Speed up fractions.gcd()

2014-09-25 Thread Wolfgang Maier

Changes by Wolfgang Maier wolfgang.ma...@biologie.uni-freiburg.de:


--
nosy: +wolma

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



[issue1682] Move Demo/classes/Rat.py to Lib/fractions.py and fix it up.

2014-09-25 Thread Wolfgang Maier

Changes by Wolfgang Maier wolfgang.ma...@biologie.uni-freiburg.de:


--
nosy: +wolma

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



[issue22486] Add math.gcd()

2014-09-25 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is updated Mark's patch from issue1682. It is ported to 3.5, slightly 
simplified and optimized (I did not touched the main algorithm still), utilized 
in the fractions module, added tests and documentation.

It speeds up Stefan's fractions benchmark about 20%.

--
components: +Extension Modules
nosy: +serhiy.storchaka
stage:  - patch review
title: Speed up fractions.gcd() - Add math.gcd()
type: performance - enhancement

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



[issue22486] Add math.gcd()

2014-09-25 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
keywords: +patch
Added file: http://bugs.python.org/file36722/lehmer_gcd_4.patch

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



[issue22495] merge large parts of test_binop.py and test_fractions.py

2014-09-25 Thread Wolfgang Maier

New submission from Wolfgang Maier:

test_binop.py says that it tests binary operators on subtypes of built-in 
types, but in fact largely focuses on testing its own class Rat, which simply 
inherits from object and is, essentially, just a simple implementation of 
fractions.Fraction.

Instead of doing mostly redundant tests here and there it might be better to 
merge this part (up to line 305) of test_binop.py into test_fractions.py, then 
maybe add tests of subtypes of built-in types other than just object to 
test_binop.py.

This requires quite a bit of work though for a relatively minor improvement so 
do you think it's worth the effort ?

--
components: Tests
messages: 227530
nosy: wolma
priority: normal
severity: normal
status: open
title: merge large parts of test_binop.py and test_fractions.py
type: enhancement
versions: Python 3.5

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



[issue22486] Add math.gcd()

2014-09-25 Thread Stefan Behnel

Stefan Behnel added the comment:

The problem is that this changes the behaviour of fractions.gcd() w.r.t. 
negative numbers.  It's a public function, so we should keep it for backwards 
compatibility reasons, *especially* when adding a new function in the math 
module.

--
components:  -Extension Modules
type: enhancement - performance

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



[issue22486] Add math.gcd()

2014-09-25 Thread Stefan Behnel

Stefan Behnel added the comment:

Oh, and thanks for working on it, Serhiy! :)

--

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



[issue22486] Add math.gcd()

2014-09-25 Thread Wolfgang Maier

Wolfgang Maier added the comment:

see issue22477 for a discussion of whether the behavior of fractions.gcd should 
be changed or not

--

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



[issue22486] Add math.gcd()

2014-09-25 Thread Wolfgang Maier

Wolfgang Maier added the comment:

sorry, forgot to format the link:
issue22477

--

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



[issue22486] Add math.gcd()

2014-09-25 Thread Stefan Behnel

Stefan Behnel added the comment:

The thing is, if we add something new in a substantially more exposed place 
(the math module), then why break legacy code *in addition*? Just leaving it 
the way it is won't harm anyone, really.

--

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



[issue22486] Add math.gcd()

2014-09-25 Thread Wolfgang Maier

Wolfgang Maier added the comment:

I wasn't arguing for or against anything, just providing a link to the relevant 
discussion.

--

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



[issue22486] Add math.gcd()

2014-09-25 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Well, here is a patch which keeps the same weird behavior of fractions.gcd().

--
Added file: http://bugs.python.org/file36723/lehmer_gcd_5.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22486
___diff -r e9d4288c32de Doc/library/math.rst
--- a/Doc/library/math.rst  Wed Sep 24 13:29:27 2014 +0300
+++ b/Doc/library/math.rst  Thu Sep 25 15:51:26 2014 +0300
@@ -100,6 +100,14 @@ Number-theoretic and representation func
http://code.activestate.com/recipes/393090/`_\.
 
 
+.. function:: gcd(a, b)
+
+   Return the greatest common divisor of the integers *a* and *b*.  If either
+   *a* or *b* is nonzero, then the value of ``gcd(a, b)`` is the largest
+   positive integer that divides both *a* and *b*.  ``gcd(0, 0)`` returns
+   ``0``.
+
+
 .. function:: isfinite(x)
 
Return ``True`` if *x* is neither an infinity nor a NaN, and
diff -r e9d4288c32de Include/longobject.h
--- a/Include/longobject.h  Wed Sep 24 13:29:27 2014 +0300
+++ b/Include/longobject.h  Thu Sep 25 15:51:26 2014 +0300
@@ -198,6 +198,9 @@ PyAPI_FUNC(int) _PyLong_FormatAdvancedWr
 PyAPI_FUNC(unsigned long) PyOS_strtoul(const char *, char **, int);
 PyAPI_FUNC(long) PyOS_strtol(const char *, char **, int);
 
+/* For use by the gcd function in mathmodule.c */
+PyAPI_FUNC(PyObject *) _PyLong_GCD(PyObject *, PyObject *);
+
 #ifdef __cplusplus
 }
 #endif
diff -r e9d4288c32de Lib/fractions.py
--- a/Lib/fractions.py  Wed Sep 24 13:29:27 2014 +0300
+++ b/Lib/fractions.py  Thu Sep 25 15:51:26 2014 +0300
@@ -20,9 +20,9 @@ def gcd(a, b):
 Unless b==0, the result will have the same sign as b (so that when
 b is divided by it, the result comes out positive).
 
-while b:
-a, b = b, a%b
-return a
+if (b or a)  0:
+return -math.gcd(a, b)
+return math.gcd(a, b)
 
 # Constants related to the hash implementation;  hash(x) is based
 # on the reduction of x modulo the prime _PyHASH_MODULUS.
@@ -174,9 +174,12 @@ class Fraction(numbers.Rational):
 if denominator == 0:
 raise ZeroDivisionError('Fraction(%s, 0)' % numerator)
 if _normalize:
-g = gcd(numerator, denominator)
+g = math.gcd(numerator, denominator)
 numerator //= g
 denominator //= g
+if denominator  0:
+numerator = -numerator
+denominator = -denominator
 self._numerator = numerator
 self._denominator = denominator
 return self
diff -r e9d4288c32de Lib/test/test_math.py
--- a/Lib/test/test_math.py Wed Sep 24 13:29:27 2014 +0300
+++ b/Lib/test/test_math.py Thu Sep 25 15:51:26 2014 +0300
@@ -595,6 +595,24 @@ class MathTests(unittest.TestCase):
 s = msum(vals)
 self.assertEqual(msum(vals), math.fsum(vals))
 
+def testGcd(self):
+self.assertEqual(gcd(0, 0), 0)
+self.assertEqual(gcd(1, 0), 1)
+self.assertEqual(gcd(-1, 0), 1)
+self.assertEqual(gcd(0, 1), 1)
+self.assertEqual(gcd(0, -1), 1)
+self.assertEqual(gcd(7, 1), 1)
+self.assertEqual(gcd(7, -1), 1)
+self.assertEqual(gcd(-23, 15), 1)
+self.assertEqual(gcd(120, 84), 12)
+self.assertEqual(gcd(84, -120), 12)
+self.assertEqual(gcd(190738355881570558882299312308821696901058000,
+ 76478560266291874249006856460326062498333440),
+ 652560)
+
self.assertEqual(gcd(83763289342793979220453055528167457860243376086879213707165435635135627040075,
+ 
33585776402955145260404154387726204875807368546078094789530226423049489520976),
+ 286573572687563623189610484223662247799)
+
 def testHypot(self):
 self.assertRaises(TypeError, math.hypot)
 self.ftest('hypot(0,0)', math.hypot(0,0), 0)
diff -r e9d4288c32de Modules/mathmodule.c
--- a/Modules/mathmodule.c  Wed Sep 24 13:29:27 2014 +0300
+++ b/Modules/mathmodule.c  Thu Sep 25 15:51:26 2014 +0300
@@ -656,6 +656,22 @@ m_log10(double x)
 }
 
 
+static PyObject *
+math_gcd(PyObject *self, PyObject *args)
+{
+PyObject *a, *b;
+
+if (!PyArg_ParseTuple(args, O!O!:gcd, PyLong_Type, a, PyLong_Type, 
b))
+return NULL;
+
+return _PyLong_GCD(a, b);
+}
+
+PyDoc_STRVAR(math_gcd_doc,
+gcd(x, y) - int\n\
+greatest common divisor of x and y);
+
+
 /* Call is_error when errno != 0, and where x is the result libm
  * returned.  is_error will usually set up an exception and return
  * true (1), but may return false (0) without setting up an exception.
@@ -1958,6 +1974,7 @@ static PyMethodDef math_methods[] = {
 {frexp,   math_frexp, METH_O, math_frexp_doc},
 {fsum,math_fsum,  METH_O, math_fsum_doc},
 {gamma,   math_gamma, METH_O, math_gamma_doc},
+

[issue22486] Add math.gcd()

2014-09-25 Thread gladman

gladman added the comment:

I am inclined to think that a maths.gcd() makes sense as this would be where I 
would go first to find this function.  And the prospect of better performance 
is attractive since the gcd is an important operation in work with number 
theory algorithms.

Would it co-exist with fractions.gcd(), with identical semantics?

Or would it co-exist with fractions.gcd(), with the 'less surprising' semantics 
that are under discussion in the 'GCD in Fractions' thread?

Would it take on the suggestion of operating on one or more input parameters?

--
nosy: +gladman

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



[issue15799] httplib client and statusline

2014-09-25 Thread R. David Murray

Changes by R. David Murray rdmur...@bitdance.com:


--
stage:  - resolved

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



[issue22477] GCD in Fractions

2014-09-25 Thread Matthew Barnett

Matthew Barnett added the comment:

After some thought, I've come to the conclusion that the GCD of two integers 
should be negative only if both of those integers are negative.  The basic 
algorithm is that you find all of the prime factors of the integers and then 
return the product of the common subset (multiset, actually).

For example, to calculate the GCD of 6 and 15:

6 = [2, 3]
15 = [3, 5]
The largest common subset is [3].
Therefore the GCD is 3.

What about negative integers?

Well, what you could do is make one of the factors -1.

For example, to calculate the GCD of -6 and 15:

-6 = [-1, 2, 3]
15 = [3, 5]
The largest common subset is [3].
Therefore the GCD is 3.

Another example, to calculate the GCD of -6 and -15:

-6 = [-1, 2, 3]
-15 = [-1, 3, 5]
The largest common subset is [-1, 3].
Therefore the GCD is -3.

--
nosy: +mrabarnett

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



[issue2202] urllib2 fails against IIS 6.0 (No support for MD5-sess auth)

2014-09-25 Thread Mathieu Dupuy

Mathieu Dupuy added the comment:

and here for the 2.7 branch

--
Added file: http://bugs.python.org/file36725/md5-sess_not_implem_27.diff

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



[issue2202] urllib2 fails against IIS 6.0 (No support for MD5-sess auth)

2014-09-25 Thread Mathieu Dupuy

Mathieu Dupuy added the comment:

here is the patch, for the trunk

--
versions:  -Python 3.4
Added file: http://bugs.python.org/file36724/md5-sess_not_implem_cur.diff

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



[issue22477] GCD in Fractions

2014-09-25 Thread gladman

gladman added the comment:

On 25/09/2014 15:55, Matthew Barnett wrote:
 
 Matthew Barnett added the comment:
 
 After some thought, I've come to the conclusion that the GCD of two integers 
 should be negative only if both of those integers are negative.  The basic 
 algorithm is that you find all of the prime factors of the integers and then 
 return the product of the common subset (multiset, actually).
 
 For example, to calculate the GCD of 6 and 15:
 
 6 = [2, 3]
 15 = [3, 5]
 The largest common subset is [3].
 Therefore the GCD is 3.
 
 What about negative integers?
 
 Well, what you could do is make one of the factors -1.
 
 For example, to calculate the GCD of -6 and 15:
 
 -6 = [-1, 2, 3]
 15 = [3, 5]
 The largest common subset is [3].
 Therefore the GCD is 3.
 
 Another example, to calculate the GCD of -6 and -15:
 
 -6 = [-1, 2, 3]
 -15 = [-1, 3, 5]
 The largest common subset is [-1, 3].
 Therefore the GCD is -3.

But should the computation of the GCD of two integers by finding the
intersection of their prime factors include -1 or 1 given that neither
of these is a prime?  :-)

--

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



[issue22496] urllib2 fails against IIS (urllib2 can't parse 401 reply www-authenticate headers)

2014-09-25 Thread Mathieu Dupuy

New submission from Mathieu Dupuy:

When connecting to a IIS server, it replies that:

Unauthorized Server: Microsoft-IIS/7.5
WWW-Authenticate: Digest 
qop=auth,algorithm=MD5-sess,nonce=+Upgraded+v1fe2ba746797cfd974e85f9f6dbdd6e514ec45becd2d8cf0112c764c676ad4a00f98517bb166e467dcad4b942254bd9b71d447e3529c509d2,charset=utf-8,realm=Digest
WWW-Authenticate: Negotiate
WWW-Authenticate: NTLM
X-Powered-By: ASP.NET
Date: Thu, 25 Sep 2014 15:11:03 GMT
Connection: close
Content-Length: 0

which blew python 2.7 utllib2 like this:

File tut2.py, line 23, in module
response = opener.open('https://exca010.encara.local.ads/ews/Services.wsdl')
  File /usr/lib64/python2.7/urllib2.py, line 410, in open
response = meth(req, response)
  File /usr/lib64/python2.7/urllib2.py, line 524, in http_response
'http', request, response, code, msg, hdrs)
  File /usr/lib64/python2.7/urllib2.py, line 442, in error
result = self._call_chain(*args)
  File /usr/lib64/python2.7/urllib2.py, line 382, in _call_chain
result = func(*args)
  File /usr/lib64/python2.7/urllib2.py, line 1090, in http_error_401
host, req, headers)
  File /usr/lib64/python2.7/urllib2.py, line 973, in http_error_auth_reqed
return self.retry_http_digest_auth(req, authreq)
  File /usr/lib64/python2.7/urllib2.py, line 977, in retry_http_digest_auth
chal = parse_keqv_list(parse_http_list(challenge))
  File /usr/lib64/python2.7/urllib2.py, line 1259, in parse_keqv_list
k, v = elt.split('=', 1)
ValueError: need more than 1 value to unpack


urllib2 seems to assume that every www-authenticate header value will be a list 
of equal-signe-separated tuple.

On python3, the error is different and trigger this 
http://bugs.python.org/issue2202 (which is soon-to-be-fixed)

--
components: Library (Lib)
messages: 227543
nosy: deronnax
priority: normal
severity: normal
status: open
title: urllib2 fails against IIS (urllib2 can't parse 401 reply 
www-authenticate headers)
type: crash
versions: Python 2.7

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



[issue5459] msiexec not creating msvcr90.dll with python -2.6.1.msi

2014-09-25 Thread Katherine Dykes

Katherine Dykes added the comment:

Installing for a single user does solve the problem but it is not a good fix.  
We have python based software where this has been an issue and a lot of our 
windows users install python for all users out of habit.  We have to put in the 
docs to install for a single user, but I'd like to see the issue re-opened.

--
nosy: +Katherine.Dykes

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



[issue22477] GCD in Fractions

2014-09-25 Thread Matthew Barnett

Matthew Barnett added the comment:

As it appears that there isn't general agreement on how to calculate the GCD 
when negative numbers are involved, I needed to look for another way of 
thinking about it.

Splitting off the sign as another factor was what I came up with.

Pragmatism beats purity, and all that! :-)

--

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



[issue22477] GCD in Fractions

2014-09-25 Thread Stefan Behnel

Stefan Behnel added the comment:

IMHO, the most straight forward way for a new gcd() function to work would be 
to always, predictably return a non-negative value and let users handle all 
cases themselves where a negative sign of any or all input values has a 
specific meaning to them. That's the path of least surprise, and it's very easy 
to implement at the C level for PyLong values (as they are internally unsigned 
anyway).

--

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



[issue22448] call_at/call_later with Timer cancellation can result in (practically) unbounded memory usage.

2014-09-25 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 2a868c9f8f15 by Yury Selivanov in branch '3.4':
asyncio: Improve canceled timer handles cleanup. Closes issue #22448.
https://hg.python.org/cpython/rev/2a868c9f8f15

New changeset a6aaacb2b807 by Yury Selivanov in branch 'default':
asyncio: Improve canceled timer handles cleanup. Closes issue #22448.
https://hg.python.org/cpython/rev/a6aaacb2b807

--
nosy: +python-dev

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



[issue5459] msiexec not creating msvcr90.dll with python -2.6.1.msi

2014-09-25 Thread Martin v . Löwis

Martin v. Löwis added the comment:

Katherine: Python 2.6 is no longer maintained. If you are talking about a 
different Python version, please submit a new bug report. Please state
1. what you did
2. what happened
3. what you expected to happen instead
(personally, I'm not willing to invest time into 2.7, either, but somebody else 
might if that's the version you care about)

--

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



[issue5459] msiexec not creating msvcr90.dll with python -2.6.1.msi

2014-09-25 Thread Katherine Dykes

Katherine Dykes added the comment:

It is indeed 2.7 with the issues; the software we are building on (OpenMDAO) 
does not support 3.x - I'll go ahead and submit a new issue for 2.7

--

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



[issue22497] msiexec not creating msvcr90.dll with python -2.7.6.msi

2014-09-25 Thread Katherine Dykes

New submission from Katherine Dykes:

This is a new issue meant to resurrect Issue 5459.  When Python 2.7.x (and 
2.6.x before that) are installed for all users, then 'msvcr90.dll' is not 
created in the installation directory.  It does if you install for a single 
user.  However, many Windows users install Python for all users by default.  
This causes problems later when trying to install software that combines any 
sort of C or Fortran code.

--
components: Windows
messages: 227550
nosy: dykesk
priority: normal
severity: normal
status: open
title: msiexec not creating msvcr90.dll with python -2.7.6.msi
versions: Python 2.7

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



[issue22477] GCD in Fractions

2014-09-25 Thread Mark Dickinson

Mark Dickinson added the comment:

 IMHO, the most straight forward way for a new gcd() function to work would
 be to always, predictably return a non-negative value.

Yes.  Any new gcd implementation (in the math module, for example) should 
definitely return the unique nonnegative gcd of its inputs.

In an effort to concentrate the discussion a bit, here's a specific
proposal, deliberately limited in scope:

1. Add a new (faster) math.gcd function for Python 3.5, taking two integral 
arguments, and returning the unique nonnegative greatest common divisor of 
those arguments.

2. Deprecate fractions.gcd in Python 3.5 (with a message suggesting that 
math.gcd should be used instead), but don't change its behaviour.  (The 
fractions module would likely be using math.gcd by this point.)

3. Remove fractions.gcd in Python 3.6.

I'd suggest that tangents about gcd of more than two arguments, gcd of rational 
/ Decimal / float inputs, etc. be discussed elsewhere.  Those are all things 
that can be added later if there's a real use-case.

--

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



[issue22477] GCD in Fractions

2014-09-25 Thread Mark Dickinson

Mark Dickinson added the comment:

On second thoughts, I'm withdrawing this part of the proposal:

 3. Remove fractions.gcd in Python 3.6.

That just falls under 'gratuitous breakage'.  Instead, we should modify the 
`fractions.gcd` docstring to point users to math.gcd.

--

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



[issue22477] GCD in Fractions

2014-09-25 Thread gladman

gladman added the comment:

On 25/09/2014 17:02, Matthew Barnett wrote:
 
 Matthew Barnett added the comment:
 
 As it appears that there isn't general agreement on how to calculate the GCD 
 when negative numbers are involved, I needed to look for another way of 
 thinking about it.
 
 Splitting off the sign as another factor was what I came up with.
 
 Pragmatism beats purity, and all that! :-)

I understand :-)

But I think we now know that we are not going to get agreement here on
grounds of principles for what the gcd should return for negative
integers.

First, in order to preserve my sanity, I am going to concede Mark's
point that returning a negative value from GCD is not wrong :-)

For negative integers we have now amassed quite a few alternatives:

1) return the GCD that is non-negative (my preference)

2) return the GCD that is negative (your suggestion)

3) return the GCD that has the same sign as its first input

4) return the GCD that has the same sign as its second input (as now)

and, I suspect, a few more I haven't thought of.

I may be wrong here, but I suspect that if we were starting from scratch
the first of these would quickly be adopted for several reasons:

1) it yields the least surprising results and the one that most users
probably both want and expect.

2) For me, Wolfgang Maier's point about the commutative properties of
the gcd is rather important since finding that gcd(a, b) != gcd(b, a) is
a real loss, not just an inconvenience.

3) Its supports a common idiom for checking for co-prime numbers by
testing if the gcd is equal to 1.

But we are not starting from scratch and it is hard to see that it makes
much sense to change the GCD in fractions given the backwards
compatibilty issues that this might create.

So, it would seem that we should eiher do nothing or we should introduce
a gcd in, say math, that adopts approach (1) above and document its
difference when compared with that in fractions, allowing both to
co-exist.

We can, hopefully speed it up (see the related threads) and it might
over time come to be the gcd that people come to use as the norm (also
nothing would stop its internal use in fractions).

We might also allow one or more inputs.

Last but not least I hope I have not done anyone a disservice in this
summary.

--

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



[issue22486] Add math.gcd()

2014-09-25 Thread Mark Dickinson

Mark Dickinson added the comment:

 Or would it co-exist with fractions.gcd(), with the 'less surprising'
 semantics that are under discussion in the 'GCD in Fractions' thread?

Yes, exactly.  math.gcd will always give a nonnegative result.  The output of 
fractions.gcd remains unchanged for integer inputs, for backwards compatibility.

--

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



[issue22486] Add math.gcd()

2014-09-25 Thread Mark Dickinson

Mark Dickinson added the comment:

Serhiy: thank you!  I've been meaning to update that patch for a long time, but 
hadn't found the courage or time to face the inevitable bitrot.

--

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



[issue22477] GCD in Fractions

2014-09-25 Thread gladman

gladman added the comment:

On 25/09/2014 17:44, Mark Dickinson wrote:
 
 Mark Dickinson added the comment:
 
 IMHO, the most straight forward way for a new gcd() function to work would
 be to always, predictably return a non-negative value.
 
 Yes.  Any new gcd implementation (in the math module, for example) should 
 definitely return the unique nonnegative gcd of its inputs.
 
 In an effort to concentrate the discussion a bit, here's a specific
 proposal, deliberately limited in scope:
 
 1. Add a new (faster) math.gcd function for Python 3.5, taking two integral 
 arguments, and returning the unique nonnegative greatest common divisor of 
 those arguments.
 
 2. Deprecate fractions.gcd in Python 3.5 (with a message suggesting that 
 math.gcd should be used instead), but don't change its behaviour.  (The 
 fractions module would likely be using math.gcd by this point.)
 
 3. Remove fractions.gcd in Python 3.6.
 
 I'd suggest that tangents about gcd of more than two arguments, gcd of 
 rational / Decimal / float inputs, etc. be discussed elsewhere.  Those are 
 all things that can be added later if there's a real use-case.

My summary crossed with this plan from Mark, which I support (minus the
bit he subsequently retracted).

+1

--

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



[issue22498] frozenset allows modification via -= operator

2014-09-25 Thread James Paget

New submission from James Paget:

The operator -= modifies a frozenset (this should not be possible),
instead of signaling a TypeError.  Contrast with the += operator.

 f=frozenset([1,2])
 f
frozenset([1, 2])
 f -= frozenset([1])
 f
frozenset([2])
 f -= frozenset([2])
 f
frozenset([])
 f += frozenset([2])
Traceback (most recent call last):
  File stdin, line 1, in module
TypeError: unsupported operand type(s) for +=: 'frozenset' and 'frozenset'


--
components: Interpreter Core
messages: 227557
nosy: James.Paget
priority: normal
severity: normal
status: open
title: frozenset allows modification via -= operator
type: behavior
versions: Python 2.7

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



[issue22498] frozenset allows modification via -= operator

2014-09-25 Thread Ezio Melotti

Ezio Melotti added the comment:

This doesn't modify f, it replaces it with a new frozenset:
   f = frozenset({1, 2})
   f
  frozenset({1, 2})
   id(f)
  3071990668
   f -= frozenset({1})
   f
  frozenset({2})
   id(f)
  3066719340
Notice how the two ids are different.

In other words,
  f -= frozenset({1})
is equivalent to
  f = f - frozenset({1})

You get an error with += because
  f = f + frozenset({1})
is not a valid operation for (frozen)sets.

--
nosy: +ezio.melotti
resolution:  - not a bug
stage:  - resolved
status: open - closed

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



[issue22477] GCD in Fractions

2014-09-25 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I strongly agree with Mark's revised plan:
1. add a fast C-coded math.gcd returning the actual greatest (in normal ordered 
int sense) common divisor;
2. use this for reduction of fractions in the fractions module to speed up 
operations on fractions.
3. revised fractions.gcd docstring Return signed version of math.gcd.  ...
I think this would be double win (users get fast, 'proper' gcd; fractions work 
faster too).

--

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



[issue22477] GCD in Fractions

2014-09-25 Thread Stefan Behnel

Stefan Behnel added the comment:

+1 for Mark  Terry, just for the record

--

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



[issue22477] GCD in Fractions

2014-09-25 Thread Akira Li

Changes by Akira Li 4kir4...@gmail.com:


--
nosy:  -akira

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



[issue22490] Using realpath for __PYVENV_LAUNCHER__ makes Homebrew installs fragile

2014-09-25 Thread Ronald Oussoren

Ronald Oussoren added the comment:

I'm not convinced that this is a bug in python. __PYVENV_LAUNCHER__ is an 
implementation detail of CPython used in the implementation of the pyvenv 
functionality. 

I consider using this undocumented environment variable in distlib as a bug in 
distlib, which should be fixed there.  

It would be nice to know why distlib uses __PYVENV_LAUNCHER__ as that could 
lead us to a real bug or missing feature. 

BTW. I haven't read the discussion in [2] yet.

--

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



[issue15279] Spurious unittest warnings

2014-09-25 Thread Ezio Melotti

Ezio Melotti added the comment:

Is this still an issue?

--

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



[issue22477] GCD in Fractions

2014-09-25 Thread Matthew Barnett

Matthew Barnett added the comment:

+1 for leaving it to the user to make it negative if so desired.

--

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



[issue22496] urllib2 fails against IIS (urllib2 can't parse 401 reply www-authenticate headers)

2014-09-25 Thread Ned Deily

Changes by Ned Deily n...@acm.org:


--
nosy: +orsenthil

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



[issue21472] Fix wsgiref handling of absolute HTTP Request-URI

2014-09-25 Thread Robert Collins

Robert Collins added the comment:

FWIW we probably need to capture the original unaltered URL somewhere, but also 
ensure that PATH_INFO is always a relative path.

One should be able to implement a proxy in WSGI (because thats just another 
specialised app), and doing that today requires special handling depending on 
the WSGI container, which isn't great for consistency.

On security; Host header - url host mismatches occur when the host to which a 
request is sent != the url; this is expected only in the case of forward 
proxies: any other time it would indeed be a smuggling attack, trying to find 
mismatches between acls and access in servers - this is another reason to 
consolidate things so that wsgi apps can rely on urls looking consistent.

--
nosy: +rbcollins

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



[issue22497] msiexec not creating msvcr90.dll with python -2.7.6.msi

2014-09-25 Thread Ned Deily

Changes by Ned Deily n...@acm.org:


--
nosy: +steve.dower, zach.ware

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



[issue22494] default logging time string is not localized

2014-09-25 Thread Ned Deily

Changes by Ned Deily n...@acm.org:


--
nosy: +vinay.sajip

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



[issue22497] msiexec not creating msvcr90.dll with python -2.7.6.msi

2014-09-25 Thread Steve Dower

Steve Dower added the comment:

When you install for all users, the msvcr90.dll is also installed for all users 
and should appear in your System32/SysWOW64 directory.

What sort of problems are you facing? Compiled DLLs/pyds that are loaded into a 
running Python process should reuse the already loaded DLL (and Python won't 
have started if it couldn't resolve the CRT DLL).

--

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



[issue22477] GCD in Fractions

2014-09-25 Thread gladman

gladman added the comment:

On 25/09/2014 17:44, Mark Dickinson wrote:
 
 Mark Dickinson added the comment:
 
 IMHO, the most straight forward way for a new gcd() function to work would
 be to always, predictably return a non-negative value.
 
 Yes.  Any new gcd implementation (in the math module, for example) should 
 definitely return the unique nonnegative gcd of its inputs.
 
 In an effort to concentrate the discussion a bit, here's a specific
 proposal, deliberately limited in scope:
 
 1. Add a new (faster) math.gcd function for Python 3.5, taking two integral 
 arguments, and returning the unique nonnegative greatest common divisor of 
 those arguments.
 
 2. Deprecate fractions.gcd in Python 3.5 (with a message suggesting that 
 math.gcd should be used instead), but don't change its behaviour.  (The 
 fractions module would likely be using math.gcd by this point.)
 
 3. Remove fractions.gcd in Python 3.6.
 
 I'd suggest that tangents about gcd of more than two arguments, gcd of 
 rational / Decimal / float inputs, etc. be discussed elsewhere.  Those are 
 all things that can be added later if there's a real use-case.

I don't know much about performance issues in the Python interpreter but
one point I would make here is implementing a multiple integer gcd on
top of a two input one will involve calling gcd and abs for each
parameter.

In contrast a gcd that operates on one or more parameters (e.g of the
sort that I posted earlier under the name mgcd) can avoid these extra
calls and any consequent overheads and _might_ do so with little
additional overhead of its own making (i.e. loops vs calls).  I also
felt that this could be implemented on top of the work going on on the
faster gcd.

So, while I don't think we need to consider a rational gcd, it might be
worth at least considering how a 'one or more parameter' gcd compares on
performance grounds with a two parameter one.

--

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



[issue17835] test_io broken on PPC64 Linux

2014-09-25 Thread Charles-François Natali

Charles-François Natali added the comment:

Let's try with this instead:

 from socket import socket, SO_SNDBUF, SOL_SOCKET
 s = socket()
 s.getsockopt(SOL_SOCKET, SO_SNDBUF)

--

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



[issue4888] misplaced (or misleading) assert in ceval.c

2014-09-25 Thread Berker Peksag

Berker Peksag added the comment:

This has been fixed as part of issue 16191:

https://hg.python.org/cpython/rev/ac30a1b1cf17#l1.2780

--
nosy: +berker.peksag
resolution:  - out of date
stage: patch review - resolved
status: open - closed

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



[issue19642] shutil to support equivalent of: rm -f /dir/*

2014-09-25 Thread Berker Peksag

Changes by Berker Peksag berker.pek...@gmail.com:


--
stage:  - needs patch

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



[issue22496] urllib2 fails against IIS (urllib2 can't parse 401 reply www-authenticate headers)

2014-09-25 Thread Mathieu Dupuy

Mathieu Dupuy added the comment:

I filled the bug in a hurry. You have to read
when connecting to a IIS for a protected resource and replying with 401 for an 
authentication challenge, it replies this [...]

--

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



[issue22486] Add math.gcd()

2014-09-25 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Now I spent more time on the patch. Changes in updated patch:

* Removed code duplication for odd and even k.
* Temporary buffers c and d no longer allocated on every iteration.
* Long result now compacted. No longer unused allocated size.
* Added checks for results of long_abs() (it can fail).
* Merged _PyLong_GCD and long_gcd. Fast path for small negative integers no 
longer need to copy long objects in long_abs().
* Added tests for large negative numbers and for case Py_SIZE(a) - Py_SIZE(b)  
3.

--
Added file: http://bugs.python.org/file36726/lehmer_gcd_6.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22486
___diff -r e9d4288c32de Doc/library/math.rst
--- a/Doc/library/math.rst  Wed Sep 24 13:29:27 2014 +0300
+++ b/Doc/library/math.rst  Thu Sep 25 23:10:36 2014 +0300
@@ -100,6 +100,14 @@ Number-theoretic and representation func
http://code.activestate.com/recipes/393090/`_\.
 
 
+.. function:: gcd(a, b)
+
+   Return the greatest common divisor of the integers *a* and *b*.  If either
+   *a* or *b* is nonzero, then the value of ``gcd(a, b)`` is the largest
+   positive integer that divides both *a* and *b*.  ``gcd(0, 0)`` returns
+   ``0``.
+
+
 .. function:: isfinite(x)
 
Return ``True`` if *x* is neither an infinity nor a NaN, and
diff -r e9d4288c32de Include/longobject.h
--- a/Include/longobject.h  Wed Sep 24 13:29:27 2014 +0300
+++ b/Include/longobject.h  Thu Sep 25 23:10:36 2014 +0300
@@ -198,6 +198,9 @@ PyAPI_FUNC(int) _PyLong_FormatAdvancedWr
 PyAPI_FUNC(unsigned long) PyOS_strtoul(const char *, char **, int);
 PyAPI_FUNC(long) PyOS_strtol(const char *, char **, int);
 
+/* For use by the gcd function in mathmodule.c */
+PyAPI_FUNC(PyObject *) _PyLong_GCD(PyObject *, PyObject *);
+
 #ifdef __cplusplus
 }
 #endif
diff -r e9d4288c32de Lib/fractions.py
--- a/Lib/fractions.py  Wed Sep 24 13:29:27 2014 +0300
+++ b/Lib/fractions.py  Thu Sep 25 23:10:36 2014 +0300
@@ -20,9 +20,9 @@ def gcd(a, b):
 Unless b==0, the result will have the same sign as b (so that when
 b is divided by it, the result comes out positive).
 
-while b:
-a, b = b, a%b
-return a
+if (b or a)  0:
+return -math.gcd(a, b)
+return math.gcd(a, b)
 
 # Constants related to the hash implementation;  hash(x) is based
 # on the reduction of x modulo the prime _PyHASH_MODULUS.
@@ -174,9 +174,12 @@ class Fraction(numbers.Rational):
 if denominator == 0:
 raise ZeroDivisionError('Fraction(%s, 0)' % numerator)
 if _normalize:
-g = gcd(numerator, denominator)
+g = math.gcd(numerator, denominator)
 numerator //= g
 denominator //= g
+if denominator  0:
+numerator = -numerator
+denominator = -denominator
 self._numerator = numerator
 self._denominator = denominator
 return self
diff -r e9d4288c32de Lib/test/test_math.py
--- a/Lib/test/test_math.py Wed Sep 24 13:29:27 2014 +0300
+++ b/Lib/test/test_math.py Thu Sep 25 23:10:36 2014 +0300
@@ -595,6 +595,43 @@ class MathTests(unittest.TestCase):
 s = msum(vals)
 self.assertEqual(msum(vals), math.fsum(vals))
 
+def testGcd(self):
+gcd = math.gcd
+self.assertEqual(gcd(0, 0), 0)
+self.assertEqual(gcd(1, 0), 1)
+self.assertEqual(gcd(-1, 0), 1)
+self.assertEqual(gcd(0, 1), 1)
+self.assertEqual(gcd(0, -1), 1)
+self.assertEqual(gcd(7, 1), 1)
+self.assertEqual(gcd(7, -1), 1)
+self.assertEqual(gcd(-23, 15), 1)
+self.assertEqual(gcd(120, 84), 12)
+self.assertEqual(gcd(84, -120), 12)
+c = 652560
+x = 434610456570399902378880679233098819019853229470286994367836600566
+y = 1064502245825115327754847244914921553977
+a = x * c
+b = y * c
+self.assertEqual(gcd(a, b), c)
+self.assertEqual(gcd(b, a), c)
+self.assertEqual(gcd(-a, b), c)
+self.assertEqual(gcd(b, -a), c)
+self.assertEqual(gcd(a, -b), c)
+self.assertEqual(gcd(-b, a), c)
+self.assertEqual(gcd(-a, -b), c)
+self.assertEqual(gcd(-b, -a), c)
+c = 576559230871654959816130551884856912003141446781646602790216406874
+a = x * c
+b = y * c
+self.assertEqual(gcd(a, b), c)
+self.assertEqual(gcd(b, a), c)
+self.assertEqual(gcd(-a, b), c)
+self.assertEqual(gcd(b, -a), c)
+self.assertEqual(gcd(a, -b), c)
+self.assertEqual(gcd(-b, a), c)
+self.assertEqual(gcd(-a, -b), c)
+self.assertEqual(gcd(-b, -a), c)
+
 def testHypot(self):
 self.assertRaises(TypeError, math.hypot)
 self.ftest('hypot(0,0)', math.hypot(0,0), 0)
diff -r e9d4288c32de Modules/mathmodule.c
--- a/Modules/mathmodule.c  

[issue22448] call_at/call_later with Timer cancellation can result in (practically) unbounded memory usage.

2014-09-25 Thread Joshua Moore-Oliva

Joshua Moore-Oliva added the comment:

 Hm. That sounds like you won't actually be interoperable with other 
 asyncio-using code.

asyncio code can be interoperated with by spinning off an asyncio coroutine 
that on completion calls a callback that reschedules a non-asyncio coroutine.

I assume we shouldn't be spamming an issue with unrelated chatter, I'd be happy 
to discuss more via email if you would like.

--

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



[issue22448] call_at/call_later with Timer cancellation can result in (practically) unbounded memory usage.

2014-09-25 Thread Joshua Moore-Oliva

Joshua Moore-Oliva added the comment:

Also - should I close this issue now that a patch has been committed?

--

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



[issue22448] call_at/call_later with Timer cancellation can result in (practically) unbounded memory usage.

2014-09-25 Thread Yury Selivanov

Yury Selivanov added the comment:

Hm, strange, usually roundup robot closes issues. Anyways, closed now. Thanks 
again, Joshua.

--
resolution:  - fixed
status: open - closed

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



[issue21472] Fix wsgiref handling of absolute HTTP Request-URI

2014-09-25 Thread Robert Collins

Robert Collins added the comment:

Oh, also - while its tempting to say that it doesn't matter whether we take the 
urls host portion, or the host header or the server name - it does. Deployments 
that look like:

LB/Firewall - backend container - WSGI app

are likely to have assumptions within the WSGI app about what sort of urls they 
expect to reach them. We can mitigate this by being very explicit about 
whatever solution we have.

--

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



[issue22264] Add wsgiref.util.dump_wsgistr load_wsgistr

2014-09-25 Thread Robert Collins

Robert Collins added the comment:

So I guess the API concern I have is that there are two cases:
 - common spec compliant - US-ASCII + RFC2047
 - dealing with exceptions - UTF8 or otherwise

The former totally makes sense as a codec, though the current email 
implementation of it isn't quite a codec.

The latter almost wants to be a separate API, which I may propose as part of 
WSGI for HTTP/2; nevertheless in PEP- its integral to the main API because 
of the bytes-encoded-as-codepoints-00-ff solution.

So, perhaps:
 - a codec or something looking like it that covers the common case
   this would not permit specifying codecs on decode, for instance [since 
RFC2047 is self describing].
 - documentation for the uncommon case. *Possibly* a helper function.

--

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



[issue22464] Speed up fractions implementation

2014-09-25 Thread Stefan Behnel

Stefan Behnel added the comment:

Sorry for reopening this, but I found one more thing. Division is pretty heavy 
on PyLong objects and there doesn't seem to be an internal optimisation for 
division by 1 and -1. Since many Fraction input values can already be 
normalised for some reason, the following change shaves off almost 30% of the 
calls to PyNumber_InPlaceFloorDivide() in the telco benchmark during Fraction 
instantiation according to callgrind, thus saving 20% of the CPU instructions 
that go into tp_new().

Instead of always executing

numerator //= g
denominator //= g

this avoids unnecessary divisions:

if g is not 1:
if g is -1:
numerator = -numerator
denominator = -denominator
else:
numerator //= g
denominator //= g

Using the is operator here is CPythonish, but doing the same with != and == 
should also be an improvement already, although not as cheap. Now, given that 
CPython caches small integers internally, I would suggest actually not adding 
these two special cases to the fractions module but more generally to the 
division routines in longobject.c.

--
status: closed - open

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



[issue22490] Using realpath for __PYVENV_LAUNCHER__ makes Homebrew installs fragile

2014-09-25 Thread Ronald Oussoren

Ronald Oussoren added the comment:

 On 25 sep. 2014, at 19:58, Ronald Oussoren rep...@bugs.python.org wrote:
 
 
 Ronald Oussoren added the comment:
 
 I consider using this undocumented environment variable in distlib as a bug 
 in distlib, which should be fixed 

Speaking of which... That environment variable shouldn't leak into Python code 
in the first place, launching a regular Python interpreter from a venv could 
currently result in unwanted behavior.  I'll try to provide an example of that. 

Ronald
 
 --
 
 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue22490
 ___

--

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



[issue21831] integer overflow in 'buffer' type allows reading memory

2014-09-25 Thread Henri Salo

Henri Salo added the comment:

CVE-2014-7185

--
nosy: +Henri.Salo

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



[issue22490] Using realpath for __PYVENV_LAUNCHER__ makes Homebrew installs fragile

2014-09-25 Thread Vinay Sajip

Vinay Sajip added the comment:

 I consider using this undocumented environment variable in distlib
 as a bug in distlib, which should be fixed there.  

Well, let me explain why it's used: when Python = 3.3 starts up, it looks for 
a pyvenv.cfg file proximate to sys.executable. If found, that means we're in a 
venv, and sys.path is set up accordingly. On OS X, the stub launcher is 
copied/symlinked to the venv when a new venv is created - the real interpreter 
is not copied. So, shebangs written by distlib into scripts installed into a 
venv must be of the form #!/path/to/venv/bin/python, and this cannot be 
obtained from sys.executable because that is pointing to a framework 
executable. There would be no pyvenv.cfg anywhere near that location.

This is why the __PYVENV_LAUNCHER__ variable was created, and distlib uses it 
because it needs to conform to how venvs work. In this respect distlib is a bit 
like setuptools - it needs to understand some low-level details which other 
libraries don't need to worry about.

Scripts installed in venvs work as expected (AFAICT) when used with stock 
Python framework builds on OS X. With HomeBrew, the complication appears to be 
caused by two levels of symlink: the executable in /usr/local/ points to one in 
/usr/local/Cellar/..., which in turn points to the framework executable.

The failing test (test_defaults) could be fixed by looking for equivalence in 
the home = directories in the test, rather than a string-contains-value test 
as at present.

--

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



[issue22417] PEP 476: verify HTTPS certificates by default

2014-09-25 Thread Jesús Cea Avión

Changes by Jesús Cea Avión j...@jcea.es:


--
nosy: +jcea

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



[issue21991] The new email API should use MappingProxyType instead of returning new dicts.

2014-09-25 Thread Sai Krishna

Changes by Sai Krishna saikrishna17...@gmail.com:


--
nosy: +saikrishna17394

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



[issue22080] Add windows_helper module helper

2014-09-25 Thread Claudiu Popa

Changes by Claudiu Popa pcmantic...@gmail.com:


--
stage:  - patch review

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



[issue21518] Expose RegUnloadKey in winreg

2014-09-25 Thread Claudiu Popa

Claudiu Popa added the comment:

Is there something I can do to move this forward?

--

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



[issue22141] rlcompleter.Completer matches too much

2014-09-25 Thread Claudiu Popa

Claudiu Popa added the comment:

Looks good. Could you add a test that reproduces the intended behaviour?

--
nosy: +Claudiu.Popa

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



[issue22499] [SSL: BAD_WRITE_RETRY] bad write retry in _ssl.c:1636

2014-09-25 Thread Nikolaus Rath

New submission from Nikolaus Rath:

I received a bugreport due to a crash when calling SSLObject.send(). The 
traceback ends with:

[...]
  File 
/usr/local/lib/python3.4/dist-packages/dugong-3.2-py3.4.egg/dugong/__init__.py,
 line 584, in _co_send
len_ = self._sock.send(buf)
  File /usr/lib/python3.4/ssl.py, line 679, in send
v = self._sslobj.write(data)
ssl.SSLError: [SSL: BAD_WRITE_RETRY] bad write retry (_ssl.c:1636)

At first I thought that this is an exception that my application should catch 
and handle. However, when trying to figure out what exactly BAD_WRITE_RETRY 
means I get the impression that the fault is actually in Python's _ssl.c. The 
only places where this error is returned by OpenSSL are ssl/s2_pkt.c:480 and 
ssl/s3_pkt.c:1179, and in each case the problem seems to be with the caller 
supplying an invalid buffer after an initial write request failed to complete 
due to non-blocking IO.

This does not seem to be something that could be caused by whatever Python 
code, so I think there is a problem in _ssl.c.

--
components: Library (Lib)
messages: 227582
nosy: alex, christian.heimes, dstufft, giampaolo.rodola, janssen, nikratio, 
pitrou
priority: normal
severity: normal
status: open
title: [SSL: BAD_WRITE_RETRY] bad write retry in _ssl.c:1636
type: crash
versions: Python 3.4

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



[issue20320] select.select(timeout) and select.kqueue.control(timeout) must round the timeout to the upper bound

2014-09-25 Thread Jesús Cea Avión

Changes by Jesús Cea Avión j...@jcea.es:


--
nosy: +jcea

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



[issue20505] Remove resolution from selectors and granularity from asyncio

2014-09-25 Thread Jesús Cea Avión

Changes by Jesús Cea Avión j...@jcea.es:


--
nosy: +jcea

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



[issue22499] [SSL: BAD_WRITE_RETRY] bad write retry in _ssl.c:1636

2014-09-25 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Hmm... this sounds like issue8240, except that it should be fixed in 3.4...

--

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



[issue22499] [SSL: BAD_WRITE_RETRY] bad write retry in _ssl.c:1636

2014-09-25 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
type: crash - behavior

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



[issue22500] Argparse always stores True for positional arguments

2014-09-25 Thread Tristan Fisher

New submission from Tristan Fisher:

It's my understanding that giving the action=store_true to an argument in 
argparse defaults to False.  When using non-double-dashed/positional arguments, 
the argument resorts to True (even if explicitly marked default=False).

I've attached a minimal example, but, for clarity, the relevant line is as such:

parser.add_argument(meow, action=store_true, default=False)


I realize that this might strike some as an odd usage, and I always have the 
option of using --meow, but I found it odd that a positional argument is 
always True, even if not specified in sys.argv.

--
components: Library (Lib)
files: argparse_always_true.py
messages: 227584
nosy: Tristan.Fisher
priority: normal
severity: normal
status: open
title: Argparse always stores True for positional arguments
type: behavior
versions: Python 3.4
Added file: http://bugs.python.org/file36727/argparse_always_true.py

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



[issue21166] Bus error in pybuilddir.txt 'python -m sysconfigure --generate-posix-vars' build step

2014-09-25 Thread Jesús Cea Avión

Changes by Jesús Cea Avión j...@jcea.es:


--
nosy: +jcea

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



[issue20671] test_create_at_shutdown_with_encoding() of test_io hangs on SPARC Solaris 10 OpenCSW 3.x

2014-09-25 Thread Jesús Cea Avión

Changes by Jesús Cea Avión j...@jcea.es:


--
nosy: +jcea

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



[issue22500] Argparse always stores True for positional arguments

2014-09-25 Thread paul j3

paul j3 added the comment:

A 'store_true' action takes 0 arguments.  In effect `nargs=0`.

With an `optional` (flagged) argument, the default `False` is used if the flag 
is absent, and set to `True` when the flag is encountered (its Action 
`__call__` function is run).

A `positional` is 'encountered' whenever there are enough values to meet its 
`nargs`.  With `nargs=0`, an empty list of strings, i.e. none, is enough.  Thus 
such a `positional` is always found, and its `__call__` is run, setting the 
value to `True`.

As a result, action types like 'store_true', 'store_false', 'store_const' only 
make sense with `optionals`.

And I can't think of simple way of using a 'positional' to set an Namespace 
'dest' to boolean values.  It could be done with a custom Action, but not with 
the predefined ones.  Or you could translate the values after parsing.

--
nosy: +paul.j3

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



[issue22474] No explanation of how a task gets destroyed in asyncio 'task' documentation

2014-09-25 Thread Martin Panter

Changes by Martin Panter vadmium...@gmail.com:


--
nosy: +vadmium

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



[issue22496] urllib2 fails against IIS (urllib2 can't parse 401 reply www-authenticate headers)

2014-09-25 Thread Senthil Kumaran

Senthil Kumaran added the comment:

Yes, urllib2 does not have any support for NTML based authentication.  And it 
is a long pending feature request too.

For 2.7, the best way to handle this might be, instead of crashing on 
WWW-Authenticate: Negotiate, which is a valid response from IIS (1). It should 
detect it and fail with a helpful message to use a 3rdparty handler along with 
urllib2 [2]

And for 3.5, I think it is worthy to consider adding the support in stdlib.
@Daniel Holth - I see you are the owner of it. If we choose to adopt it, do you 
give permission to reuse portions of code (with correct attribution) in the 
stdlib?

1) http://msdn.microsoft.com/en-us/library/ms995330#http-sso-2_topic1
2) https://code.google.com/p/python-ntlm/

--
assignee:  - orsenthil
nosy: +dholth

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



  1   2   >