[issue10879] cgi memory usage

2011-01-10 Thread Glenn Linderman

New submission from Glenn Linderman :

In attempting to review issue 4953, I discovered a conundrum in handling of 
multipart/formdata.

cgi.py has claimed for some time (at least since 2.4) that it "handles" file 
storage for uploading large files.  I looked at the code in 2.6 that handles 
such, and it uses the rfc822.Message method, which parses headers from any 
object supporting readline().  In particular, it doesn't attempt to read 
message bodies, and there is code in cgi.py to perform that.

There is still code in 3.2 cgi.py to read message bodies, but... rfc822 has 
gone away, and been replaced with the email package.  Theoretically this is 
good, but the cgi FieldStorage read_multi method now parses the whole CGI input 
and then iteration parcels out items to FieldStorage instances.  There is a 
significant difference here: email reads everything into memory (if I 
understand it correctly).  That will never work to upload large or many files 
when combined with a Web server that launches CGI programs with memory limits.

I see several possible actions that could be taken:
1) Documentation.  While it is doubtful that any is using 3.x CGI, and this 
makes it more doubtful, the present code does not match the documentation, 
because while the documenteation claims to handle file uploads as files, rather 
than in-memory blobs, the current code does not do that.

2) If there is a method in the email package that corresponds to 
rfc822.Message, parsing only headers, I couldn't find it.  Perhaps it is 
possible to feed just headers to BytesFeedParser, and stop, and get the same 
sort of effect.  However, this is not the way the cgi.py presently is coded.  
And if there is a better API, for parsing only headers, that is or could be 
exposed by email, that might be handy.

3) The 2.6 cgi.py does not claim to support nested multipart/ stuff, only one 
level.  I'm not sure if any present or planned web browsers use nested 
multipart/ stuff... I guess it would require a nested  tag? which is 
illegal HTML last I checked.  So perhaps the general logic flow of 2.6 cgi.py 
could be reinstated, with a technique to feed only headers to BytesFeedParser, 
together with reinstating the MIME body parsing in cgi.py,b and this could make 
a solution that works.

I discovered this, beacuase I couldn't figure out where a bunch of the methods 
in cgi.py were called from, particularly read_lines_to_outerboundary, and 
make_file.  They seemed to be called much too late in the process.  It wasn't 
until I looked back at 2.6 code that I could see that there was a transition 
from using rfc822 only for headers to using email for parsing the whole data 
stream, and that that was the cause of the documentation not seeming to match 
the code logic.  I have no idea if this problem is in 2.7, as I don't have it 
installed here for easy reference, and I'm personally much more interested in 
3.2.

--
components: Library (Lib)
messages: 125884
nosy: r.david.murray, v+python
priority: normal
severity: normal
status: open
title: cgi memory usage
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



[issue4953] cgi module cannot handle POST with multipart/form-data in 3.0

2011-01-10 Thread Glenn Linderman

Glenn Linderman  added the comment:

This looks much simpler than the previous patch.  However, I think it can be 
further simplified. This is my first reading of this code, however, so I might 
be totally missing something(s).

Pierre said:
Besides FieldStorage, I modified the  parse() function at module level, but not 
parse_multipart (should it be kept at all ?)

I say:
Since none of this stuff works correctly in 3.x, and since there are comments 
in the code about "folding" the parse* functions into FieldStorage, then I 
think they could be deprecated, and not fixed.  If people are still using them, 
by writing code to work around their deficiencies, that code would continue to 
work for 3.2, but then not in 3.3 when that code is removed?  That seems 
reasonable to me.  In this scenario, the few parse* functions that are used by 
FieldStorage should be copied into FieldStorage as methods (possibly private 
methods), and fixed there, instead of being fixed in place.  That was all the 
parse* functions could be deprecated, and the use of them would be unchanged 
for 3.2.

Since RFC 2616 says that the HTTP protocol uses ISO-8859-1 (latin-1), I think 
that should be required here, instead of deferring to fp.encoding, which would 
eliminate 3 lines.

Also, the use of FeedParser could be replaced by BytesFeedParser, thus 
eliminating the need to decode header lines in that loop.

And, since this patch will be applied only to Python 3.2+, the mscvrt code can 
be removed (you might want a personal copy with it for earlier version of 
Python 3.x, of course).

I wonder if the 'ascii' reference should also be 'latin-1'?

In truly reading and trying to understand this code to do a review, I notice a 
deficiency in _parseparam and parse_header: should I file new issues for them? 
(perhaps these are unimportant in practice; I haven't seen \ escapes used in 
HTTP headers).  RFC 2616 allows for "" which are handled in _parseparam.  And 
for \c inside "", which is handled in parse_header.  But: _parseparam counts " 
without concern for \", and parse_header allows for \\ and \" but not \f or \j 
or \ followed by other characters, even though they are permitted (but probably 
not needed for much).

In make_file, shouldn't the encoding and newline parameters be preserved when 
opening text files?  On the other hand, it seems like perhaps we should 
leverage the power of IO to do our encoding/decoding... open the file with the 
TextIOBase layer set to the encoding for the MIME part, but then just read 
binary without decoding it, write it to the .buffer of the TextIOBase, and when 
the end is reached, flush it, and seek(0).  Then the data can be read back from 
the TextIOBase layer, and it will be appropriate decoded.  Decoding errors 
might be deferred, but will still occur.  This technique would save two data 
operations: the explicit decode in the cgi code, and the implicit encode in the 
IO layers, so resources would be saved.  Additionally, if there is a 
CONTENT-LENGTH specified for non-binary data, the read_binary method should be 
used for it also, because it is much more efficient than readlines... less 
scanning of the data, and fewer outer iterations.  This goes well with 
 the technique of leaving that data in binary until read from the file.

It seems that in addition to fixing this bug, you are also trying to limit the 
bytes read by FieldStorage to some maximum (CONTENT_LENGTH).  This is good, I 
guess.  But skip_lines() has a readline potentially as long as 32KB, that isn't 
limited by the maximum.  Similar in read_lines_to_outer_boundary, and 
read_lines_to_eof (although that may not get called in the cases that need to 
be limited).  If a limit is to be checked for, I think it should be a true, 
exact limit, not an approximate limit.

See also issue 10879.

--

___
Python tracker 

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



[issue4953] cgi module cannot handle POST with multipart/form-data in 3.0

2011-01-10 Thread Glenn Linderman

Glenn Linderman  added the comment:

Also, the required behavior of make_file changes, to need the right encoding, 
or binary, so that needs to be documented as a change for people porting from 
2.x. It would be possible, even for files, which will be uploaded as binary, 
for a user to know the appropriate encoding and, if the file is to be processed 
rather than saved, supply that encoding for the temporary file.  So the 
temporary file may not want to be assumed to be binary, even though we want to 
write binary to it.  So similarly to the input stream, if it is TextIOBase, we 
want to write to the .buffer.

--

___
Python tracker 

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



[issue10784] os.getpriority() and os.setpriority()

2011-01-10 Thread Giampaolo Rodola'

Giampaolo Rodola'  added the comment:

Question: should Py_BEGIN/END_ALLOW_THREADS be used around getpriority() and 
setpriority() calls? It's still not clear to me when to use them exactly.

--

___
Python tracker 

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



[issue10879] cgi memory usage

2011-01-10 Thread Glenn Linderman

Glenn Linderman  added the comment:

Trying to code some of this, it would be handy if BytesFeedParser.feed would 
return a status, indicating if it has seen the end of the headers yet. But that 
would only work if it is parsing as it goes, rather than just buffering, with 
all the real parsing work being done at .close time.

--

___
Python tracker 

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



[issue1602] windows console doesn't print utf8 (Py30a2)

2011-01-10 Thread David-Sarah Hopwood

David-Sarah Hopwood  added the comment:

I'll have a look at the Py3k I/O internals and see what I can do.
(Reopening a bug appears to need Coordinator permissions.)

--

___
Python tracker 

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



[issue1602] windows console doesn't print utf8 (Py30a2)

2011-01-10 Thread Tim Golden

Tim Golden  added the comment:

Reopening as there seems to be some possibility of progress

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

___
Python tracker 

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



[issue1602] windows console doesn't print utf8 (Py30a2)

2011-01-10 Thread Tim Golden

Changes by Tim Golden :


--
versions: +Python 3.3 -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



[issue10875] Update Regular Expression HOWTO

2011-01-10 Thread SilentGhost

SilentGhost  added the comment:

> While the changes all look innocuous to me with respect to building the docs, 
> I am curious if you have tried to rebuild the HOWTO (if you have the tool 
> chain, which I do not).

I did rebuild the docs with 'make html'. Build was clean every time. If you 
meant something else please let me know.

--

___
Python tracker 

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



[issue4953] cgi module cannot handle POST with multipart/form-data in 3.0

2011-01-10 Thread Glenn Linderman

Glenn Linderman  added the comment:

I wrote:
Additionally, if there is a CONTENT-LENGTH specified for non-binary data, the 
read_binary method should be used for it also, because it is much more 
efficient than readlines... less scanning of the data, and fewer outer 
iterations.  This goes well with the technique of leaving that data in binary 
until read from the file.

I further elucidate:
Sadly, while the browser (Firefox) seems to calculate an overall CONTENT-LENGTH 
for the HTTP headers, it does not seem to calculate CONTENT-LENGTH for 
individual parts, not even file parts where it would be extremely helpful.

--

___
Python tracker 

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



[issue4953] cgi module cannot handle POST with multipart/form-data in 3.0

2011-01-10 Thread Glenn Linderman

Glenn Linderman  added the comment:

It seems the choice of whether to make_file or StringIO is based on the 
existence of self.length... per my previous comment, content-length doesn't 
seem to appear in any of the multipart/ item headers, so it is unlikely that 
real files will be created by this code.

Sadly that seems to be the case for 2.x also, so I wonder now if CGI has ever 
properly saved files, instead of buffering in memory...

I'm basing this off the use of Firefox Live HTTP headers tool.

--

___
Python tracker 

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



[issue10878] asyncore does not react properly on close()

2011-01-10 Thread Teodor Georgiev

Teodor Georgiev  added the comment:

Sorry, I forgot to mention - I have already tried to return False, but there 
was no difference.

def readable(self):
if time.time() >= self.timeout:
self.close()
return False
 else:
return True

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

___
Python tracker 

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



[issue10878] asyncore does not react properly on close()

2011-01-10 Thread Giampaolo Rodola'

Giampaolo Rodola'  added the comment:

What if you return False also in writable method?

--

___
Python tracker 

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



[issue10876] Zipfile crashes when zip password is set to 610/844/numerous other numbers

2011-01-10 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Well, the password-checking scheme uses a one-byte check against the zip header 
for consistency. 
So there is a (near) 1/256 chance of false positives, that is of bad passwords 
mistakenly detected as good; then the ZipFile class proceeds with unarchiving 
and that's where things fail (because the "decrypted" stream is really junk).

Therefore, I'd call it not a bug. If you want to crack a password, you need to 
trap this exception and interpret it as "bad password".

--
nosy: +pitrou
resolution:  -> invalid
status: open -> closed
type: crash -> behavior
versions: +Python 2.7, Python 3.1, Python 3.2 -Python 2.6

___
Python tracker 

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



[issue10878] asyncore does not react properly on close()

2011-01-10 Thread Teodor Georgiev

Teodor Georgiev  added the comment:

Precisely, I traced down the problem by putting a simple "breakpoint"
in asyncore.py:

def poll(timeout=0.0, map=None):
if map is None:
map = socket_map
if map:
r = []; w = []; e = []
for fd, obj in map.items():
is_r = obj.readable()
print "Readable??? -->" , is_r
is_w = obj.writable()
if is_r:
r.append(fd)
if is_w:
w.append(fd)
if is_r or is_w:
e.append(fd)
if [] == r == w == e:
time.sleep(timeout)
return

print r,w,e
try:
r, w, e = select.select(r, w, e, timeout)
except select.error, err:
if err.args[0] != EINTR:
raise
else:
return



And here it comes:

[5] [5] [5]
Readable??? --> True
[5] [5] [5]
Readable??? --> True
[5] [5] [5]
Readable??? --> False
[] [5] [5]

Traceback (most recent call last):
  File "./dlms_client.py", line 136, in 
asyncore.loop(timeout=0.8)
  File "/usr/lib/python2.6/asyncore.py", line 213, in loop
poll_fun(timeout)
  File "/usr/lib/python2.6/asyncore.py", line 146, in poll
raise
  File "/usr/lib/python2.6/asyncore.py", line 143, in poll
r, w, e = select.select(r, w, e, timeout)
select.error: (9, 'Bad file descriptor')

So, in order this to work, on first sight all r,w,e must not point to
a socket that has been already closed. Now I am going to think for a workaround 
at least.

--

___
Python tracker 

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



[issue1602] windows console doesn't print utf8 (Py30a2)

2011-01-10 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc  added the comment:

The script unicode2.py uses the console STD_OUTPUT_HANDLE iff 
sys.stdout.fileno()==1.
But is it always the case? What about pythonw.exe? 
Also some applications may redirect fd=1: I'm sure that py.test does this 
http://pytest.org/capture.html#setting-capturing-methods-or-disabling-capturing 
and IIRC Apache also redirects file descriptors.

--

___
Python tracker 

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



[issue1602] windows console doesn't print utf8 (Py30a2)

2011-01-10 Thread STINNER Victor

STINNER Victor  added the comment:

amaury> The script unicode2.py uses the console STD_OUTPUT_HANDLE iff
amaury> sys.stdout.fileno()==1

Interesting article about the Windows console:
http://blogs.msdn.com/b/michkap/archive/2008/03/18/8306597.aspx

There is an example which has many tests to check that stdout is the windows 
console (and not a pipe or something else).

--

___
Python tracker 

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



[issue4953] cgi module cannot handle POST with multipart/form-datain 3.0

2011-01-10 Thread STINNER Victor

STINNER Victor  added the comment:

Some comments on cgi_diff_20110109.txt, especially on FieldStorage 
constructor.

Le dimanche 09 janvier 2011 13:26:24, vous avez écrit :
> Here is the diff file for the revised version of cgi.py

+import msvcrt
+msvcrt.setmode (0, os.O_BINARY) # stdin  = 0
+msvcrt.setmode (1, os.O_BINARY) # stdout = 1
+msvcrt.setmode (2, os.O_BINARY) # stderr = 2

Why do you change stdout and stderr mode? Is it needed? Instead of 0, you 
should use sys.stdin.fileno() with a try/except on .fileno() because stdin can 
be a StringIO object:

   >>> o=io.StringIO()
   >>> o.fileno()
   io.UnsupportedOperation: fileno

I suppose that it's better to do nothing if sys.stdin has no .fileno() method.

More generally, I don't think that the cgi module should touch sys.stdin mode: 
it impacts the whole process, not only the cgi module. Eg. change sys.stdin 
mode in Python 3.1 will break the interperter because the Python parser in 
Pytohn 3.1 doesn't know how to handle \r\n end of line. If you need binary 
stdin, I should backport my patch for #10841 (for std*, FileIO and the 
parser).


def __init__(self, fp=None, headers=None, outerboundary="",
 environ=os.environ, keep_blank_values=0, strict_parsing=0,
 limit=None):
...
if 'QUERY_STRING' in environ:
   qs = environ['QUERY_STRING']
elif sys.argv[1:]:
   qs = sys.argv[1]
else:
   qs = ""
fp = BytesIO(qs.encode('ascii')) # bytes


With Python 3.2, you should use environ=environ.os.environb by default to 
avoid unnecessary conversion (os.environb --decode--> os.environ --encode--> 
qs). To decode sys.argv, ASCII is not the right encoding: you should use 
qs.encode(locale.getpreferredencoding(), 'surrogateescape') because Python 
decodes the environment and the command line arguments from 
locale.getpreferredencoding()+'surrogateescape', so it is the exact reverse 
operation and you get the original raw bytes.

For Python 3.1, use also qs.encode(locale.getpreferredencoding(), 
'surrogateescape') to encode the environment variable.

So for Python 3.2, it becomes something like:

def __init__(self, fp=None, headers=None, outerboundary="",
 environ=os.environb, keep_blank_values=0, strict_parsing=0,
 limit=None):
...
if 'QUERY_STRING' in environ:
   qs = environ[b'QUERY_STRING']
elif sys.argv[1:]:
   qs = sys.argv[1]
else:
   qs = b""
if isinstance(qs, str):
   encoding = locale.getpreferredencoding()
   qs = qs.encode(encoding, 'surrogateescape'))
fp = BytesIO(qs)

If you would like to support byte *and* Unicode environment (eg. 
environ=os.environ and environ=os.environb), you should do something a little 
bit more complex: see os.get_exec_path(). I can work on a patch if you would 
like to. A generic function should maybe be added to the os module, function 
with an optional environ argument (as os.get_exec_path()).

---
if fp is None:
   fp = sys.stdin
if fp is sys.stdin:
   ...
---
you should use sys.stdin.buffer if fp is None, and accept sys.stdin.buffer in 
the second test. Something like:
---
stdin = sys.stdin
if isinstance(fp,TextIOBase):
   stdin_buffer = stdin.buffer
else:
   stdin_buffer = stdin
if fp is None:
   fp = stdin_buffer
if fp is stdin or fp is stdin_buffer:
   ...
---

Don't you think that a warning would be appropriate if sys.stdin is passed 
here?
---
# self.fp.read() must return bytes
if isinstance(fp,TextIOBase):
self.fp = fp.buffer
else:
self.fp = fp
---
Maybe a DeprecationWarning if we would like to drop support of TextIOWrapper 
later :-)

For the else case: you should maybe add a strict test on the type, eg. check 
for RawIOBase or BufferedIOBase subclass, isinstance(fp, (io.RawIOBase, 
io.BufferedIOBase)). It would avoid to check that fp.read() returns a bytes 
object (or get an ugly error later).

Set sys.stdin.buffer.encoding attribute is not a good idea. Why do you modify 
fp, instead of using a separated attribute on FieldStorage (eg. 
self.fp_encoding)?
---
# field keys and values (except for files) are returned as strings
# an encoding is required to decode the bytes read from self.fp
if hasattr(fp,'encoding'):
self.fp.encoding = fp.encoding
else:
self.fp.encoding = 'latin-1' # ?
---

I only read the constructor code.

--
title: cgi module cannot handle POST with multipart/form-data in3.0 -> 
cgi module cannot handle POST with multipart/form-datain 3.0

___
Python tracker 

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



[issue4953] cgi module cannot handle POST with multipart/form-data in 3.0

2011-01-10 Thread Etienne Robillard

Etienne Robillard  added the comment:

On 10/01/11 05:23 AM, Glenn Linderman wrote:
> I'm basing this off the use of Firefox Live HTTP headers tool.
>
>   

is sendfile() available on Windows ? i thought the Apache server could
use that
to upload files without having to buffer files in memory..

HTH,

-- 

Etienne Robillard

Company: Green Tea Hackers Club
Occupation: Software Developer
E-mail: e...@gthcfoundation.org
Work phone: +1 514-962-7703
Website (Company):  https://www.gthc.org/
Website (Blog): https://www.gthc.org/blog/
PGP public key fingerprint:F2A9 32EA 8E7C 460F 1728  A1A7 649C 7F17 A086 
DDEC

During times of universal deceit, telling the truth becomes a revolutionary 
act. -- George Orwell

--
title: cgi module cannot handle POST with multipart/form-datain 3.0 -> cgi 
module cannot handle POST with multipart/form-data in3.0

___
Python tracker 

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



[issue10879] cgi memory usage

2011-01-10 Thread R. David Murray

R. David Murray  added the comment:

The email package does have a 'parser headers only' mode, but it doesn't do 
what you want, since it reads the remainder of the file and sets it as the 
payload of the single, un-nested Message object it returns.

Adding a flag to tell it to stop parsing instead of doing that will probably be 
fairly simple, but is a feature request.

However, I'm not clear on how that helps.  Doesn't FieldStorage also load 
everything into memory?

There's an open feature request for providing a way to use alternate backing 
stores for the bodies of message parts in the email package, which *would* 
address this issue.

--
type:  -> feature request

___
Python tracker 

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



[issue10879] cgi memory usage

2011-01-10 Thread R. David Murray

Changes by R. David Murray :


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



[issue10880] do_mkvalue and 'boolean'

2011-01-10 Thread Yuriy

New submission from Yuriy :

If a value created by Py_VaBuildValue and parameter "b" is transfered - a 
PyLong_Type value is returned despite of the fact that it would be reasonable 
if PyBool_Type were returned. Are there any reasons for this?

modsupport.c Ln 214

--
messages: 125903
nosy: IROV
priority: normal
severity: normal
status: open
title: do_mkvalue and 'boolean'
type: behavior
versions: Python 3.3

___
Python tracker 

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



[issue10866] Add sethostname()

2011-01-10 Thread Antoine Pitrou

Changes by Antoine Pitrou :


--
nosy: +pitrou
stage:  -> patch review
type:  -> feature request

___
Python tracker 

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



[issue10880] do_mkvalue and 'boolean'

2011-01-10 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc  added the comment:

What makes you think it should be a boolean?
in http://docs.python.org/py3k/c-api/arg.html#Py_BuildValue "b" means "byte" 
and is processed as a tiny integer.

Now, that's true that Py_BuildValue could have a format for boolean values.  
Maybe with a "?" parameter?

--
nosy: +amaury.forgeotdarc
type: behavior -> feature request

___
Python tracker 

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



[issue10868] ABCMeta.register() should work as a decorator

2011-01-10 Thread Daniel Urban

Daniel Urban  added the comment:

There is another return statement earlier in the ABCMeta.register method. The 
patch probably should also modify that.

--
nosy: +durban

___
Python tracker 

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



[issue10225] Fix doctest runable examples in python manual

2011-01-10 Thread Alexander Belopolsky

Alexander Belopolsky  added the comment:

On Sun, Jan 9, 2011 at 3:52 PM, Terry J. Reedy  wrote:
> .. It would be nice to get the fixes into 3.2.

Yes, it would be nice, but I don't have a 3.2 patch (yet).  As you can
see from my last comment, I ran into a bug in the alpha version of
sphinx that I used to validate py3k docs.

> What sort of feedback do you want? Proofreading of text? Recheck of doctest?
>

All of the above.  Some of the fixes may be at the expense of
readability.   I would appreciate feedback in the instances when human
and computer reader's interests are in conflict.   Some examples are
"fixed" by excluding them from being checked.  Better ideas are
welcome.

> Does sphinx suppress doctest comments like
>     #doctest: +IGNORE_EXCEPTION_DETAIL
> ?

Yes.

>
> doctest.testfile("C:/programs/PyDev/py32/Doc/howto/sorting.rst", 
> module_relative = False)
> fails 23 of 37 attempts, so improvement is needed ;-).

You cannot run documentation examples with a plain doctest.   You have
to use sphinx-build.

--

___
Python tracker 

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



[issue10868] ABCMeta.register() should work as a decorator

2011-01-10 Thread Edoardo Spadolini

Edoardo Spadolini  added the comment:

Whoops, corrected that - should I add some more tests for that too?

--
nosy:  -benjamin.peterson, durban, eric.araujo, gvanrossum, pitrou, rhettinger
Added file: http://bugs.python.org/file20335/abcmeta_register_v4.diff

___
Python tracker 

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



[issue10868] ABCMeta.register() should work as a decorator

2011-01-10 Thread Edoardo Spadolini

Changes by Edoardo Spadolini :


--
nosy: +benjamin.peterson, durban, eric.araujo, gvanrossum, pitrou, rhettinger

___
Python tracker 

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



[issue10784] os.getpriority() and os.setpriority()

2011-01-10 Thread Martin v . Löwis

Martin v. Löwis  added the comment:

You should use begin/end allow threads when the system call might block. To get 
an indication, trace through the kernel code of some system; my guess is that 
these are typically non-blocking (i.e. return immediately) - but I might be 
wrong.

--

___
Python tracker 

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



[issue10868] ABCMeta.register() should work as a decorator

2011-01-10 Thread Éric Araujo

Éric Araujo  added the comment:

You should, otherwise how would you prove it’s fixed? :)

--

___
Python tracker 

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



[issue2320] Race condition in subprocess using stdin

2011-01-10 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

I confirm that it works reliably under 3.2, while it hangs as reliably under 
2.7 and 3.1. Since fixing involves a C extension that is too heavy to backport 
to bugfix branches, I suggest closing.

By the way: triagers, please don't set stage to "unit test needed". We don't 
need an unit test before a proper decision about the issue has been done, and 
actually we don't require reporters to write an unit test either (it's done as 
part of the patch, usually).

--
nosy: +pitrou
resolution:  -> out of date
stage: unit test needed -> 
status: open -> pending
versions: +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



[issue10880] do_mkvalue and 'boolean'

2011-01-10 Thread Yuriy

Yuriy  added the comment:

Thank you, how is it possible to ask the developers to add such a flag?

--

___
Python tracker 

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



[issue10868] ABCMeta.register() should work as a decorator

2011-01-10 Thread Edoardo Spadolini

Edoardo Spadolini  added the comment:

Fair enough :)

--
Added file: http://bugs.python.org/file20336/abcmeta_register_v4_plus_tests.diff

___
Python tracker 

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



[issue2568] Seconds range in time unit

2011-01-10 Thread Alexander Belopolsky

Alexander Belopolsky  added the comment:

The C89 draft as available through a Wikipedia link, 
http://flash-gordon.me.uk/ansi.c.txt, specifies tm_sec range as [0, 60].  
Although it looks like the range has been extended in the published version.  A 
discussion on comp.std.c describes the situation as follows:

"""

The "double leap second" is complete nonsense. It never existed outside the 
ANSI C standard and never will. It was introduced by the ANSI C 89 committee 
to document its problems understanding UTC issues. Someone heard that there 
are two prefered dates for leap seconds per year and this got munched up to 
the false rumour that UTC days can be up to 86402 seconds long. The 
definition of UTC, which requires that |UTC-UT1| < 0.9 s all the time, 
obviously makes double leap seconds mathematically impossible. 
"""

The latest publicly available standard that I was able to find that specifies 
[0, 61] range was "The Single UNIX ® Specification, Version 2" from 1997: 
http://pubs.opengroup.org/onlinepubs/007908799/xsh/time.h.html

Note that this range has been recognized as a mistake by Open Group:

"""
Problem:

 The valid range of seconds is no longer 0-61, a range chosen
 to accomodate the mythical double leap second.

 The correct range is 0-60 seconds.

 This has been fixed elsewhere in 1003.1-200x already.  See for
 instance .

 Action:

 Change range to 00-60 seconds.

 Search for any other places where the range is wrongly given as 0-61
 and fix them too.
 [Ed recommendation: Accept as marked
 make the change , and add a note to the CH
 that
 The description of %S is updated so the valid range is 00-60 rather
 than 00-61.

 A search was done of the draft for other occurrences of 61 and none
 found.  ]
"""  http://www.opengroup.org/austin/docs/austin_77r1.txt

Compliance with the mistakes in old versions of various standards, does not 
seem like a valid goal for Python, but until a system is reported that 
misbehaves when tm_sec = 61 is passed to strftime, I don't see a compelling 
reason to change Python behavior.  On the other hand, the documentation should 
not refer to bogus standards, so I suggest to change 

"""
The range really is 0 to 61; according to the Posix standard this accounts for 
leap seconds and the (very rare) double leap seconds. The time module may 
produce and does accept leap seconds since it is based on the Posix standard ...
"""

to 

"""
The range really is 0 to 61; tm_sec = 60 may be necessary to represent an 
occasional leap second and tm_sec = 61 is supported for historical reasons.
"""

--
nosy: +haypo

___
Python tracker 

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



[issue10880] do_mkvalue and 'boolean'

2011-01-10 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc  added the comment:

This is the right place to ask... but it will be faster if someone provides a 
patch.

--
keywords: +easy
stage:  -> needs patch

___
Python tracker 

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



[issue10868] ABCMeta.register() should work as a decorator

2011-01-10 Thread Edoardo Spadolini

Changes by Edoardo Spadolini :


Removed file: 
http://bugs.python.org/file20336/abcmeta_register_v4_plus_tests.diff

___
Python tracker 

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



[issue10868] ABCMeta.register() should work as a decorator

2011-01-10 Thread Edoardo Spadolini

Changes by Edoardo Spadolini :


Added file: http://bugs.python.org/file20337/abcmeta_register_v4_plus_tests.diff

___
Python tracker 

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



[issue10868] ABCMeta.register() should work as a decorator

2011-01-10 Thread Éric Araujo

Éric Araujo  added the comment:

-return  # Already a subclass
+return subclass # Already a subclass
PEP 8 advises to put two spaces before inline comments, for readability.
 (There is no need to upload a new patch, I’ll change that before commit.)

+self.assertIsInstahce(c, (A,))
This is fixed in the newest version of your patch.  Running tests before
uploading diffs catches such errors :)

--

___
Python tracker 

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



[issue10820] 3.2 Makefile changes for versioned scripts break OS X framework installs

2011-01-10 Thread Stephen Hansen

Stephen Hansen  added the comment:

FYI, The patch applied cleanly to branches/py3k; I then built a framework build 
(universal), installed it and ran the test-suite.

I had two failures, but I don't know if either is related. The first was the tk 
tests didn't pass, but I'm not sure if there was something special I need to do 
to get tk compiled universal in a framework build-- I'll look into it.

But this one perplexes me:


Wimp:build pythonbuildbot$ ./python.exe -m test.regrtest test_site
[1/1] test_site
test test_site failed -- Traceback (most recent call last):
  File "/Users/pythonbuildbot/32test/build/Lib/test/test_site.py", line 225, in 
test_getsitepackages
self.assertEqual(len(dirs), 2)
AssertionError: 3 != 2

1 test failed:
test_site
Wimp:build pythonbuildbot$ ./python.exe
Python 3.2b2+ (py3k:87899M, Jan 10 2011, 11:08:48) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import site
>>> site.getsitepackages()
['/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages',
 '/Library/Frameworks/Python.framework/Versions/3.2/lib/site-python', 
'/Library/Python/3.2/site-packages']

This machine fwiw never had any Python 3.x installed anywhere: in fact it was 
an almost pure stock 10.5 with buildbots put on it.

--
nosy: +ixokai

___
Python tracker 

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



[issue10820] 3.2 Makefile changes for versioned scripts break OS X framework installs

2011-01-10 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Looks like an issue in test_site rather than site.py itself (which has 
dedicated code to add a third site directory under framework builds). The 
test_site failure is not enough to hold the release, IMO.

Given Ronald's absence, I think Ned could start exercising his commit rights on 
this one. Ned, you'll need to write a Misc/NEWS entry in the "build" section 
(reverse chronological order). And an appropriate commit message. I think 
you'll figure out the (loose) typographical conventions :-)

--
assignee: ronaldoussoren -> ned.deily
nosy: +pitrou

___
Python tracker 

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



[issue10820] 3.2 Makefile changes for versioned scripts break OS X framework installs

2011-01-10 Thread Ned Deily

Ned Deily  added the comment:

Thanks for trying a build.  There are various tk test failures possible 
depending on what version of Tcl/Tk is or isn't installed, so I wouldn't be 
concerned about them.  The test_site failure is also not new. It is documented 
in re-opened Issue8084.

--

___
Python tracker 

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



[issue10881] test_site and macframework builds fails

2011-01-10 Thread Stephen Hansen

New submission from Stephen Hansen :

With the latest from branches/py3k, in a framework build, I get:

Wimp:build pythonbuildbot$ ./python.exe -m test.regrtest test_site
[1/1] test_site
test test_site failed -- Traceback (most recent call last):
  File "/Users/pythonbuildbot/32test/build/Lib/test/test_site.py", line 225, in 
test_getsitepackages
self.assertEqual(len(dirs), 2)
AssertionError: 3 != 2

1 test failed:
test_site
Wimp:build pythonbuildbot$ ./python.exe
Python 3.2b2+ (py3k:87899M, Jan 10 2011, 11:08:48) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import site
>>> site.getsitepackages()
['/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages',
 '/Library/Frameworks/Python.framework/Versions/3.2/lib/site-python', 
'/Library/Python/3.2/site-packages']

Those three dirs look correct for me, but the test is written to find exactly 
two from site.getsitepackages() -- the code, however, adds an extra in the 
event of framework builds.

--
assignee: ronaldoussoren
components: Macintosh, Tests
messages: 125919
nosy: ixokai, ronaldoussoren
priority: normal
severity: normal
status: open
title: test_site and macframework builds fails
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



[issue10881] test_site and macframework builds fails

2011-01-10 Thread Stephen Hansen

Stephen Hansen  added the comment:

... oops! Apparently dupe. Forgot to search first. Ignore.

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



[issue4953] cgi module cannot handle POST with multipart/form-data in 3.0

2011-01-10 Thread Glenn Linderman

Glenn Linderman  added the comment:

Victor said:
Don't you think that a warning would be appropriate if sys.stdin is passed 
here?
---
# self.fp.read() must return bytes
if isinstance(fp,TextIOBase):
self.fp = fp.buffer
else:
self.fp = fp
---
Maybe a DeprecationWarning if we would like to drop support of TextIOWrapper 
later :-)

I say:
I doubt we ever want to Deprecate the use of "plain stdin" as the default (or 
as an explicit) parameter for FieldStorage's fp parameter.  Most usage of 
FieldStorage will want to use stdin; if FieldStorage detects that stdin is 
TextIOBase (generally it is) and uses its buffer to get binary data, that is 
very convenient for the typical CGI application.  I think I agree with the rest 
of your comments.

Etienne said:
is sendfile() available on Windows ? i thought the Apache server could
use that to upload files without having to buffer files in memory..

I say:
I don't think it is called that, but similar functionality may be available on 
Windows under another name.  I don't know if Apache uses it or not.  But I have 
no idea how FieldStorage could interact with Apache via the CGI interface, to 
access such features.  I'm unaware of any APIs Apache provides for that 
purpose, but if there are some, let me know.  On the other hand, there are 
other HTTP servers besides Apache to think about. 

I'm also not sure if sendfile() or equivalent, is possible to use from within 
FieldStorage, because it seems in practice we don't know the size of the 
uploaded file without parsing it (which requires buffering it in memory to look 
at it).

--

___
Python tracker 

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



[issue10822] test_getgroups failure under Solaris

2011-01-10 Thread Ross Lagerwall

Changes by Ross Lagerwall :


--
nosy: +rosslagerwall

___
Python tracker 

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



[issue10820] 3.2 Makefile changes for versioned scripts break OS X framework installs

2011-01-10 Thread Ned Deily

Ned Deily  added the comment:

(BTW, I was planning to see what we could do about Issue8084 before release 
anyway.  I'll get on it.)

--

___
Python tracker 

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



[issue10784] os.getpriority() and os.setpriority()

2011-01-10 Thread Antoine Pitrou

Changes by Antoine Pitrou :


--
stage:  -> patch review

___
Python tracker 

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



[issue10879] cgi memory usage

2011-01-10 Thread Glenn Linderman

Glenn Linderman  added the comment:

R. David said:
However, I'm not clear on how that helps.  Doesn't FieldStorage also load 
everything into memory?

I say:
FieldStorage in 2.x (for x <= 6, at least) copies incoming file data to a file, 
using limited size read/write operations.  Non-file data is buffered in memory.

In 3.x, FieldStorage doesn't work.  The code that is there, though, for 
multipart/ data, would call email to do all the parsing, which would happen to 
include file data, which always comes in as part of a multipart/ data stream.  
This would prevent cgi from being used to accept large files in a limited 
environment.  Sadly, there is code is place that would the copy the memory 
buffers to files, and act like they were buffered... but process limits do not 
care that the memory usage is only temporary...

--

___
Python tracker 

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



[issue10882] Add os.sendfile()

2011-01-10 Thread Ross Lagerwall

New submission from Ross Lagerwall :

Attached is a patch which implements os.sendfile for unix systems (linux, 
freebsd, apple, solaris, dragonfly).

It takes the iov initialization code and off_t parsing from i10812.

It encapsulates all the functionality from the various sendfiles which means a 
fair amount of #ifdefs but the basic case works for all of them.

Tested on Linux & FreeBSD - it should work on solaris but since it needs to 
link with the sendfile library and I have no idea how to link the posix module 
with the sendfile library only on Solaris, i couldn't test it. If someone could 
please contribute this...

I think it might be possible to get a Windows equivalent of this - i'll leave 
it for someone else to do ;-)

--
components: Extension Modules
files: sendfile.patch
keywords: patch
messages: 125924
nosy: giampaolo.rodola, loewis, pitrou, rosslagerwall
priority: normal
severity: normal
status: open
title: Add os.sendfile()
type: feature request
versions: Python 3.3
Added file: http://bugs.python.org/file20338/sendfile.patch

___
Python tracker 

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



[issue10880] do_mkvalue and 'boolean'

2011-01-10 Thread Yuriy

Yuriy  added the comment:

case 'g':
{
int n;
n = va_arg(*p_va, int);

if (n == 0)
Py_RETURN_FALSE;
else
Py_RETURN_TRUE;
}

--

___
Python tracker 

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



[issue4953] cgi module cannot handle POST with multipart/form-data in 3.0

2011-01-10 Thread Pierre Quentel

Pierre Quentel  added the comment:

@Glenn
"Also, the use of FeedParser could be replaced by BytesFeedParser, thus 
eliminating the need to decode header lines in that loop."

BytesFeedParser only uses the ascii codec ; if the header has non ASCII 
characters (filename in a multipart/form-data), they are replaced by ? : the 
original file name is lost. So for the moment I leave the text version of 
FeedParser

@Victor :
"you should use qs.encode(locale.getpreferredencoding(), 'surrogateescape')"
Ok, I changed the code to that

"Maybe a DeprecationWarning if we would like to drop support of TextIOWrapper 
later :-)"
Maybe I'm missing something here, but sys.stdin is always a TextIOWrapper 
instance, even if set to binary mode

"For the else case: you should maybe add a strict test on the type, eg. check 
for RawIOBase or BufferedIOBase subclass, isinstance(fp, (io.RawIOBase, 
io.BufferedIOBase)). It would avoid to check that fp.read() returns a bytes 
object (or get an ugly error later)."

Rejecting non-instances of RawIOBase or BufferedIOBase is too much, I think. 
Any class whose instances have a read() method that return bytes should be 
accepted, like the TestReadLine class in test_cgi.py

"Set sys.stdin.buffer.encoding attribute is not a good idea. Why do you modify 
fp, instead of using a separated attribute on FieldStorage (eg. 
self.fp_encoding)?"

I set an attribute encoding to self.fp because, for each part of a 
multipart/form-data, a new instance of FieldStorage is created, and this 
instance needs to know how to decode bytes. So, either an attribute must be set 
to one of the arguments of the FieldStorage constructor, and fp comes to mind, 
or an extra argument has to be passed to this constructor, i.e. the encoding of 
the original stream

--

___
Python tracker 

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



[issue10882] Add os.sendfile()

2011-01-10 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

> Tested on Linux & FreeBSD - it should work on solaris but since it
> needs to link with the sendfile library and I have no idea how to link 
> the posix module with the sendfile library only on Solaris, i couldn't 
> test it.

Since the posix module is linked statically inside the interpreter, it probably 
needs some change in the base ldflags. I'll take a look when I have some time.

--
stage:  -> patch review

___
Python tracker 

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



[issue4953] cgi module cannot handle POST with multipart/form-data in 3.0

2011-01-10 Thread Glenn Linderman

Glenn Linderman  added the comment:

Victor said:
"Set sys.stdin.buffer.encoding attribute is not a good idea. Why do you modify 
fp, instead of using a separated attribute on FieldStorage (eg. 
self.fp_encoding)?"

Pierre said:
I set an attribute encoding to self.fp because, for each part of a 
multipart/form-data, a new instance of FieldStorage is created, and this 
instance needs to know how to decode bytes. So, either an attribute must be set 
to one of the arguments of the FieldStorage constructor, and fp comes to mind, 
or an extra argument has to be passed to this constructor, i.e. the encoding of 
the original stream

I say:
Ah, now I understand why you did it that way, but:

The RFC 2616 says the CGI stream is ISO-8859-1 (or latin-1).  The _defined_ 
encoding of the original stream is irrelevant, in the same manner that if it is 
a text stream, that is irrelevant.  The stream is binary, and latin-1, or it is 
non-standard.  Hence, there is not any reason to need a parameter, just use 
latin-1. If non-standard streams are to be supported, I suppose that would 
require a parameter, but I see no need to support non-standard streams: it is 
hard enough to support standard streams without complicating things.  The 
encoding provided with stdin is reasonably unlikely to be latin-1: Linux 
defaults to UTF-8 (at least on many distributions), and Windows to CP437, and 
in either case is configurable by the sysadmin.  But even the sysadmin should 
not be expected to configure the system locale to have latin-1 as the default 
encoding for the system, just because one of the applications that might run is 
an CGI program.  So I posit that the encoding on fp is irrelevan
 t and should be ignored, and using it as a parameter between FieldStorage 
instances is neither appropriate nor necessary, as the standard defines latin-1 
as the encoding for the stream.

--

___
Python tracker 

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



[issue5871] email.header.Header too lax with embeded newlines

2011-01-10 Thread Barry A. Warsaw

Barry A. Warsaw  added the comment:

I'm inclined not to support backporting to Python 2.6.  It seems like a fairly 
rare and narrow hole for security problem, because it would require a program 
to add the bogus header explicitly, as opposed to getting it after parsing some 
data.  To me, that smacks of SQL-injection or XSS type bug, where it's really 
the application that's the problem.

Or in other words, assuming you don't have a program that is deliberately 
adding such headers (and then it should be considered a feature, i.e. they know 
what they're doing), then you'd have to trick a header-adding program to add 
some unvalidated text.

I dunno, it doesn't seem like a serious enough threat to backport.

--

___
Python tracker 

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



[issue4953] cgi module cannot handle POST with multipart/form-data in 3.0

2011-01-10 Thread R. David Murray

R. David Murray  added the comment:

I don't have time to review the patch or even respond in detail to the comments 
right now, but I do want to respond about BytesFeedParser.  It is true that 
there is currently no interface to get the raw-bytes version of the header back 
out of the Message object, even though it still has it when constructed via 
BytesFeedParser.  This is an API oversight that needs to be rectified.

--

___
Python tracker 

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



[issue4953] cgi module cannot handle POST with multipart/form-data in 3.0

2011-01-10 Thread Guido van Rossum

Changes by Guido van Rossum :


--
nosy:  -gvanrossum

___
Python tracker 

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



[issue4953] cgi module cannot handle POST with multipart/form-data in 3.0

2011-01-10 Thread STINNER Victor

STINNER Victor  added the comment:

> I set an attribute encoding to self.fp because, for each part 
> of a multipart/form-data, a new instance of FieldStorage is created,
> and this instance needs to know how to decode bytes.

Set fp.encoding may raise an error (eg. for a read-only object, or an object 
implemented in C). You should add a new argument to the constructor.

> Maybe I'm missing something here, but sys.stdin is always
> a TextIOWrapper instance, even if set to binary mode

I mean: you should pass sys.stdin.buffer instead of sys.stdin.

--

___
Python tracker 

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



[issue5871] email.header.Header too lax with embeded newlines

2011-01-10 Thread R. David Murray

R. David Murray  added the comment:

Well, imagine a web form that has a 'subject' text entry field, and the 
application does Message['Subject'] = subject_from_form as it builds a Message 
to hand off to smtp.sendmail.  If the application didn't sanitize the subject 
for newlines (and as a programmer I doubt I would have thought of doing that), 
then we can have header injection.  So, yes, it is analogous to an sql 
injection attack.

Since we don't have a report of an exploit, I'm fine with not backporting it.

--
status: open -> closed

___
Python tracker 

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



[issue5871] email.header.Header too lax with embeded newlines

2011-01-10 Thread R. David Murray

R. David Murray  added the comment:

Ah, I should clarify.  A sensible web application should be dealing with any 
multiline input it allows by turning it into a newline-less single line before 
using it as a subject, so the probability that there are exploitable 
applications out there is, I think, sufficiently low that a backport isn't 
needed.

--

___
Python tracker 

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



[issue10394] subprocess Popen deadlock

2011-01-10 Thread Charles-Francois Natali

Charles-Francois Natali  added the comment:

It's now fixed in py3k, FD_CLOEXEC is set atomically (using pipe2 if available, 
otherwise it still has the GIL protection). See 
http://svn.python.org/view?view=rev&revision=87207

--
nosy: +neologix, pitrou

___
Python tracker 

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



[issue10881] test_site and macframework builds fails

2011-01-10 Thread Stephen Hansen

Changes by Stephen Hansen :


--
superseder:  -> pep-0370 on osx duplicates existing functionality

___
Python tracker 

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



[issue4953] cgi module cannot handle POST with multipart/form-data in 3.0

2011-01-10 Thread Pierre Quentel

Pierre Quentel  added the comment:

@Glenn
" The _defined_ encoding of the original stream is irrelevant, in the same 
manner that if it is a text stream, that is irrelevant.  The stream is binary, 
and latin-1, or it is non-standard"

I wish it could be as simple, but I'm afraid it's not. On my PC, 
sys.stdin.encoding is cp-1252. I tested a multipart/form-data with an INPUT 
field, and I entered the euro character, which is encoded  \x80 in cp-1252

If I use the encoding defined for sys.stdin (cp-1252) to decode the bytes 
received on sys.stdin.buffer, I get the correct value in the cgi script ; if I 
set the encoding to latin-1 in FieldStorage, since \x80 maps to undefined in 
latin-1, I get a UnicodeEncodeError if I try to print the value ("character 
maps to ")

--

___
Python tracker 

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



[issue2320] Race condition in subprocess using stdin

2011-01-10 Thread Gregory P. Smith

Gregory P. Smith  added the comment:

btw, I will be backporting all recent subprocess changes to 
http://code.google.com/p/python-subprocess32/

there have been a lot of changes recently, i was waiting for that to settle 
down before bring it up to current.  3.2rc1 sounds like a good time.

--
status: pending -> open

___
Python tracker 

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



[issue8084] pep-0370 on osx duplicates existing functionality

2011-01-10 Thread Éric Araujo

Changes by Éric Araujo :


--
nosy: +eric.araujo

___
Python tracker 

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



[issue10394] subprocess Popen deadlock

2011-01-10 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Ok, so let's close the issue. The fix can't reasonably be backported since it 
involves a whole new C extension and a rather large chunk of new code.

--
nosy: +gregory.p.smith
resolution:  -> out of date
status: open -> closed
versions:  -Python 2.6

___
Python tracker 

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



[issue1602] windows console doesn't print utf8 (Py30a2)

2011-01-10 Thread David-Sarah Hopwood

David-Sarah Hopwood  added the comment:

> The script unicode2.py uses the console STD_OUTPUT_HANDLE iff 
> sys.stdout.fileno()==1.

You may have missed "if not_a_console(hStdout): real_stdout = False".
not_a_console uses GetFileType and GetConsoleMode to check whether that handle 
is directed to something other than a console.

> But is it always the case?

The technique used here for detecting a console is almost the same as the code 
for IsConsoleRedirected at 
http://blogs.msdn.com/b/michkap/archive/2010/05/07/10008232.aspx , or in 
WriteLineRight at 
http://blogs.msdn.com/b/michkap/archive/2010/04/07/9989346.aspx (I got it from 
that blog, can't remember exactly which page).

[This code will give a false positive in the strange corner case that 
stdout/stderr is redirected to a console *input* handle. It might be better to 
use GetConsoleScreenBufferInfo instead of GetConsoleMode, as suggested by 
http://stackoverflow.com/questions/3648711/detect-nul-file-descriptor-isatty-is-bogus/3650507#3650507
 .]

> What about pythonw.exe?

I just tested that, using pythonw run from cmd.exe with stdout redirected to a 
file; it works as intended. It also works (for both console and non-console 
cases) when the handles are inherited from a parent process.

Incidentally, what's the earliest supported Windows version for Py3k? I see 
that http://www.python.org/download/windows/ mentions Windows ME. I can fairly 
easily make it fall back to never using WriteConsoleW on Windows ME, if that's 
necessary.

--

___
Python tracker 

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



[issue10820] 3.2 Makefile changes for versioned scripts break OS X framework installs

2011-01-10 Thread Ned Deily

Ned Deily  added the comment:

Fixed in r87908.

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

___
Python tracker 

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



[issue1697943] msgfmt cannot cope with BOM

2011-01-10 Thread STINNER Victor

STINNER Victor  added the comment:

Extract of the Unicode standard: "Use of a BOM is neither required nor 
recommended for UTF-8, but may be encountered in contexts where UTF-8 data is 
converted from other encoding forms that use a BOM or where the BOM is used as 
a UTF-8 signature".

See also the following section explaing issues with UTF-8 BOM:
http://en.wikipedia.org/wiki/Byte_order_mark#UTF-8

I agree that Python should handle (UTF-8) BOM to read a CSV file (#7185), 
because the file format is common on Windows.

But msgfmt is an UNIX tool: I would expect that Python behaves like the 
original msgfmt tool, fail with a fatal error on the BOM "invisible character". 
How do you explain to a user msgfmt fails but not msgfmt.py?

About the patch: *ignore* the BOM is not a good idea. The BOM announces the 
encoding (eg. UTF-8): if a Content-Type header announces another encoding, you 
should raise an error.

--

___
Python tracker 

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



[issue1697943] msgfmt cannot cope with BOM

2011-01-10 Thread STINNER Victor

STINNER Victor  added the comment:

See also issue #7651: "Python3: guess text file charset using the BOM".

--

___
Python tracker 

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



[issue1602] windows console doesn't print utf8 (Py30a2)

2011-01-10 Thread David-Sarah Hopwood

David-Sarah Hopwood  added the comment:

Note: Michael Kaplan's code checks whether GetConsoleMode failed due to 
ERROR_INVALID_HANDLE. My code intentionally doesn't do that, because it is 
correct and conservative to fall back to the non-console behaviour when there 
is *any* error from GetConsoleMode. (It could also fail due to not having the 
GENERIC_READ right on the handle, for example.)

--

___
Python tracker 

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



[issue9742] Python 2.7: math module fails to build on Solaris 9

2011-01-10 Thread Reid Madsen

Reid Madsen  added the comment:

Python support,

This issue with not being able to build on Solaris 9 is easily fixed.  I have 
attached a patch with the fix for Python 2.7.

When linking with libpython-2.7.a, the linker will only extract modules that 
satisfy dependencies emanating from python.o.  There may be objects in the 
archive that are not needed to satisfy any of these dependencies and those WILL 
NOT be included in the executable.

The GNU linker supports two options that can be use to force the linker to 
include ALL objects in the archive.  Thus if you change the python link line 
from:


 $(BUILDPYTHON):  Modules/python.o $(LIBRARY) $(LDLIBRARY)
 $(LINKCC) $(LDFLAGS) $(LINKFORSHARED) -o $@ \
 Modules/python.o \
 $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)

to:

 $(BUILDPYTHON): Modules/python.o $(LIBRARY) $(LDLIBRARY)
 $(LINKCC) $(LDFLAGS) $(LINKFORSHARED) -o $@ \
 Modules/python.o \
 -Wl,--whole-archive $(BLDLIBRARY) -Wl,--no-whole-archive \
 $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)

Then the problem is resolved.

For compiler toolchains that do not support the --whole-library option, you can 
change the link to link with the individual .o files and not use the archive 
library at all.

Let me know if I can be of any more help.

Reid Madsen

--
keywords: +patch
nosy: +srmadsen
Added file: http://bugs.python.org/file20339/Python-2.7.patch

___
Python tracker 

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



[issue10883] urllib: socket is not closed explicitly

2011-01-10 Thread STINNER Victor

New submission from STINNER Victor :

test_urllibnet.py and test_urllibnet2.py emit ResourceWarning:
==
$ ./python Lib/test/test_urllibnet.py 
testURLread (__main__.URLTimeoutTest) ... ok
test_bad_address (__main__.urlopenNetworkTests) ... ok
test_basic (__main__.urlopenNetworkTests) ... ok
test_fileno (__main__.urlopenNetworkTests) ... ok
test_getcode (__main__.urlopenNetworkTests) ... 
/home/haypo/prog/GIT/py3k/Lib/socket.py:333: ResourceWarning: unclosed 

  self._sock = None
ok
test_geturl (__main__.urlopenNetworkTests) ... ok
test_info (__main__.urlopenNetworkTests) ... ok
test_readlines (__main__.urlopenNetworkTests) ... ok
test_basic (__main__.urlretrieveNetworkTests) ... 
/home/haypo/prog/GIT/py3k/Lib/socket.py:333: ResourceWarning: unclosed 

  self._sock = None
ok
test_data_header (__main__.urlretrieveNetworkTests) ... 
/home/haypo/prog/GIT/py3k/Lib/socket.py:333: ResourceWarning: unclosed 

  self._sock = None
ok
test_header (__main__.urlretrieveNetworkTests) ... 
/home/haypo/prog/GIT/py3k/Lib/socket.py:333: ResourceWarning: unclosed 

  self._sock = None
ok
test_specified_path (__main__.urlretrieveNetworkTests) ... 
/home/haypo/prog/GIT/py3k/Lib/socket.py:333: ResourceWarning: unclosed 

  self._sock = None
ok

--
Ran 12 tests in 17.473s
==

It looks like these warning are real bugs: the socket is not closed explicitly 
by urllib.

Nadeem Vawda suggests a first fix:

  diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py
  --- a/Lib/urllib/request.py
  +++ b/Lib/urllib/request.py
  @@ -2151,7 +2151,9 @@
   conn = self.ftp.ntransfercmd(cmd)
   self.busy = 1
   # Pass back both a suitably decorated object and a retrieval length
  -return (addclosehook(conn[0].makefile('rb'), self.endtransfer), 
conn[1])
  +fp = addclosehook(conn[0].makefile('rb'), self.endtransfer)
  +conn[0].close()
  +return (fp, conn[1])
   def endtransfer(self):
   if not self.busy:
   return

--
components: Library (Lib)
messages: 125944
nosy: haypo, nvawda, orsenthil
priority: normal
severity: normal
status: open
title: urllib: socket is not closed explicitly
versions: Python 2.6, Python 2.7, 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



[issue10512] regrtest ResourceWarning - unclosed sockets and files

2011-01-10 Thread STINNER Victor

STINNER Victor  added the comment:

I opened a separated issue for test_urllib and test_urllib2net: #10883.

--

___
Python tracker 

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



[issue10875] Update Regular Expression HOWTO

2011-01-10 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

I applied patch to 3.2, 3.1 in r87904, r87905. Thanks.
I had to re-edit for 2.7: r87909.

I made a separate small patch for my suggested addition to Matching Characters. 
Could someone check that it is correct, given that re.rst contains the target 
directive (or whatever it is called):
.. _re-syntax:

--
assignee: d...@python -> terry.reedy
stage: needs patch -> commit review
Added file: http://bugs.python.org/file20340/zregex2.rst.diff

___
Python tracker 

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



[issue1602] windows console doesn't print utf8 (Py30a2)

2011-01-10 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc  added the comment:

Even if python.exe starts normally, py.test for example uses os.dup2() to 
redirect the file descriptors 1 and 2 to temporary files. sys.stdout.fileno() 
is still 1, the STD_OUTPUT_HANDLE did not change, but normal print() now goes 
to a file; but the proposed script won't detect this and will write to the 
console...
Somehow we should extract the file handle from the file descriptor, with a call 
to _get_osfhandle() for example.

--

___
Python tracker 

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



[issue5924] When setting complete PYTHONPATH on Python 3.x, paths in the PYTHONPATH are ignored

2011-01-10 Thread David-Sarah Hopwood

David-Sarah Hopwood  added the comment:

Looking at 
http://svn.python.org/view/python/branches/py3k/PC/getpathp.c?r1=73322&r2=73321&pathrev=73322
 , wouldn't it be better to add a Py_WGETENV function? There are likely to be 
other cases where that would be the correct thing to use.

--
nosy: +davidsarah

___
Python tracker 

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



[issue2568] Seconds range in time unit

2011-01-10 Thread Alexander Belopolsky

Alexander Belopolsky  added the comment:

Committed in revision 87910.

--
resolution:  -> fixed
stage: needs patch -> 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



[issue10875] Update Regular Expression HOWTO

2011-01-10 Thread Éric Araujo

Éric Araujo  added the comment:

Looks good, builds without warnings.

Note that you can use :ref:`re-syntax` and Sphinx will substitute the heading 
for you.  The :role:`some special text ` form is used when you 
want to control the text of the link.

(That thing is called an hyperlink target: 
http://docutils.sourceforge.net/docs/user/rst/quickref.html#hyperlink-targets)

--

___
Python tracker 

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



[issue9566] Compilation warnings under x64 Windows

2011-01-10 Thread STINNER Victor

STINNER Victor  added the comment:

> [readinst) should return a negative value on error, whereas it 
> returns the string length which is always positive

Fixed by r87911.

--

___
Python tracker 

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



[issue10628] Typos in 3.2 what’s new

2011-01-10 Thread Éric Araujo

Changes by Éric Araujo :


Removed file: http://bugs.python.org/file20333/whatsnew-3.2-typos.diff

___
Python tracker 

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



[issue4953] cgi module cannot handle POST with multipart/form-data in 3.0

2011-01-10 Thread Glenn Linderman

Glenn Linderman  added the comment:

Victor said:
I mean: you should pass sys.stdin.buffer instead of sys.stdin.

I say:
That would be possible, but it is hard to leave it at default, in that case, 
because sys.stdin will, by default, not be a binary stream.  It is a 
convenience for FieldStorage to have a useful default for its input, since RFC 
3875 declares that the message body is obtained from "standard input".

Pierre said:
I wish it could be as simple, but I'm afraid it's not. On my PC, 
sys.stdin.encoding is cp-1252. I tested a multipart/form-data with an INPUT 
field, and I entered the euro character, which is encoded  \x80 in cp-1252

If I use the encoding defined for sys.stdin (cp-1252) to decode the bytes 
received on sys.stdin.buffer, I get the correct value in the cgi script ; if I 
set the encoding to latin-1 in FieldStorage, since \x80 maps to undefined in 
latin-1, I get a UnicodeEncodeError if I try to print the value ("character 
maps to ")

I say:
Interesting. I'm curious what your system (probably Windows since you mention 
cp-) and browser, and HTTP server is, that you used for that test.  Is it 
possible to capture the data stream for that test?  Describe how, and at what 
stage the data stream was captured, if you can capture it.  Most interesting 
would be on the interface between browser and HTTP server.

RFC 3875 states (section 4.1.3) what the default encodings should be, but I see 
that the first possibility is "system defined".  On the other hand, it seems to 
imply that it should be a system definition specifically defined for particular 
media types, not just a general system definition such as might be used as a 
default encoding for file handles... after all, most Web communication crosses 
system boundaries.  So lacking a system defined definition for text/ types, it 
then indicates that the default for text/ types is Latin-1.

I wonder what result you get with the same browser, at the web page 
http://rishida.net/tools/conversion/ by entering the euro symbol into the 
Characters entry field, and choosing convert.

--

___
Python tracker 

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



[issue10628] Typos in 3.2 what’s new

2011-01-10 Thread Éric Araujo

Éric Araujo  added the comment:

Remaining fixes and nitpicks, in separate patches to avoid missing fixes when 
cherry-picking nits.

--
Added file: http://bugs.python.org/file20341/whatsnew-3.2-typos.diff

___
Python tracker 

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



[issue10628] Typos in 3.2 what’s new

2011-01-10 Thread Éric Araujo

Changes by Éric Araujo :


Added file: http://bugs.python.org/file20342/whatsnew-3.2-nitpicks.diff

___
Python tracker 

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



[issue10875] Update Regular Expression HOWTO

2011-01-10 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

Thanks. r87911,r87912

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



[issue5434] datetime.monthdelta

2011-01-10 Thread AdamN

AdamN  added the comment:

For future reference, python-dateutil seems like the maintained way to deal 
with "human" dates outside of the stdlib.

http://pypi.python.org/pypi/python-dateutil

--
nosy: +adamnelson

___
Python tracker 

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



[issue1602] windows console doesn't print utf8 (Py30a2)

2011-01-10 Thread David-Sarah Hopwood

David-Sarah Hopwood  added the comment:

"... os.dup2() ..."

Good point, thanks.

It would work to change os.dup2 so that if its second argument is 0, 1, or 2, 
it calls _get_osfhandle to get the Windows handle for that fd, and then reruns 
the console-detection logic. That would even allow Unicode output to work after 
redirection to a different console.

Programs that directly called the CRT dup2 or SetStdHandle would bypass this. 
Can we consider such programs to be broken? Methinks a documentation patch for 
os.dup2 would be sufficient, something like:

"When fd1 refers to the standard input, output, or error handles (0, 1 and 2 
respectively), this function also ensures that state associated with Python's 
initial sys.{stdin,stdout,stderr} streams is correctly updated if needed. It 
should therefore be used in preference to calling the C library's dup2, or 
similar APIs such as SetStdHandle on Windows."

--

___
Python tracker 

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



[issue5979] strptime() gives inconsistent exceptions

2011-01-10 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
stage: unit test needed -> needs patch
versions: +Python 3.3 -Python 3.2

___
Python tracker 

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



[issue1667546] Time zone-capable variant of time.localtime

2011-01-10 Thread Alexander Belopolsky

Alexander Belopolsky  added the comment:

I am going to close this as superseded by #9527.  In order to properly 
implement #9527 in datetime.py, some kind of tm_gmtoff support will need to be 
added to the time module, but I don't want this to become a feature that is 
exclusively available from the time module.

--
resolution:  -> duplicate
stage: patch review -> committed/rejected
status: open -> pending
superseder:  -> Add aware local time support to datetime module

___
Python tracker 

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



[issue8915] Use locale.nl_langinfo in _strptime

2011-01-10 Thread Alexander Belopolsky

Alexander Belopolsky  added the comment:

I would also like to consider using OS strptime on platforms with a decent 
implementation.

--
stage:  -> needs patch
type:  -> feature request
versions: +Python 3.3 -Python 3.2

___
Python tracker 

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



[issue9263] Try to print repr() when an C-level assert fails (in the garbage collector, beyond?)

2011-01-10 Thread Dave Malcolm

Dave Malcolm  added the comment:

Attaching updated version of the patch.

I've added a selftest which (in a sacrificial subprocess) abuses ctypes to 
break an ob_refcnt, and then triggers a garbage collection.

I also changed the printing to stderr to directly use fprintf and fflush to 
ensure that data leaves the process before abort kills it (not sure if this is 
a cross-platform or unicode no-no, though).

--
Added file: 
http://bugs.python.org/file20343/py3k-objdump-on-gcmodule-assertions-2011-01-10-001.patch

___
Python tracker 

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



[issue9263] Try to print repr() when an C-level assert fails (in the garbage collector, beyond?)

2011-01-10 Thread Dave Malcolm

Dave Malcolm  added the comment:

As above, but I added an extra call to fflush in case the call to 
_PyObject_Dump leads to a segfault.

--
Added file: 
http://bugs.python.org/file20344/py3k-objdump-on-gcmodule-assertions-2011-01-10-002.patch

___
Python tracker 

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



[issue1109963] bdist_wininst ignores build_lib from build command

2011-01-10 Thread Éric Araujo

Changes by Éric Araujo :


--
nosy: +eric.araujo

___
Python tracker 

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



[issue9611] FileIO not 64-bit safe under Windows

2011-01-10 Thread STINNER Victor

STINNER Victor  added the comment:

r87917 removes (useless and dangerous) conversion to size_t.

--

___
Python tracker 

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



[issue9566] Compilation warnings under x64 Windows

2011-01-10 Thread STINNER Victor

Changes by STINNER Victor :


Removed file: http://bugs.python.org/file20263/pyexpat.patch

___
Python tracker 

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



[issue10875] Update Regular Expression HOWTO

2011-01-10 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

and r87918 for 2.7, with bytes -> byte string

--

___
Python tracker 

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



[issue9566] Compilation warnings under x64 Windows

2011-01-10 Thread STINNER Victor

STINNER Victor  added the comment:

socketmodule_int.patch: Fix similar to the fix for #9611: clamp length to 
INT_MAX on Windows for recv(), recvfrom(), send() and sendto().

--
Added file: http://bugs.python.org/file20345/socketmodule_int.patch

___
Python tracker 

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



[issue7739] time.strftime may hung while trying to open /etc/localtime but does not release GIL

2011-01-10 Thread Alexander Belopolsky

Alexander Belopolsky  added the comment:

-1 on releasing the GIL around strftime().  Until we have an implementation 
that can support multiple locales and multiple timezones, people will work 
around this limitation by messing up with the TZ environment variable or global 
locale settings.

--
assignee: belopolsky -> 
stage:  -> patch review
type:  -> performance
versions: +Python 3.3 -Python 2.6

___
Python tracker 

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



[issue10848] Move test.regrtest from getopt to argparse

2011-01-10 Thread Sandro Tosi

Sandro Tosi  added the comment:

> R. David Murray  added the comment:
>
> Note that based on my experience with the conversion of compileall to 
> argparse,it is important to have good tests.  Of course, regrtest itself has 
> no tests...

Indeed that's quite funny :) anyhow, any suggestions on how to
properly test it while porting it to argparse? f.e, I can think to get
all the examples in the devguide and make sure they work, but since
I'm new to python development I might miss something really important,
hence the commends from more experienced devs would be really
important for me :)

Cheers,
Sandro

--

___
Python tracker 

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



[issue8957] strptime('%c', ..) fails to parse output of strftime('%c', ..) in non-English locale

2011-01-10 Thread Alexander Belopolsky

Alexander Belopolsky  added the comment:

Adding #8915 as a dependency because deducing D_T_FMT locale setting from 
strftime output seems impossible:

>>> locale.nl_langinfo(locale.D_T_FMT)
'%a %b %e %H:%M:%S %Y'

--
dependencies: +Use locale.nl_langinfo in _strptime
versions: +Python 3.3 -Python 3.2

___
Python tracker 

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



[issue10512] regrtest ResourceWarning - unclosed sockets and files

2011-01-10 Thread Nadeem Vawda

Nadeem Vawda  added the comment:

Good idea; they look like more work to fix than the warnings so far. Aside from 
those two, it looks like test_cgi is all that's left. Just to clarify, did you 
manage to reproduce the test_cgi warning?

--

___
Python tracker 

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



  1   2   >