[ python-Bugs-1739107 ] Bug assigning list comprehension to __slots__ in python 2.5

2007-06-18 Thread SourceForge.net
Bugs item #1739107, was opened at 2007-06-18 10:32
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1739107&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Fran�ois Desloges (fdesloges)
Assigned to: Nobody/Anonymous (nobody)
Summary: Bug assigning list comprehension to __slots__ in python 2.5

Initial Comment:
I use the package 2.5-4.1mdv2007.1.i586 in mandriva.
I don't know if this has already been reported elsewhere but the following code:

  a= ['C','D']
  class A(object):
__slots__ = a + ['__'+name for name in a]
def __init(self, c, d):
  self.__C = c
  self.__D = d
C = property(lambda self: self.__C)
D = property(lambda self: self.__D)
  a = A()

results is an a.name attribute with value 'D'.

But using :

  b= tuple('C','D')
  class B(object):
__slots__ = b + tuple('__'+name for name in b)
def __init(self, c, d):
  self.__C = c
  self.__D = d
C = property(lambda self: self.__C)
D = property(lambda self: self.__D)
  b = B()

b appropriately do not have a b.name attribute.


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1739107&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1739115 ] shutil.rmtree's error message is confusing

2007-06-18 Thread SourceForge.net
Bugs item #1739115, was opened at 2007-06-18 16:41
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1739115&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Bj�rn Lindqvist (sonderblade)
Assigned to: Nobody/Anonymous (nobody)
Summary: shutil.rmtree's error message is confusing

Initial Comment:
If you run shutil.rmtree(something) on Windows where something is file and not 
a directory, you get the following exception:

Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Python25\Lib\shutil.py", line 161, in rmtree
onerror(os.listdir, path, sys.exc_info())
  File "C:\Python25\Lib\shutil.py", line 159, in rmtree
names = os.listdir(path)
WindowsError: [Error 22] The directory name is invalid: 'foobar/*.*'

The error message is pretty confusing and it shouldn't be to hard to fix it. 
Plus, if it shouldn't be possible to remove files with shutil.rmtree(), then 
the docs should say so.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1739115&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1739118 ] Investigated ref leak report related to thread(regrtest.py -

2007-06-18 Thread SourceForge.net
Bugs item #1739118, was opened at 2007-06-18 23:43
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1739118&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Threads
Group: Python 2.6
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Hirokazu Yamamoto (ocean-city)
Assigned to: Nobody/Anonymous (nobody)
Summary: Investigated ref leak report related to thread(regrtest.py -

Initial Comment:
Hello. I investigated ref leak report related to thread.
Please run python regrtest.py -R :: test_leak.py (attached file)
Sometimes ref leak is reported.
# I saw this as regression failure on python-checkins.

# total ref count 92578 -> 92669
  _Condition 2
  Thread 6
  _Event 1
  bool 10
  instancemethod 1
  code 2
  dict 9
  file 1
  frame 3
  function 2
  int 1
  list 2
  builtin_function_or_method 5
  NoneType 2
  str 27
  thread.lock 7
  tuple 5
  type 5

Probably this happens because threading.Thread is implemented as Python
code,
(expecially threading.Thread#join), the code of regrtest.py

if i >= nwarmup:
deltas.append(sys.gettotalrefcount() - rc - 2)

can run before thread really quits. (before Moudles/threadmodule.c
t_bootstrap()'s

 Py_DECREF(boot->func);
 Py_DECREF(boot->args);
 Py_XDECREF(boot->keyw);

runs)

So I experimentally inserted the code to wait for thread termination.
(attached file experimental.patch) And I confirmed error was gone.

# Sorry for hackish patch which only runs on windows. It should run
# on other platforms if you replace Sleep() in Python/sysmodule.c
# sys_debug_ref_leak_leave() with appropriate function.


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1739118&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1739107 ] Bug assigning list comprehension to __slots__ in python 2.5

2007-06-18 Thread SourceForge.net
Bugs item #1739107, was opened at 2007-06-18 14:32
Message generated for change (Comment added) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1739107&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.5
>Status: Pending
Resolution: None
Priority: 5
Private: No
Submitted By: Fran�ois Desloges (fdesloges)
Assigned to: Nobody/Anonymous (nobody)
Summary: Bug assigning list comprehension to __slots__ in python 2.5

Initial Comment:
I use the package 2.5-4.1mdv2007.1.i586 in mandriva.
I don't know if this has already been reported elsewhere but the following code:

  a= ['C','D']
  class A(object):
__slots__ = a + ['__'+name for name in a]
def __init(self, c, d):
  self.__C = c
  self.__D = d
C = property(lambda self: self.__C)
D = property(lambda self: self.__D)
  a = A()

results is an a.name attribute with value 'D'.

But using :

  b= tuple('C','D')
  class B(object):
__slots__ = b + tuple('__'+name for name in b)
def __init(self, c, d):
  self.__C = c
  self.__D = d
C = property(lambda self: self.__C)
D = property(lambda self: self.__D)
  b = B()

b appropriately do not have a b.name attribute.


--

>Comment By: Georg Brandl (gbrandl)
Date: 2007-06-18 15:20

Message:
Logged In: YES 
user_id=849994
Originator: NO

Sorry, I can't follow you. Why should b have a "name" attribute?

Also, is it intentional that your __init is not named __init__?

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1739107&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1739107 ] Bug assigning list comprehension to __slots__ in python 2.5

2007-06-18 Thread SourceForge.net
Bugs item #1739107, was opened at 2007-06-18 14:32
Message generated for change (Comment added) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1739107&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.5
>Status: Closed
>Resolution: Wont Fix
Priority: 5
Private: No
Submitted By: Fran�ois Desloges (fdesloges)
Assigned to: Nobody/Anonymous (nobody)
Summary: Bug assigning list comprehension to __slots__ in python 2.5

Initial Comment:
I use the package 2.5-4.1mdv2007.1.i586 in mandriva.
I don't know if this has already been reported elsewhere but the following code:

  a= ['C','D']
  class A(object):
__slots__ = a + ['__'+name for name in a]
def __init(self, c, d):
  self.__C = c
  self.__D = d
C = property(lambda self: self.__C)
D = property(lambda self: self.__D)
  a = A()

results is an a.name attribute with value 'D'.

But using :

  b= tuple('C','D')
  class B(object):
__slots__ = b + tuple('__'+name for name in b)
def __init(self, c, d):
  self.__C = c
  self.__D = d
C = property(lambda self: self.__C)
D = property(lambda self: self.__D)
  b = B()

b appropriately do not have a b.name attribute.


--

>Comment By: Georg Brandl (gbrandl)
Date: 2007-06-18 15:21

Message:
Logged In: YES 
user_id=849994
Originator: NO

Ah, strike my last comment.

This is not a bug, or at least not fixable, since list comprehensions do
leak their iteration
variable into the enclosing scope, while generator expressions don't.

They will stop doing this in Py3k.

--

Comment By: Georg Brandl (gbrandl)
Date: 2007-06-18 15:20

Message:
Logged In: YES 
user_id=849994
Originator: NO

Sorry, I can't follow you. Why should b have a "name" attribute?

Also, is it intentional that your __init is not named __init__?

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1739107&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1737127 ] re.findall hangs python completely

2007-06-18 Thread SourceForge.net
Bugs item #1737127, was opened at 2007-06-14 08:05
Message generated for change (Comment added) made by gregsmith
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1737127&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Regular Expressions
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Arno Bakker (abakker)
Assigned to: Gustavo Niemeyer (niemeyer)
Summary: re.findall hangs python completely

Initial Comment:

Running a re.findall() on 40 KB of HTML appears to hang python completely. It 
hogs the CPU (perhaps not unexpected) but other python threads do not continue 
and pressing Ctrl-C does not trigger a KeyboardInterrupt. Only a SIGQUIT 
(Ctrl-\) can kill it.

Attached is a small script to illustrate the problem, and the data file that 
causes it to hang. Using 40 KB of random data does let it get past the first 
findall. It creates a Thread that should printout hashes continuously, however, 
as soon as the MainThread hits the findall the printing stops.

Occurs on Python-2.4.4 (direct from www.python.org) and 2.5.1 (2.5.1-0ubuntu1 
from Feisty)


--

Comment By: Gregory Smith (gregsmith)
Date: 2007-06-18 13:23

Message:
Logged In: YES 
user_id=292741
Originator: NO

First off, don't expect other threads to run during re execution.
Multi-threading in python is mainly to allow one thread to run while the
others are waiting for I/O or doing a time.sleep() or something specific
like that. Switching between runnable threads only occurs in interpreter
loop.
There may exceptions to allow switching during some really long core
operations (a mutex needs to be released and taken again) but it has to be
done under certain conditions so that threads won't mess each other's data
up.

So, on to the r.e.: first, try changing all the .*? to just .*  -- the ?
is redundant and may be increasing the runtime by expanding the number of
permutations that are being tried.

But I think your real trouble is all of these :  img src=\"(.*?)\"
This allows the second " to match with anything at all between, including
any number of quoted strings.
 Your combination of several of these may be causing the RE engine to
spend a huge amount of time looking at many different combinations for the
first few .*?, all of which fail by the time you get to the last one.

Try   img src=\"([^"]*)\"  instead; this will only match the pair of "
with no " in between.

Likewise, in .*?> the .* will match any number of '>' chars if this is
needed to make the whole thing match, which is probably not what you want.

You might get it to work just by turning off 'greedy' matching for '*'.










--

Comment By: Arno Bakker (abakker)
Date: 2007-06-14 08:06

Message:
Logged In: YES 
user_id=216477
Originator: YES

File Added: page.html

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1737127&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1739118 ] Investigated ref leak report related to thread(regrtest.py -

2007-06-18 Thread SourceForge.net
Bugs item #1739118, was opened at 2007-06-18 23:43
Message generated for change (Comment added) made by ocean-city
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1739118&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Threads
Group: Python 2.6
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Hirokazu Yamamoto (ocean-city)
Assigned to: Nobody/Anonymous (nobody)
Summary: Investigated ref leak report related to thread(regrtest.py -

Initial Comment:
Hello. I investigated ref leak report related to thread.
Please run python regrtest.py -R :: test_leak.py (attached file)
Sometimes ref leak is reported.
# I saw this as regression failure on python-checkins.

# total ref count 92578 -> 92669
  _Condition 2
  Thread 6
  _Event 1
  bool 10
  instancemethod 1
  code 2
  dict 9
  file 1
  frame 3
  function 2
  int 1
  list 2
  builtin_function_or_method 5
  NoneType 2
  str 27
  thread.lock 7
  tuple 5
  type 5

Probably this happens because threading.Thread is implemented as Python
code,
(expecially threading.Thread#join), the code of regrtest.py

if i >= nwarmup:
deltas.append(sys.gettotalrefcount() - rc - 2)

can run before thread really quits. (before Moudles/threadmodule.c
t_bootstrap()'s

 Py_DECREF(boot->func);
 Py_DECREF(boot->args);
 Py_XDECREF(boot->keyw);

runs)

So I experimentally inserted the code to wait for thread termination.
(attached file experimental.patch) And I confirmed error was gone.

# Sorry for hackish patch which only runs on windows. It should run
# on other platforms if you replace Sleep() in Python/sysmodule.c
# sys_debug_ref_leak_leave() with appropriate function.


--

>Comment By: Hirokazu Yamamoto (ocean-city)
Date: 2007-06-19 02:48

Message:
Logged In: YES 
user_id=1200846
Originator: YES

Sorry, I updated the patch. Moved

fprintf(stderr, "= thread leave\n");
current_thread_count--;

in threadmodule.c just before PyThread_exit_thread().
File Added: archive.zip

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1739118&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1682241 ] Problems with urllib2 read()

2007-06-18 Thread SourceForge.net
Bugs item #1682241, was opened at 2007-03-16 16:00
Message generated for change (Comment added) made by andyshorts
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1682241&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Lucas Malor (lucas_malor)
Assigned to: Nobody/Anonymous (nobody)
Summary: Problems with urllib2 read()

Initial Comment:
urllib2 objects opened with urlopen() does not have the method seek() as file 
objects. So reading only some bytes from opened urls is pratically forbidden.

An example: I tried to open an url and check if it's a gzip file. If IOError is 
raised I read the file (to do this I applied the #1675951 patch: 
https://sourceforge.net/tracker/index.php?func=detail&aid=1675951&group_id=5470&atid=305470
 )

But after I tried to open the file as gzip, if it's not a gzip file the current 
position in the urllib object is on the second byte. So read() returns the data 
from the 3rd to the last byte. You can't check the header of the file before 
storing it on hd. Well, so what is urlopen() for? If I must store the file by 
url on hd and reload it, I can use urlretrieve() ...

--

Comment By: AndyShorts (andyshorts)
Date: 2007-06-18 22:28

Message:
Logged In: YES 
user_id=1563697
Originator: NO

While a newbie to Python I would like to point out that RFC2616 (the
HTTP/1.1 spec) does allow for byte ranges to be requested and that these
could be used to mimic seek &c. In order to do so though the client must
retain the file pointer itself etc.

However, given my experience of real world servers you are never sure if
the target will support them - it need not - and even if it does proxies
(both visible and transparent) are free to utterly trash these requests as
they see fit. I've gained this the hard way while writing HTTP client
software :-)

The only safe thing to do with HTTP data is treat it as a stream and if
you want to seek through it then your choices are:

 a. Buffer it locally and access it that way
 b. Keep opening and closing the resource and reading through to where you
want to be.

imo the urllib.urlopen acts in the only sane way possible.

[btw this is my first post so sorry if this is OT - though I notice this
thread has gone into torpor]

--

Comment By: Zacherates (maenpaa)
Date: 2007-04-27 11:57

Message:
Logged In: YES 
user_id=1421845
Originator: NO

> import urllib

> urlobj = urllib.urlopen("someurl")
> header = urlobj.read(1)
> # some other operations (no other urlobj.read())

> contents = header + urlobj.read()

This is effectively buffering the output, which is a perfectly acceptable
solution...  although I'd write like this:

import urllib

class BufferedReader(object):
   def __init__(self, fileobj, buffsize = 8192):
   
   def mark(self, maxbytes = 8192):

   def seek(self):

br = BufferedReader(urllib.urlopen())
br.mark()
header = br.read(1)

br.seek()
contents = br.read()

That way you store all bytes that have been read.  Rather than hoping
nobody calls read().


> On the contrary I'm pretty sure using a sequential access this can be
done
> without doing these workarounds.

Right now sequential access is provided without keeping a copy in memory. 
The issue arises when you want random access, however; urlobjs have no
indication as to whether you're going to call seek().  As such, to provide
the method they must assume you will call it.  Therefore, regardless of
whether seek() is actually called or not, a copy must be kept to offer the
*possibility* that it can be called.

You can work around this by offering the degenerate seek() provided by
BufferedReader, but that's functionality that belongs in it's own class
anyway.


> anyway I don't understand a thing: HTTP can't delegate the server to
> seek() the file?

For one thing, its not supported by the standard.  For another, it would
be a waste of server resources, bandwidth and to top it off it would be
really slow... even slower than using StringIO.  HTTP resources are not
simply files served up by httpd, they can also be dynamically generated
content... How is an HTTP server supposed to seek backward and forward in a
page that is programatically generated? Go try an tell web developers that
they need to keep a copy of every page requested indefinitely, in case you
want to send a SEEK request.




HTTP resources are not local.  To treat them as local you must make then
local by putting them in a container, such as StringIO, a buffer or a local
file. It's that simple.  To try and abstract this fact would result in
major performance issues or unreliability, or both.


[ python-Bugs-1739118 ] Investigated ref leak report related to thread(regrtest.py -

2007-06-18 Thread SourceForge.net
Bugs item #1739118, was opened at 2007-06-18 23:43
Message generated for change (Comment added) made by ocean-city
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1739118&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Threads
Group: Python 2.6
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Hirokazu Yamamoto (ocean-city)
Assigned to: Nobody/Anonymous (nobody)
Summary: Investigated ref leak report related to thread(regrtest.py -

Initial Comment:
Hello. I investigated ref leak report related to thread.
Please run python regrtest.py -R :: test_leak.py (attached file)
Sometimes ref leak is reported.
# I saw this as regression failure on python-checkins.

# total ref count 92578 -> 92669
  _Condition 2
  Thread 6
  _Event 1
  bool 10
  instancemethod 1
  code 2
  dict 9
  file 1
  frame 3
  function 2
  int 1
  list 2
  builtin_function_or_method 5
  NoneType 2
  str 27
  thread.lock 7
  tuple 5
  type 5

Probably this happens because threading.Thread is implemented as Python
code,
(expecially threading.Thread#join), the code of regrtest.py

if i >= nwarmup:
deltas.append(sys.gettotalrefcount() - rc - 2)

can run before thread really quits. (before Moudles/threadmodule.c
t_bootstrap()'s

 Py_DECREF(boot->func);
 Py_DECREF(boot->args);
 Py_XDECREF(boot->keyw);

runs)

So I experimentally inserted the code to wait for thread termination.
(attached file experimental.patch) And I confirmed error was gone.

# Sorry for hackish patch which only runs on windows. It should run
# on other platforms if you replace Sleep() in Python/sysmodule.c
# sys_debug_ref_leak_leave() with appropriate function.


--

>Comment By: Hirokazu Yamamoto (ocean-city)
Date: 2007-06-19 10:13

Message:
Logged In: YES 
user_id=1200846
Originator: YES

Umm, maybe still not enough? applied this patch (fix for 3 str leaks)
test_urllib2_localnet.py  still reports leaks sometimes.

Index: Lib/test/test_urllib2_localnet.py
===
--- Lib/test/test_urllib2_localnet.py   (revision 56002)
+++ Lib/test/test_urllib2_localnet.py   (working copy)
@@ -208,7 +208,7 @@
 testing.
 """
 
-digest_auth_handler = DigestAuthHandler()
+digest_auth_handler = None
 
 def log_message(self, format, *args):
 # Uncomment the next line for debugging.
@@ -240,6 +240,7 @@
 PROXY_URL = "http://127.0.0.1:%d"; % PORT
 
 def setUp(self):
+FakeProxyHandler.digest_auth_handler = DigestAuthHandler()
 FakeProxyHandler.digest_auth_handler.set_users({
 self.USER : self.PASSWD
 })
@@ -257,6 +258,7 @@
 
 def tearDown(self):
 self.server.stop()
+FakeProxyHandler.digest_auth_handler = None
 
 def test_proxy_with_bad_password_raises_httperror(self):
 self._digest_auth_handler.add_password(self.REALM, self.URL,

///

test_urllib2_localnet leaked [2, 0, 0, 0] references, sum=2

# it is now rare case though

--

Comment By: Hirokazu Yamamoto (ocean-city)
Date: 2007-06-19 02:48

Message:
Logged In: YES 
user_id=1200846
Originator: YES

Sorry, I updated the patch. Moved

fprintf(stderr, "= thread leave\n");
current_thread_count--;

in threadmodule.c just before PyThread_exit_thread().
File Added: archive.zip

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1739118&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com