[issue11697] Unsigned type in mmap_move_method

2011-04-24 Thread Rafael Zanella

Rafael Zanella rafael.zane...@yahoo.com.br added the comment:

Seems like it should use size_t since it deals with memory location/obj size, 
but Python doesn't have size_t only ssize_t, and ssize_t is signed...

m.move(2**32, 10, 4)   # Should throw a ValueError - Won't it wrap around 
and become 0 once truncated ?

I've attached a patch that I believe fixes the bounds check, though it's still 
wrong on the types, since it's not portable.

--
keywords: +patch
nosy: +zanella
Added file: http://bugs.python.org/file21763/mmap.move.patch

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



[issue1490929] urllib.retrieve's reporthook called with non-helpful value

2011-04-24 Thread Rafael Zanella

Rafael Zanella azraellzane...@gmail.com added the comment:

Simple (lazy) test case added.

It just replicates one test case of reporthook to work with progresshook.

The testcases assume the hard-coded value of blocksize on urllib, maybe it 
should become a public property.

Also commented on diff: http://bugs.python.org/review/1490929/show

--
nosy: +zanella
Added file: http://bugs.python.org/file21766/test_urllib.patch

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



[issue4608] urllib.request.urlopen does not return an iterable object

2011-04-23 Thread Rafael Zanella

Rafael Zanella rafael.zane...@yahoo.com.br added the comment:

The patch that makes addinfourl() iterable was not commited due to the change 
to HTTP request see: msg86365 (http://bugs.python.org/issue4608#msg86365).

Since urllib is protocol agnostic it should behave the same with FTP, right?

So, where to fix? Change the addinfourl() to become itrable or change the 
FTPHandler return?

--
nosy: +zanella

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



[issue3826] BaseHTTPRequestHandler depends on GC to close connections

2008-09-24 Thread Rafael Zanella

Changes by Rafael Zanella [EMAIL PROTECTED]:


--
nosy: +zanella

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3826
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2683] subprocess.Popen.communicate takes bytes, not str

2008-07-01 Thread Rafael Zanella

Rafael Zanella [EMAIL PROTECTED] added the comment:

_communicate still encodes the string under the hood

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2683
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2683] subprocess.Popen.communicate takes bytes, not str

2008-06-29 Thread Rafael Zanella

Rafael Zanella [EMAIL PROTECTED] added the comment:

On subprocess.py the new method communicate() doesn't encode the string:


_communicate(self, input):
...
  if isinstance(input, str):
input = input.encode()
...


I've attached a patch that adds the str.encode() call on communicate().

--
keywords: +patch
nosy: +zanella
Added file: http://bugs.python.org/file10779/subprocess_strEncode.diff

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2683
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2325] isinstance(anything, MetaclassThatDefinesInstancecheck) raises instead of returning False

2008-06-29 Thread Rafael Zanella

Rafael Zanella [EMAIL PROTECTED] added the comment:

So..., could this issue be closed ?

--
nosy: +zanella

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2325
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3194] Demo/loop.c passing char * instead of wchar_t *

2008-06-24 Thread Rafael Zanella

New submission from Rafael Zanella [EMAIL PROTECTED]:

The Demo/loop.c passes a char pointer (argv[0]) while 
Py_SetProgramName() now expects a wchar_t pointer.

I've attached a patch, the solution on the patch was borrowed,
ok stolen, from Python/frozenmain.c

--
files: loop_c.diff
keywords: patch
messages: 68715
nosy: zanella
severity: normal
status: open
title: Demo/loop.c passing char * instead of wchar_t *
type: crash
versions: Python 3.0
Added file: http://bugs.python.org/file10725/loop_c.diff

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3194
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2791] subprocess.py leaks fd in communicate

2008-05-19 Thread Rafael Zanella

Rafael Zanella [EMAIL PROTECTED] added the comment:

I don't know a lot about the matter at hand, that's why I'm not gonna
append a patch.

On _communicate() after a pipe is read it's closed, doing the same on
communicate() seems to solve the issue of the extra pipe:


 if [self.stdin, self.stdout, self.stderr].count(None) = 2:
stdout = None
stderr = None
if self.stdin:
if input:
self.stdin.write(input)
self.stdin.close()
elif self.stdout:
stdout = self.stdout.read()
+ self.stdout.close()
elif self.stderr:
stderr = self.stderr.read()
+ self.stderr.close()
self.wait()
return (stdout, stderr)



Tested on Python 2.6a2+ (trunk:62767M, May 19 2008, 13:11:07).

--
nosy: +zanella

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2791
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2302] Uses of SocketServer.BaseServer.shutdown have a race

2008-05-07 Thread Rafael Zanella

Rafael Zanella [EMAIL PROTECTED] added the comment:

With the code as it stands, calls to shutdown that happen before
serve_forever enters its loop will deadlock, and there's no simple way
for the user to avoid this. The attached patch prevents the deadlock and
allows multiple serve_forever..shutdown cycles, but it's pretty
complicated. I could make it a lot simpler by making shutdown permanent:
any later serve_forever calls would return immediately.

Never thought of using the SocketServer taht way, wouldn't the person
doing this bunch of shutdown()s and serve_forever()s be better off using
handle_request() on a loop instead ?

A third choice would be to add a .serve_in_thread function that returns
a token that can be used to shut down exactly that loop, instead of
putting .shutdown() on the server. Any opinions?

I don't think I understand this part, what loop do you refer to ?

--
nosy: +zanella

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2302
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2650] re.escape should not escape underscore

2008-05-07 Thread Rafael Zanella

Rafael Zanella [EMAIL PROTECTED] added the comment:

AFAIK the lookup on dictionaries is faster than on lists.

Patch added, mainly a compilation of the previous patches with an
expanded test.

--
nosy: +zanella
Added file: http://bugs.python.org/file10215/re_patch.diff

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2650
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1193577] add server.shutdown() method and daemon arg to SocketServer

2008-02-25 Thread Rafael Zanella

Changes by Rafael Zanella:


--
nosy: +zanella

_
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1193577
_
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1533] Bug in range() function for large values

2008-02-24 Thread Rafael Zanella

Rafael Zanella added the comment:

According to the documentation
(http://docs.python.org/dev/library/functions.html) The arguments must
be plain integers, so I think the wrong thing here is to run the
object's __int__() under the range()'s hood. I think the right thing to
do would be to explicitly invoke int() on passing an non-int argument as
parameter.

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1533
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1524] os.system() fails for commands with multiple quoted file names

2008-02-24 Thread Rafael Zanella

Rafael Zanella added the comment:

I don't have access to a Windows machine, but is it really necessary to
quote the command part? I mean, on GNU/Linux if you pass a command wich
has spaces , say e.g.: ls -lah, quoted it fails too, but if passed
without quotes it runs just fine.

--
nosy: +zanella

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1524
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1986] io.StringIO allows any parameter

2008-02-24 Thread Rafael Zanella

Rafael Zanella added the comment:

oops, stupid me, this a 3.0 issue..., well seems the str() conversion is
done as well on the 3.0 io module:


class StringIO(TextIOWrapper):
   def __init__(self, initial_value=, encoding=utf-8,
 errors=strict, newline=\n):
super(StringIO, self).__init__(BytesIO(),
   encoding=encoding,
   errors=errors,
   newline=newline)
if initial_value:
if not isinstance(initial_value, str):
initial_value = str(initial_value)


__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1986
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1986] io.StringIO allows any parameter

2008-02-24 Thread Rafael Zanella

Rafael Zanella added the comment:

I believe you're referring to StringIO, if so, it changes the parameter
received to a string:


class StringIO:
  def __init__(self, buf = ''):
# Force self.buf to be a string or unicode
if not isinstance(buf, basestring):
buf = str(buf)


--
nosy: +zanella

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1986
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2118] smtplib.SMTP() raises socket.error rather than SMTPConnectError

2008-02-23 Thread Rafael Zanella

Changes by Rafael Zanella:


--
nosy: +zanella

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2118
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2149] Queue.maxsize, __init__() accepts any value as maxsize

2008-02-23 Thread Rafael Zanella

Rafael Zanella added the comment:

Just to exemplify:

from threading import Thread
import time
import Queue

class C:
  def __int__(self):
return 3
  
  #def __del__(self): print collected... # won't happen since q holds
a reference to it

c = C()
q = Queue.Queue(c)

# Not dynamic
print maxsize: , q.maxsize

# Not full() with instance
print c  0
print len(q.queue) == q.maxsize

class T(Thread):
  def __init__(self, q):
self._q = q
Thread.__init__(self)
  
  def run(self):
#For sme bizarre motive
self._q.maxsize = 5

#Ends up being infinite most of the times
t = T(q)

for i in xrange(1000):
  q.put_nowait(i)
  if i == 1: # otherwise the and len(self.queue) == self.maxsize will fail
t.start()
time.sleep(1)

t.join()


I guess rhettinger is right, there's no issue here, anyone that decides
to change the maxsize afterwards should know what is doing.

The only possible problem I'm able to see is someone passing an object
wich has __int__() and expecting it to be used.

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2149
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2143] smtplib.SSLFakeFile hangs forever if \n is not encountered

2008-02-23 Thread Rafael Zanella

Rafael Zanella added the comment:

As of 2.6 the smtplib uses the ssl module, until 2.5 it uses _ssl, I
*think* that this issue would bring an Exception on 2.5 while on 2.6
would return a zero length string:

def read(self, len=1024):

Read up to LEN bytes and return them.
Return zero-length string on EOF.

return self._sslobj.read(len)


wich would fulfill the if not chr:

--
nosy: +zanella

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2143
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1533] Bug in range() function for large values

2008-02-21 Thread Rafael Zanella

Rafael Zanella added the comment:

FWIW, using xrange() it seems to give the proper error message:

Traceback (most recent call last):
  File bad_range.py, line 12, in module
print xrange(MyInt(2**64), MyInt(2**64+10))
OverflowError: long int too large to convert to int

--
nosy: +zanella

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1533
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2149] Queue.maxsize, __init__() accepts any value as maxsize

2008-02-21 Thread Rafael Zanella

Rafael Zanella added the comment:

@gutworth: Since one of the main uses of Queue is with threads, I think
it *really* should acquire the mutex before changing the maxsize;

@amaury.forgeotdarc: Your patch makes the point of allowing the size to
be changed at some other place (e.g.: an attribute of an instance passed
as the maxsize), but as stated above I think (am not an expert) the
mutex really should be held before the maxsize change, another point:
using an instance on your patch a call to Queue.maxsize would return
something like:

Python 2.5.1 (r251:54863, Oct  5 2007, 13:36:32)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type help, copyright, credits or license for more information.
 class C:
...   def __init(self): self.n = 1;
...   def __int__(self): return int(self.n);
...
 c = C()
 import Queue
 q = Queue.Queue(c)
 q.maxsize
__main__.C instance at 0xb7c341ac


wich would force to have a get() to the maxsize attribute;

I have added a diff;

Added file: http://bugs.python.org/file9478/queue_maxsize_3.diff

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2149
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2149] Queue.maxsize, __init__() accepts any value as maxsize

2008-02-21 Thread Rafael Zanella

Rafael Zanella added the comment:

Mine patch doesn't address the hold the mutex before changing the
maxsize guess it would then force a get()?

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2149
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2149] Queue.maxsize, __init__() accepts any value as maxsize

2008-02-20 Thread Rafael Zanella

Changes by Rafael Zanella:


--
components: Library (Lib)
nosy: zanella
severity: minor
status: open
title: Queue.maxsize, __init__() accepts any value as maxsize
type: security
versions: Python 2.4, Python 2.5

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2149
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2149] Queue.maxsize, __init__() accepts any value as maxsize

2008-02-20 Thread Rafael Zanella

New submission from Rafael Zanella:

Queue.Queue(), accepts any value as the maxsize, example:

foo = Queue.Queue('j');
l = []; foo = Queue.Queue(l);
...

Shouldn't the value passed be checked on init :
isinstance(maxsize, int) ?

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2149
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2149] Queue.maxsize, __init__() accepts any value as maxsize

2008-02-20 Thread Rafael Zanella

Rafael Zanella added the comment:

Firts: the security type was my error.

The method wich uses the maxsize:

# Check whether the queue is full
def _full(self):
  return self.maxsize  0 and len(self.queue) == self.maxsize


@rhettinger: As per the documentation, negative values result on an
infinite Queue; well that AND will never be fulfilled with a negative
value anyway;

@gutworth: What I mean is that's awkward, if you put an string for
example, it'll be the size of the string wich will be used on the
__cmp__ and on len(), but that's not explicit, or is it?

Example:

[EMAIL PROTECTED] ~]$ python
Python 2.5.1 (r251:54863, Oct 30 2007, 13:54:11)
[GCC 4.1.2 20070925 (Red Hat 4.1.2-33)] on linux2
Type help, copyright, credits or license for more information.
 class C:
...   def __init__(self): pass;
...
 c = C()
 import Queue
 a = Queue.Queue(c)
 len(c)
Traceback (most recent call last):
  File stdin, line 1, in module
AttributeError: C instance has no attribute '__len__'
 a = Queue.Queue(c)
 a.put('q')
 a.get()
'q'
 a.put(1)
 a.put(2)
 a.put(3)


--
type: security - feature request

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2149
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com