[issue4966] Improving Lib Doc Sequence Types Section

2012-01-30 Thread Nick Coghlan

Nick Coghlan  added the comment:

Good point, without doing the split in both, any doc merges in this section 
will be a nightmare. OK, with the caveat that the initial 3.2 version may gloss 
over some issues that no longer apply in 3.3 (specifically the narrow/wide 
split), I'll make a new branch in the sandbox so the changes will be once again 
based on 3.2.

--

___
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-30 Thread Martin v . Löwis

Martin v. Löwis  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.

Then I still don't understand your remarks. You said "is there any
reason for the clients in the stdlib are not carrying a ca_file",
but this isn't actually true: clients in the stdlib *do* carry
the CA file and *do* perform verification, see ftplib, nntplib,
imaplib, http.client, etc. It's just that it was forgotten in
xmlrpc.client.

--

___
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-30 Thread STINNER Victor

STINNER Victor  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.

If we choose to give the possibility to get decimal.Decimal objects,
we should also patch some functions to support Decimal objects, like
datetime.datetime.fromtimestamp() (today, it "just works", because a
Decimal object can be converted to float). We may accept Decimal in
os.futimens() and os.utimensat(), but I am not sure for this
particular case.

To come back to my format solution, we can also support classical C
structures to interact with C functions (in Python or more directly
using ctypes):
 - "timeval": (secs, usec) where sec and usec are int
 - "timespec": (secs, nsec) where sec and nsec are int

Or we may introduce conversion functions from other types like float,
Decimal or another type.

--

___
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-30 Thread Martin v . Löwis

Martin v. Löwis  added the comment:

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

I think this is bike-shedding. The requirements for environment
variables are
a) with no variable set, it must not do randomization
b) there must be a way to seed from the platform's RNG
Having an explicit seed actually is no requirement, so I'd propose
to drop PYTHONHASHSEED instead.

However, I really suggest to let the patch author (Dave Malcolm)
design the API within the constraints.

--

___
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-30 Thread Ezio Melotti

Ezio Melotti  added the comment:

Thanks for the patch!

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

This should probably be done on a separate patch that will be applied to 
3.2/3.3 (assuming that it can go to 3.2).  Rejecting surrogates will go in 3.3 
only.  (Note that lot of Unicode-related code changed between 3.2 and 3.3.)

> Should we really reject lone surrogates for UTF-7?

No, I meant only UTF-8/16/32; UTF-7 is fine as is.

--

___
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-30 Thread STINNER Victor

STINNER Victor  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.

Oh, I realized that these two functions were added to Python 3.3, so
it is not too late to change their API. I would prefer to limit the
number of timestamp formats: Python 3.2 has float and datetime, I (and
Martin) propose to add Decimal to Python 3.3 (to get nanosecond
resolution). (sec, nsec) is a new format, except if Python 3.2 has
already functions expecting such tuple?

I know that the underlying C function expects a timespec structure,
but Python can try to use a higher level API, isn't it?

Decimal is more practical than a tuple because you can just write :
t2-t1 to compute a time delta. Decimal has other advantages (read the
issue for the full list ;-)).

--

___
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-30 Thread Boštjan Mejak

Boštjan Mejak  added the comment:

I know that there are a lot of non-hyphenated occurences of "floating 
point" in Python docs, so I just want to raise awareness about those 
occurences. Can you fix all occurences of "floating point" (when in a role of 
an adjective) to "floating-point" throughout Python docs?

As a matter of fact, everything that is an adjective is hyphenated if there are 
2 words that form the adjective.

Example: "This is built in." versus "This is a built-in method."

--

___
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-30 Thread Sandro Tosi

Sandro Tosi  added the comment:

On Mon, Jan 30, 2012 at 15:08, Boštjan Mejak  wrote:
> Can you fix all occurences of "floating point" (when in a role of 
> an adjective) to "floating-point" throughout Python docs?

What I was asking is if *you* (since you care about the topic) would
provide a patch fixing all that needs fixing. At that point there will
be people interesting reviewing your patch, instead of people been
told what to do.

Regards,
Sandro

--

___
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-30 Thread Arfrever Frehtes Taifersar Arahesis

Arfrever Frehtes Taifersar Arahesis  added the comment:

(secs, nsecs) tuples are more practical in performance-critical applications 
(e.g. synchronization of timestamps between 2 trees with large number of files).

--

___
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-30 Thread Stefan Krah

Stefan Krah  added the comment:

Congratulations: You (again) have found a fundamental error in TAOCP.
Example (Third Edition, page 233):

"The following definitions seem to be appropriate for base b, excess q,
floating point numbers ..."

--
nosy: +skrah

___
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-30 Thread STINNER Victor

STINNER Victor  added the comment:

> (secs, nsecs) tuples are more practical in performance-critical applications
> (e.g. synchronization of timestamps between 2 trees with large number of 
> files).

This is also why I propose an argument to choose the format: everyone
has a different use case and use cases are incompatible. Tuples are
quick to create but has not a practical API, datetime has a nice API
but also issues listed before by Martin (and don't support nanosecond
resolution currently), Decimal has a nice API but is expensive to
create, etc.

--

___
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-30 Thread R. David Murray

R. David Murray  added the comment:

There is also the fact that we have traditionally exposed thin wrappers around 
posix functions (and then were practical provided Windows emulations).  We 
aren't 100% consistent about this, but we are pretty consistent about it.

--

___
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-30 Thread Boštjan Mejak

Boštjan Mejak  added the comment:

For the time being I don't find any other "floating point" occurences in Python 
docs. I found one and made a patch for it. Please apply the patch.  Thanks.

--

___
Python tracker 

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



[issue10580] Installer sentence in bold

2012-01-30 Thread Boštjan Mejak

Boštjan Mejak  added the comment:

Please apply this patch.

--

___
Python tracker 

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



[issue10580] Installer sentence in bold

2012-01-30 Thread Brian Curtin

Changes by Brian Curtin :


--
nosy:  -brian.curtin

___
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-30 Thread Éric Araujo

Éric Araujo  added the comment:

Thanks for the analysis Ned.  Can you apply your patch to distutils and 
packaging?  Also, what do you think about adding a buildbot configured with 
--enable-shared?

--
components: +Distutils2
nosy: +alexis

___
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-30 Thread Éric Araujo

Éric Araujo  added the comment:

> I think this support should be backported to Python 2.7 and 3.2.
I think our policy is pretty clear: the module docs did not say multiple 
streams were supported, so when support for them was added it was clearly a new 
feature.

> Current code can't decompress files generated by "pbzip2", fairly popular.
That is unfortunate, but I don’t think that the features of one tool, even 
popular, should make us break the policy.  That’s why I concur with Nadeem and 
think that a PyPI backport is the only way to provide multi-streams bz2 to 
previous versions.

Best regards

--

___
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-30 Thread Ronald Oussoren

Ronald Oussoren  added the comment:

I'd prefer a buildbot with --enable-framework and --enable-universalsdk (that 
is, one closer to the options used to build the installer for OSX).

--

___
Python tracker 

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



[issue10910] pyport.h FreeBSD/Mac OS X "fix" causes errors in C++ compilation

2012-01-30 Thread Ronald Oussoren

Ronald Oussoren  added the comment:

The only real fix I found is to introduce "Py_" prefixed versions of all 
definitions in ctypes.h that are used in Python (that is Py_isalnum) and use 
that throughout the python source tree.

That's a pretty invasive patch though and would probably be off-limit for 2.7 
and 3.2.

--

___
Python tracker 

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



[issue13609] Add "os.get_terminal_size()" function

2012-01-30 Thread Zbyszek Szmek

Zbyszek Szmek  added the comment:

Here's is an updated version: termsize.diff.6

Following Antoine Pitrou's comment get_terminal_size_raw is renamed back to 
query_terminal_size.

Tests are moved to test_os.py, and there's a new test for query_terminal_size 
-- the output from 'stty size' is parsed. If something fails (e.g. stty is not 
available), the test is skipped.

I noticed that bash uses $LINES, not $ROWS. I have renamed rows to lines 
everywhere, to follow existing convention.

The big remaining question seems to be one function vs. two functions.
I'm still convinced that the high-level two function is better. This issue 
originated in the argparse module, which can use proper terminal size to 
efficiently format messages. Of course argparse must use a function with a 
fallback -- if it cannot query, some default must be used. So argparse would 
implement the high-level function anyway. It might just as well be in os, 
available for others to be used. Anyway, the second function is 18 lines of 
python code (excluding docstring and whitespace) -- a bit too much to copy and 
paste.

--
Added file: http://bugs.python.org/file24369/termsize.diff.6

___
Python tracker 

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



[issue13912] ImportError using __import__ and relative level 1

2012-01-30 Thread Jason R. Coombs

New submission from Jason R. Coombs :

The Python 2.7.2 docs say this about __import__:

Positive values for level indicate the number of parent directories to 
search relative to the directory of the module calling __import__().

But I find that even when setting level=1, the parent directory is not searched.

I've created this project tree to replicate the issue:

jaraco@devjaraco:~$ tree master
master
├── __init__.py
├── pkgA
│   ├── foo.py
│   └── __init__.py
└── pkgB
├── bar.py
└── __init.py

2 directories, 5 files
jaraco@devjaraco:~$ cat master/pkgA/foo.py

bar = __import__('pkgB', level=1).bar
jaraco@devjaraco:~$ cat master/pkgB/bar.py
var = "success"

It fails as so with python 2.7.2:

jaraco@devjaraco:~$ python2.7 -c "import master.pkgA.foo"
Traceback (most recent call last):
  File "", line 1, in 
  File "master/pkgA/foo.py", line 2, in 
bar = __import__('pkgB', level=1).bar
ImportError: No module named pkgB


It's conceivable I'm not using this correctly, but if so, I'm unable to find my 
mistake. I've confirmed that foo.__name__ is 'master.pkgA.foo'. I've tried 
using level=2 (in case I was off by one, but that wasn't the case).

--
components: Interpreter Core
messages: 152331
nosy: jason.coombs
priority: normal
severity: normal
status: open
title: ImportError using __import__ and relative level 1
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



[issue10580] Minor grammar change in Python’s MSI installer

2012-01-30 Thread Éric Araujo

Changes by Éric Araujo :


--
title: Installer sentence in bold -> Minor grammar change in Python’s MSI 
installer
versions:  -Python 3.1

___
Python tracker 

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



[issue13851] Packaging distutils2 for Fedora

2012-01-30 Thread Éric Araujo

Éric Araujo  added the comment:

Thanks for your support of distutils2, but this tracker is the wrong place for 
this bug tracker, as no RPM spec file will be added to the distutils2 repo.  If 
there are bugs in distutils2 that prevent you from making a RPM, please say so, 
otherwise I will close this report (but stay available via private email or the 
distutils-sig mailing list).

--
assignee: tarek -> eric.araujo
status: open -> pending

___
Python tracker 

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



[issue12804] "make test" fails on systems without internet access

2012-01-30 Thread Éric Araujo

Éric Araujo  added the comment:

Thanks!

--

___
Python tracker 

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



[issue13609] Add "os.get_terminal_size()" function

2012-01-30 Thread STINNER Victor

STINNER Victor  added the comment:

> I noticed that bash uses $LINES, not $ROWS. I have renamed rows to lines 
> everywhere, to follow existing convention.

The stty program has "rows" and "columns" commands to set the terminal
size. The tput programs has "cols" and "lines" commands to get the
terminal size. The curses library uses (y, x), e.g. it has a
getmaxyx() function. I don't know the most common term, lines or rows.

Extract of 
http://stackoverflow.com/questions/1780483/lines-and-columns-environmental-variables-lost-in-a-script
"The variables $LINES and $COLUMNS are shell variables, not
environmental variables, and thus are not exported to the child
process (...)"

If I understood correctly, LINES and COLUMNS environment variables are
only set by the user. In a bash script, these variables are wrapper to
ioctl().

The tput program reads TERM environment variable to decide if LINES
and COLUMNS are used or not:
"-Ttype indicates  the type of terminal.  Normally this option is
unnecessary, because the default is taken from the environment
variable TERM.  If -T is specified, then the shell variables LINES and
COLUMNS will be ignored,and the operating system will not be queried
for the actual screen size."

Extract of http://pubs.opengroup.org/onlinepubs/7908799/xbd/envvar.html :
--
COLUMNS
A decimal integer > 0 used to indicate the user's preferred width
in column positions for the terminal screen or window. (See column
position .) If this variable is unset or null, the implementation
determines the number of columns, appropriate for the terminal or
window, in an unspecified manner. When COLUMNS is set, any
terminal-width information implied by TERM will be overridden. Users
and portable applications should not set COLUMNS unless they wish to
override the system selection and produce output unrelated to the
terminal characteristics. The default value for the number of column
positions is unspecified because historical implementations use
different methods to determine values corresponding to the size of the
screen in which the utility is run. This size is typically known to
the implementation through the value of TERM or by more elaborate
methods such as extensions to the stty utility, or knowledge of how
the user is dynamically resizing windows on a bit-mapped display
terminal. Users should not need to set this variable in the
environment unless there is a specific reason to override the
implementation's default behaviour, such as to display data in an area
arbitrarily smaller than the terminal or window.

LINES
A decimal integer > 0 used to indicate the user's preferred number
of lines on a page or the vertical screen or window size in lines. A
line in this case is a vertical measure large enough to hold the
tallest character in the character set being displayed. If this
variable is unset or null, the implementation determines the number of
lines, appropriate for the terminal or window (size, terminal baud
rate, and so forth), in an unspecified manner. When LINES is set, any
terminal-height information implied by TERM will be overridden. Users
and portable applications should not set LINES unless they wish to
override the system selection and produce output unrelated to the
terminal characteristics. The default value for the number of lines is
unspecified because historical implementations use different methods
to determine values corresponding to the size of the screen in which
the utility is run. This size is typically known to the implementation
through the value of TERM or by more elaborate methods such as
extensions to the stty utility, or knowledge of how the user is
dynamically resizing windows on a bit-mapped display terminal. Users
should not need to set this variable in the environment unless there
is a specific reason to override the implementation's default
behaviour, such as to display data in an area arbitrarily smaller than
the terminal or window.
--

> The big remaining question seems to be one function vs. two functions.

Not exactly. I suggested to keep only the simple function in the os
module, and add maybe a function with a higher level API (using
environment variables) in another module (e.g. in shutil).

--

___
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-30 Thread Dave Malcolm

Dave Malcolm  added the comment:

It's useful for the selftests, so I've kept PYTHONHASHSEED.  However,
I've removed it from the man page; the only other place it's mentioned
(in Doc/using/cmdline.rst) I now explicitly say that it exists just to
serve the interpreter's own selftests.

Am attaching a revised patch, which has the above change, plus some
tweaks to Lib/test/test_hash.py (adds test coverage for the datetime
hash randomization):
  optin-hash-randomization-for-3.1-dmalcolm-2012-01-30-001.patch

Has anyone had a chance to try this patch on Windows?  Martin?  I'm
hoping that it doesn't impose a startup cost in the default
no-randomization cost, and that any startup cost in the -R case is
acceptable.

--
Added file: 
http://bugs.python.org/file24370/optin-hash-randomization-for-3.1-dmalcolm-2012-01-30-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   Mon Jan 30 12:29:09 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   Mon Jan 30 12:29:09 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 Mon Jan 30 12:29:09 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,24 @@
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`.
+
+   Its purpose is for use in selftests for the interpreter.
+
+   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  Mon Jan 30 12:29:09 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 Mon Jan 30 12:29:09 2012 -0500
@@ -19,6 +19,7 @@
 PyAPI_DATA(int) Py_DontWriteBytecodeFlag;
 PyAPI_DATA(int) Py_NoUserSiteDirectory;

[issue13912] ImportError using __import__ and relative level 1

2012-01-30 Thread Eric Snow

Eric Snow  added the comment:

what value do you see for __package__ in pkgA?

--
nosy: +eric.snow

___
Python tracker 

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



[issue13851] Packaging distutils2 for Fedora

2012-01-30 Thread Vikash Agrawal

Vikash Agrawal  added the comment:

hi merwok, 
I didn't know this is the right place for that bug/query. I am still in the 
process of learning packaging, and at this moment I wont be able to tell that 
if its a problem of distutils2 or not, though I do feel that pysetup should 
have installed directly, considering my spec file is correct.

So as o now, the bug is closed, and later I will come with concrete results.

I will be available via private email and I will discuss this issue with 
dmalcolm over IRC

--
status: pending -> 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-30 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset 54d7823ec488 by Brett Cannon in branch 'default':
Issue #13890: Fix importlib case-sensitivity tests to not run on Windows.
http://hg.python.org/cpython/rev/54d7823ec488

--
nosy: +python-dev

___
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-30 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset 2914ce82bf89 by Brett Cannon in branch 'default':
Issue #13890: Also fix for extension module tests for case-insensitivity.
http://hg.python.org/cpython/rev/2914ce82bf89

--

___
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-30 Thread Brett Cannon

Changes by Brett Cannon :


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



[issue10910] pyport.h FreeBSD/Mac OS X "fix" causes errors in C++ compilation

2012-01-30 Thread Bert JW Regeer

Bert JW Regeer  added the comment:

In my first comment on this bug post I posted what project has issues with 
this, Botan with Boost.Python on FreeBSD and Mac OS X.

If required I will post how to reproduce this error using that project. If you 
would prefer a simplified test case, unfortunately I don't have the time to dig 
into that and find one.

One way to solve it is by including the Python header before any other file, 
however this is not an option for most 3rd party software that never sees this 
bug because those functions are not redefined for Linux...

--

___
Python tracker 

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



[issue13912] ImportError using __import__ and relative level 1

2012-01-30 Thread Brett Cannon

Brett Cannon  added the comment:

You have a typo in a filename: it should be pkgB/__init__.py (not the missing 
trailing underscores).

--
nosy: +brett.cannon
resolution:  -> invalid
status: open -> closed

___
Python tracker 

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



[issue13912] ImportError using __import__ and relative level 1

2012-01-30 Thread Jason R. Coombs

Jason R. Coombs  added the comment:

Sorry for the mistake.

I corrected the pkgB package, but the result is the same:

jaraco@devjaraco:~$ tree master
master
├── __init__.py
├── __init__.pyc
├── pkgA
│   ├── foo.py
│   ├── foo.pyc
│   ├── __init__.py
│   └── __init__.pyc
└── pkgB
├── bar.py
└── __init__.py

2 directories, 8 files
jaraco@devjaraco:~$ python2.7 -c 'import master.pkgA; 
print("pkgA.__package__ is {}".format(master.pkgA.__package__)); import 
master.pkgA.foo'
pkgA.__package__ is None
Traceback (most recent call last):
  File "", line 1, in 
  File "master/pkgA/foo.py", line 2, in 
bar = __import__('pkgB', level=1).bar
ImportError: No module named pkgB

As you can see, __package__ for pkgA is None. Same is true for 
master.__package__.

--
resolution: invalid -> 
status: closed -> open

___
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-30 Thread Justin Wehnes

Justin Wehnes  added the comment:

Just wondering if someone is already working on this or am I free to supply a 
patch?

--
nosy: +jwehnes

___
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-30 Thread Jim Jewett

Jim Jewett  added the comment:

On Mon, Jan 30, 2012 at 12:31 PM,  Dave Malcolm 
added the comment:

> It's useful for the selftests, so I've kept PYTHONHASHSEED.

The reason to read PYTHONHASHSEED was so that multiple members of a
cluster could use the same hash.

It would have been nice to have fewer environment variables, but I'll
grant that it is hard to say "use something random that we have *not*
precomputed" without either a config file or a magic value for
PYTHONHASHSEED.

-jJ

--

___
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-30 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

This would likely require a PEP before having a chance of being considered for 
inclusion.

--
nosy: +rhettinger

___
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-30 Thread Nick Coghlan

Nick Coghlan  added the comment:

Please go ahead!

And Georg is right - the short spelling doesn't handle the first line 
correctly. It also suffers from the "trailing whitespace" problem that Amaury 
pointed out in my original version.

The tests for the new function should check both those cases (i.e. don't indent 
blank lines, ensure the first line is correctly indented).

--

___
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-30 Thread Georg Brandl

Georg Brandl  added the comment:

Wow, does that mean he can cash in a Knuth check?

--
nosy: +georg.brandl

___
Python tracker 

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



[issue8828] Atomic function to rename a file

2012-01-30 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset 80ddbd87 by Antoine Pitrou in branch 'default':
Issue #8828: Add new function os.replace(), for cross-platform renaming with 
overwriting.
http://hg.python.org/cpython/rev/80ddbd87

--
nosy: +python-dev

___
Python tracker 

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



[issue8828] Atomic function to rename a file

2012-01-30 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

os.replace() committed in 3.3!

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



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

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

Martin v. Löwis  added the comment:

> I know that the underlying C function expects a timespec structure,
> but Python can try to use a higher level API, isn't it?

I agree entirely.

--

___
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-30 Thread Mark Shannon

Mark Shannon  added the comment:

Does this really need a PEP?
There is no new language feature and no change to any API.
It is just saving some memory.

The only possible issue is changing dict repr() ordering, 
but issue 13703 will do that anyway.

--

___
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-30 Thread Dave Malcolm

Dave Malcolm  added the comment:

I slightly messed up the test_hash.py changes.

Revised patch attached:
  optin-hash-randomization-for-3.1-dmalcolm-2012-01-30-002.patch

--
Added file: 
http://bugs.python.org/file24371/optin-hash-randomization-for-3.1-dmalcolm-2012-01-30-002.patch

___
Python tracker 

___diff -r e7706bdaaa0d Doc/library/sys.rst
--- a/Doc/library/sys.rst   Fri Jan 27 09:48:47 2012 +0100
+++ b/Doc/library/sys.rst   Mon Jan 30 17:21:17 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 e7706bdaaa0d Doc/reference/datamodel.rst
--- a/Doc/reference/datamodel.rst   Fri Jan 27 09:48:47 2012 +0100
+++ b/Doc/reference/datamodel.rst   Mon Jan 30 17:21:17 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 e7706bdaaa0d Doc/using/cmdline.rst
--- a/Doc/using/cmdline.rst Fri Jan 27 09:48:47 2012 +0100
+++ b/Doc/using/cmdline.rst Mon Jan 30 17:21:17 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,24 @@
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`.
+
+   Its purpose is for use in selftests for the interpreter.
+
+   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 e7706bdaaa0d Include/object.h
--- a/Include/object.h  Fri Jan 27 09:48:47 2012 +0100
+++ b/Include/object.h  Mon Jan 30 17:21:17 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 e7706bdaaa0d Include/pydebug.h
--- a/Include/pydebug.h Fri Jan 27 09:48:47 2012 +0100
+++ b/Include/pydebug.h Mon Jan 30 17:21:17 2012 -0500
@@ -19,6 +19,7 @@
 PyAPI_DATA(int) Py_DontWriteBytecodeFlag;
 PyAPI_DATA(int) Py_NoUserSiteDirectory;
 PyAPI_DATA(int) Py_UnbufferedStdioFlag;
+PyAPI_DATA(int) Py_HashRandomizationFlag;
 
 /* this is a wrapper around getenv() that pays attention to
Py_IgnoreEnvironmentFlag.  It should be used for getting variables like
diff -r e7706bdaaa0d Include/pythonrun.h
--- a/Include/pythonrun.h   Fri Jan 27 09:48:47 2012 +0100
+++ b/Include/pythonrun.h   Mon Jan 30 17:21:17 2012 -0500
@@ -174,6 +174,8 @@
 PyAPI_FUNC(PyOS_sighandler_t) PyOS_getsig(int);
 PyAPI_FUNC(PyOS_sighandler_t) PyOS_setsig(int, PyOS_sighandler_t);
 
+/* Random */
+Py

[issue13837] test_shutil fails with symlinks enabled under Windows

2012-01-30 Thread Stefan Krah

Changes by Stefan Krah :


--
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-30 Thread STINNER Victor

STINNER Victor  added the comment:

Version 5:
 - add "datetime" and "timespec" formats: datetime.datetime object and  (sec: 
int, nsec: int)
 - add timestamp optional format to os.stat(), os.lstat(), os.fstat(), 
os.fstatat()
 - support passing the timestamp format as a keyword: 
time.time(format="decimal")

I am not really conviced by the usefulness of "timespec" format, but it was 
just an example for #11457.

The "datetime" format is surprising for time.clock() and time.wallclock(), 
these timestamps use an arbitrary start. I suppose that 
time.clock(format="datetime") and time.wallclock(format="datetime") should 
raise a ValueError.

--
Added file: http://bugs.python.org/file24372/time_decimal-5.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-30 Thread STINNER Victor

Changes by STINNER Victor :


Removed 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



[issue13912] ImportError using __import__ and relative level 1

2012-01-30 Thread Brett Cannon

Brett Cannon  added the comment:

I see your mistake now: you need to call it as __import__('pkgB', globals(), 
index=1), else __import__ has no clue how to anchor your import in the relative 
package space.

Try that and let me know if it makes it work.

And why exactly are you trying to call __import__ directly? You should be using 
importlib.import_module() for programmatic imports.

--

___
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-30 Thread STINNER Victor

STINNER Victor  added the comment:

I attached a more complete patch to the issue #13882: it adds an optional 
timestamp format to os.stat(), os.lstat(), os.fstat(), os.fstatat().

Examples:

$ ./python 
Python 3.3.0a0 (default:2914ce82bf89+, Jan 30 2012, 23:07:24) 
>>> import os
>>> s=os.stat("setup.py", timestamp="datetime")
>>> s.st_mtime - s.st_ctime
datetime.timedelta(0)
>>> print(s.st_atime - s.st_ctime)
52 days, 1:44:06.191293
>>> os.stat("setup.py", timestamp="timespec").st_ctime
(1323458640, 702327236)
>>> os.stat("setup.py", timestamp="decimal").st_ctime
Decimal('1323458640.702327236')

--

___
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-30 Thread Alexander Belopolsky

Alexander Belopolsky  added the comment:

On Sun, Jan 29, 2012 at 6:42 PM, STINNER Victor  wrote:
..
> 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)?

Yes. This was explained on python-dev not so long ago:

http://mail.python.org/pipermail/python-dev/2010-July/102100.html

The problem is not with the type of the argument (although boolean or
enum argument type is often a symptom pointing to the issue.)  The
issue is that an argument that is never given a variable value at the
call site is usually a sign of an awkward API.  For example, what
would you prefer:

math('log', x)

or

math.log(x)

?

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

With all my respect for MAL, codecs are not my favorite part of the
python library.

One possibility (still awkward IMO) would be to use the return type as
the format specifier.  This would at least require the user to import
datetime or decimal before calling time() with corresponding format.
Few users would tolerate I/O delay when they want to get time with
nanosecond precision.

--

___
Python tracker 

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



[issue13912] ImportError using __import__ and relative level 1

2012-01-30 Thread Jason R. Coombs

Jason R. Coombs  added the comment:

Thanks for the tip Brent. Still, no luck.

jaraco@devjaraco:~$ python2.7 -c 'import master.pkgA; 
print("pkgA.__package__ is {}".format(master.pkgA.__package__)); import 
master.pkgA.foo'
pkgA.__package__ is None
Traceback (most recent call last):
  File "", line 1, in 
  File "master/pkgA/foo.py", line 2, in 
bar = __import__('pkgB', globals(), level=1).bar
ImportError: No module named pkgB

I considered importlib, but it is only included for Python 2.7+ and I have to 
support Python 2.6. I'm using programmatic imports for a few  reasons:

1) I'm importing the modules for the side effects, so I don't need or want the 
name in the namespace.
2) If I import it naturally, I get pyflakes warnings that it's an used imports.
3) The order of imports is important. If I place it too early in the imports, 
it doesn't have the state it needs and fails.
4) By placing it in the top of the file with other imports, it's not obvious 
why it's being imported, so requires comments.
5) The most appropriate place to invoke this functionality is in a specific 
function, "run_app".

I see now that there is an importlib backport in the cheeseshop for earlier 
versions of Python. Given your recommendation, I'll give that a try.

--

___
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-30 Thread STINNER Victor

STINNER Victor  added the comment:

> One possibility (still awkward IMO) would be to use the return type as
> the format specifier.

Yeah, I already thaught to this idea. The API would be:
 - time.time(format=float)
 - time.time(format=decimal.Decimal)
 - time.time(format=datetime.datetime)
 - time.time(format=?) # for timespec, but I don't think that we need timespec 
in Python which is a object oriented language, we can use better than low level 
strutures
 - os.stat(path, format=decimal.Decimal)
 - etc.

I have to write a function checking that obj is decimal.Decimal or 
datetime.datetime without importing the module. I suppose that it is possible 
by checking obj type (it must be a class) and then obj.__module__.

> This would at least require the user to import
> datetime or decimal before calling time() with corresponding
> format.

Another possibility is what I proposed before in the issue #11457: take a 
callback argument.
http://bugs.python.org/issue11457#msg143738

The callback prototype would be:

def myformat(seconds, floatpart, divisor):
return ...

Each module can implements its own converter and time can provide some builtin 
converts (because I don't want to add something related to time in the decimal 
module for example).

But I don't really like this idea because it requires to decide the API of the 
low level structure of a timestamp (which may change later), and it doesn't 
really solve the issue of "import decimal" if the converter is in the time 
module.

--

___
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-30 Thread Alexander Belopolsky

Alexander Belopolsky  added the comment:

On Mon, Jan 30, 2012 at 6:15 PM, STINNER Victor  wrote:
> Another possibility is what I proposed before in the issue #11457: take a 
> callback argument.
> http://bugs.python.org/issue11457#msg143738

I think you are over-engineering a complicated solution to a simple
problem.  If you want to add functionality to time module, add a
function with a new name that would mimic appropriate POSIX API and
return a (named) tuple of integers where C function would populate a
struct.  If you write a new high resolution time module - import
decimal at the top of the module and make all your clocks return
seconds as Decimal objects.

--

___
Python tracker 

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



[issue13609] Add "os.get_terminal_size()" function

2012-01-30 Thread Zbyszek Szmek

Zbyszek Szmek  added the comment:

Updated version following comments by Victor Stinner: termsize.diff.7

- os.get_terminal_size() is moved to shutil.get_terminal_size()
- some small doc updates

Victor STINNER wrote:
>> I noticed that bash uses $LINES, not $ROWS. I have renamed rows to
>> lines everywhere, to follow existing convention.
> The stty program has "rows" and "columns" commands to set the terminal
Yes, also struct winsize uses 'rows' and 'cols'. But since we use the variable 
$LINES, it seems better to use 'lines'.

Thanks for the link to SUSv2! I've added a link in the docs, since it adds a 
nice justification to the COLUMNS/query/fallback behaviour.

Now get_terminal_size() lives in shutil. I don't think it matters much, but I 
see the point of keeping os clean.

I also looked at some programs, to see who behaves how.
dpkg -> COLUMNS first
aptitude -> ignores COLUMNS
git -> COLUMNS first
systemctl, loginctl, systemd-cgls (systemd cmdline interface) -> COLUMNS first
less, w ->  ioctl, COLUMNS as fallback

(Of course this is very unscientific, because I just picked some programs at 
random which I remembered to care about the terminal size).
I guess that the case of 'less' is special, because less is very
much dependent on the terminal and does quite a lot of manipulations on it. 
Otherwise, taking COLUMNS as highest priority seems well established, even if 
not universal.

--
Added file: http://bugs.python.org/file24373/termsize.diff.7

___
Python tracker 

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



[issue13912] ImportError using __import__ and relative level 1

2012-01-30 Thread Eric Snow

Eric Snow  added the comment:

Jason: just a warning.  importlib_backport is a relatively naive tool for 
generating the backport from the py3k source.  It's also relatively fragile and 
at this point probably doesn't work with the default branch.

--

___
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-30 Thread Martin

Martin  added the comment:

> Has anyone had a chance to try this patch on Windows?  Martin?  I'm
> hoping that it doesn't impose a startup cost in the default
> no-randomization cost, and that any startup cost in the -R case is
> acceptable.

Just tested as requested. Is the patch against 3.1 for a reason? Can't
really be compared to earlier results, but get enough weird outliers
that that may not be useful anyway. Also needed the following change:

-+chunk = Py_MIN(size, INT_MAX);
++chunk = size > INT_MAX ? INT_MAX : size;

Summary, looks like extra work in the default case is avoided and
isn't crippling otherwise, though there were a couple of very odd runs
not presented probably due to other disk access.

Vanilla:

>timeit PCbuild\python.exe -c "import sys;print(sys.version)"
3.1.4+ (default, Jan 30 2012, 22:38:52) [MSC v.1500 32 bit (Intel)]

Version Number:   Windows NT 5.1 (Build 2600)
Exit Time:10:42 pm, Monday, January 30 2012
Elapsed Time: 0:00:00.218
Process Time: 0:00:00.187
System Calls: 3974
Context Switches: 574
Page Faults:  1696
Bytes Read:   480331
Bytes Written:0
Bytes Other:  190860


Patched:

>timeit PCbuild\python.exe -c "import sys;print(sys.version)"
3.1.4+ (default, Jan 30 2012, 22:55:06) [MSC v.1500 32 bit (Intel)]

Version Number:   Windows NT 5.1 (Build 2600)
Exit Time:10:55 pm, Monday, January 30 2012
Elapsed Time: 0:00:00.218
Process Time: 0:00:00.187
System Calls: 3560
Context Switches: 441
Page Faults:  1660
Bytes Read:   461956
Bytes Written:0
Bytes Other:  24926


>timeit PCbuild\python.exe -Rc "import sys;print(sys.version)"
3.1.4+ (default, Jan 30 2012, 22:55:06) [MSC v.1500 32 bit (Intel)]

Version Number:   Windows NT 5.1 (Build 2600)
Exit Time:11:05 pm, Monday, January 30 2012
Elapsed Time: 0:00:00.249
Process Time: 0:00:00.234
System Calls: 3959
Context Switches: 483
Page Faults:  1847
Bytes Read:   892464
Bytes Written:0
Bytes Other:  27090

--

___
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-30 Thread Ezra Berch

Ezra Berch  added the comment:

I've created a patch using the conditional expression in msg151945. The one 
problem I found with it is that when the input string is terminated by a 
newline it removes that newline.

I've added an optional third argument: a function which determines which lines 
are indented. If omitted, the default behavior is to indent non-empty lines.

--
keywords: +patch
nosy: +ezberch
Added file: http://bugs.python.org/file24374/indent.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-30 Thread Dave Malcolm

Dave Malcolm  added the comment:

Am attaching a backport of 
optin-hash-randomization-for-3.1-dmalcolm-2012-01-30-002.patch to 2.6

Randomization covers the str, unicode and buffer types; equality of hashes is 
preserved for these types.

--
Added file: 
http://bugs.python.org/file24375/optin-hash-randomization-for-2.6-dmalcolm-2012-01-30-001.patch

___
Python tracker 

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



[issue13912] ImportError using __import__ and relative level 1

2012-01-30 Thread Eric Snow

Eric Snow  added the comment:

The problem is your level is off and the name is incomplete.  
master.pkgA.foo.py should have the following:

__import__('pkgB.bar', master.pkgA.__dict__, level=2).bar

or 

__import__('pkgB.bar', master.pkgA.__dict__, fromlist=['-'], level=2)

--

___
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-30 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
assignee:  -> rhettinger

___
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-30 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

Changing dictionaries is a big deal.  You're changing many pieces at once (not 
a good idea) including changing tunable parameters that are well-studied (I 
spent a month testing whether 5/8 was better idea that 2/3 for resizing or when 
the ideal small dict size was 4, 8, or 16).  You're changing the meaning of the 
fields in dictobject.h which will likely break any code that relied on those.

The ideas may be good ones but they warrant a good deal of thought.  Dicts 
weren't just slapped together -- the current code is the product to two decades 
of tweaking by engineers who devoted significant time to the task.  It would be 
easy to unknowingly undo some of their work.

--

___
Python tracker 

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



[issue13506] IDLE sys.path does not contain Current Working Directory

2012-01-30 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

I tested on 3.2, Win 7. sys.path starts with '' on startup, after restart, and 
after ^c interrupt of 'while True: pass'. It start with absolute path when 
running a file from the editor. I believe this is as should be.

I simplified the patch a bit. Its basic idea is to add a parameter with_cwd to 
PyShell.ModifiedInterpreter.transfer_path. That method is called by methods 
start_subprocess and restart_subprocess. start_process is only called by 
PyShell.PyShell.begin. So I think there is no need to propagate the new 
parameter back past the call in start_subprocess.

.restart_subprocess is called in .poll_subprocess, .runcode, 
PyShell.cancel_process, and PyShell.restart_shell. (I am a little puzzled why 
ModifiedInterpreter.runcode calls self.interp.restart_subprocess, as in the 
PyShell methods, instead of self.restart_subprocess, as in poll_subprocess, but 
moving on...)

restart_process needs the new parameter to pass to transfer_path because it 
should be True for F6 Restart Shell and not for F5 Run Module. Roger's patch 
also left the default False for the other calls. I do not know what they do so 
I cannot judge them. Roger, do you know, and did you consider each? (Leaving 
the current behavior for those will at worst not fix something that could be, 
so it is safe.)

restart_shell is *bound* to F6 Restart Shell (which passes the ignored even), 
so the default with_cwd must be True for that binding. It is *called* by a 
function ScriptBinding.py that gets bound, so the call can be altered to pass 
the correct False. I prefer that to making two functions. That call could be 
replaces by a call directly to .interp.restart_subprocess(False) (and 
restart_shell slightly simplified).

I retested after these changes to the patch. It is from TortoiseHG, so should 
apply (after I modified the file paths). Since hacking on idlelib is new for 
me, I would like other eyes and tests before I apply.

--
assignee:  -> terry.reedy
Added file: http://bugs.python.org/file24376/issue13506c.diff

___
Python tracker 

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



[issue13506] IDLE sys.path does not contain Current Working Directory

2012-01-30 Thread Terry J. Reedy

Changes by Terry J. Reedy :


Removed file: http://bugs.python.org/file24376/issue13506c.diff

___
Python tracker 

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



[issue13506] IDLE sys.path does not contain Current Working Directory

2012-01-30 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

Whoops, hit submit too soon, before saving tab to space change.

--
Added file: http://bugs.python.org/file24377/issue13506d.diff

___
Python tracker 

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



[issue13506] IDLE sys.path does not contain Current Working Directory

2012-01-30 Thread Roger Serwy

Roger Serwy  added the comment:

I tested your patch and it works. For the sake of completeness, here's what I 
did:

Test 1: Start IDLE in shell mode and run "import sys; print(sys.path)". The 
first entry should be ''

This is consistent with the behavior of the regular python shell.

Test 2: Restart the shell with Ctrl+F6 (and View->Restart Shell) and repeat 
Test 1. This should give the same result.

Test 3: Create a script in /tmp/a.py with "import sys; print(sys.path)" as its 
contents. Running this script from the editor gives '/tmp' as the first entry.

This is consistent with the behavior of running "python3 /tmp/a.py".

I'd make one minor change to the patch for sake of being explicit in 
ScriptBinding.py:
shell.restart_shell(event, with_cwd=False)

My rationale was to modify only PyShell.py to get the correct behavior. 
Clearly, making a simple modification to ScriptBinding.py gives a much shorter 
solution. I also like your simplification for "start_subprocess". 

I did consider each case of default arguments. I developed my patch iteratively 
starting by having "with_cwd=False" for all function calls that called 
"transfer_path" so that the existing (incorrect) behavior remained. I then 
modified how these functions were called, setting "with_cwd=True" in the cases 
where '' needed to be transferred, namely on the shell start and restart from 
within the PyShell window. That is why I introduced 
"restart_shell_interactive". I do agree with your reasoning that one function 
call is better than two.

--

___
Python tracker 

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



[issue13701] Remove Decimal Python 2.3 Compatibility

2012-01-30 Thread Ramchandra Apte

Ramchandra Apte  added the comment:

There is another problem with the code it creates a dummy module when threading 
is not available but now threading imports dummy_threading when threading is 
not available.

Thanks

--

___
Python tracker 

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



[issue13506] IDLE sys.path does not contain Current Working Directory

2012-01-30 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset 1b5abba0c808 by Terry Jan Reedy in branch '2.7':
#13506 Add '' to path for interactive interpreter by adding with_cwd parameter
http://hg.python.org/cpython/rev/1b5abba0c808

New changeset 1993aa091d89 by Terry Jan Reedy in branch '3.2':
#13506 Add '' to path for interactive interpreter by adding with_cwd parameter
http://hg.python.org/cpython/rev/1993aa091d89

New changeset acedd92086c5 by Terry Jan Reedy in branch 'default':
Merge 3.2
http://hg.python.org/cpython/rev/acedd92086c5

--
nosy: +python-dev

___
Python tracker 

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