[issue18197] insufficient error checking causes crash on windows

2013-06-12 Thread Max DeLiso

New submission from Max DeLiso:

hi.

if you cross compile the mercurial native extensions against python 2.7.5 (x64) 
on 64 bit windows 7 and then try to clone something, it will crash. 

I believe the reason for this is that the c runtime functions in the microsoft 
crt will throw a win32 exception if they are given invalid parameters, and 
since the return value of fileno() is not checked in Objects/fileobject.c, if a 
file handle is passed to fileno and the result is not a valid file descriptor, 
that invalid decriptor will get passed to _fstat64i32, an invalid parameter 
exception will be raised, and the program will crash.

here's the function with the alleged bug:

static PyFileObject*
dircheck(PyFileObject* f)
{
#if defined(HAVE_FSTAT)  defined(S_IFDIR)  defined(EISDIR)
struct stat buf;  
if (f-f_fp == NULL)
return f;
if (fstat(fileno(f-f_fp), buf) == 0  // this line is the problem, 
fileno's return value never gets checked
S_ISDIR(buf.st_mode)) {
char *msg = strerror(EISDIR);
PyObject *exc = PyObject_CallFunction(PyExc_IOError, (isO),
  EISDIR, msg, f-f_name);
PyErr_SetObject(PyExc_IOError, exc);
Py_XDECREF(exc);
return NULL;
}
#endif
return f;
}

here's the stack trace:

   msvcr90.dll!_invalid_parameter()   Unknown
msvcr90.dll!_fstat64i32()  Unknown
python27.dll!dircheck(PyFileObject * f) Line 127C
python27.dll!fill_file_fields(PyFileObject * f, _iobuf * fp, _object * 
name, char * mode, int (_iobuf *) * close) Line 183  C
python27.dll!PyFile_FromFile(_iobuf * fp, char * name, char * mode, int 
(_iobuf *) * close) Line 484C

here's a dump summary:

Dump Summary

Process Name:   python.exe : c:\Python27\python.exe
Process Architecture:   x64
Exception Code: 0xC417
Exception Information:  
Heap Information:   Present

about the patch:

the attached patch fixes that behavior and doesn't break any test cases on 
windows or linux. it applies against the current trunk of cpython. the return 
value of fileno should get checked for correctness anyways, even on *nix. the 
extra overhead is tiny, (one comparison and a conditional jump and a few extra 
bytes of stack space), but you do catch some weird edge cases.  

here are the steps to reproduce:

download the python 2.7.5 installer for windows
download the mercurial 2.6.2 source release
build the native extensions with 64 bit microsoft compilers
try to hg clone any remote repo 
(it should crash)

here are some version strings:

Python 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)] on 
win32
Microsoft (R) C/C++ Optimizing Compiler Version 17.00.60315.1 for x64
mercurial 2.6.2

here are some links:

in particular, read the bits about the invalid parameter exception:

_fsta64i32: 
http://msdn.microsoft.com/en-US/library/221w8e43%28v=vs.80%29.aspx 

_fileno:
http://msdn.microsoft.com/en-US/library/zs6wbdhx%28v=vs.80%29.aspx

Please let me know if my patch needs work or if I missed something.
Thanks!

--
components: IO
files: fileobject_fix.patch
hgrepos: 199
keywords: patch
messages: 191012
nosy: maxdeliso
priority: normal
severity: normal
status: open
title: insufficient error checking causes crash on windows
type: crash
versions: Python 2.7
Added file: http://bugs.python.org/file30552/fileobject_fix.patch

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



[issue18197] insufficient error checking causes crash on windows

2013-06-12 Thread Max DeLiso

Changes by Max DeLiso maxdel...@gmail.com:


--
hgrepos:  -199

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



[issue18183] Calling .lower() on certain unicode string raises SystemError

2013-06-12 Thread Roundup Robot

Roundup Robot added the comment:

New changeset b11507395ce4 by Serhiy Storchaka in branch '3.3':
Add tests for issue #18183.
http://hg.python.org/cpython/rev/b11507395ce4

New changeset 17c9f1627baf by Serhiy Storchaka in branch 'default':
Add tests for issue #18183.
http://hg.python.org/cpython/rev/17c9f1627baf

--

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



[issue18183] Calling .lower() on certain unicode string raises SystemError

2013-06-12 Thread Serhiy Storchaka

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


--
stage: patch review - committed/rejected
status: open - closed

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



[issue18167] cgi.FieldStorage fails to handle multipart/form-data when \r\n appears at end of 65535 bytes without other newlines

2013-06-12 Thread Serhiy Storchaka

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


--
stage:  - patch review

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



[issue10581] Review and document string format accepted in numeric data type constructors

2013-06-12 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 12.06.2013 07:32, Alexander Belopolsky wrote:
 
 Alexander Belopolsky added the comment:
 
 It looks like we a approaching consensus on some points:
 
 1. Mixed script numerals should be disallowed.
 2. '\N{MINUS SIGN}' should be accepted as an alternative to '\N{HYPHEN-MINUS}'
 
 Open question: should we accept fullwidth + and -, sub/superscript variants 
 etc.?  I believe rather than debating variant codepoints one by one, we 
 should consider applying NFKC (compatibility) normalization to unicode 
 strings to be interpreted as numbers.  This would allow parsing strings like 
 this:
 
 float(normalize('NFKC', '\N{FULLWIDTH HYPHEN-MINUS}\N{DIGIT ONE FULL 
 STOP}\N{FULLWIDTH DIGIT TWO}'))
 -1.2

While it would solve these cases, I think that would cause a
significant performance hit.

Perhaps we could do this in two phases:
1. detect whether the string uses non-ASCII digits and symbols
2. if it does, apply normalization and then use the decimal codec

--

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



[issue18198] unittest discover should provide a way to define discovery at package level

2013-06-12 Thread vila

New submission from vila:

While most test suites are a tree with test_*.py files, there are cases where 
being able to define the discovery for a subtree in the package __init__.py 
file comes handy.

A poc implementation is available at 
http://bazaar.launchpad.net/~canonical-isd-qa/selenium-simple-test/trunk/view/head:/src/sst/tests/test_loader.py
 

http://bazaar.launchpad.net/~canonical-isd-qa/selenium-simple-test/trunk/view/head:/src/sst/loader.py

It allows test writers to define their own discovery when needed (including a 
specific edge case for the project mentioned above: test scripts that should 
not be imported at load time).

It also addresses http://bugs.python.org/issue16662

--
messages: 191015
nosy: vila
priority: normal
severity: normal
status: open
title: unittest discover should provide a way to define discovery at package 
level

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



[issue18198] unittest discover should provide a way to define discovery at package level

2013-06-12 Thread Robert Collins

Robert Collins added the comment:

This is a duplicate of 16662

--
nosy: +rbcollins

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



[issue18198] unittest discover should provide a way to define discovery at package level

2013-06-12 Thread Robert Collins

Robert Collins added the comment:

Well, spoke with vila on IRC. I content it's a duplicate because if load_tests 
in __init__ kicks in and supercedes discovery, I believe this bug would not be 
needed.

--

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



[issue16487] Allow ssl certificates to be specified from memory rather than files.

2013-06-12 Thread Kristján Valur Jónsson

Kristján Valur Jónsson added the comment:

Hi there.
Thanks for your comments.  This is the kind of discussion I was hoping to have 
about my draft patch.

I too have reservations about adding arguments.  In the version of this that we 
have in house, we actually don't use a certdata argument, but rather this:
 - 'certfile' can be either a filename or a string containing the data.  The 
start of the string is examined to determine if is the latter

The reason I didn't do it this way in the patch is because:
a) it could be confusing and possibly un-pythonic to have that level of 
polymorphism employed
b) There are possible edge cases.  What if you had a filename that started with 
the magic tokens (unlikely but technically possible).

I also would prefer passing in the certificates as raw bytes data, rather than 
file-like objects.  there is no reason for them to be files, this is not data 
that is read on demand.  libssl reads the entire contents of these files in one 
gulp, so there is no efficiency to be gained through any sort of pipelining by 
providing a file-like-object..  Adding the plumbing inside the library to do 
python read() calls is completely unnecessary when the caller can simply do 
that.

The only possible reason would be to resolve the above ambiguity, i.e. to allow 
the api to try to invoke a read() function on the 'file' to determine if it 
is a file-like object.

--

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



[issue18054] Add more exception related assertions to unittest

2013-06-12 Thread vila

Changes by vila v.ladeuil+bugs-pyt...@free.fr:


--
nosy: +vila

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



[issue18167] cgi.FieldStorage fails to handle multipart/form-data when \r\n appears at end of 65535 bytes without other newlines

2013-06-12 Thread Serhiy Storchaka

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


--
versions: +Python 3.3, Python 3.4
Added file: http://bugs.python.org/file30554/issue18167-3.3.patch

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



[issue18167] cgi.FieldStorage fails to handle multipart/form-data when \r\n appears at end of 65535 bytes without other newlines

2013-06-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you for your report, but your patch looks overcomplicated, it fails on 
'x'*65535+'\r'+'y'*65535 and hangs on 'x'*65535+'\r'.

Here is a simpler patch with tests.

--
assignee:  - serhiy.storchaka
nosy: +serhiy.storchaka
Added file: http://bugs.python.org/file30553/issue18167-2.7.patch

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



[issue18181] super vs. someclass.__getattribute__

2013-06-12 Thread Ronald Oussoren

Ronald Oussoren added the comment:

added draft of a pep-style proposal

--
Added file: http://bugs.python.org/file30556/super-hook-proposal.rst

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



[issue18181] super vs. someclass.__getattribute__

2013-06-12 Thread Ronald Oussoren

Ronald Oussoren added the comment:

Slightly updated patch (different names, added some documentation)

--
Added file: http://bugs.python.org/file30555/issue-18181-poc-v3.txt

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



[issue18198] unittest discover should provide a way to define discovery at package level

2013-06-12 Thread Barry A. Warsaw

Changes by Barry A. Warsaw ba...@python.org:


--
nosy: +barry

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



[issue515074] Extended storage in new-style classes

2013-06-12 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

Most concrete variable-sized types don't use tp_basicsize to know where the 
data lives. For example, PyBytesObject has a char ob_sval[1]; member, and 
PyBytes_AsString() looks at this fixed offset.
For this reason, additional data cannot be stored before the variable-length 
section, only after.

It is possible to store data after the variable section, and CPython does it 
already for the __dict__ slot of user-defined classes::
 bytes.__basicsize__
33
 class B(bytes): pass
...
 B.__basicsize__
41
 B.__dictoffset__
-8

Note that tp_basicsize was increased by the size of the additional data (here a 
PyObject*).
To access your data, the logic is something like::
tp-tp_basicsize + (obj-ob_size * tp-tp_itemsize) - sizeof(MyData)
The function _PyObject_GetDictPtr() has similar code, and already aligns to the 
pointer size.

Of course, at the end of one object you cannot have *both* a __dict__ slot and 
custom data.
The custom type needs to either disallow subclassing, or provide a (negative) 
tp_dictoffset.
Also, some care may be required if the base class uses a custom allocator.

Overall, I think it's a bit involved, but doable.
I close the issue as works for me, someone can reopen if there is something 
wrong in the base types.

--
nosy: +amaury.forgeotdarc
resolution:  - works for me
status: open - closed

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



[issue16662] load_tests not invoked in package/__init__.py

2013-06-12 Thread Michael Foord

Changes by Michael Foord mich...@voidspace.org.uk:


--
assignee:  - michael.foord
nosy: +michael.foord

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



[issue18149] filecmp.cmp() incorrect results when previously compared file is modified within modification time resolution

2013-06-12 Thread Mark Levitt

Mark Levitt added the comment:

I've added a clear_cache() method to filecmp.py. Patch attached. 

I had thought about implementing an optional parameter to only invalidate the 
cache of a specific file object, but figured I'd keep it simple for now.

First time submitting a patch, so apologies if I've done something the wrong 
way.

--
keywords: +patch
nosy: +melevittfl
Added file: http://bugs.python.org/file30557/18149.patch

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



[issue18191] urllib2/urllib.parse.splitport does not handle IPv6 correctly

2013-06-12 Thread Julien Danjou

Julien Danjou added the comment:

Attached is a patch inspired by a function written for OpenStack Oslo library.

--
keywords: +patch
Added file: 
http://bugs.python.org/file30558/0001-Make-urllib.parse.splitport-handle-IPv6-correctly.patch

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



[issue18198] unittest discover should provide a way to define discovery at package level

2013-06-12 Thread vila

vila added the comment:

 The linked code does something different.

Right, it addressed other issues encountered in that project:
1 - the need for different paterns for files and directories 
(http://bugs.python.org/issue16662),
2 - handling import errors at load time (http://bugs.python.org/issue7559 as 
Robert told me),
3 - changing discovery policy at package level
4 - not importing test files (project specific)

The most blocking issue in that project was that there was no way to address 
(3). If that's fixed (and (1) as well) with http://bugs.python.org/issue16662, 
I'm fine with that, I'll be able to build the specifics for that project on top 
of it.

--

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



[issue18198] unittest discover should provide a way to define discovery at package level

2013-06-12 Thread R. David Murray

R. David Murray added the comment:

The linked code does something different.  I believe the title of this issue is 
incorrect for the implicitly suggested enhancement.  I also suspect the 
suggested enhancement (to the extent that I understand it) is not ripe for 
stdlib inclusion, but I'll leave that up to Michael.

--
nosy: +michael.foord, r.david.murray

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



[issue18198] unittest discover should provide a way to define discovery at package level

2013-06-12 Thread Michael Foord

Michael Foord added the comment:

The load_tests protocol is already the intended way for test writers to 
customize discovery. The problem, as issue 16662 states, is that load_tests is 
not invoked for packages by default. Fixing that is the right fix.

I'm rejecting this issue in favour of 16662.

--
assignee:  - michael.foord
resolution:  - rejected
stage:  - committed/rejected
status: open - closed

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



[issue16662] load_tests not invoked in package/__init__.py

2013-06-12 Thread Michael Foord

Michael Foord added the comment:

I agree that load_tests *should* be used in packages and that not doing this 
from the start was a mistake.

--

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



[issue7559] TestLoader.loadTestsFromName swallows import errors

2013-06-12 Thread vila

Changes by vila v.ladeuil+bugs-pyt...@free.fr:


--
nosy: +vila

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



[issue3329] API for setting the memory allocator used by Python

2013-06-12 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@gmail.com:


Added file: http://bugs.python.org/file30560/benchmarks.txt

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



[issue3329] API for setting the memory allocator used by Python

2013-06-12 Thread STINNER Victor

STINNER Victor added the comment:

Benchmark of py_setallocators-3.patch:

 - benchmarks suite (-b 2n3): some tests are 1.04x faster, some tests are 1.04 
slower, significant is between 115 and -191. I don't understand these output, 
but I guess that the overhead cannot be seen with such test.
 - pybench: +0.1% (diff between -4.9% and +5.6%)

If I understood correctly, the overhead is really really low (near zero).

--

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



[issue3329] API for setting the memory allocator used by Python

2013-06-12 Thread STINNER Victor

STINNER Victor added the comment:

 If I understood correctly, the overhead is really really low (near zero).

See attached output pybench.txt and benchmarks.txt.

--

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



[issue17860] subprocess docs lack info how to use output result

2013-06-12 Thread Ronald Oussoren

Ronald Oussoren added the comment:

The attached patch explicitly mentions that stdin/stdout/stderr are opened as 
binary streams when universal_newlines is False. 

I'm not convinced that adding this text will solve the confusion, subprocess 
has fairly complex documentation due to the rich API and it is easy to mis 
information when you don't read carefully. That said, the documentation for 
check_output (which is likely the most common way to run a command and fetch 
its output) is already clear about the types of the returned data, both in 
prose and example code.

--
nosy: +ronaldoussoren
Added file: http://bugs.python.org/file30562/issue17860.txt

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



[issue18174] Make regrtest with --huntrleaks check for fd leaks

2013-06-12 Thread Richard Oudkerk

Richard Oudkerk added the comment:

Updated version which adds checks for handle leaks on Windows.

--
Added file: http://bugs.python.org/file30561/fdleak.patch

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



[issue3329] API for setting the memory allocator used by Python

2013-06-12 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@gmail.com:


Added file: http://bugs.python.org/file30559/pybench.txt

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



[issue18199] No long filename support for Windows

2013-06-12 Thread Daniel Sturm

New submission from Daniel Sturm:

Python at the moment does not handle paths with more than MAX_PATH characters 
well under Windows.

With Windows 7 x64, Python 3.3 32bit, the attached file fails with:
Traceback (most recent call last):
  File .\filename_bug.py, line 4, in module
os.makedirs(dir)
  File C:\Python33\lib\os.py, line 269, in makedirs
mkdir(name, mode)
FileNotFoundError: [WinError 3] The system cannot find the path specified: 
'./aa

aa/b
bbb'

Same things apply to os.rmdir and probably other functions.

The problem is that in posixmodule.c:path_converter (which is used to get the 
wchar_t* pathname that is expected by the Win32 API) we do have the following 
check:
length = PyUnicode_GET_SIZE(unicode);
if (length  32767) {
FORMAT_EXCEPTION(PyExc_ValueError, %s too long for Windows);
Py_DECREF(unicode);
return 0;
}
wide = PyUnicode_AsUnicode(unicode);
but the documentation states:
The Windows API has many functions that also have Unicode versions to permit 
an extended-length path for a maximum total path length of 32,767 characters. 
This type of path is composed of components separated by backslashes, each up 
to the value returned in the lpMaximumComponentLength parameter of the 
GetVolumeInformation function (this value is commonly 255 characters). To 
specify an extended-length path, use the \\?\ prefix. For example, 
\\?\D:\very long path.

Source: 
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx

The problem is that we never prepend \\?\ to the pathname hence getting the 
old MAX_PATH limit. 

To fix this the easiest solution would be to change the unicode code path of 
the function to always return an absolute path (relative paths are always 
limited by MAX_PATH) with \\?\. For optimization we could only do this if the 
path is longer than 248 (CreateDir has another interesting exception there..) 
resp. MAX_CHAR characters.

--
components: Unicode, Windows
files: filename_bug.py
messages: 191033
nosy: Voo, ezio.melotti
priority: normal
severity: normal
status: open
title: No long filename support for Windows
Added file: http://bugs.python.org/file30563/filename_bug.py

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



[issue18199] No long filename support for Windows

2013-06-12 Thread Daniel Sturm

Changes by Daniel Sturm voodoo...@gmail.com:


--
components: +IO
type:  - behavior

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



[issue18164] Embedding Python doc incorrectly refers to LINKFORSHARED

2013-06-12 Thread egallager

egallager added the comment:

For reference, this originally came from the following MacPorts ticket: 
https://trac.macports.org/ticket/39223#comment:14

--
nosy: +E.Money

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



[issue18199] No long filename support for Windows

2013-06-12 Thread STINNER Victor

STINNER Victor added the comment:

Using extended path (\\?\ prefix) causes new issues.

 * #13234: issue in os.listdir()
 * #13772: issue with os.symlink()
 * #9949: issue in os.path.realpath()

--
nosy: +brian.curtin, haypo, loewis, pitrou, serhiy.storchaka, tim.golden

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



[issue18199] No long filename support for Windows

2013-06-12 Thread STINNER Victor

STINNER Victor added the comment:

 The problem is that we never prepend \\?\ to the pathname hence getting the 
 old MAX_PATH limit.

I would not call this a problem. In my opinion, it is a bug in Windows: I 
don't understand why we should preprend something to support longer path.

I'm not sure that low-level APIs (functions of the os module) should workaround 
this Windows limitation. An higher level API like pathlib may prepend \\?\ 
prefix to support longer path.

pathlib: PEP 428 and https://pypi.python.org/pypi/pathlib/

--
type: behavior - enhancement

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



[issue18199] No long filename support for Windows

2013-06-12 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@gmail.com:


--
versions: +Python 3.4

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



[issue18174] Make regrtest with --huntrleaks check for fd leaks

2013-06-12 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@gmail.com:


--
nosy: +haypo

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



[issue18199] No long filename support for Windows

2013-06-12 Thread Daniel Sturm

Daniel Sturm added the comment:

 In my opinion, it is a bug in Windows
I don't think calling every complicated API a bug is useful. Is the Win32 API 
exceedingly annoying? I think everybody agrees on that, but imo it's  better to 
fix this once in python itself and don't force all developers to think about 
those details.

Fixing this in pathlib is better than not doing anything, although with the 
large amounts of code out there that use os, it'd be nice if we could fix it at 
the source (also since I assume pathlib internally is going to call the os 
module, it's still the same amount of work). 


If I provide unit tests for all the involved file system functions and fix the 
issues (more work than expected looking at the linked issues, but doesn't seem 
too hard), would such a patch have chances to be included?

--

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



[issue18191] urllib2/urllib.parse.splitport does not handle IPv6 correctly

2013-06-12 Thread Doug Hellmann

Changes by Doug Hellmann doug.hellm...@gmail.com:


--
nosy: +doughellmann

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



[issue18163] Add a 'key' attribute to KeyError

2013-06-12 Thread Brett Cannon

Brett Cannon added the comment:

What David said. =)

The fact that the key is the first value from args is almost happenstance as 
the exception message is customized in __str__() and not in what is passed to 
the exception. But what if I had defined __getattr__ or __getattribute__ and 
had some prefix requirement? It would be more helpful to say ``KeyError({!r} 
does not start with py_.format(key))`` which breaks your args[0] usage but is 
a much more descriptive message and has no defined way to provide the key as an 
attribute.

It's basically explicit is better than implicit since there is no API 
guarantee that the first thing in 'args' for KeyError will in actuality be the 
key.

--

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



[issue18192] Move imp.get_magic() to importlib

2013-06-12 Thread Brett Cannon

Brett Cannon added the comment:

So what are your arguments to making it more accessible? The typical user won't 
need to use it so I don't know if it really requires being off of importlib 
directly like find_loader, import_module, or (eventually) reload (which for 
convenience-sake while at the interpreter should be there).

While I'm happy to entertain the argument that it should be 
importlib.machinery.MAGIC (like the file suffixes for the various file types) 
instead of importlib.abc.SourceLoader.magic, I don't want to make it 
importlib.magic.

--

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



[issue18191] urllib2/urllib.parse.splitport does not handle IPv6 correctly

2013-06-12 Thread Doug Hellmann

Doug Hellmann added the comment:

LGTM

--

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



[issue18191] urllib2/urllib.parse.splitport does not handle IPv6 correctly

2013-06-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I see only tests.

It is more common to use arguments for assertEqual() in the reverse order, 
first actual value, and than expected value.

--
nosy: +serhiy.storchaka

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



[issue18191] urllib2/urllib.parse.splitport does not handle IPv6 correctly

2013-06-12 Thread Berker Peksag

Berker Peksag added the comment:

FTR, urllib.parse.splitport is undocumented and it is only used by 
urllib.request in the stdlib.

--
nosy: +berker.peksag
versions:  -Python 3.1, Python 3.2

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



[issue18199] No long filename support for Windows

2013-06-12 Thread STINNER Victor

STINNER Victor added the comment:

 it'd be nice if we could fix it at the source

Yes, it is what we are trying to do. But it's not so simple. That's why the 
issue is splitted into more specific issues.

 If I provide unit tests for all the involved file system
 functions and fix the issues (more work than expected looking
 at the linked issues, but doesn't seem too hard), 
 would such a patch have chances to be included?

Sure! If adding \\?\ prefix causes new issue, you have to fix these issues 
first.

--

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



[issue18164] Embedding Python doc incorrectly refers to LINKFORSHARED

2013-06-12 Thread Éric Araujo

Éric Araujo added the comment:

I think it was Antoine who committed the patch originally.

--
nosy: +eric.araujo, pitrou

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



[issue17860] subprocess docs lack info how to use output result

2013-06-12 Thread anatoly techtonik

anatoly techtonik added the comment:

The only thing that can save the docs is pictures. Or tables.

  +-+---+
  | | universal_newlines = True |
   +--+-+---+
   |Py.2  |   str   | str   |
   +--+ |   |
   |Py.3  |  bytes  | str   |
   +--+-+---+

--

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



[issue15767] add ModuleNotFoundError

2013-06-12 Thread Brett Cannon

Changes by Brett Cannon br...@python.org:


--
title: add ImportNotFoundError - add ModuleNotFoundError

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



[issue15767] add ModuleNotFoundError

2013-06-12 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 8a0ed9f63c6e by Brett Cannon in branch 'default':
Issue #15767: Introduce ModuleNotFoundError, a subclass of
http://hg.python.org/cpython/rev/8a0ed9f63c6e

--
nosy: +python-dev

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



[issue15767] add ModuleNotFoundError

2013-06-12 Thread Brett Cannon

Changes by Brett Cannon br...@python.org:


--
resolution:  - fixed
stage: test needed - committed/rejected
status: open - closed

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



[issue18200] Update stdlib to use ModuleNotFoundError

2013-06-12 Thread Brett Cannon

New submission from Brett Cannon:

The common idiom::

 try:
  import something
 except ImportError:
  pass

should be updated to use ModuleNotFoundError instead to not accidentally 
swallow ImportError exceptions which signal actual errors.

--
components: Library (Lib)
keywords: easy
messages: 191047
nosy: brett.cannon
priority: normal
severity: normal
stage: needs patch
status: open
title: Update stdlib to use ModuleNotFoundError
versions: Python 3.4

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



[issue18200] Update stdlib to use ModuleNotFoundError

2013-06-12 Thread Brett Cannon

Changes by Brett Cannon br...@python.org:


--
dependencies: +add ModuleNotFoundError

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



[issue18149] filecmp.cmp() incorrect results when previously compared file is modified within modification time resolution

2013-06-12 Thread Ned Deily

Ned Deily added the comment:

Thanks for the patch, Mark. I've left some review comments via Rietveld (the 
review link next to the patch).  Also, if you haven't already, please fill out 
the contributor form as described in the Developer's Guide 
(http://docs.python.org/devguide/patch.html#licensing).

--

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



[issue3329] API for setting the memory allocator used by Python

2013-06-12 Thread STINNER Victor

STINNER Victor added the comment:

New version (4) of the patch:

 - move the opaque pointer (now called void *ctx, context) as the first 
parameter instead of the last parameter, as done in zlib, lzma and Oracle's OCI 
APIs; ctx is also the first parameter of Py*_GetFunctions() and 
Py*_SetFunctions() instead of the last
 - rename public functions:

   * Py_GetAllocators() - PyMem_GetAllocators(), PyObject_GetAllocators()
   * Py_SetAllocators() - PyMem_SetAllocators(), PyObject_SetAllocators()
   * Py_GetBlockAllocators() - PyObject_GetArenaAllocators()
   * Py_SetBlockAllocators() - PyObject_SetArenaAllocators()

 - move declaration of PyObject_*() functions from pymem.h to objimpl.h
 - split _PyMem big structure into smaller structures: _PyMem, _PyObject, 
_PyObject_Arena
 - move if (size == 0) size = 1; from PyMem_Malloc() to _PyMem_Malloc(), so 
the custom allocator can decide how to implement PyMem_Malloc(0) (maybe 
something more efficient)

Does the new API look better? py_setallocators-4.patch is ready for a final 
review. If nobody complains, I'm going to commit it.

--
Added file: http://bugs.python.org/file30564/py_setallocators-4.patch

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



[issue3329] API for setting the memory allocator used by Python

2013-06-12 Thread STINNER Victor

STINNER Victor added the comment:

py_setallocators-4.patch:
- Oh, I forgot another change: Py*_Get/SetAllocators() cannot fail anymore 
(because of an unknown API identifier), so the return type is now void

I just saw that I forgot .. versionadded:: 3.4 in the doc.

--

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



[issue18149] filecmp.cmp() incorrect results when previously compared file is modified within modification time resolution

2013-06-12 Thread Mark Levitt

Mark Levitt added the comment:

Ned,

Thanks for taking the time to review. I've updated the docs, added a unit test, 
signed the contributor form, and made the changes/corrections from your review.

Updated patch attached.

--
Added file: http://bugs.python.org/file30565/18149-2.patch

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



[issue11957] re.sub confusion between count and flags args

2013-06-12 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@gmail.com:


--
components:  -Unicode

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



[issue18164] Embedding Python doc incorrectly refers to LINKFORSHARED

2013-06-12 Thread Ned Deily

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


Added file: http://bugs.python.org/file30567/issue18164-27.patch

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



[issue18200] Update stdlib to use ModuleNotFoundError

2013-06-12 Thread Jesús Cea Avión

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


--
nosy: +jcea

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



[issue18164] Embedding Python doc incorrectly refers to LINKFORSHARED

2013-06-12 Thread Ned Deily

Ned Deily added the comment:

On further review, I think the 3.x documentation is pretty good as is.  I 
propose one change to it: getting another config var to help emphasize the 
configuration values that you will want to combine together.  The proposed 2.7 
patch backports the whole 3.x section including that change.

--
keywords: +patch
stage: needs patch - commit review
Added file: http://bugs.python.org/file30566/issue18164_3x.patch

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



[issue18200] Update stdlib to use ModuleNotFoundError

2013-06-12 Thread Brett Cannon

Brett Cannon added the comment:

Changeset 84105:281857369a78 and 84106:c4d7228421df have some updates to use 
ModuleNotFoundError.

--

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



[issue15767] add ModuleNotFoundError

2013-06-12 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 3a50025f1900 by Brett Cannon in branch 'default':
Issue #15767: Touch up ModuleNotFoundError usage by import.
http://hg.python.org/cpython/rev/3a50025f1900

--

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



[issue15767] add ModuleNotFoundError

2013-06-12 Thread Roundup Robot

Roundup Robot added the comment:

New changeset c6c0faaf65d7 by Brett Cannon in branch 'default':
Issue #15767: Add an explicit test for raising ModuleNotFoundError
http://hg.python.org/cpython/rev/c6c0faaf65d7

--

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



[issue18200] Update stdlib to use ModuleNotFoundError

2013-06-12 Thread Brett Cannon

Changes by Brett Cannon br...@python.org:


--
stage: needs patch - patch review

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



[issue18200] Update stdlib to use ModuleNotFoundError

2013-06-12 Thread Brett Cannon

Brett Cannon added the comment:

Here is a patch that uses ModuleNotFoundError in the stdlib sans test modules.

--
keywords: +patch
Added file: http://bugs.python.org/file30568/use_ModuleNotFoundError.diff

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



[issue18201] distutils write into symlinks instead of replacing them

2013-06-12 Thread Michał Górny

New submission from Michał Górny:

We're doing heavy wrapping of Python scripts on Gentoo in order to efficiently 
support having multiple versions of Python installed. For that reason, every 
Python script installed using the package manager is renamed, and a symlink to 
a common wrapper binary is installed in its place.

For example, setuptools install looks like:

  /usr/bin/easy_install - python-exec
  /usr/bin/easy_install-python2.7
  /usr/bin/easy_install-python3.2

Using the wrappers like this allow us to actively support user preference of 
Python version and map it to supported ones. Symlinking a common binary makes 
this more maintainable since there's just one place where wrapper needs to be 
updated.

However, it seems that setup.py is failing hard in replacing symlinks. Whenever 
user upgrades any installed package, either externally or due to some tool like 
easy_install or pip, the relevant setup.py writes into /usr/bin/easy_install 
rather than properly replacing it with a new file.

The effect, as you may imagine, is the wrapper being replaced with a random 
Python script and system-wide breakage.

The proper thing to do would be to write into temporary file in the destination 
directory, then use os.rename() to atomically replace the destination with the 
temporary file.

Since distutils is no longer maintained, I would be equally happy with simply 
os.remove() before writing the scripts. The problem may affect distutils2 as 
well.

--
assignee: eric.araujo
components: Distutils
messages: 191057
nosy: eric.araujo, mgorny, tarek
priority: normal
severity: normal
status: open
title: distutils write into symlinks instead of replacing them
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3

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



[issue18201] distutils write into symlinks instead of replacing them

2013-06-12 Thread Michał Górny

Changes by Michał Górny mgo...@gentoo.org:


--
type:  - behavior

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