[ python-Feature Requests-1702036 ] Turtle isn't thread-safe (crashes)

2007-04-18 Thread SourceForge.net
Feature Requests item #1702036, was opened at 2007-04-17 03:29
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1702036&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.6
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: lomm (korka)
Assigned to: Nobody/Anonymous (nobody)
Summary: Turtle isn't thread-safe (crashes)

Initial Comment:
These are a few examples of errors during code-reentry in the turtle module:

System tested: Windows XP sp2, Python 2.5

1. turtle.circle fails if the tkinter is closed while drawing.

# Code example:
import turtle
turtle.circle(100)
# close the tkinter window while the circle is drawing
# will give an "invalid command name" exception



2. using multiple inheritance, it's possible to draw more than 1 turtle running 
around at a time. This works part of the time, but crashes python completely on 
occasions.

# Code example:
import turtle, random
from threading import Thread

class Ninja(Thread, turtle.Turtle):
'A ninja is a threaded turtle'

def __init__(self):
# constructors
Thread.__init__(self)
turtle.Turtle.__init__(self)

# where will i go?
self.Direction = random.randint(-180,180)

def run(self):
# that way!
self.left(self.Direction)

# march 'forward'
for i in range(50):
self.forward(16*random.random())
self.left(22 - 45*random.random())




ninjas = []
for i in range(3):
ninjas.append(Ninja())
ninjas[-1].start()


--

>Comment By: Raymond Hettinger (rhettinger)
Date: 2007-04-19 01:58

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

As Josiah says, the current docs do not make any promises about
thread-safety.  So, this isn't a bug.

That being said, it would be nice to offer a way to have multiple turtles
running around under the control of different threads.

--

Comment By: Josiah Carlson (josiahcarlson)
Date: 2007-04-19 00:12

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

Does Turtle claim to be thread safe in the documentation?  Should we
explicitly state that Turtle is not thread safe?  Should we also say,
"don't close the turtle window while it is drawing"?

--

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



[ python-Bugs-1701409 ] Segfault in c_char_p of ctypes

2007-04-18 Thread SourceForge.net
Bugs item #1701409, was opened at 2007-04-16 03:45
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1701409&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: Extension Modules
Group: None
Status: Open
Resolution: None
>Priority: 6
Private: No
Submitted By: sebastien Martini (seb_martini)
Assigned to: Thomas Heller (theller)
Summary: Segfault in c_char_p of ctypes

Initial Comment:
Hi,

I experienced a segmentation fault (when providing a wrong argument type to 
c_char_p) in the ctypes module under Linux and with the version 2.5 .


sundae:~$ python
Python 2.5.1c1 (release25-maint, Apr  6 2007, 22:02:36) 
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import *
>>> c_char_p(42)
zsh: segmentation fault (core dumped)  python
sundae:~$  


Regards,

Sebastien Martini


--

>Comment By: Neal Norwitz (nnorwitz)
Date: 2007-04-18 23:58

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

> Do other platforms have a function that can do this check?

There's no platform independent way to do this.

I don't know anything about ctypes, but what might be a way to handle this
is providing a way to convert an integer into a pointer (like a void*). 
Then all these routines could accept this void* type that you would define,
but not accept a raw integer.  That means people would still have access to
do the same thing they can currently do, but it would be clearer that they
are playing with fire by converting any int into a pointer.

There are so many ways to use ctypes to crash, I'm not sure if this is
worth fixing, except perhaps in the docs to point out the issues.

--

Comment By: Thomas Heller (theller)
Date: 2007-04-18 12:20

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

This is a difficult issue.  The integer (which is interpreted as address)
is allowed because some libraries use 'char *' pointers initialized to
small, invalid addresses for special purposes.

On windows, printing a c_char_p(42) does not crash, it raises a ValueError
instead:
>>> from ctypes import *
>>> c_char_p(42)
Traceback (most recent call last):
  File "", line 1, in 
ValueError: invalid string pointer 0x00B20B48
>>>

Windows does this by checking if there is a valid string at the address
(see Modules/_ctypes/cfield.c, line 1366) by calling the IsBadStringPointer
api function.  Do other platforms have a function that can do this check?

If not, I'm afraid we would have to give up on the very convenient repr of
'normal' c_char_p instances:

>>> c_char_p("foo bar")
c_char_p('foo bar')
>>>

and only print the address (at least on non-windows).

--

Comment By: Neal Norwitz (nnorwitz)
Date: 2007-04-18 00:37

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

Thanks for the bug report Sebastien.

This bug occurs in 2.5 and in the trunk, so it's not a regression. 
Thomas, could you take a look?  Integers are specifically allowed here
(floats are not).  The problem is when trying to print the repr:

#0  PyString_FromString (str=0x2a ) at
Objects/stringobject.c:108
#1  z_get (ptr=0x2ae1aa9d6450, size=8) at Modules/_ctypes/cfield.c:1373
#2  Simple_get_value (self=0x2ae1aa9d63f8) at
Modules/_ctypes/_ctypes.c:4007
#3  Simple_repr (self=0x2ae1aa9d63f8) at Modules/_ctypes/_ctypes.c:4095
#4  PyObject_Repr (v=0x2ae1aa9d63f8) at Objects/object.c:361


--

Comment By: sebastien Martini (seb_martini)
Date: 2007-04-16 12:40

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

c_wchar_p also contains this bug.




--

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



[ python-Feature Requests-1686390 ] csv sniff example

2007-04-18 Thread SourceForge.net
Feature Requests item #1686390, was opened at 2007-03-22 17:04
Message generated for change (Settings changed) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1686390&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: Documentation
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Thomas Guettler (guettli)
>Assigned to: Skip Montanaro (montanaro)
Summary: csv sniff example

Initial Comment:
Hi,

I think the csv module misses an example for the
nice sniff method:

import csv
dialect=csv.Sniffer().sniff(open(csvfile).read(1024))
fd=open(csvfile)
for row in csv.reader(fd, dialect):
for col in row:
print col,
print


--

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



[ python-Bugs-1700821 ] audioop module - request to add a note

2007-04-18 Thread SourceForge.net
Bugs item #1700821, was opened at 2007-04-14 18:07
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1700821&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: Documentation
Group: None
Status: Open
>Resolution: Accepted
Priority: 5
Private: No
Submitted By: ncryptor (ncryptor)
>Assigned to: Raymond Hettinger (rhettinger)
Summary: audioop module - request to add a note

Initial Comment:
The audioop function lin2lin converts sample sizes of linear pcm fragments.
However, when converting to 8-bit, there is a pitfall (that wasted for me a few 
hours).
In some audio formats, such as .WAV files, 16 and 32 bit samples are signed, 
but 8 bit samples are unsigned. So when converting from 2 to 1 byte wide 
samples, you need to also add 128 to the result.
Example code:

new_frames = audioop.lin2lin(frames, old_width, new_width)
if 1 == new_width:
   new_frames = audioop.bias(new_frames, 1, 128)

the same, in reverse, has to be applied when converting from 8 to 16 or 32 bit 
width samples.

This wasted so much time for me and is hardly documented.


--

>Comment By: Raymond Hettinger (rhettinger)
Date: 2007-04-19 01:45

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

I will add a note.

--

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



[ python-Feature Requests-1701452 ] Feature request: Comparing regexps

2007-04-18 Thread SourceForge.net
Feature Requests item #1701452, was opened at 2007-04-16 07:28
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1701452&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: None
>Status: Closed
>Resolution: Rejected
Priority: 5
Private: No
Submitted By: Thomas Dybdahl Ahle (thomasda)
Assigned to: Gustavo Niemeyer (niemeyer)
Summary: Feature request: Comparing regexps

Initial Comment:
It would be very nice with a function in the re module to compare two regular 
expressions and see how they overlap.
Return value would perhaps be an a constant like DISJOINT, SUBSET etc.

--

>Comment By: Raymond Hettinger (rhettinger)
Date: 2007-04-19 01:44

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

Am closing the feature request because it has very little chance of making
it into the core distribution without being a third-party module first. 
The existing implementation is already somewhat difficult to maintain and
we don't want to make that worse.  Also, the new functionality is of
interest to only a small subset of the re module users.

If you do write it, respect the GPL license on the SML code and take some
care to make sure you can license your new code in any way you see fit.



--

Comment By: Thomas Dybdahl Ahle (thomasda)
Date: 2007-04-18 09:33

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

I talked with the guy who wrote the ZZ comparator.

"""I can give you the source code under the GPL if you like. However, I  
think it would be difficult to port to python. It's 1100 lines of  
very SML-style mostly-uncommented code. Do you know SML?

It's available at svn://mlton.org/mltonlib/trunk/ca/terpstra/regexp.  
I would expect credit for the algorithm. :-) Let me know if you  
succeed in porting it."""

I don't know any SML though.
If anybody does or can write a python equaliant of the algorithm:

"""1. Parse the regular expression (in GNU regular expression syntax)
2. Convert that parse tree into an NFA
3. Convert the NFA into a DFA by an algorithm I invented (it's why I
wrote this program; I thought of the algorithm and found it amusing
to see it in action)

For comparing regular expressions I take the following additional  
steps
4. Combine the two DFA's (with the cross product)
4a. For finding common words, I intersect them
4b. For finding words in A, but not B, I intersect A with the negated
DFA of B
4c. ...
5. Find the minimal DFA corresponding to this intersection
6. Run a weighted depth-first search (similar to Dijkstra's) to find
the least-weighted path from the initial state to an accepting state
(the weighting makes it prefer human readable characters in the
examples)"""

It could be cool.
Otherwise I can also try to learn sml and port it.

--

Comment By: Thomas Dybdahl Ahle (thomasda)
Date: 2007-04-17 02:51

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

I found this page with the function to do so:
http://terpstra.ca/compare.html

I also found this thread:
http://bumppo.net/lists/fun-with-perl/1999/09/msg0.html which discusses
how to do this with some canonical formed expressions. 

A function like this would really be able to speed some applications up,
which matches a lot of strings with a number of expressions. If you know
which ones are disjoint, you can break the test when one test matches.

--

Comment By: Raymond Hettinger (rhettinger)
Date: 2007-04-16 15:43

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

Can this be done in the existing implementation by comparing the racetrack
diagrams (character transitions)?

Thomas, do you know of anywhere this have been done (third-party modules
or in other languages)?

--

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



[ python-Feature Requests-1702681 ] Prevent textwrap from breaking words at hyphens

2007-04-18 Thread SourceForge.net
Feature Requests item #1702681, was opened at 2007-04-18 01:40
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1702681&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: Matt Kraai (kraai)
>Assigned to: Greg Ward (gward)
Summary: Prevent textwrap from breaking words at hyphens

Initial Comment:
I'm using textwrap to wrap text that contains URLs that contain hyphens.  When 
it wraps these URLs after a hyphen, it breaks the URL.  I wish there was a way 
to prevent it from doing so.

--

>Comment By: Raymond Hettinger (rhettinger)
Date: 2007-04-19 01:37

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

FWIW, one workaround is to "monkey patch" the module:

  textwrap.TextWrapper.wordsep_re =
re.compile(r'(\s+|(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))')

Another workaround is to "hide" the hyphens during wrapping and then
restore them.
  
  def myfill(text, width=70, **kwargs):
 althyphen = chr(127)
 text = text.replace('-', althyphen)
 result = wrap(text, width, **kwargs)
 return result.replace(althyphen, '-')

That being said, I'm +1 on adding a keyword argument treating hyphens as
non-breaking.


--

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



[ python-Bugs-1703178 ] link_objects in setup.cfg crashes build

2007-04-18 Thread SourceForge.net
Bugs item #1703178, was opened at 2007-04-18 12:03
Message generated for change (Settings changed) made by nnorwitz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1703178&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: Python 2.4
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Markus Schatten (mschatte)
Assigned to: Nobody/Anonymous (nobody)
Summary: link_objects in setup.cfg crashes build

Initial Comment:
When I put the following into setup.cfg:

---

[build_ext]
include_dirs = 
/home/mschatte/myPackages/XSB/config/i686-pc-linux-gnu:/home/mschatte/myPackages/XSB/emu
link_objects = 
/home/mschatte/myPackages/XSB/config/i686-pc-linux-gnu/saved.o/xsb.o

---

in order to link a c extension to another object which should reside on the 
users computer, I get the following error (tested on two kubuntu machines, 
python 2.4):

# python setup.py build
Distribution.parse_config_files():
  reading setup.cfg
options (after parsing config files):
option dict for 'build_ext' command:
  {'include_dirs': ('setup.cfg',

'/home/mschatte/myPackages/XSB/config/i686-pc-linux-gnu:/home/mschatte/myPackages/XSB/emu'),
   'link_objects': ('setup.cfg',

'/home/mschatte/myPackages/XSB/config/i686-pc-linux-gnu/saved.o/xsb.o')}
options (after parsing command line):
option dict for 'build' command:
  {}
option dict for 'build_ext' command:
  {'include_dirs': ('setup.cfg',

'/home/mschatte/myPackages/XSB/config/i686-pc-linux-gnu:/home/mschatte/myPackages/XSB/emu'),
   'link_objects': ('setup.cfg',

'/home/mschatte/myPackages/XSB/config/i686-pc-linux-gnu/saved.o/xsb.o')}
running build
Distribution.get_command_obj(): creating 'build' command object
running build_py
Distribution.get_command_obj(): creating 'build_py' command object
creating build
creating build/lib.linux-i686-2.4
copying dbms.py -> build/lib.linux-i686-2.4
copying __init__.py -> build/lib.linux-i686-2.4
copying f.py -> build/lib.linux-i686-2.4
copying interface.py -> build/lib.linux-i686-2.4
copying py2f.py -> build/lib.linux-i686-2.4
copying reasonable.py -> build/lib.linux-i686-2.4
creating build/lib.linux-i686-2.4/xsb_swig
copying xsb_swig/__init__.py -> build/lib.linux-i686-2.4/xsb_swig
copying xsb_swig/xsb.py -> build/lib.linux-i686-2.4/xsb_swig
running build_ext
Distribution.get_command_obj(): creating 'build_ext' command object
  setting options for 'build_ext' command:
link_objects = 
/home/mschatte/myPackages/XSB/config/i686-pc-linux-gnu/saved.o/xsb.o (from 
setup.cfg)
include_dirs = 
/home/mschatte/myPackages/XSB/config/i686-pc-linux-gnu:/home/mschatte/myPackages/XSB/emu
 (from setup.cfg)
building 'xsb_swig._xsb' extension
creating build/temp.linux-i686-2.4
creating build/temp.linux-i686-2.4/xsb_swig
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O2 -Wall -Wstrict-prototypes 
-fPIC -I/home/mschatte/myPackages/XSB/config/i686-pc-linux-gnu 
-I/home/mschatte/myPackages/XSB/emu -I/usr/include/python2.4 -c 
xsb_swig/swig_xsb_wrap.c -o build/temp.linux-i686-2.4/xsb_swig/swig_xsb_wrap.o
In file included from xsb_swig/swig_xsb.h:25,
 from xsb_swig/swig_xsb_wrap.c:2346:
/home/mschatte/myPackages/XSB/emu/cinterf.h:259: warning: function declaration 
isn’t a prototype
/home/mschatte/myPackages/XSB/emu/cinterf.h:262: warning: function declaration 
isn’t a prototype
/home/mschatte/myPackages/XSB/emu/cinterf.h:285: warning: function declaration 
isn’t a prototype
/home/mschatte/myPackages/XSB/emu/cinterf.h:286: warning: function declaration 
isn’t a prototype
/home/mschatte/myPackages/XSB/emu/cinterf.h:294: warning: function declaration 
isn’t a prototype
/home/mschatte/myPackages/XSB/emu/cinterf.h:296: warning: function declaration 
isn’t a prototype
/home/mschatte/myPackages/XSB/emu/cinterf.h:300: warning: function declaration 
isn’t a prototype
/home/mschatte/myPackages/XSB/emu/cinterf.h:304: warning: function declaration 
isn’t a prototype
/home/mschatte/myPackages/XSB/emu/cinterf.h:305: warning: function declaration 
isn’t a prototype
In file included from xsb_swig/swig_xsb_wrap.c:2346:
xsb_swig/swig_xsb.h:101: warning: function declaration isn’t a prototype
xsb_swig/swig_xsb.h:135: warning: function declaration isn’t a prototype
xsb_swig/swig_xsb.h:137: warning: function declaration isn’t a prototype
xsb_swig/swig_xsb.h:141: warning: function declaration isn’t a prototype
xsb_swig/swig_xsb.h:145: warning: function declaration isn’t a prototype
xsb_swig/swig_xsb.h:146: warning: function declaration isn’t a prototype
xsb_swig/swig_xsb_wrap.c:2498: warning: function declaration isn’t a prototype
xsb_swig/swig_xsb_wrap.c:5124: warning: function declaration isn’t a prototype
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O2 -Wall -Wstrict-prototypes 
-fPIC 

[ python-Bugs-1702036 ] Turtle isn't thread-safe (crashes)

2007-04-18 Thread SourceForge.net
Bugs item #1702036, was opened at 2007-04-17 01:29
Message generated for change (Comment added) made by josiahcarlson
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1702036&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: lomm (korka)
Assigned to: Nobody/Anonymous (nobody)
Summary: Turtle isn't thread-safe (crashes)

Initial Comment:
These are a few examples of errors during code-reentry in the turtle module:

System tested: Windows XP sp2, Python 2.5

1. turtle.circle fails if the tkinter is closed while drawing.

# Code example:
import turtle
turtle.circle(100)
# close the tkinter window while the circle is drawing
# will give an "invalid command name" exception



2. using multiple inheritance, it's possible to draw more than 1 turtle running 
around at a time. This works part of the time, but crashes python completely on 
occasions.

# Code example:
import turtle, random
from threading import Thread

class Ninja(Thread, turtle.Turtle):
'A ninja is a threaded turtle'

def __init__(self):
# constructors
Thread.__init__(self)
turtle.Turtle.__init__(self)

# where will i go?
self.Direction = random.randint(-180,180)

def run(self):
# that way!
self.left(self.Direction)

# march 'forward'
for i in range(50):
self.forward(16*random.random())
self.left(22 - 45*random.random())




ninjas = []
for i in range(3):
ninjas.append(Ninja())
ninjas[-1].start()


--

Comment By: Josiah Carlson (josiahcarlson)
Date: 2007-04-18 22:12

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

Does Turtle claim to be thread safe in the documentation?  Should we
explicitly state that Turtle is not thread safe?  Should we also say,
"don't close the turtle window while it is drawing"?

--

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



[ python-Bugs-1700912 ] questionable results from IDLE, Windows, & several built-in

2007-04-18 Thread SourceForge.net
Bugs item #1700912, was opened at 2007-04-15 01:28
Message generated for change (Comment added) made by josiahcarlson
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1700912&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: Windows
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: bavantgarde314 (bavantgarde314)
Assigned to: Nobody/Anonymous (nobody)
Summary: questionable results from IDLE, Windows, & several built-in 

Initial Comment:
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on 
win32

Windows(ME)


Attachment reveals questionable results from IDLE, Windows, & several built-in 
functions.

Under IDLE: function swapcase() updates 120 characters.
Under Windows (dos-screen) or a Windows ide swapcase() updates only 52 
characters: ord values 65-90 for (uppercase)A-Z and 97-122 for (lowercase)a-z.
   
Under IDLE: functions lower() & upper() return different results than swapcase()
for hex values:  8a,  8c,  8e,  9a,  9c,  9e,  9f, ff  
 or ord values  138, 140, 142, 154, 156, 158, 159, 255
 or characters   ŠŒŽšœžŸÿ




--

Comment By: Josiah Carlson (josiahcarlson)
Date: 2007-04-18 22:02

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

The behaviors of those functions depend on the locale.

Check the results of:

import locale
locale.getlocale()


--

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



[ python-Bugs-1124861 ] subprocess fails on GetStdHandle in interactive GUI

2007-04-18 Thread SourceForge.net
Bugs item #1124861, was opened at 2005-02-17 16:23
Message generated for change (Comment added) made by grante
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1124861&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: Windows
Group: Python 2.4
Status: Closed
Resolution: Fixed
Priority: 7
Private: No
Submitted By: davids (davidschein)
Assigned to: Nobody/Anonymous (nobody)
Summary: subprocess fails on GetStdHandle in interactive GUI

Initial Comment:
Using the suprocess module from with IDLE or PyWindows,
it appears that calls GetStdHandle (STD__HANDLE)
returns None, which causes an error.  (All appears fine
on Linux, the standard Python command-line, and ipython.)

For example:
>>> import subprocess
>>> p = subprocess.Popen("dir", stdout=subprocess.PIPE)

Traceback (most recent call last):
  File "", line 1, in -toplevel-
p = subprocess.Popen("dir", stdout=subprocess.PIPE)
  File "C:\Python24\lib\subprocess.py", line 545, in
__init__
(p2cread, p2cwrite,
  File "C:\Python24\lib\subprocess.py", line 605, in
_get_handles
p2cread = self._make_inheritable(p2cread)
  File "C:\Python24\lib\subprocess.py", line 646, in
_make_inheritable
DUPLICATE_SAME_ACCESS)
TypeError: an integer is required

The error originates in the mswindows implementation of
_get_handles.  You need to set one of stdin, stdout, or
strerr because the first line in the method is:
if stdin == None and stdout == None and stderr == None:
...return (None, None, None, None, None, None)

I added "if not handle: return GetCurrentProcess()" to
_make_inheritable() as below and it worked.  Of course,
I really do not know what is going on, so I am letting
go now...

def _make_inheritable(self, handle):
..."""Return a duplicate of handle, which is inheritable"""
...if not handle: return GetCurrentProcess()
...return DuplicateHandle(GetCurrentProcess(), handle,
GetCurrentProcess(),
0, 1,
DUPLICATE_SAME_ACCESS)


--

Comment By: Grant Edwards (grante)
Date: 2007-04-18 19:20

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

I _think_ this traceback from a program running under Pythonw 2.4.3
Enthought Edition on WinXP is caused by the same underlying bug (in this
case, stdin was set to PIPE, and stdout/stderr were both left to default):

 File "subprocess.pyc", line 533, in __init__
 File "subprocess.pyc", line 607, in _get_handles
 File "subprocess.pyc", line 634, in _make_inheritable
   WindowsError: [Errno 6] The handle is invalid



--

Comment By: Peter Åstrand (astrand)
Date: 2007-02-06 15:43

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

I've applied 1124861.3.patch to both trunk (rev 53646) and the
release25-maint branch (rev 53647). 

--

Comment By: Peter Åstrand (astrand)
Date: 2007-01-30 20:05

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

Please review 1124861.3.patch. 

--

Comment By: Peter Åstrand (astrand)
Date: 2007-01-30 20:04

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

File Added: 1124861.3.patch

--

Comment By: Peter Åstrand (astrand)
Date: 2007-01-29 21:42

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

Some ideas of possible solutions for this bug:

1) As Roger Upole suggests, throw an readable error when GetStdHandle
fails. This would not really change much, besides of subprocess being a
little less confusing. 

2) Automatically create PIPEs for those handles that fails. The PIPE could
either be left open or closed. A WriteFile in the child would get
ERROR_BROKEN_PIPE, if the parent has closed it. Not as good as
ERROR_INVALID_HANDLE, but pretty close. (Or should I say pretty closed?
:-)

3) Try to attach the handles to a NUL device, as 1238747 suggests. 

4) Hope for the best and actually pass invalid handles in
startupinfo.hStdInput, startupinfo.hStdOutput, or
startupinfo.hStdError. It would be nice if this was possible: If
GetStdHandle fails in the current process, it makes sense that GetStdHandle
will fail in the child as well. But, as far as I understand, it's not
possible or safe to pass invalid handles in the startupinfo structure. 

Currently, I'm leaning towards solution 2), with closing the parents PIPE
ends. 

--

Comment By: Peter Åstrand (astrand)
Date: 2007-01-22 19:36

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

The following bugs have been marked as duplicate of this bug:

1358527
1603

[ python-Bugs-1701409 ] Segfault in c_char_p of ctypes

2007-04-18 Thread SourceForge.net
Bugs item #1701409, was opened at 2007-04-16 12:45
Message generated for change (Comment added) made by theller
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1701409&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: Extension Modules
Group: None
Status: Open
Resolution: None
Priority: 7
Private: No
Submitted By: sebastien Martini (seb_martini)
Assigned to: Thomas Heller (theller)
Summary: Segfault in c_char_p of ctypes

Initial Comment:
Hi,

I experienced a segmentation fault (when providing a wrong argument type to 
c_char_p) in the ctypes module under Linux and with the version 2.5 .


sundae:~$ python
Python 2.5.1c1 (release25-maint, Apr  6 2007, 22:02:36) 
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import *
>>> c_char_p(42)
zsh: segmentation fault (core dumped)  python
sundae:~$  


Regards,

Sebastien Martini


--

>Comment By: Thomas Heller (theller)
Date: 2007-04-18 21:20

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

This is a difficult issue.  The integer (which is interpreted as address)
is allowed because some libraries use 'char *' pointers initialized to
small, invalid addresses for special purposes.

On windows, printing a c_char_p(42) does not crash, it raises a ValueError
instead:
>>> from ctypes import *
>>> c_char_p(42)
Traceback (most recent call last):
  File "", line 1, in 
ValueError: invalid string pointer 0x00B20B48
>>>

Windows does this by checking if there is a valid string at the address
(see Modules/_ctypes/cfield.c, line 1366) by calling the IsBadStringPointer
api function.  Do other platforms have a function that can do this check?

If not, I'm afraid we would have to give up on the very convenient repr of
'normal' c_char_p instances:

>>> c_char_p("foo bar")
c_char_p('foo bar')
>>>

and only print the address (at least on non-windows).

--

Comment By: Neal Norwitz (nnorwitz)
Date: 2007-04-18 09:37

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

Thanks for the bug report Sebastien.

This bug occurs in 2.5 and in the trunk, so it's not a regression. 
Thomas, could you take a look?  Integers are specifically allowed here
(floats are not).  The problem is when trying to print the repr:

#0  PyString_FromString (str=0x2a ) at
Objects/stringobject.c:108
#1  z_get (ptr=0x2ae1aa9d6450, size=8) at Modules/_ctypes/cfield.c:1373
#2  Simple_get_value (self=0x2ae1aa9d63f8) at
Modules/_ctypes/_ctypes.c:4007
#3  Simple_repr (self=0x2ae1aa9d63f8) at Modules/_ctypes/_ctypes.c:4095
#4  PyObject_Repr (v=0x2ae1aa9d63f8) at Objects/object.c:361


--

Comment By: sebastien Martini (seb_martini)
Date: 2007-04-16 21:40

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

c_wchar_p also contains this bug.




--

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



[ python-Bugs-1703110 ] Incorrect example for add_password()

2007-04-18 Thread SourceForge.net
Bugs item #1703110, was opened at 2007-04-18 12:56
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=1703110&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: Documentation
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Bob Kline (bkline)
Assigned to: Nobody/Anonymous (nobody)
Summary: Incorrect example for add_password()

Initial Comment:
In the documentation for urllib2, the example [1] for using basic HTTP 
authentication has the following code for the call to add_password():

auth_handler.add_password('realm', 'host', 'username', 'password')

This actually worked in earlier (pre-2.4.3) versions of urllib2, but even in 
those older versions, the documentation for HTTPPasswordMgr.add_password() 
makes it clear that a URI must be passed as the second argument to the method, 
not a host name.

Even though the behavior in the library method has changed (passing a full URI 
versions of Python earlier than 2.4.3 didn't work, at least when a non-standard 
port was specified), the documentation has not changed (the add_password() 
documentation specifies a URI, even in the pre-2.4.3 versions of Python) and 
the examples in the documentation for urllib2 still say 'host'.

[1] http://docs.python.org/lib/urllib2-examples.html

--

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



[ python-Feature Requests-1701452 ] Feature request: Comparing regexps

2007-04-18 Thread SourceForge.net
Feature Requests item #1701452, was opened at 2007-04-16 14:28
Message generated for change (Comment added) made by thomasda
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1701452&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: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Thomas Dybdahl Ahle (thomasda)
Assigned to: Gustavo Niemeyer (niemeyer)
Summary: Feature request: Comparing regexps

Initial Comment:
It would be very nice with a function in the re module to compare two regular 
expressions and see how they overlap.
Return value would perhaps be an a constant like DISJOINT, SUBSET etc.

--

>Comment By: Thomas Dybdahl Ahle (thomasda)
Date: 2007-04-18 16:33

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

I talked with the guy who wrote the ZZ comparator.

"""I can give you the source code under the GPL if you like. However, I  
think it would be difficult to port to python. It's 1100 lines of  
very SML-style mostly-uncommented code. Do you know SML?

It's available at svn://mlton.org/mltonlib/trunk/ca/terpstra/regexp.  
I would expect credit for the algorithm. :-) Let me know if you  
succeed in porting it."""

I don't know any SML though.
If anybody does or can write a python equaliant of the algorithm:

"""1. Parse the regular expression (in GNU regular expression syntax)
2. Convert that parse tree into an NFA
3. Convert the NFA into a DFA by an algorithm I invented (it's why I
wrote this program; I thought of the algorithm and found it amusing
to see it in action)

For comparing regular expressions I take the following additional  
steps
4. Combine the two DFA's (with the cross product)
4a. For finding common words, I intersect them
4b. For finding words in A, but not B, I intersect A with the negated
DFA of B
4c. ...
5. Find the minimal DFA corresponding to this intersection
6. Run a weighted depth-first search (similar to Dijkstra's) to find
the least-weighted path from the initial state to an accepting state
(the weighting makes it prefer human readable characters in the
examples)"""

It could be cool.
Otherwise I can also try to learn sml and port it.

--

Comment By: Thomas Dybdahl Ahle (thomasda)
Date: 2007-04-17 09:51

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

I found this page with the function to do so:
http://terpstra.ca/compare.html

I also found this thread:
http://bumppo.net/lists/fun-with-perl/1999/09/msg0.html which discusses
how to do this with some canonical formed expressions. 

A function like this would really be able to speed some applications up,
which matches a lot of strings with a number of expressions. If you know
which ones are disjoint, you can break the test when one test matches.

--

Comment By: Raymond Hettinger (rhettinger)
Date: 2007-04-16 22:43

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

Can this be done in the existing implementation by comparing the racetrack
diagrams (character transitions)?

Thomas, do you know of anywhere this have been done (third-party modules
or in other languages)?

--

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



[ python-Bugs-1699853 ] locale.getlocale() output fails as setlocale() input

2007-04-18 Thread SourceForge.net
Bugs item #1699853, was opened at 2007-04-13 12:26
Message generated for change (Comment added) made by iszegedi
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1699853&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: Bernhard Reiter (ber)
Assigned to: Nobody/Anonymous (nobody)
Summary: locale.getlocale() output fails as setlocale() input 

Initial Comment:
This problem report about the locale module
consists of three closely related parts 
(this is why I have decided to put it in one report).
a) the example in the docs is wrong / missleading
b) under some locale settings python as a defect
c) a test case for the locale module, showing b)
   but useful as general start for a test module.

Details:
a)
Section example:
The line
>>> loc = locale.getlocale(locale.LC_ALL) # get current locale
contradicts that getlocale should not be called with
LC_ALL, as stated in the description of getlocale.
Suggestion is to change the example to be more useful
as getting the locale as first action is not really useful.
It should be "C" anyway which will lead to (None, None)
so the value is already known. It would make more sense to

first set the default locale to the user preferences:
import locale
locale.setlocale(locale.LC_ALL,'')
loc = locale.getlocale(locale.LC_NUMERIC)
locale.setlocale(locale.LC_NUMERIC,"C")
# convert a string here
locale.setlocale(locale.LC_NUMERIC, loc)

_but_ this does not work, see problem b).
What does work is:

import
locale.setlocale(locale.LC_ALL,'')
loc = locale.setlocale(locale.LC_NUMERIC)
locale.setlocale(locale.LC_NUMERIC,"C")
# convert a string here
locale.setlocale(locale.LC_NUMERIC, loc)

Note that all_loc = locale.setlocale(locale.LC_ALL) might contain
several categories (see attached test_locale.py where I needed to decode
this).
'LC_CTYPE=de_DE.UTF-8;LC_NUMERIC=en_GB.utf8;LC_TIME=de_DE.UTF-8;LC_COLLATE=de_DE.UTF-8;LC_MONETARY=de_DE.UTF-8;LC_MESSAGES=de_DE.UTF-8;LC_PAPER=de_DE.UTF-8;LC_NAME=de_DE.UTF-8;LC_ADDRESS=de_DE.UTF-8;LC_TELEPHONE=de_DE.UTF-8;LC_MEASUREMENT=de_DE.UTF-8;LC_IDENTIFICATION=de_DE.UTF-8'


b)
The output of getlocale cannot be used as input to
setlocale sometimes.
Works with
* python2.5 und python2.4 on
  Debian GNU/Linux Etch ppc, de_DE.utf8.

I had failures with
* python2.3, python2.4, python2.5
  on Debian GNU/Linux Sarge ppc, [EMAIL PROTECTED]
* Windows XP SP2
python-2.4.4.msiGerman, see:

>>> import locale
>>> result = locale.setlocale(locale.LC_NUMERIC,"")
>>> print result
German_Germany.1252
>>> got = locale.getlocale(locale.LC_NUMERIC)
>>> print got
('de_DE', '1252')
>>> # works
... locale.setlocale(locale.LC_NUMERIC, result)
'German_Germany.1252'
>>> # fails
... locale.setlocale(locale.LC_NUMERIC, got)
Traceback (most recent call last):
  File "", line 2, in ?
  File "C:\Python24\lib\locale.py", line 381, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting
>>>



--

Comment By: Istvan Szegedi (iszegedi)
Date: 2007-04-18 12:05

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

I could reproduce the problem on Fedora Core 5 with Python 2.4.3.

After tracing down the issue, I found the following:

The problem is in locate.py. There is a function called normalize defined
in the locate.py file. This function is invoked by setlocale function if
the incoming locale argument is not a string. (in your example this
condition is true because locale.getlocale function returns a tuple so got
variable is a tuple.) The normalize function is using an encoding_alias
table which results to translate the full locale into an incorrect version.
What happens in my environment is that there is an incoming value
en_us.utf-8  which is converted to en_us.utf and that is the return value
from normalize function. Then _setlocale low level function invoked in
setlocale function throws an exception when it receives en_us.utf  argument
and it is an unsupported locale setting.


This is the original code snippet in locale.py where it is con

[ python-Bugs-1303614 ] Bypassing __dict__ readonlyness

2007-04-18 Thread SourceForge.net
Bugs item #1303614, was opened at 2005-09-24 23:40
Message generated for change (Comment added) made by arigo
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1303614&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: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Armin Rigo (arigo)
Assigned to: Nobody/Anonymous (nobody)
Summary: Bypassing __dict__ readonlyness

Initial Comment:
The __dict__ attribute of some objects is read-only,
e.g. for type objects.  However, there is a generic
way to still access and modify it (without hacking with
gc.get_referrents(), that is).  This can lead to
obscure crashes.  Attached is an example that shows
a potential "problem" involving putting strange keys
in the __dict__ of a type.

This is probably very minor anyway.  If we wanted to
fix this, we would need a __dict__ descriptor that
looks more cleverly at the object to which it is
applied.

BTW the first person who understand why the attached
program crashes gets a free coffee.

--

>Comment By: Armin Rigo (arigo)
Date: 2007-04-18 09:22

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

I'm skeptical about the whole revision 53997
which introduced not only the unneeded metaclass
condition, but also the strange check when
assigning to __bases__.  I don't think that this
check about __bases__ is correct or relevant or
really fixes any crash.  The link between the
bases and the metaclass of a class is tenuous
anyway: the bases are just used to compute the
metaclass if none is specified explicitly.

As I said on python-dev (with no answer) I am
thinking about reverting r53997 completely.
I'm going to check what I said above a bit more
in-depth first.

--

Comment By: Ziga Seilnacht (zseil)
Date: 2007-04-17 00:42

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

Here is a patch that shold fix the deldict bug.  It also
removes the new condition for metaclasses, because it
isn't needed anymore, and fixes bug #1174712.  These two
changes were needed so that the patch could be properly
tested.

The patch does what Armin suggested; the __dict__ descriptor
looks for a builtin base with tp_dictoffset != 0, and if one
is found, it delegates to that base's __dict__ descriptor.

File Added: modify_dict_bug.diff

--

Comment By: Armin Rigo (arigo)
Date: 2007-02-26 08:23

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

456?  Now that's interesting.  Not 579?

I'm not sure if I ever thought about what the
expected answer should be, but I'd say that
you are correct: 'x.__dict__' should be empty
in the end.  Actually I don't really see how
it manages *not* to be empty in IronPython;
looks like either a very minor detail or a
deeper bug...

--

Comment By: Jeremy Hylton (jhylton)
Date: 2007-02-25 22:36

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

I tried test67.py in IronPython.  It reports that x.hello has the value
456.  Is that the correct behavior?  It seems incorrect to me.  If the
__eq__ method is called, then the object should no longer have either the
Strange() or hello attributes.  They are cleared by reseting __dict__.  Is
that right?

--

Comment By: Jeremy Hylton (jhylton)
Date: 2007-02-25 22:23

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

I tried test67.py in IronPython.  It reports that x.hello has the value
456.  Is that the correct behavior?  It seems incorrect to me.  If the
__eq__ method is called, then the object should no longer have either the
Strange() or hello attributes.  They are cleared by reseting __dict__.  Is
that right?

--

Comment By: Armin Rigo (arigo)
Date: 2006-06-30 07:05

Message:
Logged In: YES 
user_id=4771

Well, try making an "empty" class Foo(object): pass, and see
what magically shows up in Foo.__dict__.keys().  Here is the
__dict__ descriptor used for instances of Foo.  This
descriptor is connected to subtype_dict() and
subtype_setdict() in typeobject.c.

INCREF/DECREFs are in theory missing around every use of the
dictionary returned by _PyObject_GetDictPtr(), because more
or less any such use could remove the dict from the object
from which _PyObject_GetDictPtr() returned from, and so
decref the dict - while it's used.  This might require some
timing, to check the performance impact.

--

Comment By: Brett Cannon (bcannon)
Date: 2006-06-30 01:14

Message:
L

[ python-Bugs-1701449 ] documentation bug in profile module

2007-04-18 Thread SourceForge.net
Bugs item #1701449, was opened at 2007-04-16 21:13
Message generated for change (Comment added) made by quiver
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1701449&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: Documentation
Group: Python 2.5
>Status: Closed
>Resolution: Out of Date
Priority: 5
Private: No
Submitted By: Keith Briggs (kbriggs)
Assigned to: Nobody/Anonymous (nobody)
Summary: documentation bug in profile module

Initial Comment:
At http://docs.python.org/lib/module-profile.html, it says...

This function takes a single argument that has can be passed to the exec 
statement

This doesn't make sense.  Should "has" be deleted?


--

>Comment By: George Yoshida (quiver)
Date: 2007-04-18 17:04

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

This is aleady fixed in the development version of 2.5 and trunk.

With the relase of 2.5.1, the page you specified will be updated.

--

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



[ python-Bugs-1701409 ] Segfault in c_char_p of ctypes

2007-04-18 Thread SourceForge.net
Bugs item #1701409, was opened at 2007-04-16 03:45
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1701409&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: Extension Modules
Group: None
Status: Open
Resolution: None
>Priority: 7
Private: No
Submitted By: sebastien Martini (seb_martini)
>Assigned to: Thomas Heller (theller)
Summary: Segfault in c_char_p of ctypes

Initial Comment:
Hi,

I experienced a segmentation fault (when providing a wrong argument type to 
c_char_p) in the ctypes module under Linux and with the version 2.5 .


sundae:~$ python
Python 2.5.1c1 (release25-maint, Apr  6 2007, 22:02:36) 
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import *
>>> c_char_p(42)
zsh: segmentation fault (core dumped)  python
sundae:~$  


Regards,

Sebastien Martini


--

>Comment By: Neal Norwitz (nnorwitz)
Date: 2007-04-18 00:37

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

Thanks for the bug report Sebastien.

This bug occurs in 2.5 and in the trunk, so it's not a regression. 
Thomas, could you take a look?  Integers are specifically allowed here
(floats are not).  The problem is when trying to print the repr:

#0  PyString_FromString (str=0x2a ) at
Objects/stringobject.c:108
#1  z_get (ptr=0x2ae1aa9d6450, size=8) at Modules/_ctypes/cfield.c:1373
#2  Simple_get_value (self=0x2ae1aa9d63f8) at
Modules/_ctypes/_ctypes.c:4007
#3  Simple_repr (self=0x2ae1aa9d63f8) at Modules/_ctypes/_ctypes.c:4095
#4  PyObject_Repr (v=0x2ae1aa9d63f8) at Objects/object.c:361


--

Comment By: sebastien Martini (seb_martini)
Date: 2007-04-16 12:40

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

c_wchar_p also contains this bug.




--

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