[issue13703] Hash collision security issue

2012-01-29 Thread Gregory P. Smith

Gregory P. Smith  added the comment:

> What about PYTHONHASHSEED= -> off, PYTHONHASHSEED=0 -> random,
> PYTHONHASHSEED=n -> n ? I agree with Jim that it's better to have one
> env. variable than two.

Rather than the "" empty string for off I suggest an explicit string
that makes it clear what the meaning is.  PYTHONHASHSEED="disabled"
perhaps.

Agreed, if we can have a single env var that is preferred.  It is more
obvious that the PYTHONHASHSEED env var. has no effect when it is set
to a special value rather than when it is set to something but it is
configured to be ignored by a _different_ env var.

--

___
Python tracker 

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



[issue12892] UTF-16 and UTF-32 codecs should reject (lone) surrogates

2012-01-29 Thread Kang-Hao (Kenny) Lu

Kang-Hao (Kenny) Lu  added the comment:

Attached patch does the following beyond what the patch from haypo does:
  * call the error handler
  * reject 0xd800~0xdfff when decoding utf-32

The followings are on my TODO list, although this patch doesn't depend on any 
of these and can be reviewed and landed separately:
  * make the surrogatepass error handler work for utf-16 and utf-32. (I should 
be able to finish this by today)
  * fix an error in the error handler for utf-16-le. (In, Python3.2 
b'\xdc\x80\x00\x41'.decode('utf-16-be', 'ignore') returns "\x00" instead of "A" 
for some reason)
  * make unicode_encode_call_errorhandler return bytes so that we can simplify 
this patch. (This arguably belongs to a separate bug so I'll file it when 
needed)

> All UTF codecs should reject lone surrogates in strict error mode,

Should we really reject lone surrogates for UTF-7? There's a test in 
test_codecs.py that tests "\udc80" to be encoded b"+3IA-" (. Given that UTF-7 
is not really part of the Unicode Standard and it is more like a "data 
encoding" than a "text encoding" to me, I am not sure it's a good idea.

> but let them pass using the surrogatepass error handler (the UTF-8
> codec already does) and apply the usual error handling for ignore
> and replace.

For 'replace', the patch now emits b"\x00?" instead of b"?" so that UTF-16 
stream doesn't get corrupted. It is not "usual" and not matching

  # Implements the ``replace`` error handling: malformed data is replaced
  # with a suitable replacement character such as ``'?'`` in bytestrings 
  # and ``'\ufffd'`` in Unicode strings.

in the documentation. What do we do? Are there other encodings that are not 
ASCII compatible besides UTF-7, UTF-16 and UTF-32 that Python supports? I think 
it would be better to use encoded U+fffd whenever possible and fall back to 
'?'. What do you think?

Some other self comments on my patch:
  * In the STORECHAR macro for utf-16 and utf-32, I change all instances of "ch 
& 0xFF" to (unsigned char) ch. I don't have enough C knowledge to know if this 
is actually better or if this makes any difference at all.
  * The code for utf-16 and utf-32 are duplicates of the uft-8 one. That one's 
complexity comes from issue #8092 . Not sure if there are ways to simplify 
these. For example, are there suitable functions there so that we don't need to 
check integer overflow at these places?

--
nosy: +kennyluck
Added file: http://bugs.python.org/file24368/utf-16&32_reject_surrogates.patch

___
Python tracker 

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



[issue13703] Hash collision security issue

2012-01-29 Thread Zbyszek Szmek

Zbyszek Szmek  added the comment:

What about PYTHONHASHSEED= -> off, PYTHONHASHSEED=0 -> random, 
PYTHONHASHSEED=n -> n ? I agree with Jim that it's better to have one 
env. variable than two.

--

___
Python tracker 

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



[issue4966] Improving Lib Doc Sequence Types Section

2012-01-29 Thread Georg Brandl

Georg Brandl  added the comment:

ISTM that not doing this will make maintenance harder.  For 2.7 I agree that 
there is no clear boundary to make, but 3.2 should be split up as well to ease 
merging of updates.

--

___
Python tracker 

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



[issue4966] Improving Lib Doc Sequence Types Section

2012-01-29 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

I agree with 3.3 only. This might not be ready for 3.2.3 anyway, depending on 
how soon hash patch is ready, and if not, it becomes a somewhat moot point as 
new people should then download 3.3.0 instead of 3.2.4 next August.

--

___
Python tracker 

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



[issue9207] multiprocessing occasionally spits out exception during shutdown (_handle_workers)

2012-01-29 Thread Paul Nasrat

Changes by Paul Nasrat :


--
nosy: +pnasrat

___
Python tracker 

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



[issue11457] os.stat(): add new fields to get timestamps as Decimal objects with nanosecond resolution

2012-01-29 Thread Arfrever Frehtes Taifersar Arahesis

Arfrever Frehtes Taifersar Arahesis  added the comment:

I think that one of available types of time values returned by os.stat() should 
allow to directly pass these values to os.futimens() and os.utimensat(), which 
expect (time_sec, time_nsec) tuples.

--

___
Python tracker 

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



[issue11457] os.stat(): add new fields to get timestamps as Decimal objects with nanosecond resolution

2012-01-29 Thread STINNER Victor

STINNER Victor  added the comment:

I don't like the idea of adding new fields to os.stat() *by default* because it 
may break backward compatibility. And if the new fields are decimal.Decimal 
objects, the module has to be imported and it means that any call to os.stat() 
would be slower just to provide timestamps with a finer resolution: this is not 
acceptable if you just want to check if a file exists.

In the issue #13882, I propose to add a format argument to functions getting 
time (time.time(), time.clock(), etc.). My patch doesn't change the default 
type, but add a "decimal" format to get time as a decimal.Decimal object.

The option (format) value is a string to be able to add other formats without 
having to change the API later:

 - "decimal": decimal.Decimal object
 - "datetime": datetime.datetime object
 - "tuple": low-level value, (intpart: int, floatpart: int, divisor: int)
 - "float128"
 - etc.

For os.stat(), the optional argument can be called "timestamp".

So if you want timestamps in the best available resolution, use 
timestamp="decimal". If you prefer the datetime API, use timestamp="datetime". 
If you don't care of timestamps, just call os.stat() without setting the 
timestamp option ;-)

We might add a registry to add user-defined types, but the "tuple" format 
should be enough. (I don't know if we need to expose the low level "tuple" 
format.)

--

___
Python tracker 

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



[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-29 Thread STINNER Victor

Changes by STINNER Victor :


--
nosy: +skrah

___
Python tracker 

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



[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-29 Thread STINNER Victor

Changes by STINNER Victor :


--
assignee: Arfrever -> 

___
Python tracker 

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



[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-29 Thread STINNER Victor

STINNER Victor  added the comment:

> Another possible format would be "tuple"

Or, I forgot an obvious format: "datetime"!

--

___
Python tracker 

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



[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-29 Thread STINNER Victor

Changes by STINNER Victor :


Removed file: http://bugs.python.org/file24331/time_decimal-3.patch

___
Python tracker 

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



[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-29 Thread STINNER Victor

Changes by STINNER Victor :


Removed file: http://bugs.python.org/file24330/time_decimal-2.patch

___
Python tracker 

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



[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-29 Thread STINNER Victor

Changes by STINNER Victor :


--
assignee:  -> Arfrever
Added file: http://bugs.python.org/file24367/time_decimal-4.patch

___
Python tracker 

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



[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-29 Thread STINNER Victor

STINNER Victor  added the comment:

Patch version 4, minor update:
 - remove the resolution field of _PyTime_t and remove int_log10(): use 
1/divisior as the resolution to support divisor different than a power of 10 
(e.g. the cpu frequency on Windows)
 - inline and remove _PyTime_FromTimespec()

--

___
Python tracker 

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



[issue13856] xmlrpc / httplib changes to allow for certificate verification

2012-01-29 Thread Senthil Kumaran

Senthil Kumaran  added the comment:

I think, I was using wrong terminology, by 'sending' I meant, 'using' the 
ca_file in the client to verify Server's certificates.

--

___
Python tracker 

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



[issue13901] test_get_outputs (test_distutils) failure with --enable-shared on Mac OS X

2012-01-29 Thread Ned Deily

Ned Deily  added the comment:

On OS X, the linker includes in executables the absolute path to referenced 
shared libraries and normally --enable-shared builds are only usable from their 
installed location, i.e. after doing 'make install'.  RUNSHARED is defined as 
it is on OS X so that during the build of the standard library, the newly built 
interpreter uses its shared library before being installed.  After a 'make 
install', RUNSHARED should not be used on OS X; the shared library will always 
be found via the absolute path linked in the executable.  So I think the right 
solution for the problem here is to bypass the fixup code, so something like 
this (note the current 2.7.x is now similar to 3.2.x and differs from 2.7.2):


diff --git a/Lib/distutils/tests/support.py b/Lib/distutils/tests/support.py
--- a/Lib/distutils/tests/support.py
+++ b/Lib/distutils/tests/support.py
@@ -211,5 +211,8 @@
 if runshared is None:
 cmd.library_dirs = ['.']
 else:
-name, equals, value = runshared.partition('=')
-cmd.library_dirs = value.split(os.pathsep)
+if sys.platform == 'darwin':
+cmd.library_dirs = []
+else:
+name, equals, value = runshared.partition('=')
+cmd.library_dirs = value.split(os.pathsep)

--
nosy: +ned.deily, ronaldoussoren
versions: +Python 3.3

___
Python tracker 

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



[issue13703] Hash collision security issue

2012-01-29 Thread Dave Malcolm

Dave Malcolm  added the comment:

On Sat, 2012-01-28 at 23:56 +, Terry J. Reedy wrote:
> Terry J. Reedy  added the comment:
> 
> > I think you should check with randomization enabled, if only to see the
> > nature of the failures and if they are expected.
> 
> Including the list of when-enabled expected failures in the release 
> notes would help those who compile and test.

Am attaching a patch which fixes various problems that are clearly just
assumptions about dict ordering:
  fix-unittests-broken-by-randomization-dmalcolm-2012-01-29-001.patch

 json/__init__.py|4 +++-
 test/mapping_tests.py   |2 +-
 test/test_descr.py  |   12 +++-
 test/test_urllib.py |4 +++-
 tkinter/test/test_ttk/test_functions.py |2 +-
 5 files changed, 19 insertions(+), 5 deletions(-)

Here are the issues that it fixes:
Lib/test/test_descr.py: fix for intermittent failure due to dict repr:
  File "Lib/test/test_descr.py", line 4304, in test_repr
self.assertEqual(repr(self.C.__dict__), 
'dict_proxy({!r})'.format(dict_))
AssertionError: "dict_proxy({'__module__': 'test.test_descr', '__dict__': 
, '__doc__': None, '__weakref__': 
, 'meth': })"
 != "dict_proxy({'__module__': 'test.test_descr', '__doc__': 
None, '__weakref__': , 'meth': 
, '__dict__': })"

Lib/json/__init__.py: fix (based on haypo's work) for intermittent failure:
Failed example:
json.dumps([1,2,3,{'4': 5, '6': 7}], separators=(',', ':'))
Expected:
'[1,2,3,{"4":5,"6":7}]'
Got:
'[1,2,3,{"6":7,"4":5}]'

Lib/test/mapping_tests.py: fix (based on haypo's work) for intermittent 
failures of test_collections, test_dict, and test_userdict seen here:
==
ERROR: test_update (__main__.GeneralMappingTests)
--
Traceback (most recent call last):
  File "Lib/test/mapping_tests.py", line 207, in test_update
i1 = sorted(d.items())
TypeError: unorderable types: str() < int()

Lib/test/test_urllib.py: fix (based on haypo's work) for intermittent failure:
==
FAIL: test_nonstring_seq_values (__main__.urlencode_Tests)
--
Traceback (most recent call last):
  File "Lib/test/test_urllib.py", line 844, in test_nonstring_seq_values
urllib.parse.urlencode({"a": {"a": 1, "b": 1}}, True))
AssertionError: 'a=a&a=b' != 'a=b&a=a'
--

Lib/tkinter/test/test_ttk/test_functions.py: fix from haypo's patch for 
intermittent failure:
Traceback (most recent call last):
  File "Lib/tkinter/test/test_ttk/test_functions.py", line 146, in 
test_format_elemcreate
('a', 'b'), a='x', b='y'), ("test a b", ("-a", "x", "-b", "y")))
AssertionError: Tuples differ: ('test a b', ('-b', 'y', '-a',... != ('test 
a b', ('-a', 'x', '-b',...

I see two remaining issues (which this patch doesn't address):
test test_module failed -- Traceback (most recent call last):
  File "Lib/test/test_module.py", line 79, in test_clear_dict_in_ref_cycle
self.assertEqual(destroyed, [1])
AssertionError: Lists differ: [] != [1]

test_multiprocessing
Exception AssertionError: AssertionError() in  ignored

--
Added file: http://bugs.python.org/file24366/unnamed

___
Python tracker 

___diff -r 73dad4940b88 Lib/json/__init__.py
--- a/Lib/json/__init__.py	Fri Jan 20 11:23:02 2012 +
+++ b/Lib/json/__init__.py	Sun Jan 29 20:20:43 2012 -0500
@@ -31,7 +31,9 @@
 Compact encoding::
 
 >>> import json
->>> json.dumps([1,2,3,{'4': 5, '6': 7}], separators=(',', ':'))
+>>> from collections import OrderedDict
+>>> mydict = OrderedDict([('4', 5), ('6', 7)])
+>>> json.dumps([1,2,3,mydict], separators=(',', ':'))
 '[1,2,3,{"4":5,"6":7}]'
 
 Pretty printing::
diff -r 73dad4940b88 Lib/test/mapping_tests.py
--- a/Lib/test/mapping_tests.py	Fri Jan 20 11:23:02 2012 +
+++ b/Lib/test/mapping_tests.py	Sun Jan 29 20:20:43 2012 -0500
@@ -14,7 +14,7 @@
 def _reference(self):
 """Return a dictionary of values which are invariant by storage
 in the object under test."""
-return {1:2, "key1":"value1", "key2":(1,2,3)}
+return {"1": "2", "key1":"value1", "key2":(1,2,3)}
 def _empty_mapping(self):
 """Return an empty mapping object"""
 return self.type2test()
diff -r 73dad4940b88 Lib/test/test_descr.py
--- a/Lib/test/test_descr.py	Fri Jan 20 11:23:02 2012 +
+++ b/Lib/test/test_descr.py	Sun Jan 29 20:20:43 2012 -0500
@@ -4300,8 +4300,18 @@
 
 def test_repr(self):
 # Test

[issue13874] test_faulthandler: read_null test fails with current clang

2012-01-29 Thread STINNER Victor

Changes by STINNER Victor :


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

___
Python tracker 

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



[issue13703] Hash collision security issue

2012-01-29 Thread Dave Malcolm

Dave Malcolm  added the comment:

On Sun, 2012-01-29 at 00:06 +, Dave Malcolm wrote:

I went ahead and added the flag to sys.flags, so now
  $ make test TESTPYTHONOPTS=-R
shows:
Testing with flags: sys.flags(debug=0, division_warning=0, inspect=0,
interactive=0, optimize=0, dont_write_bytecode=0, no_user_site=0,
no_site=0, ignore_environment=1, verbose=0, bytes_warning=2,
hash_randomization=1)

...note the:
  hash_randomization=1
at the end of sys.flags.  (This seems useful for making it absolutely
clear if you're getting randomization or not).  Hopefully I'm not
creating too much work for the other Python implementations.

Am attaching new version of patch for 3.1:
  optin-hash-randomization-for-3.1-dmalcolm-2012-01-29-001.patch

--
Added file: 
http://bugs.python.org/file24365/optin-hash-randomization-for-3.1-dmalcolm-2012-01-29-001.patch

___
Python tracker 

___diff -r 73dad4940b88 Doc/library/sys.rst
--- a/Doc/library/sys.rst   Fri Jan 20 11:23:02 2012 +
+++ b/Doc/library/sys.rst   Sun Jan 29 20:19:11 2012 -0500
@@ -220,6 +220,7 @@
:const:`ignore_environment`   :option:`-E`
:const:`verbose`  :option:`-v`
:const:`bytes_warning`:option:`-b`
+   :const:`hash_randomization`   :option:`-R`
= =
 
 
diff -r 73dad4940b88 Doc/reference/datamodel.rst
--- a/Doc/reference/datamodel.rst   Fri Jan 20 11:23:02 2012 +
+++ b/Doc/reference/datamodel.rst   Sun Jan 29 20:19:11 2012 -0500
@@ -1265,6 +1265,8 @@
inheritance of :meth:`__hash__` will be blocked, just as if :attr:`__hash__`
had been explicitly set to :const:`None`.
 
+   See also the :option:`-R` command-line option.
+
 
 .. method:: object.__bool__(self)
 
diff -r 73dad4940b88 Doc/using/cmdline.rst
--- a/Doc/using/cmdline.rst Fri Jan 20 11:23:02 2012 +
+++ b/Doc/using/cmdline.rst Sun Jan 29 20:19:11 2012 -0500
@@ -21,7 +21,7 @@
 
 When invoking Python, you may specify any of these options::
 
-python [-bBdEhiOsSuvVWx?] [-c command | -m module-name | script | - ] 
[args]
+python [-bBdEhiORsSuvVWx?] [-c command | -m module-name | script | - ] 
[args]
 
 The most common use case is, of course, a simple invocation of a script::
 
@@ -215,6 +215,30 @@
Discard docstrings in addition to the :option:`-O` optimizations.
 
 
+.. cmdoption:: -R
+
+   Turn on "hash randomization, so that the :meth:`__hash__` values of str,
+   bytes and datetime objects are "salted" with an unpredictable random value.
+   Although they remain constant within an individual Python process, they
+   are not predictable between repeated invocations of Python.
+
+   This is intended to provide protection against a denial-of-service
+   caused by carefully-chosen inputs that exploit the worst case performance
+   of a dict lookup, O(n^2) complexity.  See:
+
+   http://www.ocert.org/advisories/ocert-2011-003.html
+
+   for details.
+
+   Changing hash values affects the order in which keys are retrieved from
+   a dict.  Although Python has never made guarantees about this ordering
+   (and it typically varies between 32-bit and 64-bit builds), enough
+   real-world code implicitly relies on this non-guaranteed behavior that
+   the randomization is disabled by default.
+
+   See also :envvar:`PYTHONHASHRANDOMIZATION`.
+
+
 .. cmdoption:: -s
 
Don't add user site directory to sys.path
@@ -435,6 +459,25 @@
import of source modules.
 
 
+.. envvar:: PYTHONHASHRANDOMIZATION
+
+   If this is set to a non-empty string it is equivalent to specifying the
+   :option:`-R` option.
+
+
+.. envvar:: PYTHONHASHSEED
+
+   If this is set, it is used as a fixed seed for generating the hash() of
+   the types covered by the :option:`-R` option (or its equivalent,
+   :envvar:`PYTHONHASHRANDOMIZATION`.
+
+   It is primarily intended for use in selftests for the interpreter, but
+   may perhaps be of use for reproducing a specific dict ordering.
+
+   It should be a decimal number in the range [0; 4294967295].  Specifying
+   the value 0 overrides the other setting, disabling the hash random salt.
+
+
 .. envvar:: PYTHONIOENCODING
 
Overrides the encoding used for stdin/stdout/stderr, in the syntax
diff -r 73dad4940b88 Include/object.h
--- a/Include/object.h  Fri Jan 20 11:23:02 2012 +
+++ b/Include/object.h  Sun Jan 29 20:19:11 2012 -0500
@@ -473,6 +473,12 @@
 PyAPI_FUNC(long) _Py_HashDouble(double);
 PyAPI_FUNC(long) _Py_HashPointer(void*);
 
+typedef struct {
+long prefix;
+long suffix;
+} _Py_HashSecret_t;
+PyAPI_DATA(_Py_HashSecret_t) _Py_HashSecret;
+
 /* Helper for passing objects to printf and the like */
 #define PyObject_REPR(obj) _PyUnicode_AsString(PyObject_Repr(obj))
 
diff -r 73dad4940b88 Include/pydebug.h
--- a/Include/pydebug.h Fri Jan 20 11:23:02 2012 +
+++ b/Include/pydebug.h Sun Jan 29 20:19:11 2012

[issue13845] Use GetSystemTimeAsFileTime() to get a resolution of 100 ns on Windows

2012-01-29 Thread STINNER Victor

STINNER Victor  added the comment:

Two articles (Microsoft and IBM) about high resolution time on Windows:
http://msdn.microsoft.com/en-us/magazine/cc163996.aspx
http://www.ibm.com/developerworks/library/i-seconds/

I installed the Windows port of the NTP daemon:
http://www.meinberg.de/english/sw/ntp.htm

Using the NTP daemon, the resolution is 1 ms instead of 15 ms (on Windows 
Seven). It looks like it is possible to have a resolution of 0.5 ms, but I 
failed to get this resolution.

Attached patch is much more simple than the previous one: it only changes 
_PyTime_gettimeofday().

--
Added file: http://bugs.python.org/file24364/GetSystemTimeAsFileTime.patch

___
Python tracker 

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



[issue13908] PyType_FromSpec() lacks PyType_Ready() call

2012-01-29 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset 53b8f55e08bd by Benjamin Peterson in branch 'default':
merge 3.2 (closes #13908)
http://hg.python.org/cpython/rev/53b8f55e08bd

--
nosy: +python-dev
resolution:  -> fixed
stage:  -> committed/rejected
status: open -> closed

___
Python tracker 

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



[issue13856] xmlrpc / httplib changes to allow for certificate verification

2012-01-29 Thread Martin v . Löwis

Martin v. Löwis  added the comment:

> By that I mean, sending the ca_file and cert_reqs from the client,
> which I believe would be required if you want to verify the server
> certificate from the client end [1]. The other clients send only
> the cert_file and the key_file.

Ah, you are probably referring to the "server name indication",
which is a fairly recent TLS feature.

Python does support it, in the server_hostname context field.

You never ever send the CA certificate to the server in TLS,
AFAIK (except as part of a chain including your own client
certificate).

--

___
Python tracker 

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



[issue13903] New shared-keys dictionary implementation

2012-01-29 Thread John O'Connor

Changes by John O'Connor :


--
nosy: +jcon

___
Python tracker 

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



[issue6210] Exception Chaining missing method for suppressing context

2012-01-29 Thread Patrick Westerhoff

Patrick Westerhoff  added the comment:

Oh, where did that PEP come from? ^^ Also thanks for hinting at python-dev, 
didn’t realize that there was a discussion going on about this!

--

___
Python tracker 

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



[issue6210] Exception Chaining missing method for suppressing context

2012-01-29 Thread Nick Coghlan

Nick Coghlan  added the comment:

This was discussed a little more in the python-dev thread for PEP 409, but both 
Guido and I have been burned in the past by badly written libraries that 
replaced detailed exceptions that explained *exactly* what was going wrong with 
bland, generic "it broke!" exceptions that told us nothing. What should have 
been a 5 minute fix turns into a long bug hunt because useful information was 
being thrown away.

With __context__ always being set, all you need to do to cope with 
inappropriate use of "raise X from None" by libraries is write your own 
exception handler that always reports the entire exception chain, regardless of 
the __cause__ setting. If "raise X from None" actually *clobbers* the context, 
though, you instead have to go in and try to get hold of the detailed exception 
information *before* it gets clobbered (which is a lot harder to do).

--

___
Python tracker 

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



[issue13903] New shared-keys dictionary implementation

2012-01-29 Thread STINNER Victor

STINNER Victor  added the comment:

I see two unrelated parts in your patch:
 - change dictionary structure in memory
 - change many constants linked to optimization: PyDICT_MAXFREELIST: 80->40, 
2/3->5/8, etc.

You may open a new issue for the second part, except if I am wrong and you need 
to change constants for the first part?

(I don't understand why you changed constants and how you chose new values.)

--
nosy: +haypo

___
Python tracker 

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



[issue13874] test_faulthandler: read_null test fails with current clang

2012-01-29 Thread Stefan Krah

Stefan Krah  added the comment:

STINNER Victor  wrote:
> Does my commit fix the issue?

Yes, perfectly.

--

___
Python tracker 

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



[issue13856] xmlrpc / httplib changes to allow for certificate verification

2012-01-29 Thread Senthil Kumaran

Senthil Kumaran  added the comment:

On Sun, Jan 29, 2012 at 10:30:45PM +, Antoine Pitrou wrote:
> 
> Well, if you are a security expert you can volunteer to maintain a
> trusted certificates' file in the Python repository :) I think
> nobody else amongst us is qualified.

:-) haha. Neither am I (and I didn't figure out immediately that,
that's the requirement to go forward, so definitely not the person.)

But given that curl [1] has adopted the approach the user will know
where the CA cert will be and let's the user specify the details, I
wondered if the just having the provision to give ca_cert details is a
good thing.

Yeah, I recollect a discussion that there is not a standard
file-system path where OS store the certs and relying on them is not a
good idea.

[1] http://curl.haxx.se/docs/sslcerts.html

--

___
Python tracker 

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



[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-29 Thread STINNER Victor

STINNER Victor  added the comment:

> Constant arguments

What do you call a constant argument? "float" and "decimal"? You would prefer a 
constant like time.FLOAT_FORMAT? Or maybe a boolean (decimal=True)?

I chose a string because my first idea was to add a registry to support other 
format, maybe user defined formats, like the one used by Unicode codecs.

If we choose to not support other formats, but only float and decimal, a 
simpler API can be designed.

Another possible format would be "tuple": (intpart: int, floatpart: int, 
divisor: int), a low level type used to "implement" other user-defined types. 
Using such tuple, you have all information (clock value and clock resolution) 
without losing information.

> varying return type

I agree that it is something uncommon in Python. I know 
os.listdir(bytes)->bytes and os.listdir(str)->str. I suppose that there are 
other functions with a different result type depending on the input.

I am not attached to my API, it was just a proposition.

> hidden import

Ah? I wouldn't call it hidden because I don't see how a function can return a 
decimal.Decimal object without importing it. If you consider that it is 
surprising (unexepected), it can be documented.

> and the list can go on.

What else?

> What is wrong with simply creating a new module, say "hirestime"
> with functions called decimal_time(), float_time(), datetime_time()
> and whatever else you would like.

Hum, adding a new module would need to duplicate code. The idea of adding an 
argument is also to simplify the implementation: most code is shared. We can 
still share a lot of code if we choose to add a new function in th time module 
instead of adding a new argument to existing functions.

> Let's keep the good old 'time' module simple.

What is complex in my patch? It doesn't break backward compatibility and should 
have a low (or null) overhead in runtime speed if the format is not set.

--

I notified something surprising in my patch: "t1=time.time("decimal"); 
t2=time.time("decimal"); t2-t1" returns something bigger than 20 ms... That's 
because the "import decimal" is done after reading the first clock value, and 
not before.

--

___
Python tracker 

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



[issue13856] xmlrpc / httplib changes to allow for certificate verification

2012-01-29 Thread Senthil Kumaran

Senthil Kumaran  added the comment:

On Sun, Jan 29, 2012 at 10:48:35PM +, Martin v. Löwis wrote:
> orsenthil: I don't fully understand your question (what kind of "carrying" 
> should the clients do); 

By that I mean, sending the ca_file and cert_reqs from the client,
which I believe would be required if you want to verify the server
certificate from the client end [1]. The other clients send only
the cert_file and the key_file.

[1]: 
http://code.activestate.com/recipes/577548-https-httplib-client-connection-with-certificate-v/

--

___
Python tracker 

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



[issue13911] test_trace depends on dict repr() ordering

2012-01-29 Thread Mark Shannon

New submission from Mark Shannon :

Changing PyDict_MINSIZE to 4 causes the following failure
python -m test.test_trace  
... 
==
ERROR: test_coverage (__main__.TestCoverage)
--
Traceback (most recent call last):
  File "/home/mark/python/cpython/Lib/test/test_trace.py", line 307, in 
test_coverage
self._coverage(tracer)
  File "/home/mark/python/cpython/Lib/test/test_trace.py", line 300, in 
_coverage
tracer.run(cmd)
  File "/home/mark/python/cpython/Lib/trace.py", line 501, in run
self.runctx(cmd, dict, dict)
  File "/home/mark/python/cpython/Lib/trace.py", line 509, in runctx
exec(cmd, globals, locals)
  File "", line 1, in 
  File "/home/mark/python/cpython/Lib/test/test_pprint.py", line 479, in 
test_main
test.support.run_unittest(QueryTestCase)
  File "/home/mark/python/cpython/Lib/test/support.py", line 1403, in 
run_unittest
_run_suite(suite)
  File "/home/mark/python/cpython/Lib/test/support.py", line 1378, in _run_suite
raise TestFailed(err)
test.support.TestFailed: Traceback (most recent call last):
  File "/home/mark/python/cpython/Lib/test/test_pprint.py", line 273, in 
test_set_reprs
self.assertEqual(pprint.pformat(cube), cube_repr_tgt)
AssertionError: '{frozenset(): frozenset({frozenset({2}), frozenset({0}), 
frozenset({1})}),\n fr [truncated]... != '{frozenset(): 
frozenset({frozenset({2}), frozenset({0}), frozenset({1})}),\n fr [truncated]...
Diff is 1436 characters long. Set self.maxDiff to None to see it.


==
ERROR: test_coverage_ignore (__main__.TestCoverage)
--
Traceback (most recent call last):
  File "/home/mark/python/cpython/Lib/test/test_trace.py", line 322, in 
test_coverage_ignore
self._coverage(tracer)
  File "/home/mark/python/cpython/Lib/test/test_trace.py", line 300, in 
_coverage
tracer.run(cmd)
  File "/home/mark/python/cpython/Lib/trace.py", line 501, in run
self.runctx(cmd, dict, dict)
  File "/home/mark/python/cpython/Lib/trace.py", line 509, in runctx
exec(cmd, globals, locals)
  File "", line 1, in 
  File "/home/mark/python/cpython/Lib/test/test_pprint.py", line 479, in 
test_main
test.support.run_unittest(QueryTestCase)
  File "/home/mark/python/cpython/Lib/test/support.py", line 1403, in 
run_unittest
_run_suite(suite)
  File "/home/mark/python/cpython/Lib/test/support.py", line 1378, in _run_suite
raise TestFailed(err)
test.support.TestFailed: Traceback (most recent call last):
  File "/home/mark/python/cpython/Lib/test/test_pprint.py", line 273, in 
test_set_reprs
self.assertEqual(pprint.pformat(cube), cube_repr_tgt)
AssertionError: '{frozenset(): frozenset({frozenset({2}), frozenset({0}), 
frozenset({1})}),\n fr [truncated]... != '{frozenset(): 
frozenset({frozenset({2}), frozenset({0}), frozenset({1})}),\n fr [truncated]...
Diff is 1436 characters long. Set self.maxDiff to None to see it.

--
components: Tests
messages: 152288
nosy: Mark.Shannon
priority: normal
severity: normal
status: open
title: test_trace  depends on dict repr() ordering
type: behavior

___
Python tracker 

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



[issue13868] Add hyphen doc fix

2012-01-29 Thread Sandro Tosi

Sandro Tosi  added the comment:

Wow.. do you really expect any positive outcome from you reply style?

I'll pretend I didn't read your reply and let me rephrase my question like 
this: there are several occurrences of 'floating point' in python doc, are you 
going to fix all the ones that are wrong?

--

___
Python tracker 

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



[issue13910] test_packaging is dependent on dict ordering.

2012-01-29 Thread Mark Shannon

New submission from Mark Shannon :

Changing PyDict_MINSIZE to 4 causes the following failure:

python -m test.test_packaging
...
Traceback (most recent call last):
  File "/home/mark/python/cpython/Lib/runpy.py", line 160, in 
_run_module_as_main
"__main__", fname, loader, pkg_name)
  File "/home/mark/python/cpython/Lib/runpy.py", line 73, in _run_code
exec(code, run_globals)
  File "/home/mark/python/cpython/Lib/test/test_packaging.py", line 5, in 

test_main()
  File "/home/mark/python/cpython/Lib/test/support.py", line 1496, in decorator
return func(*args)
  File "/home/mark/python/cpython/Lib/packaging/tests/__main__.py", line 18, in 
test_main
run_unittest(test_loader.discover(start_dir, top_level_dir=top_dir))
  File "/home/mark/python/cpython/Lib/test/support.py", line 1403, in 
run_unittest
_run_suite(suite)
  File "/home/mark/python/cpython/Lib/test/support.py", line 1378, in _run_suite
raise TestFailed(err)
test.support.TestFailed: Traceback (most recent call last):
  File "/home/mark/python/cpython/Lib/packaging/tests/test_create.py", line 
168, in test_convert_setup_py_to_cfg
"""))
AssertionError: '[metadata]\nname = pyxfoil\nversion = 0.2\nsummary = Python 
bindings for the Xf [truncated]... != '[metadata]\nname = pyxfoil\nversion = 
0.2\nsummary = Python bindings for the Xf [truncated]...
  [metadata]
  name = pyxfoil
  version = 0.2
  summary = Python bindings for the Xfoil engine
  download_url = UNKNOWN
  home_page = http://www.python-science.org/project/pyxfoil
  maintainer = André Espaze
  maintainer_email = andre.esp...@logilab.fr
  description = My super Death-scription
 |barbar is now on the public domain,
 |ho, baby !

  [files]
  packages = pyxfoil
  babar
  me
  modules = my_lib
  mymodule
  scripts = my_script
  bin/run
  extra_files = Martinique/Lamentin/dady
  Martinique/Lamentin/mumy
  Martinique/Lamentin/sys
  Martinique/Lamentin/bro
  setup.py
  README
- pyxfoil/fengine.so
  Pom
  Flora
  Alexander
+ pyxfoil/fengine.so

  resources =
  README.rst = {doc}
  pyxfoil.1 = {man}

--
messages: 152286
nosy: Mark.Shannon
priority: normal
severity: normal
status: open
title: test_packaging is dependent on dict ordering.

___
Python tracker 

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



[issue6210] Exception Chaining missing method for suppressing context

2012-01-29 Thread Steven D'Aprano

Steven D'Aprano  added the comment:

Patrick Westerhoff wrote:
> Patrick Westerhoff  added the comment:
> 
> I have to agree with Georg on that. I think it would make more sense to
> introduce some internal flag/variable that keeps track of if the cause was
> explicitely set. So if cause was set (i.e. `from X` syntax is used), then
> always display it in favor of the context – except that a None-cause causes
> nothing to display.
> 
> Regardless of that I’m actually not sure if just changing the way the cause
> is displayed is a correct way to handle the context. If I explicitely raise
> an exception in an except-handler, I usually don’t expect that new
> exception to get the previous exception attached to.

I'm inclined to agree. I'm not convinced that "raise MyError from None" should 
leave any trace of the old exception at all.

Suppose you have a couple of functions like this:

def spam(x):# LBYL
 if hasattr(x, "__len__"):
 y = len(x)+1
 else:
 raise MyError("x has no length")
 do_stuff_with(y)

def ham(x):# EAFP
 try:
 y = len(x)+1
 except TypeError:
 raise MyError("x has no length") from None
 do_stuff_with(y)

It is entirely an irrelevant implementation detail whether you happen to write 
spam or ham. The exception that the caller gets should, in my opinion, be the 
same. I can't see any benefit to exposing the TypeError, even if the caller 
has to overtly go looking for it in order to see it.

But having said that, if others have a specific scenario in mind where they 
would need to distinguish between spam and ham, I'm happy for the context to 
be set. But I am curious to learn what the scenario is. Is it just a matter of 
"just in case"?

--

___
Python tracker 

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



[issue13909] Ordering of free variables in dis is dependent on dict ordering.

2012-01-29 Thread Mark Shannon

New submission from Mark Shannon :

This only seems to apply to free variables, not local or cell variables.

The offending tests are lines 429 & 430 of Lib/test/test_dis.py
  (tricky, code_info_tricky),
  (co_tricky_nested_f, code_info_tricky_nested_f),


Changing PyDict_MINSIZE to 4 provokes this failure
python3 -m test.test_dis

--
components: Tests
messages: 152284
nosy: Mark.Shannon
priority: normal
severity: normal
status: open
title: Ordering of free variables in dis is dependent on dict ordering.
type: behavior

___
Python tracker 

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



[issue13847] Catch time(), ftime(), localtime() and clock() errors

2012-01-29 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset 5b42aefb8969 by Victor Stinner in branch 'default':
Issue #13847: Fix test_time, time.gmtime() doesn't use localtime()
http://hg.python.org/cpython/rev/5b42aefb8969

--

___
Python tracker 

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



[issue13908] PyType_FromSpec() lacks PyType_Ready() call

2012-01-29 Thread Andreas Stührk

New submission from Andreas Stührk :

As already stated by Amaury in 
http://mail.python.org/pipermail/python-dev/2011-October/113829.html, that 
leads to crashes:

>>> import xxlimited
>>> repr(xxlimited.Str)
[1]19575 segmentation fault (core dumped)  ./python

--
files: pytype_fromspec.patch
keywords: patch
messages: 152282
nosy: Trundle, amaury.forgeotdarc, loewis
priority: normal
severity: normal
status: open
title: PyType_FromSpec() lacks PyType_Ready() call
type: crash
versions: Python 3.2, Python 3.3
Added file: http://bugs.python.org/file24363/pytype_fromspec.patch

___
Python tracker 

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



[issue6210] Exception Chaining missing method for suppressing context

2012-01-29 Thread Ethan Furman

Ethan Furman  added the comment:

Not sure I have traceback._iter_chain() patched correctly, but all the tests 
pass.

Here's the latest code.

--
Added file: http://bugs.python.org/file24362/raise_from_none_v3.diff

___
Python tracker 

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



[issue13846] Add time.monotonic() function

2012-01-29 Thread STINNER Victor

STINNER Victor  added the comment:

> Do we actually yet another function, or could this be covered by adding a 
> parameter such as monotonic=False, perhaps to wallclock().

A monotonic is a different clock, it would be surprising that an
argument uses another clock.

--

___
Python tracker 

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



[issue13874] test_faulthandler: read_null test fails with current clang

2012-01-29 Thread STINNER Victor

STINNER Victor  added the comment:

Does my commit fix the issue?

--

___
Python tracker 

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



[issue13874] test_faulthandler: read_null test fails with current clang

2012-01-29 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset f71249d785d6 by Victor Stinner in branch 'default':
Issue #13874: read_null() of faulthandler uses volatile to avoid optimisation
http://hg.python.org/cpython/rev/f71249d785d6

--
nosy: +python-dev

___
Python tracker 

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



[issue13903] New shared-keys dictionary implementation

2012-01-29 Thread Gregory P. Smith

Changes by Gregory P. Smith :


--
nosy: +gregory.p.smith

___
Python tracker 

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



[issue4966] Improving Lib Doc Sequence Types Section

2012-01-29 Thread Nick Coghlan

Nick Coghlan  added the comment:

Trying to make this change in 2.7 would actually be a bit of a nightmare - how 
do you cleanly split documentation of the binary data and text processing 
sequence types when "str" is used for both?

The change would be *mostly* feasible in 3.2 (that's why I started my branch 
from there), but there are still some sharp edges that go away in 3.3 (mainly 
the narrow/wide Unicode split).

So unless anyone is really keen to see the update in 3.2, my current plan is to 
leave the maintenance versions alone and only update it for 3.3. Going that way 
also provides better opportunities for post-checkin feedback from folks that 
aren't set up to build the docs themselves (rebuilding the docs is fairly 
straightforward on *nix, but Terry tells me that using Windows complicates that 
process quite a bit).

--

___
Python tracker 

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



[issue13703] Hash collision security issue

2012-01-29 Thread Martin v . Löwis

Martin v. Löwis  added the comment:

> Given PYTHONHASHSEED, what is the point of PYTHONHASHRANDOMIZATION?

How would you do what it does without it? I.e. how would you indicate
that it should randomize the seed, rather than fixing the seed value?

> On startup, python reads a config file with the seed (which defaults to zero).

-1 on configuration files that Python reads at startup (let alone in a
bugfix release).

--

___
Python tracker 

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



[issue13703] Hash collision security issue

2012-01-29 Thread Mark Shannon

Mark Shannon  added the comment:

Barry A. Warsaw wrote:
> Barry A. Warsaw  added the comment:
> 
> On Jan 28, 2012, at 07:26 PM, Dave Malcolm wrote:
> 
>> This turns out to pass without PYTHONHASHRANDOMIZATION in the
>> environment, and fail intermittently with it.
>>
>> Note that "make test" invokes the built python with "-E", so that it
>> ignores the setting of PYTHONHASHRANDOMIZATION in the environment.
>>
>> Barry, Benjamin: does fixing this bug require getting the full test
>> suite to pass with randomization enabled (and fixing the intermittent
>> failures due to ordering issues), or is it acceptable to "merely" have
>> full passes without randomizing the hashes?
> 
> I think we at least need to identify (to the best of our ability) the tests
> that fail and include them in release notes.  If they're easy to fix, we
> should fix them.  Maybe also open a bug report for each failure.

http://bugs.python.org/issue13903 causes even more tests to fail,
so I'm submitting bug reports for most of the failing tests already.

--

___
Python tracker 

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



[issue13907] test_pprint relies on set/dictionary repr() ordering

2012-01-29 Thread Mark Shannon

New submission from Mark Shannon :

The function test_set_reprs() includes the comment:
"Consequently, this test is fragile and implementation-dependent"
Changing the dictionary iteration ordering breaks it.

--
components: Tests
messages: 152272
nosy: Mark.Shannon
priority: normal
severity: normal
status: open
title: test_pprint relies on set/dictionary repr() ordering

___
Python tracker 

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



[issue13856] xmlrpc / httplib changes to allow for certificate verification

2012-01-29 Thread Martin v . Löwis

Martin v. Löwis  added the comment:

For 3.x, xmlrpc.client should just pass-through the SSL context. Since the code 
to do so will be quite different from the current patch, I'm tempted to close 
this issue as rejected, unless Nathanael indicates that he would like to redo 
the patch for 3.x; this issue could then be recycled for that.

orsenthil: I don't fully understand your question (what kind of "carrying" 
should the clients do); the standard library most certainly supports validation 
of the server certificate.

--

___
Python tracker 

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



[issue7097] urlparse.urljoin of simple "http://" and "somedomain.com" produces incorrect result

2012-01-29 Thread Senthil Kumaran

Senthil Kumaran  added the comment:

>>> urljoin("http://";, "//somedomain.com")
results in "http://somedomain.com";

So, I wonder if this  way to specify the relative url properly and not the 
base-url. 

The test suite of urlparse tries to follow all the advertised scenarios for 
RFC3986 and also some more tests (which are usually discovered by de-facto 
scenarios of how other clients (mainly browsers) deal with it. If there is a 
browser behavior which we should emulate, without breaking existing code, we 
should consider this, otherwise we could leave this in invalid state.  Thanks!

--
nosy: +orsenthil

___
Python tracker 

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



[issue13703] Hash collision security issue

2012-01-29 Thread Jim Jewett

Jim Jewett  added the comment:

Given PYTHONHASHSEED, what is the point of PYTHONHASHRANDOMIZATION?

Alternative:

On startup, python reads a config file with the seed (which defaults to zero).

Add a function to write a random value to that config file for the next startup.

--

___
Python tracker 

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



[issue13703] Hash collision security issue

2012-01-29 Thread Barry A. Warsaw

Barry A. Warsaw  added the comment:

On Jan 28, 2012, at 07:26 PM, Dave Malcolm wrote:

>This turns out to pass without PYTHONHASHRANDOMIZATION in the
>environment, and fail intermittently with it.
>
>Note that "make test" invokes the built python with "-E", so that it
>ignores the setting of PYTHONHASHRANDOMIZATION in the environment.
>
>Barry, Benjamin: does fixing this bug require getting the full test
>suite to pass with randomization enabled (and fixing the intermittent
>failures due to ordering issues), or is it acceptable to "merely" have
>full passes without randomizing the hashes?

I think we at least need to identify (to the best of our ability) the tests
that fail and include them in release notes.  If they're easy to fix, we
should fix them.  Maybe also open a bug report for each failure.

I'm okay though with some tests failing in 2.6 with this environment variable
set.  We needn't go back and fix them in 2.6 (since we're in security-fix only
mode), but I'll bet you'll get almost the same set for 2.7 and there we
*should* fix them, even if it happens after the release.

>What do the buildbots do?

I'm not sure, but as long as the buildbots are green, I'm happy. :)

--

___
Python tracker 

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



[issue13856] xmlrpc / httplib changes to allow for certificate verification

2012-01-29 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

> Antoine - I fail to recollect, but is there any reason for the clients 
> in the stdlib are not carrying a ca_file and doing a certificate
> validation of the server connection?

Well, if you are a security expert you can volunteer to maintain a trusted 
certificates' file in the Python repository :) I think nobody else amongst us 
is qualified.

--

___
Python tracker 

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



[issue13906] mimetypes.py under windows - bad exception catch

2012-01-29 Thread R. David Murray

R. David Murray  added the comment:

This is a duplicate of issue 9291.

--
nosy: +r.david.murray
resolution:  -> duplicate
stage:  -> committed/rejected
status: open -> closed
superseder:  -> mimetypes initialization fails on Windows because of non-Latin 
characters in registry

___
Python tracker 

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



[issue13856] xmlrpc / httplib changes to allow for certificate verification

2012-01-29 Thread Senthil Kumaran

Senthil Kumaran  added the comment:

Thanks for submitting the patch. Couple of comments.

1. This is a new feature, so the patch should be addressed against 3.x. 
2. The patch lacks tests and documentation and hence it is not complete.

You could take a look at http/client.py or ssl.py (with test_ssl.py) for for 
passing the key and cert from the client.

Antoine - I fail to recollect, but is there any reason for the clients in the 
stdlib are not carrying a ca_file and doing a certificate validation of the 
server connection? Is it required (or a good idea) ?

--
nosy: +pitrou
versions: +Python 3.3 -Python 2.7

___
Python tracker 

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



[issue13906] mimetypes.py under windows - bad exception catch

2012-01-29 Thread Alexander Maksimenko

New submission from Alexander Maksimenko :

mimetypes.py(249) expectts Unicode*En*codeError, but Unicode*De*codeError 
happens when registry has non latin symbols (Vista Home 64).

I just change cathc jn next line to UnicodeDecodeError and all now works fine. 
But may be error not here, but on encode method which raise "negative" exception


F:\>c:\python27\python -m SimpleHTTPServer
Traceback (most recent call last):
  File "test.py", line 2, in 
import SimpleHTTPServer
  File "c:\python27\lib\SimpleHTTPServer.py", line 27, in 
class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
  File "c:\python27\lib\SimpleHTTPServer.py", line 204, in 
SimpleHTTPRequestHandler
mimetypes.init() # try to read system mime.types
  File "c:\python27\lib\mimetypes.py", line 355, in init
db.read_windows_registry()
  File "c:\python27\lib\mimetypes.py", line 259, in read_windows_registry
for ctype in enum_types(mimedb):
  File "c:\python27\lib\mimetypes.py", line 249, in enum_types
ctype = ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 0: ordinal 
not in range(128)


-- here after changes -

F:\>c:\python27\python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...
mc-quad - - [30/Jan/2012 02:02:18] "GET / HTTP/1.1" 200 -
mc-quad - - [30/Jan/2012 02:02:18] code 404, message File not found
mc-quad - - [30/Jan/2012 02:02:18] "GET /favicon.ico HTTP/1.1" 404 -

--
components: Library (Lib)
messages: 152267
nosy: mclander
priority: normal
severity: normal
status: open
title: mimetypes.py under windows - bad exception catch
type: behavior
versions: Python 2.7

___
Python tracker 

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



[issue13889] str(float) and round(float) issues with FPU precision

2012-01-29 Thread Samuel Iseli

Samuel Iseli  added the comment:

Hi Marc, the changes to the pythoncore.vcproj Visual-Studio file define the 
HAVE_VC_FUNC_FOR_X87 symbol. I use this symbol to enable the precision-setting 
macros in pyport.h. I made this similar to the existing code for gcc (linux).

You can change this but currently this symbol has to be defined somewhere for 
the macros to have an effect.

--

___
Python tracker 

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



[issue13899] re pattern r"[\A]" should work like "A" but matches nothing. Ditto B and Z.

2012-01-29 Thread John Machin

John Machin  added the comment:

Whoops: "normal Python rules for backslash escapes" should have had a note "but 
revert to the C behaviour of stripping the \ from unrecognised escapes" which 
is what re appears to do in its own \ handling.

--

___
Python tracker 

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



[issue13899] re pattern r"[\A]" should work like "A" but matches nothing. Ditto B and Z.

2012-01-29 Thread John Machin

John Machin  added the comment:

@Ezio: Comparison of the behaviour of \letter inside/outside character classes 
is irrelevant. The rules for inside can be expressed simply as:

1. Letters dDsSwW are special; they represent categories as documented, and do 
in fact have a similar meaning outside character classes.

2. Otherwise normal Python rules for backslash escapes in string literals 
should be followed. This means automatically that \a -> \x07, \A -> A, \b -> 
backspace, \B -> B, \z -> z and \Z -> Z.

@Georg: No need to read the source, just read my initial posting: It's compiled 
as a zero-length matcher ("at") inside a character class ("in") i.e. a 
nonsense, then at runtime the illegality is deliberately ignored.

--

___
Python tracker 

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



[issue13868] Add hyphen doc fix

2012-01-29 Thread Boštjan Mejak

Boštjan Mejak  added the comment:

If "floating point" in a sentence is in a role of an adjective, then it must be 
written as "floating-point" (with a hyphen), otherwise not.

Example: "The number 3.5 is a floating-point number."

Please consult some English orthography book and start writing correct English.

--

___
Python tracker 

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



[issue13897] Move fields relevant to coroutine/generators out of frame into generator/threadstate

2012-01-29 Thread Mark Shannon

Mark Shannon  added the comment:

The important part is not the change of name, but wrapping them in a 
struct which can be embedded in both PyThreadState and PyGenObject.

The state->exc_XXX trio of values are the currently handled exception
(sys.exc_info()) and are shadowed by generator exception handlers.
My patch models that shadowing rather than swapping the values in and 
out. This allows me to eliminate save_exc_state(), swap_exc_state()
and restore_and_clear_exc_state() completely.

--

___
Python tracker 

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



[issue13897] Move fields relevant to coroutine/generators out of frame into generator/threadstate

2012-01-29 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc  added the comment:

IMO "tstate->exc_value" has nothing to do with generators.  Changing its name 
seems gratuitous breakage to me.

--

___
Python tracker 

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



[issue5231] Change format of a memoryview

2012-01-29 Thread Stefan Krah

Stefan Krah  added the comment:

Yes, it's really superseded by #10181 now. I'm closing as 'duplicate',
since technically it'll be fixed once the patch for #10181 is committed.

--
dependencies:  -Problems with Py_buffer management in memoryobject.c (and 
elsewhere?)
resolution:  -> duplicate
stage: needs patch -> committed/rejected
status: open -> closed
superseder:  -> Problems with Py_buffer management in memoryobject.c (and 
elsewhere?)

___
Python tracker 

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



[issue13507] Modify OS X installer builds to package liblzma for the new lzma module

2012-01-29 Thread David Bolen

David Bolen  added the comment:

I recently built the xz library on my OSX Tiger buildbot (that also does the 
daily DMGs via the build script), and Nadeem mentioned this ticket.

As an FYI, I wasn't able to get the xz library (5.0.3) to configure/build as a 
universal build (i386/ppc) in a single step (as in the build script recipes).  
It appears to use some compile options incompatible with multiple -arch.

For my buildbot, I built it twice (as i386 and ppc) and then combined the 
libraries (static and shared) using lipo.  This appears to work for both the 
regular buildbot and the DMG creation.

In peeking at the build script this approach is a bit beyond the current recipe 
process, so would need more work than just a new recipe.  Assuming a build/lipo 
process is considered legitimate for release installers, of course, I'm not 
that sure how much I ended up "cheating".

--
nosy: +db3l

___
Python tracker 

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



[issue1625] bz2.BZ2File doesn't support multiple streams

2012-01-29 Thread Nadeem Vawda

Nadeem Vawda  added the comment:

> An alternative solution I'd like to pursue is to backport 3.3's BZ2File
> implementation to run on 2.7, and release it on PyPI.

Well, that was easier than I expected. It didn't take much work to get it
working under 2.6, 2.7 and 3.2. I've put up this "bz2file" module on
GitHub . I'll package it up and upload
it to PyPI sometime soon.

--

___
Python tracker 

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



[issue5231] Change format of a memoryview

2012-01-29 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Shouldn't this be closed in favour of #10181?

--

___
Python tracker 

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



[issue13905] Built-in Types Comparisons should mention rich comparison methods

2012-01-29 Thread Catalin Iacob

Catalin Iacob  added the comment:

Here's my attempt at a patch. It mostly takes the text from the default branch 
and adds references to __cmp__.

--
keywords: +patch
Added file: http://bugs.python.org/file24361/issue13905v1.patch

___
Python tracker 

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



[issue13905] Built-in Types Comparisons should mention rich comparison methods

2012-01-29 Thread Catalin Iacob

New submission from Catalin Iacob :

In 2.7 the Comparisons section of stdtypes.rst only talks about __cmp__ and 
never mentions the rich comparison methods:
"Instances of a class normally compare as non-equal unless the class defines 
the __cmp__() method. Refer to Basic customization) for information on the use 
of this method to effect object comparisons."

The first sentence is false, instances can also compare as equal if they define 
__eq__. And since __cmp__ is gone in Python3, I think the rich comparison 
methods should at least be mentioned, or even emphasized over __cmp__ to help 
people write more forward compatible code.

--
assignee: docs@python
components: Documentation
messages: 152254
nosy: catalin.iacob, docs@python
priority: normal
severity: normal
status: open
title: Built-in Types Comparisons should mention rich comparison methods
type: enhancement
versions: Python 2.7

___
Python tracker 

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



[issue13903] New shared-keys dictionary implementation

2012-01-29 Thread Philip Jenvey

Changes by Philip Jenvey :


--
nosy: +pjenvey

___
Python tracker 

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



[issue13903] New shared-keys dictionary implementation

2012-01-29 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola' :


--
nosy: +giampaolo.rodola

___
Python tracker 

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



[issue13903] New shared-keys dictionary implementation

2012-01-29 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

In the initial comment, 'Dummy' to 'Deleted' here but only here:
-   Holds an active (key, value) pair.  Active can transition to Dummy 
+   Holds an active (key, value) pair.  Active can transition to Deleted 

Im Lib/test/test_pprint.py
 def test_set_reprs(self): ...
 # Consequently, this test is fragile and ...
+# XXX So why include this "test" in the first place?
Raymond, I believe you added this 44927 and revised for 3.x in 45067.
I imagine it will also be a problem with randomized hashes. Should it be 
removed or somehow revised?

--
nosy: +terry.reedy

___
Python tracker 

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



[issue6210] Exception Chaining missing method for suppressing context

2012-01-29 Thread Ethan Furman

Ethan Furman  added the comment:

Patrick: The value in this enhancement is in not displaying the chained 
exception.  I do not see any value in throwing it away completely.  If you 
don't care about __context__ you can safely ignore it.  On the other hand, if 
it is completely removed, and you do care about it... well, too bad.

Georg, Nick:  On further thought, I agree that having 'from None' set cause 
from None to True is counter-intuitive, and there is consistency in having 
__context__ as None and __cause__ as False.

Thanks, Nick, for the pointers on the necessary changes.

--

___
Python tracker 

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



[issue13903] New shared-keys dictionary implementation

2012-01-29 Thread Antoine Pitrou

Changes by Antoine Pitrou :


--
nosy: +benjamin.peterson, pitrou
stage:  -> patch review
versions: +Python 3.3 -Python 3.4

___
Python tracker 

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



[issue13890] test_importlib failures under Windows

2012-01-29 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

I think it's more laziness. _Environ.__setitem__ could also update the original 
mapping.

--
nosy: +haypo

___
Python tracker 

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



[issue13848] io.open() doesn't check for embedded NUL characters

2012-01-29 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

I've made small changes and committed the patch in 3.2 and 3.3.
2.7 would need further changes and I don't think it's worth the bother.
Thanks!

--
resolution:  -> fixed
stage: patch review -> committed/rejected
status: open -> closed

___
Python tracker 

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



[issue13890] test_importlib failures under Windows

2012-01-29 Thread Brett Cannon

Brett Cannon  added the comment:

Is there a technological reason environ is not updated, or is it simply
oversight?

Lib/os.py: under POXIX, os.environ reflects posix.environ (it uses the same
underlying dict), while under Windows, os.environ uses a distinct dict from
nt.environ.
>
> --
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue13848] io.open() doesn't check for embedded NUL characters

2012-01-29 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset 572bb8c265c0 by Antoine Pitrou in branch '3.2':
Issue #13848: open() and the FileIO constructor now check for NUL characters in 
the file name.
http://hg.python.org/cpython/rev/572bb8c265c0

New changeset 6bb05ce1cd1f by Antoine Pitrou in branch 'default':
Issue #13848: open() and the FileIO constructor now check for NUL characters in 
the file name.
http://hg.python.org/cpython/rev/6bb05ce1cd1f

--
nosy: +python-dev

___
Python tracker 

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



[issue13872] socket.detach doesn't mark socket._closed

2012-01-29 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

> socket.socket.detach doesn't mark the socket._closed flag.

Well, does it have to? It's only an internal detail, it's not exposed as a 
public API.

--

___
Python tracker 

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



[issue2636] Adding a new regex module (compatible with re)

2012-01-29 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

> It'd be nice if we had some sort of representative benchmark for
> real-world uses of Python regexps. The JS guys have all pitched in to
> create such a thing for uses of regexps on thew web. I don't know of
> any such thing for Python.

See http://hg.python.org/benchmarks/, there are regex benchmarks there.

> I agree that a Python implementation wouldn't be useful for some
> cases. On the other hand, I believe it would be fine (or at least
> tolerable) for some others. I don't know the ratio between the two.

I think the ratio would be something like 2% tolerable :)

As I said to Ezio and Georg, I think adding the regex module needs a
PEP, even if it ends up non-controversial.

--

___
Python tracker 

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



[issue10181] Problems with Py_buffer management in memoryobject.c (and elsewhere?)

2012-01-29 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

> Of course this could also be exposed as a function, e.g.:
> 
>/* stealing a reference to bytes */
>PyMemoryView_FromBytesAndInfo(PyObject *bytes, Py_buffer *info);

I think we should minimize the number of reference-stealing functions.

> So let's make the flags private. What do you prefer?

I don't really mind, whatever you think is best :)

--

___
Python tracker 

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



[issue13848] io.open() doesn't check for embedded NUL characters

2012-01-29 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

The patch works under Windows here (on branch default).

--
stage: needs patch -> patch review

___
Python tracker 

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



[issue13903] New shared-keys dictionary implementation

2012-01-29 Thread Georg Brandl

Changes by Georg Brandl :


Removed file: http://bugs.python.org/file24357/061f8573af54.diff

___
Python tracker 

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



[issue13903] New shared-keys dictionary implementation

2012-01-29 Thread Mark Shannon

Changes by Mark Shannon :


Added file: http://bugs.python.org/file24360/6a21f3b35e20.diff

___
Python tracker 

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



[issue13904] Generator as *args: TypeError replaced

2012-01-29 Thread July Tikhonov

Changes by July Tikhonov :


Added file: 
http://bugs.python.org/file24359/typeerror-replaced-in-stararg-test.diff

___
Python tracker 

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



[issue13904] Generator as *args: TypeError replaced

2012-01-29 Thread July Tikhonov

New submission from July Tikhonov :

>>> set().union(*(None[k] for k in range(5)))
Traceback (most recent call last):
  File "", line 1, in 
TypeError: union() argument after * must be a sequence, not generator

Clearly, exception in not relevant, since next line works:

>>> set().union(*([k] for k in range(5)))
{0, 1, 2, 3, 4}

Correct exception would be

>>> None[1]
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'NoneType' object is not subscriptable

Problem is in python function call mechanics.
set().union can be replaced by any callable;
Generator can be replaced by any TypeError-raising iterable. Exceptions other 
then TypeError are handled correctly.

Python/ceval.c:4322
ext_do_call() converts stararg to tuple.
If any TypeError is raised, it is replaced with
TypeError("%s argument after * must be a sequence, not %s")


Proposed solution:

Probably, we can avoid replacing TypeError. Exceptions in the above cases would 
become relevant, and

>>> int(*None)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: type object argument after * must be a sequence, not NoneType

would become

>>> int(*None)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'NoneType' object is not iterable

so exception is still recognizable (and, may be, even more relevant, since we 
don't actually need _sequence_ as stararg, _iterable_ would be enough).

--
components: Interpreter Core
files: typeerror-replaced-in-stararg.diff
keywords: patch
messages: 152243
nosy: july
priority: normal
severity: normal
status: open
title: Generator as *args: TypeError replaced
type: behavior
versions: Python 3.3
Added file: http://bugs.python.org/file24358/typeerror-replaced-in-stararg.diff

___
Python tracker 

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



[issue6210] Exception Chaining missing method for suppressing context

2012-01-29 Thread Patrick Westerhoff

Patrick Westerhoff  added the comment:

I have to agree with Georg on that. I think it would make more sense to 
introduce some internal flag/variable that keeps track of if the cause was 
explicitely set. So if cause was set (i.e. `from X` syntax is used), then 
always display it in favor of the context – except that a None-cause causes 
nothing to display.

Regardless of that I’m actually not sure if just changing the way the cause is 
displayed is a correct way to handle the context. If I explicitely raise an 
exception in an except-handler, I usually don’t expect that new exception to 
get the previous exception attached to. In the original example, I want to 
completely replace the “context” by a new exception without implicitely keeping 
over the original exception.

So even if using `from None` will prevent the context from being displayed (as 
the explicitely set cause will override it), the `__context__` will probably 
still be set by the `raise` statement, and I think that shouldn’t happen. Hence 
the `raise X instead` or `raise as X` idea that simply does not set the context 
but “destroys” it.

--

___
Python tracker 

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



[issue6774] socket.shutdown documentation: on some platforms, closing one half closes the other half

2012-01-29 Thread Charles-François Natali

Charles-François Natali  added the comment:

I've reverted the commit.

--
resolution:  -> rejected
stage:  -> committed/rejected
status: open -> closed
versions: +Python 3.3

___
Python tracker 

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



[issue4966] Improving Lib Doc Sequence Types Section

2012-01-29 Thread Ezio Melotti

Ezio Melotti  added the comment:

> One other point... the branch is actually now relative to default, not
> 3.2. While that was due to a merging mistake on my part, it also means
> I can legitimately ignore the narrow/wide build distinction in the
> section on strings.

So will this go on 3.3 only or are you planning to push it on 3.2(/2.7) too?

--

___
Python tracker 

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



[issue6774] socket.shutdown documentation: on some platforms, closing one half closes the other half

2012-01-29 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset 9be82f458b79 by Charles-François Natali in branch 'default':
Issue #6774: Back out c8b77efe8b56, which only brings confusion.
http://hg.python.org/cpython/rev/9be82f458b79

--
nosy: +python-dev

___
Python tracker 

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



[issue13872] socket.detach doesn't mark socket._closed

2012-01-29 Thread Charles-François Natali

Changes by Charles-François Natali :


--
nosy: +pitrou

___
Python tracker 

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



[issue13899] re pattern r"[\A]" should work like "A" but matches nothing. Ditto B and Z.

2012-01-29 Thread Georg Brandl

Georg Brandl  added the comment:

Interesting. That shifts the issue, since the current behavior is neither of 
the two that make sense. Then it would indeed make the most sense to raise in 
these cases.

(I wonder what these patterns actually would match, but I have no time to look 
in the sre sources right now...)

--

___
Python tracker 

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



[issue13899] re pattern r"[\A]" should work like "A" but matches nothing. Ditto B and Z.

2012-01-29 Thread Ezio Melotti

Ezio Melotti  added the comment:

[\w] should definitely work, but [\B] doesn't seem to match anything useful, 
and it just fails silently because it's neither equivalent to \B nor to [B]:
>>> re.match(r'foo\B', 'foobar')  # on a non-word-boundary -- matches fine
<_sre.SRE_Match object at 0xb76dd3a0>
>>> re.match(r'foo[B]', 'fooBar')  # same as r'fooB'
<_sre.SRE_Match object at 0xb76dd1e0>
>>> re.match(r'foo[\B]', 'foobar')  # not equivalent to \B
>>> re.match(r'foo[\B]', 'fooBar')  # not equivalent to [B]

The same is true for \Z and \A:
>>> re.match(r'foo\Z', 'foo')  # end of the string -- matches fine
<_sre.SRE_Match object at 0xb76dd3a0>
>>> re.match(r'foo[Z]', 'fooZ')  # same as r'fooZ'
<_sre.SRE_Match object at 0xb76dd1e0>
>>> re.match(r'foo[\Z]', 'foo')  # not equivalent to \Z
>>> re.match(r'foo[\Z]', 'fooZ')  # not equivalent to [Z]
>>>
>>> re.match(r'\Afoo', 'foo')  # beginning of the string -- matches fine
<_sre.SRE_Match object at 0xb76dd1e0>
>>> re.match(r'[A]foo', 'Afoo')  # same as r'Afoo'
<_sre.SRE_Match object at 0xb76dd3a0>
>>> re.match(r'[\A]foo', 'foo')  # not equivalent to \A
>>> re.match(r'[\A]foo', 'Afoo')  # not equivalent to [A]

Inside [], \b switches from word boundary to backspace:
>>> re.match(r'foo\b', 'foobar')  # not on a word boundary -- no matches
>>> re.match(r'foo\b', 'foo bar')  # on a word boundary  -- matches fine
<_sre.SRE_Match object at 0xb74a4ec8>
>>> re.match(r'foo[\b]', 'foo bar')  # not equivalent to \b
>>> re.match(r'foo[\b]', 'foo\bbar')  # matches backspace
<_sre.SRE_Match object at 0xb76dd3d8>
>>> re.match(r'foo([\b])', 'foo\bbar').group(1)
'\x08'

Given that \b doesn't keep its word boundary meaning inside the [], \B (and \A 
and \Z) shouldn't keep it either (also because I can't see how having these 
inside [] would be of any use).
On the other hand I'm not sure they should be equivalent to B, A, Z either.  
There are several escape sequences in the form \X (where X is an upper- or 
lower-case letter) that are not equivalent to X (\a\b\d\f\s\x\w\D\S\W...).
Raising an error that says something like "I don't think [\A] does what you 
think it does, use [A] instead." might be a better option (and in case anyone 
is wondering about re.escape, I just checked and it doesn't escape letters).  
Even if this is technically backward incompatible, any string that has \A, \B, 
\Z inside [] can be considered buggy IMHO (unless someone can come up with a 
valid use case where they do something useful).

--
assignee: docs@python -> 

___
Python tracker 

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



[issue13896] shelf doesn't work with 'with'

2012-01-29 Thread Filip Gruszczyński

Filip Gruszczyński  added the comment:

Oh, I haven't noticed that. Using contextlib.closing solves my problem. Thanks.

--

___
Python tracker 

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



[issue13903] New shared-keys dictionary implementation

2012-01-29 Thread Georg Brandl

Changes by Georg Brandl :


--
keywords: +patch
Added file: http://bugs.python.org/file24357/061f8573af54.diff

___
Python tracker 

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



[issue13900] documentation page on email.parser contains self-referential non-definition of headersonly parameter

2012-01-29 Thread Georg Brandl

Changes by Georg Brandl :


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

___
Python tracker 

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



[issue13900] documentation page on email.parser contains self-referential non-definition of headersonly parameter

2012-01-29 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset 690d5978bd21 by Georg Brandl in branch '2.7':
Fix #13900: resolve self-referential description of a parameter.
http://hg.python.org/cpython/rev/690d5978bd21

--

___
Python tracker 

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



[issue13900] documentation page on email.parser contains self-referential non-definition of headersonly parameter

2012-01-29 Thread Georg Brandl

Georg Brandl  added the comment:

Should now be fixed. Thanks for the report.

--
nosy: +georg.brandl

___
Python tracker 

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



[issue13900] documentation page on email.parser contains self-referential non-definition of headersonly parameter

2012-01-29 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset 0d5667171356 by Georg Brandl in branch '3.2':
Fix #13900: resolve self-referential description of a parameter.
http://hg.python.org/cpython/rev/0d5667171356

--
nosy: +python-dev

___
Python tracker 

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



[issue13899] re pattern r"[\A]" should work like "A" but matches nothing. Ditto B and Z.

2012-01-29 Thread Georg Brandl

Georg Brandl  added the comment:

r'[\w]' also matches word chars.  I find that a very useful property, since you 
can easily build classes like '[\w.]'  It's also impossible to change this 
without breaking lots of regexes.  It's also explicitly documented, although 
IMO it's not clear it extends to \A and \Z, since it talks about "character 
classes".  So this is a docs issue.

--
assignee:  -> docs@python
components: +Documentation
nosy: +docs@python, georg.brandl

___
Python tracker 

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



[issue13857] Add textwrap.indent() as counterpart to textwrap.dedent()

2012-01-29 Thread Georg Brandl

Georg Brandl  added the comment:

Otherwise +1.

--

___
Python tracker 

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



[issue13857] Add textwrap.indent() as counterpart to textwrap.dedent()

2012-01-29 Thread Georg Brandl

Georg Brandl  added the comment:

BTW, the short spelling looks like it wouldn't indent the first line.

--
nosy: +georg.brandl

___
Python tracker 

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



  1   2   >