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

2012-01-31 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

I noticed that the script in ScriptBinding.py already dereferences interp and 
calls 3 interp functions directly, so I decided that calling a 4th on interp 
was fine. That lets restart_shell be specialized to the one purpose of being 
bound to Restart Shell on the menu. I added a docstring to that effect so no 
will will try to generalize it again to use when running a module.

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



[issue13903] New shared-keys dictionary implementation

2012-01-31 Thread Mark Shannon

Mark Shannon  added the comment:

Raymond Hettinger wrote:
> 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.
> 

OK.
I'll write a PEP.

By the way, I'm trying not changing the tunable parameters for the 
unshared-keys case, just the shared-keys case. Of course, they do 
interact with each other.

--

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

Nick Coghlan  added the comment:

It sounds like you may want runpy.run_module [1], rather than using imports at 
all. If you know how many levels up you want to go, it isn't hard to do your 
own munging of __name__ to create absolute module references to pass to runpy.

The signature of __import__ is known to be unintuitive to the point of being 
insane - it's really designed for the convenience of the compiler and the 
interpreter, not for direct use by humans.

[1] http://docs.python.org/release/2.6.7/library/runpy#runpy.run_module

--
nosy: +ncoghlan

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

STINNER Victor  added the comment:

Patch version 6:

 - timestamp format is now a type instead of a string, e.g. time.time(int)
 - add int and datetime.timedelta formats, remove timespec format
 - complete the documentation
 - fix integer overflows, convert correctly time_t to PyLong

There are now 5 timestamp formats:

 - int
 - float
 - decimal.Decimal
 - datetime.datetime
 - datetime.timedelta

I consider the patch as ready to be commited, or at least ready for a
review ;-) There is no more FIXME or known limitation. Well, now the
most important part is to decide the API and the list of timestamp
formats.

The patch should be tested on Linux, FreeBSD and Windows, 32 and 64
bits to check assertions on type sizes:

assert(sizeof(clock_t) <= sizeof(size_t));
assert(sizeof(LONGLONG) <= sizeof(size_t));
assert(sizeof(time_t) <= sizeof(PY_LONG_LONG));

--
Added file: http://bugs.python.org/file24378/time_decimal-6.patch

___
Python tracker 

___diff --git a/Doc/library/os.rst b/Doc/library/os.rst
--- a/Doc/library/os.rst
+++ b/Doc/library/os.rst
@@ -808,13 +808,16 @@ as internal buffering of data.
Availability: Unix.
 
 
-.. function:: fstat(fd)
+.. function:: fstat(fd, timestamp=None)
 
Return status for file descriptor *fd*, like :func:`~os.stat`.
 
Availability: Unix, Windows.
 
-.. function:: fstatat(dirfd, path, flags=0)
+   .. versionchanged:: 3.3
+  Added the *timestamp* argument.
+
+.. function:: fstatat(dirfd, path, flags=0, timestamp="float")
 
Like :func:`stat` but if *path* is relative, it is taken as relative to 
*dirfd*.
*flags* is optional and may be 0 or :data:`AT_SYMLINK_NOFOLLOW`.
@@ -1696,7 +1699,7 @@ Files and Directories
.. versionadded:: 3.3
 
 
-.. function:: lstat(path)
+.. function:: lstat(path, timestamp=None)
 
Perform the equivalent of an :c:func:`lstat` system call on the given path.
Similar to :func:`~os.stat`, but does not follow symbolic links.  On
@@ -1706,6 +1709,9 @@ Files and Directories
.. versionchanged:: 3.2
   Added support for Windows 6.0 (Vista) symbolic links.
 
+   .. versionchanged:: 3.3
+  The *timestamp* argument was added.
+
 
 .. function:: lutimes(path[, times])
 
@@ -1955,7 +1961,7 @@ Files and Directories
.. versionadded:: 3.3
 
 
-.. function:: stat(path)
+.. function:: stat(path, timestamp=None)
 
Perform the equivalent of a :c:func:`stat` system call on the given path.
(This function follows symlinks; to stat a symlink use :func:`lstat`.)
@@ -1975,6 +1981,11 @@ Files and Directories
* :attr:`st_ctime` - platform dependent; time of most recent metadata 
change on
  Unix, or the time of creation on Windows)
 
+   :attr:`st_atime`, :attr:`st_mtime` and :attr:`st_ctime` values type is
+   :class:`float` by default, or :class:`int` if :func:`os.stat_float_times` is
+   ``False``. Set the optional *timestamp* argument to get another
+   :ref:`timestamp format `.
+
On some Unix systems (such as Linux), the following attributes may also be
available:
 
@@ -2030,6 +2041,9 @@ Files and Directories
 
Availability: Unix, Windows.
 
+   .. versionchanged:: 3.3
+  Added the *timestamp* argument.
+
 
 .. function:: stat_float_times([newvalue])
 
@@ -2055,6 +2069,9 @@ Files and Directories
are processed, this application should turn the feature off until the 
library
has been corrected.
 
+   .. deprecated:: 3.3
+  Use *timestamp* argument of stat functions instead.
+
 
 .. function:: statvfs(path)
 
diff --git a/Doc/library/time.rst b/Doc/library/time.rst
--- a/Doc/library/time.rst
+++ b/Doc/library/time.rst
@@ -95,6 +95,16 @@ An explanation of some terminology and c
   | local time  | |
 |
   
+-+-+-+
 
+.. _timestamp-formats:
+
+* Python supports the following timestamp formats:
+
+  * :class:`int`
+  * :class:`float`
+  * :class:`datetime.datetime`
+  * :class:`datetime.timedelta`
+  * :class:`decimal.Decimal`
+
 
 The module defines the following functions and data items:
 
@@ -118,7 +128,7 @@ The module defines the following functio
   Unlike the C function of the same name, there is no trailing newline.
 
 
-.. function:: clock()
+.. function:: clock(format=float)
 
.. index::
   single: CPU time
@@ -135,16 +145,27 @@ The module defines the following functio
:c:func:`QueryPerformanceCounter`. The resolution is typically better than 
one
microsecond.
 
+   Return the time as a floating point number by default, set the optional
+   *format* argument to get another :ref:`timestamp format 
`.
 
-.. function:: clock_getres(clk_id)
+   .. versionchanged:: 3.3
+  Added the *format* argument.
+
+
+.. function:: clock_getres(clk_id, format=float)
 
Return the resolution (precision) of the specified clock *c

[issue13734] Add a generic directory walker method to avoid symlink attacks

2012-01-31 Thread Nick Coghlan

Nick Coghlan  added the comment:

Hmm, given the various *at() APIs that sort alphabetically next to their path 
based counterparts, perhaps we can make the naming consistency change go the 
other way? (i.e. listdirfd() and walkfd()). Even if POSIX puts the fd at the 
front, do we really have to follow them in a silly naming scheme?

And as per the python-dev discussion, +1 for being consistent with os.walk() 
when it comes to symlinks to directories.

Aside from the naming question, is there anything else holding this up?

--

___
Python tracker 

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



[issue13734] Add a generic directory walker method to avoid symlink attacks

2012-01-31 Thread Nick Coghlan

Nick Coghlan  added the comment:

Taking a closer look at the current naming scheme in the os module, fdopen() 
appears to be the only current function that uses the 'fd' prefix. All the 
other operations that accept a file descriptor just use 'f' as the prefix 
(fchmod, fchown, faccess, etc).

Given that, flistdir() and fwalk() seem like the most consistent choices of 
name for APIs that aren't directly matching an underlying POSIX function name.

--

___
Python tracker 

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



[issue13734] Add a generic directory walker method to avoid symlink attacks

2012-01-31 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

There's something I don't understand in the patch: why does _are_same_file 
examine st_mode?

--

___
Python tracker 

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



[issue13229] Improve tools for iterating over filesystem directories

2012-01-31 Thread Nick Coghlan

Nick Coghlan  added the comment:

With the release of 0.3, I'm pretty happy with the WalkDir design (previous 
versions coerced the output values to ordinary 3-tuples, now it will pass along 
whatever the underlying iterable produces with changing the type at all).

--

___
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-31 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

As Victor I think the tunables could be changed separately, unless they truely 
get in the way of the shared-keys optimization.

By the way, there will need a "protection" for the case where instances are 
used as bags of key/value pairs (dict-alikes with attribute access). Perhaps 
bound the size of the keys array to 100 entries and then switch into unshared 
mode.

--

___
Python tracker 

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



[issue13229] Improve tools for iterating over filesystem directories

2012-01-31 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

(speaking of which, I'd just mention I've published pathlib as a standalone 
package: http://pypi.python.org/pypi/pathlib/ )

--

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

Boštjan Mejak  added the comment:

What's the purpose of this tracker if the author of an issue report has 
to beg for something to be fixed, despite the fact that (s)he even made a patch 
?

--

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

Boštjan Mejak  added the comment:

Rather apply the patch, not change the title.

--

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

Ezio Melotti  added the comment:

The rule 1 makes sense, but it's not entirely obvious (people might consider 
bBaAzZ special too).

The "normal Python rules for backslash escapes but revert to the C behaviour of 
stripping the \ from unrecognised escapes" is not obvious either, and from 
r'[\A]' people might expect:
  1) same as \A, (beginning of the string);
  2) a letter 'A';
  3) a '\' or a letter 'A' (especially if they write it as '[\\A]');

This is why I suggested to raise an error (and refuse the temptation to guess), 
but on the other hand, if you consider 'A' a "normal" letter like 'C', having 
an error for \A would be incoherent.
It would have been better if \C raised an error too (I don't see why that would 
appear in a regex, since re.escape doesn't escape C and the user has no reason 
to add the \), but now it's too late for that.

--

___
Python tracker 

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



[issue13734] Add a generic directory walker method to avoid symlink attacks

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

Charles-François Natali  added the comment:

> Given that, flistdir() and fwalk() seem like the most consistent choices of 
> name for APIs that aren't directly
> matching an underlying POSIX function name.

Well, that seems OK for me.
I guess the only reason fdlistdir() is named that way is because of
fdopendir(3).
I can make the change for fwalk(), and since 3.3 hasn't been released
yet, I guess we can rename fdlistdir() too.

> There's something I don't understand in the patch: why does _are_same_file 
> examine st_mode?

It doesn't have to, that's actually useless.

The only thing that bothers me is that it needs O(height of directory
tree), so with really deep directory trees, we could run out of FDs.
Not sure that could be a problem in practice, but that's something to
keep in mind.

--

___
Python tracker 

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



[issue13734] Add a generic directory walker method to avoid symlink attacks

2012-01-31 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

One other thing: is it deliberate to silence errors in the following snippet?

+try:
+names = fdlistdir(topfd)
+except error as err:
+if onerror is not None:
+onerror(err)
+return

--

___
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-31 Thread Jesús Cea Avión

Changes by Jesús Cea Avión :


--
nosy: +jcea

___
Python tracker 

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



[issue13734] Add a generic directory walker method to avoid symlink attacks

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

Charles-François Natali  added the comment:

It's to mimic os.walk()'s behavior:

http://hg.python.org/cpython/file/bf31815548c9/Lib/os.py#l268

--

___
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-31 Thread anatoly techtonik

anatoly techtonik  added the comment:

Terminal stuff is irrelevant to `shutil`, which is the module for 'High-level 
file operations' and deserve a separate module named 'console'.

Why? Because terminal size is only relevant when you want to page output. The 
next step would be to detect if terminal supports color to see if ANSI 
sequences will be collapsed. Then you'll want to get user input without 
pressing '' key.

It is a whole new module.

--
nosy: +techtonik

___
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-31 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

"except Exception" clauses in the tests are too broad. Otherwise, looks fine.

--

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

STINNER Victor  added the comment:

termsize.diff.7:
 - shutil.get_terminal_size(): I would prefer columns and lines
variable names instead of "ccc" and "rrr"
 - "Right now the values are not cached, but this might change." why
would it be cached? this sentence can just be removed
 - I would prefer os.get_terminal_size() instead of
os.query_terminal_size(), I didn't know other function using the verb
"query" in Python
 - To keep os simple, os.query_terminal_size() can return a simple,
whereas shutil.get_terminal_size() returns a namedtuple
 - test_os.py: use @unittest.skipUnless() on TermsizeTests to check if
os.query_terminal_size() is available
 - test.py, test_does_not_crash() catchs OSError, you may only ignore
some error codes, not any. For example, skip the test if stdout is not
a tty

+try:
+size = os.query_terminal_size(sys.__stdout__.fileno())
+except (NameError, OSError):
+size = os.terminal_size(fallback)

AttributeError should be catched here, not NameError. Or better, check
if os has a query_terminal_size() function.

+.. function:: get_terminal_size(fallback=(columns, lines))

Hum, you may document the default value: (80, 24).

shutil.get_terminal_size() doesn't allow to choose the file
descriptor. Would it be useful to allow to get the size of sys.stderr
or another TTY?

--

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

Brett Cannon  added the comment:

On Mon, Jan 30, 2012 at 18:33, Eric Snow  wrote:

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

I think Jason was thinking of http://pypi.python.org/pypi/importlib/ which
is my personal backport of importlib from Python 2.7 all the way back to
Python 2.3.

--

___
Python tracker 

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



[issue13496] bisect module: Overflow at index computation

2012-01-31 Thread Jesús Cea Avión

Jesús Cea Avión  added the comment:

I think the patch is *NOT* correct. Does it work with 
http://bugs.python.org/msg148567, in a 32 bits python?

--

___
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-31 Thread Jesús Cea Avión

Jesús Cea Avión  added the comment:

Éric, bz2 module in Python is documented as able to manage bz2 files. But that 
is not true, since it is unable to manage popular bz2 files. That looks like a 
bug to me. In fact, you can create those files from python, files that python 
can not unpack later.

Moreover, Python 2.7 is going to live for a long time.

If the refusal of backporting this to 3.2 and 2.7 is firm, I would beg to 
document this limitation in the 2.7/3.2 docs. It is serious enough.

Please, reconsider backporting this to 2.7, at least.

--

___
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-31 Thread Zbyszek Szmek

Zbyszek Szmek  added the comment:

Well, right now it's just one function. Functionality which you propose
could of course be useful, but let's leave if for another day, another 
issue.

See also http://bugs.python.org/issue13609#msg149627 and #444582 and 
#12442 -- shutil is growing in different directions, and terminal size 
can be one of them.

 > Antoine Pitrou added the comment:
 > "except Exception" clauses in the tests are too broad.
Fixed.
 > Otherwise, looks fine.

 > STINNER Victor added the comment:
 > - shutil.get_terminal_size(): I would prefer columns and lines
 > variable names instead of "ccc" and "rrr"
Changed (this was a leftover from the version when there was no named 
tuple).

 > - I would prefer os.get_terminal_size() instead of
 > os.query_terminal_size(), I didn't know other function using the verb
 > "query" in Python
Changed. I used os.g_t_s and shutil.g_t_s in docs so it should be clear 
which is which.

 > - To keep os simple, os.query_terminal_size() can return a simple,
 > whereas shutil.get_terminal_size() returns a namedtuple
We would have two very similar functions returning something different. 
Also, the amount of code saved will be negligible, because the named 
tuple is mostly docs. I prefer to keep it in os to keep both functions 
similar.

 > - test_os.py: use @unittest.skipUnless() on TermsizeTests to check if
 > os.query_terminal_size() is available
> - To keep os simple, os.query_terminal_size() can return a simple,
> whereas shutil.get_terminal_size() returns a namedtuple
> AttributeError should be catched here, not NameError. Or better, check
> if os has a query_terminal_size() function.
Fixed. I changed the tests a bit, e.g. to take into account that stty 
queries stdin, not stdout.

 > Hum, you may document the default value: (80, 24).
Done.

shutil.get_terminal_size() is tied to COLUMNS and ROWS and thus makes 
most sense for stdout. But I guess that an optional parameter could be 
added:
   shutil.get_terminal_size(fd=None, fallback=(80, 24))
where fd could be either an integer, or an object with .fileno().
I don't know.

 > - "Right now the values are not cached, but this might change." why
 > would it be cached? this sentence can just be removed
Done. In theory it could be cached with watching for SIGWINCH, but I'll 
just remove the comment for now.

Thanks for the review and comments!

Patch version nine attached: termsize.diff.8

--
Added file: http://bugs.python.org/file24379/termsize.diff.8

___
Python tracker 

___diff --git a/Doc/library/os.rst b/Doc/library/os.rst
--- a/Doc/library/os.rst
+++ b/Doc/library/os.rst
@@ -1408,6 +1408,44 @@
.. versionadded:: 3.3
 
 
+.. _terminal-size:
+
+Querying the size of the output terminal
+
+
+.. versionadded:: 3.3
+
+.. function:: get_terminal_size(fd=STDOUT_FILENO)
+
+   Return the size of the terminal window as ``(columns, lines)``,
+   tuple of type :class:`terminal_size`.
+
+   The optional argument ``fd`` (default ``STDOUT_FILENO``, or standard
+   output) specifies which file descriptor should be queried.
+
+   If the file descriptor is not connected to a terminal, an :exc:`OSError`
+   is thrown.
+
+   This function is only present if an implementation is available for
+   this system (currently POSIX and Windows).
+
+   :func:`shutil.get_terminal_size` is the high-level function which
+   should normally be used, ``os.get_terminal_size`` is the low-level
+   implementation.
+
+.. class:: terminal_size(tuple)
+
+   A tuple of ``(columns, lines)`` for holding terminal window size.
+
+   .. attribute:: columns
+
+  Width of the terminal window in characters.
+
+   .. attribute:: lines
+
+  Height of the terminal window in characters.
+
+
 .. _os-file-dir:
 
 Files and Directories
diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst
--- a/Doc/library/shutil.rst
+++ b/Doc/library/shutil.rst
@@ -450,3 +450,33 @@
 -rw-r--r-- tarek/staff   37192 2010-02-06 18:23:10 ./known_hosts
 
 
+Querying the size of the output terminal
+
+
+.. versionadded:: 3.3
+
+.. function:: get_terminal_size(fallback=(columns, lines))
+
+   Get the size of the terminal window.
+
+   For each of the two dimensions, the environment variable, ``COLUMNS``
+   and ``LINES`` respectively, is checked. If the variable is defined and
+   the value is a positive integer, it is used.
+
+   When ``COLUMNS`` or ``LINES`` is not defined, which is the common case,
+   the terminal connected to :data:`sys.__stdout__` is queried
+   by invoking :func:`os.get_terminal_size`.
+
+   If the terminal size cannot be successfully queried, either because
+   the system doesn't support querying, or because we are not
+   connected to a terminal, the value given in ``fallback`` parameter
+   is used. ``fallback`` defaults to ``(80, 24)`` which is t

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

2012-01-31 Thread Jesús Cea Avión

Changes by Jesús Cea Avión :


--
nosy: +jcea

___
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-31 Thread Jesús Cea Avión

Changes by Jesús Cea Avión :


--
nosy: +jcea

___
Python tracker 

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



[issue7856] cannot decode from or encode to big5 \xf9\xd8

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

Changes by Kang-Hao (Kenny) Lu :


--
nosy: +kennyluck

___
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-31 Thread anatoly techtonik

anatoly techtonik  added the comment:

What happens with COLUMNS env variables if terminal is resized after the Python 
script is executed. Will get_terminal_size() return new value?

--

___
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-31 Thread Zbyszek Szmek

Zbyszek Szmek  added the comment:

> the Python script is executed. Will get_terminal_size()
 > return new value?
Please see previous discussion and the docs (and the SUSv2 specs).
The env. var. is for overriding.

--

___
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-31 Thread anatoly techtonik

anatoly techtonik  added the comment:

On Tue, Jan 31, 2012 at 7:48 PM, Zbyszek Szmek wrote:

>
> Zbyszek Szmek  added the comment:
>
> > the Python script is executed. Will get_terminal_size()
>  > return new value?
> Please see previous discussion and the docs (and the SUSv2 specs).
> The env. var. is for overriding.
>

Could you just answer the question or provide a relevant link
(unfortunately I don't have time to read SUSv2 specs)?

--

___
Python tracker 

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



[issue13913] utf-8 or utf8 or utf-8 (codec display name inconsistency)

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

New submission from Kang-Hao (Kenny) Lu :

Since Python 3.2.2 (I don't have earlier version to test with),

>>> "\udc80".encode("utf-8")
UnicodeEncodeError: *utf-8* codec can't encode character '\udc80'...

but

>>> b"\xff".decode("utf-8")
UnicodeDecodeError: *utf8* codec can't decode byte 0xff in position 0

and the table on the documentation of the codec module suggests *utf_8* as the 
name of the codec, which I believe to be equivalent to "utf_8" because '-' is 
not a valid character of an identifier.

Can we at least make the above two consistent? I would go for "utf-8", which 
was probably introduced for rejecting surrogates, but "utf8" has been there for 
years. What do we do? I am happy to submit patches for all branches. These are 
one-liners anyway.

The backward compatibility risk should be pretty low as usually you don't get 
encoding from these errors and I don't see any use of 
PyUnicode(Encode|Decode)Error_GetEncoding in trunk, although I'm using it for 
issue #12892. 

Also, "latin_1" displays as *latin-1* but "iso2022-jp" displays as 
*iso2022_jp*. I care less about this nit though.

--
components: Unicode
messages: 152399
nosy: ezio.melotti, kennyluck
priority: normal
severity: normal
status: open
title: utf-8 or utf8 or utf-8 (codec display name inconsistency)
versions: Python 2.7, Python 3.2, Python 3.3

___
Python tracker 

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



[issue13913] utf-8 or utf8 or utf-8 (codec display name inconsistency)

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

Changes by Kang-Hao (Kenny) Lu :


--
type:  -> behavior

___
Python tracker 

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



[issue13817] deadlock in subprocess while running several threads using Popen

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

Changes by Charles-François Natali :


--
stage: patch review -> commit review

___
Python tracker 

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



[issue13496] bisect module: Overflow at index computation

2012-01-31 Thread Mark Dickinson

Mark Dickinson  added the comment:

> I think the patch is *NOT* correct.

Can you elaborate?  It works fine for that example on a 64-bit build;  not sure 
why 32-bit would be any different.

The idea is just that the single cast forces the addition to be done as an 
addition of integers of type size_t.  Since the integers being added are (a) 
nonnegative and (b) both fit into a Py_ssize_t, the sum fits into a size_t 
without overflow, and the result of dividing the sum by 2 fits into a size_t.

(This is all assuming that 2*Py_SSIZE_T_MAX fits into a size_t, but that's a 
fairly safe assumption in practice.)

--

___
Python tracker 

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



[issue13496] bisect module: Overflow at index computation

2012-01-31 Thread Mark Dickinson

Mark Dickinson  added the comment:

> Does it work with http://bugs.python.org/msg148567, in a 32 bits python?

Yes.

--

___
Python tracker 

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



[issue13496] bisect module: Overflow at index computation

2012-01-31 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Perhaps adding a comment before those two lines would make the reason for the 
cast clearer.

--

___
Python tracker 

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



[issue13402] Document absoluteness of sys.executable

2012-01-31 Thread Petri Lehtinen

Petri Lehtinen  added the comment:

Attached one more patch. The documentation now also mentions None as a possible 
value.

--
Added file: http://bugs.python.org/file24380/issue13402_v3.patch

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

Changes by Stefan Krah :


Added file: http://bugs.python.org/file24381/a5c4a96dc981.diff

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

Stefan Krah  added the comment:

I've uploaded a new patch that should address the remaining issues:

   o In the documentation _testbuffer has been replaced by
 m.cast() + the now multi-dimensional m.tolist().

   o I restored the state of the limited API. If we want
 to include Py_buffer again, I think this should be done
 in a separate patch.

   o Flags of the memoryview object are private.


Additionally, because NumPy allows non-aligned array accesses,
I changed the packing functions to use memcpy for multi-byte types.

On x86/amd64 gcc is smart enough to produce almost exactly the same
asm output as before, with a slowdown of 0-1%, depending on the
benchmark.

On other platforms the situation might be worse, but I don't have
access to real hardware where alignment actually matters.

--

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

Boštjan Mejak  added the comment:

Apply this patch. It is not necessary to change the title of this issue report, 
it is of most importance that this patch gets applied already after more than a 
year. Come on people, move your butts on this.

--

___
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-31 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc  added the comment:

Retro, this kind of tone is not appropriate for the bug tracker, and not 
appreciated at all by core developers.

--
nosy: +amaury.forgeotdarc

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

Stefan Krah  added the comment:

Georg Brandl  wrote:
> Wow, does that mean he can cash in a Knuth check?

Two already: One for the insight that "i-th" is the only true spelling,
and now this one.

--

___
Python tracker 

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



[issue13734] Add a generic directory walker method to avoid symlink attacks

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

Charles-François Natali  added the comment:

Here are two new versions, both addressing Antoine's and Nick's comments:
- fwalk-3.diff is just an updated version
- fwalk-single_fd.diff doesn't use more than 2 FDs to walk a directory
tree, instead of the depth of directory tree. It's not as simple and
clean as I'd like it to be, but it should be much more robust, and
still safe (please make sure about that :-).
I was a little worried about the performance impact, so I did some
trivial benchmarks:
- O(depth) fwalk() is actually a tiny bit faster than walk() (it may
be because we don't do as much path lookup)
- O(1) fwalk() is around 20% slower, on a pure-traversal benchmark (so
in a realistic use case where we would actually do something with the
values returned by fwalk() the difference shouldn't be that
noticeable)

--
Added file: http://bugs.python.org/file24382/fwalk-3.diff
Added file: http://bugs.python.org/file24383/fwalk-single_fd.diff

___
Python tracker 

___diff --git a/Doc/library/os.rst b/Doc/library/os.rst
--- a/Doc/library/os.rst
+++ b/Doc/library/os.rst
@@ -2251,6 +2251,56 @@
   os.rmdir(os.path.join(root, name))
 
 
+.. function:: fwalk(top, topdown=True, onerror=None, followlinks=False)
+
+   .. index::
+  single: directory; walking
+  single: directory; traversal
+
+This behaves exactly like :func:`walk`, except that it yields a 4-tuple
+``(dirpath, dirnames, filenames, dirfd)``.
+
+   *dirpath*, *dirnames* and *filenames* are identical to :func:`walk` output,
+   and *dirfd* is a file descriptor referring to the directory *dirpath*.
+
+   .. note::
+
+  Since :func:`fwalk` yields file descriptors, those are only valid until
+  the next iteration step, so you should duplicate them (e.g. with
+  :func:`dup`) if you want to keep them longer.
+
+   This example displays the number of bytes taken by non-directory files in 
each
+   directory under the starting directory, except that it doesn't look under 
any
+   CVS subdirectory::
+
+  import os
+  for root, dirs, files, rootfd in os.fwalk('python/Lib/email'):
+  print(root, "consumes", end="")
+  print(sum([os.fstatat(rootfd, name).st_size for name in files]),
+end="")
+  print("bytes in", len(files), "non-directory files")
+  if 'CVS' in dirs:
+  dirs.remove('CVS')  # don't visit CVS directories
+
+   In the next example, walking the tree bottom-up is essential:
+   :func:`unlinkat` doesn't allow deleting a directory before the directory is
+   empty::
+
+  # Delete everything reachable from the directory named in "top",
+  # assuming there are no symbolic links.
+  # CAUTION:  This is dangerous!  For example, if top == '/', it
+  # could delete all your disk files.
+  import os
+  for root, dirs, files, rootfd in os.fwalk(top, topdown=False):
+  for name in files:
+  os.unlinkat(rootfd, name)
+  for name in dirs:
+  os.unlinkat(rootfd, name, os.AT_REMOVEDIR)
+
+   Availability: Unix.
+
+   .. versionadded:: 3.3
+
 .. _os-process:
 
 Process Management
diff --git a/Doc/whatsnew/3.3.rst b/Doc/whatsnew/3.3.rst
--- a/Doc/whatsnew/3.3.rst
+++ b/Doc/whatsnew/3.3.rst
@@ -497,6 +497,10 @@
 
   (Patch submitted by Giampaolo Rodolà in :issue:`10784`.)
 
+* The :mod:`os` module has a new :func:`~os.fwalk` function similar to
+  :func:`~os.walk` except that it also yields file descriptors referring to the
+  directories visited. This is especially useful to avoid symlink races.
+
 * "at" functions (:issue:`4761`):
 
   * :func:`~os.faccessat`
diff --git a/Lib/os.py b/Lib/os.py
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -24,6 +24,7 @@
 #'
 
 import sys, errno
+import stat as st
 
 _names = sys.builtin_module_names
 
@@ -32,6 +33,9 @@
"defpath", "name", "path", "devnull",
"SEEK_SET", "SEEK_CUR", "SEEK_END"]
 
+def _exists(name):
+return name in globals()
+
 def _get_exports_list(module):
 try:
 return list(module.__all__)
@@ -120,7 +124,12 @@
 umask(mask)
 return mode & ~mask
 
-#'
+def _are_same_file(stat1, stat2):
+"""Helper function that checks whether two stat results refer to the same
+file.
+"""
+return (stat1.st_ino == stat2.st_ino and stat1.st_dev == stat2.st_dev)
+#
 
 # Super directory utilities.
 # (Inspired by Eric Raymond; the doc strings are mostly his)
@@ -151,7 +160,6 @@
 try:
 mkdir(name, mode)
 except OSError as e:
-import stat as st
 if not (e.errno == errno.EEXIST and exist_ok and path.isdir(name) and
 st.S_IMODE(lstat(name).st_mode) == _get_masked_mode(mode)):
 raise
@@ -298,6 +306,94 @@
 
 __all__.append("walk")
 
+if _exists("openat"):
+
+def fwalk(top, topdown=True, onerror=None, followlinks=False):
+"""Directory tree gene

[issue13914] In module re the repeat interval {} doesn't accept numbers greater than 65535

2012-01-31 Thread py.user

New submission from py.user :

>>> import re
>>> len(re.search(r'a+', 'a' * 10).group())
10
>>>
>>> re.search(r'a{65536,}', 'a' * 10)
Traceback (most recent call last):
  File "/usr/local/lib/python3.2/functools.py", line 176, in wrapper
result = cache[key]
KeyError: (, 'a{65536,}', 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python3.2/re.py", line 158, in search
return _compile(pattern, flags).search(string)
  File "/usr/local/lib/python3.2/re.py", line 255, in _compile
return _compile_typed(type(pattern), pattern, flags)
  File "/usr/local/lib/python3.2/functools.py", line 180, in wrapper
result = user_function(*args, **kwds)
  File "/usr/local/lib/python3.2/re.py", line 267, in _compile_typed
return sre_compile.compile(pattern, flags)
  File "/usr/local/lib/python3.2/sre_compile.py", line 491, in compile
p = sre_parse.parse(p, flags)
  File "/usr/local/lib/python3.2/sre_parse.py", line 692, in parse
p = _parse_sub(source, pattern, 0)
  File "/usr/local/lib/python3.2/sre_parse.py", line 315, in _parse_sub
itemsappend(_parse(source, state))
  File "/usr/local/lib/python3.2/sre_parse.py", line 511, in _parse
raise error("bad repeat interval")
sre_constants.error: bad repeat interval
>>>
>>>
>>> re.search(r'a{65536}', 'a' * 10)
Traceback (most recent call last):
  File "/usr/local/lib/python3.2/functools.py", line 176, in wrapper
result = cache[key]
KeyError: (, 'a{65536}', 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python3.2/re.py", line 158, in search
return _compile(pattern, flags).search(string)
  File "/usr/local/lib/python3.2/re.py", line 255, in _compile
return _compile_typed(type(pattern), pattern, flags)
  File "/usr/local/lib/python3.2/functools.py", line 180, in wrapper
result = user_function(*args, **kwds)
  File "/usr/local/lib/python3.2/re.py", line 267, in _compile_typed
return sre_compile.compile(pattern, flags)
  File "/usr/local/lib/python3.2/sre_compile.py", line 514, in compile
groupindex, indexgroup
OverflowError: regular expression code size limit exceeded
>>>

--
components: Library (Lib), Regular Expressions
messages: 152409
nosy: ezio.melotti, py.user
priority: normal
severity: normal
status: open
title: In module re the repeat interval {} doesn't accept numbers greater than 
65535
type: behavior
versions: Python 3.2

___
Python tracker 

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



[issue13734] Add a generic directory walker method to avoid symlink attacks

2012-01-31 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

> I was a little worried about the performance impact, so I did some
> trivial benchmarks:
> - O(depth) fwalk() is actually a tiny bit faster than walk() (it may
> be because we don't do as much path lookup)
> - O(1) fwalk() is around 20% slower, on a pure-traversal benchmark (so
> in a realistic use case where we would actually do something with the
> values returned by fwalk() the difference shouldn't be that
> noticeable)

I think the O(depth) version is fine. The O(1) version is quite more
complicated, difficult to follow, and it seems less robust (it doesn't
use try/finally and therefore might leak fds if the generator isn't
exhausted before being destroyed).

On modern systems you have at least 1024 fds, so the restriction
shouldn't be a problem.

--

___
Python tracker 

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



[issue13914] In module re the repeat interval {} doesn't accept numbers greater than 65535

2012-01-31 Thread STINNER Victor

STINNER Victor  added the comment:

This issue is a duplicate of #13169.

--
nosy: +haypo
resolution:  -> duplicate
status: open -> closed

___
Python tracker 

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



[issue13169] Regular expressions with 0 to 65536 repetitions raises OverflowError

2012-01-31 Thread STINNER Victor

STINNER Victor  added the comment:

Issue #13914 has been marked as a duplicate of this issue.

--

___
Python tracker 

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



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

2012-01-31 Thread STINNER Victor

Changes by STINNER Victor :


Removed file: http://bugs.python.org/file24306/timespec-2.patch

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



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

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

Martin v. Löwis  added the comment:

Retro: Indeed I'm ignoring your reports because of your tone. If you want to 
insult me, go ahead, but please don't use the bug tracker (I can ignore insults 
pretty well by now). If you want to achieve something, stop insulting people.

--

___
Python tracker 

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



[issue13706] non-ascii fill characters no longer work in formatting

2012-01-31 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset 056f5cc8885d by Victor Stinner in branch 'default':
Issue #13706: Add assertions to detect bugs earlier
http://hg.python.org/cpython/rev/056f5cc8885d

--

___
Python tracker 

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



[issue13915] Update Tutorial 6.1.3 for PEP 3145

2012-01-31 Thread Terry J. Reedy

New submission from Terry J. Reedy :

http://docs.python.org/py3k/tutorial/modules.html#compiled-python-files
needs to be updated for 3.2+ to reflect 
http://python.org/dev/peps/pep-3147/

The first sentence is still technically correct, but finding x.pyc in the same 
directory as x.py is now an anomaly, so that sentence, revised, should be near 
the bottom. Otherwise, the text should say that the default is to put 
x..pyc in __pycache__, where  is, for instance, 'cpython-32'. 
Note that this allows other implementations and other versions of cpython to 
use the same .py file.

I do not know if there is anywhere else that this info is or should be. Using 
Python?.

--
assignee: docs@python
components: Documentation
messages: 152415
nosy: docs@python, terry.reedy
priority: normal
severity: normal
stage: needs patch
status: open
title: Update Tutorial 6.1.3 for PEP 3145
type: behavior
versions: Python 3.2, Python 3.3

___
Python tracker 

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



[issue13916] disallow the "surrogatepass" handler for non utf-* encodings

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

New submission from Kang-Hao (Kenny) Lu :

Currently the "surrogatepass" handler always encodes the surrogates in UTF-8 
and hence the behavior for, say, "\udc80".encode("latin-1", 
"surrogatepass").decode("latin-1") might be unexpected and I don't even know 
what would, say, "\udc80\udc80".encode("big5", "surrogatepass").decode("big5"), 
return. Regardless of the fact that the documentation says "surrogatepass" is 
specific to utf-8", the currently behavior is arguably not too harmful thanks 
to PyBytesObject's '\0' ending (so that ((p[0] & 0xf0) == 0xe0 || (p[1] & 0xc0) 
== 0x80 || (p[2] & 0xc0) == 0x80) in PyCodec_SurrogatePassErrors would not 
crash).

However, I suggest we have the system either 1) raise early LookupError 2) 
raise the original Unicode(Decode|Encoding)Exception as soon as 
PyCodec_SurrogatePassErrors is called. I prefer the former.

Having this could shorten PyCodec_SurrogatePassErrors significantly in the 
patch I will shortly submit for issue #12892 as all the error conditions for 
utf-8, utf-16 and utf-32 are predicable* and almost all the conditionals could 
be removed. (The * statement is arguable if someone initializes 
interp->codec_search_path before _PyCodecRegistry_Init and the utf-16/32 
encoders are overwritten. I don't think we need to worry about this too much 
though. Or am I wrong here?)

--
components: Unicode
messages: 152416
nosy: ezio.melotti, kennyluck
priority: normal
severity: normal
status: open
title: disallow the "surrogatepass" handler for non  utf-* encodings
type: behavior
versions: Python 3.1, Python 3.2, Python 3.3

___
Python tracker 

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



[issue13916] disallow the "surrogatepass" handler for non utf-* encodings

2012-01-31 Thread STINNER Victor

Changes by STINNER Victor :


--
nosy: +haypo

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

STINNER Victor  added the comment:

Hum, it looks like _PyTime_AsDecimal() is wrong is ts->divisor is not a power 
of 10. The exponent must be computed with Context(1), not Context(26). 
Something simpler can maybe be used, I don't know even the decimal API.

--

___
Python tracker 

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



[issue13706] non-ascii fill characters no longer work in formatting

2012-01-31 Thread STINNER Victor

STINNER Victor  added the comment:

With the changeset 056f5cc8885d, format(1234, 'n') fails in a locale using a 
non-ASCII thousands separator. Patch showing the problem:

diff --git a/Lib/test/test_format.py b/Lib/test/test_format.py
--- a/Lib/test/test_format.py
+++ b/Lib/test/test_format.py
@@ -1,4 +1,5 @@
 from test.support import verbose, TestFailed
+import locale
 import sys
 import test.support as support
 import unittest
@@ -282,6 +283,19 @@ class FormatTest(unittest.TestCase):
 self.assertEqual(format(1+2j, "\u2007^8"), "\u2007(1+2j)\u2007")
 self.assertEqual(format(0j, "\u2007^4"), "\u20070j\u2007")
 
+def test_locale(self):
+try:
+oldloc = locale.setlocale(locale.LC_ALL, '')
+except locale.Error as err:
+self.skipTest("Cannot set locale: {}".format(err))
+try:
+sep = locale.localeconv()['thousands_sep']
+self.assertEqual(format(123456789, "n"),
+ sep.join(('123', '456', '789')))
+finally:
+locale.setlocale(locale.LC_ALL, oldloc)
+
+
 
 def test_main():
 support.run_unittest(FormatTest)

--

___
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-31 Thread Gregory P. Smith

Gregory P. Smith  added the comment:

FYI - I strongly support this type of work to reduce memory use of the Python 
interpreter!  :)

Also, yes, constant changing should be separate from this change but are worth 
occasionally re-measuring and justifying as common computer architectures have 
changed since the original decisions were made.

--

___
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-31 Thread Kang-Hao (Kenny) Lu

Kang-Hao (Kenny) Lu  added the comment:

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

Unfortunately this took longer than I thought but here comes 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.)

This turns out to be just two liners so I fixed that on the way. I can create 
separate patch with separate test for 3.2 (certainly doable) and even for 3.3, 
but since the test is now part of test_lone_surrogates, I feel less willing to 
do that for 3.3.

You might notice the codec naming inconsistency (utf-16-be and utf16be for 
encoding and decoding respectively). I have filed issue #13913 for this.

Also, the strcmps are quite crappy. I am working on issue #13916 (disallow the 
"surrogatepass" handler for non utf-* encodings). As long as we have that we 
can examine individual character instead...

In this patch, The "encoding" attribute for UnicodeDecodeException is now 
changed to return utf16(be|le) for utf-16. This is necessary info for 
"surrogatepass" to work although admittedly this is rather ugly. Any good idea? 
A new attribute for Unicode(Decode|Encode)Exception might be helpful but 
utf-16/32 are fairly uncommon encodings anyway and we should not add more 
burden for, say, utf-8.

>> Should we really reject lone surrogates for UTF-7?
>
> No, I meant only UTF-8/16/32; UTF-7 is fine as is.

Good to know.

--
Added file: http://bugs.python.org/file24384/surrogatepass_for_utf-16&32.patch

___
Python tracker 

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



[issue13913] utf-8 or utf8 or utf-8 (codec display name inconsistency)

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

Kang-Hao (Kenny) Lu  added the comment:

> and the table on the documentation of the codec module suggests *utf_8*
> as the name of the codec, which I believe to be equivalent to "utf_8"
> because '-' is not a valid character of an identifier.

typo: equivalent to "utf_8" → equivalent to "utf-8".

--

___
Python tracker 

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



[issue12100] Incremental encoders of CJK codecs reset the codec at each call to encode()

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

Changes by Kang-Hao (Kenny) Lu :


--
nosy: +kennyluck

___
Python tracker 

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



[issue3566] httplib persistent connections violate MUST in RFC2616 sec 8.1.4.

2012-01-31 Thread Jesús Cea Avión

Changes by Jesús Cea Avión :


--
nosy: +jcea
versions: +Python 3.3 -Python 2.7, Python 3.1, Python 3.2

___
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-31 Thread Ethan Furman

Ethan Furman  added the comment:

Attached patch now includes doc changes.

--
Added file: http://bugs.python.org/file24386/raise_from_none_v4.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-31 Thread Ethan Furman

Ethan Furman  added the comment:

Okay, *all* the documentation updates this time.  Thanks, Nick!

--
Added file: http://bugs.python.org/file24387/raise_from_none_v5.diff

___
Python tracker 

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