Re: Compiling python from soruce vs RPM ?
On Apr 19, 6:10 am, Paul Boddie [EMAIL PROTECTED] wrote: Since /usr/bin/python isn't found, it doesn't look like there's an existing version of Python that you might overwrite, but it's important to verify such things when installing software. That's where your distribution's packages have an advantage, and it's arguably a better idea to install such packages instead, possibly building them from source if no binary packages exist yet for Python 2.5. (If no source packages exist, you have a bit more work to do.) Paul Thanks. One more question: How to uninstall using the source package? the source package doesn't come with `make uninstall`? -- http://mail.python.org/mailman/listinfo/python-list
Re: Strange terminal behavior after quitting Tkinter application
Chris wrote: But does anyone know why the Tkinter program is doing this to the terminal in the first place? I don't want to have to tell users of my program that they must recover their terminal's sanity each time after running my program. I don't know about Tkinter, but my guess would be that it has to change the terminal settings to do what it does, and you are quitting without restoring the settings. Is there some Tkinter clean up that you have omitted ? Have you ensured that the clean up runs on both normal exit and abnormal exit (eg ^C) ? For example, the curses library (in C) requires an endwin() call before exit to restore settings. If this is omitted, a stty sane is needed to set the terminal to a semi-sensible default. On Unix and similar systems, signal handlers are normally installed to ensure (as far as possible) that the cleanup occurs if the process is killed. This also applies to vi and similar programs that take total control of the terminal. Charles -- http://mail.python.org/mailman/listinfo/python-list
Re: python - dll access (ctypes or swig)
Thomas Heller [EMAIL PROTECTED] wrote: ... and some technical issues such as threading (if COM client and server ... I think that the latter problem (incompatible threading models in the same process) are solved by COM apartments - aren't they? apartment is one threading model, but it still means that your application and your in-process server must be compatible with it (again, we're discussing the fact that out-of-process servers, at a performance price, can do away with these minor limitations). Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: What makes an iterator an iterator?
7stud [EMAIL PROTECTED] wrote: ... Can you explain some of the details of why this code fails: ... def next(self): for word in Norwegian Blue's have beautiful plumage!.split(): yield word Sure, easily: a loop like for x in y: binds an unnamed temporary variable (say _t) to iter(y) and then repeatedly calls _t.next() [or to be pedantic type(_t).next(t)] until that raises StopIteration. Calling a generator, such as this next method, returns an iterator object; calling it repeatedly returns many such iterator objects, and never raises StopIteration, thus obviously producing an unending loop. Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: comparison with None
Terry Reedy [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Should be in the reference manual section on comparisons. Only to this extent: http://www.python.org/doc/2.4/ref/comparisons.html objects of different types always compare unequal, and are ordered consistently but arbitrarily. (This unusual definition of comparison was used to simplify the definition of operations like sorting and the in and not in operators. In the future, the comparison rules for objects of different types are likely to change.) ... Most other types compare unequal unless they are the same object; the choice whether one object is considered smaller or larger than another one is made arbitrarily but consistently within one execution of a program. This does not provide a direct answer to why None comparisons. (As far as I can tell, None is less than any object.) However, Gary Herron's explanation makes sense: this provides a stable sort when None is involved, and meets the criterion that objects of different types must always compare unequal. However this would also be true if None always compared greater than any object, and the current behavior does not seem to be guaranteed. Is that about right? Cheers, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list
Re: Future Python Gui?
The wrapper I maintain works differently, and includes the notebook widget. I've seen the page. You can get to it via Google's cache; just put the url in the box and the one search result returned usually has a cached link. However, that file is completely useless without instructions on how to use it, and there are no instructions within the page or file. That is: - exactly where does it get installed - what else needs to get installed (eg. some dll) - where do you find these other things - where does that something else get installed - how do you import this module - how does use of Tkinter change (if at all) once imported I know all this stuff is obvious to those that have been working with it for a while, but for those of us just getting started with Python, it's immensely frustrating that we're assumed to know all these steps. -- Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: Python COM iterator
[...] On Tue, 2007-04-17 at 16:54 -0500, Larry Bates wrote: Does anyone know if there is a way to make a Python COM object act like a proper iterator in VB/Delphi? [...] After more googling, staring at win32com's code, and a fair bit of trial and error, I've come up with the following working example: # server.py import pythoncom class HelloWorld: _reg_clsid_ = {CAB8BED1-9174-4AAD-ABC5-F377951CB71B} _reg_desc_ = Python Test COM Server _reg_progid_ = Python.TestServer _public_methods_ = ['Next'] _com_interfaces_ = [pythoncom.IID_IEnumVARIANT] def __init__(self): self.numbers=[1,2,3,4,5,6,7,8] def Next(self, count): assert count==1 try: return (self.numbers.pop(0),) except IndexError: return () def _NewEnum(self): import win32com.server.util return win32com.server.util.wrap(self) if __name__=='__main__': import win32com.server.register win32com.server.register.UseCommandLine(HelloWorld) # client.py import win32com.client comobj = win32com.client.Dispatch(Python.TestServer) for x in comobj: print x This works for me on Python 2.5 and pywin32 Build 210, but I don't know whether clients in VB or Delphi are able to use this iterator. -Carsten -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Threads -
S.Mohideen [EMAIL PROTECTED] wrote: Hi All, Can you please suggest a technique in Python where we can spawn few number of worker threads and later map them to a function/s to execute individual Jobs. Any references would be helpful.. I believe I give some examples in the Nutshell, but the basic idea is very simple: start the N worker threads you want in your pool -- they all use .get on the same Queue.Queue instance qI which contains work requests (WRs). A WR could e.g. be a tuple with a Queue qO (or None to indicate that the result is not interesting), a callable, and 0+ arguments (or an empty tuple to request thread termination); the worker thread just calls the callable on the arguments and puts the result to qO (if qO is not None). Many other similar arrangements are possible, depending on your application's exact needs, but I hope the general idea is clear. Alex -- http://mail.python.org/mailman/listinfo/python-list
Question about Tkinter MenuOption variable
Is there anyway to set the individual options in Tkinter to a particular variable. For example, I have a menu option(code is below) which has January, February, March and so on, which I would like to have corresponding values of 01, 02, 03 and so on. Can someone please tell me how to do that within the context of the code I have below - or even totally modify it if you must. Label(self, text = Month ).grid(row = 5, column = 1, sticky = W) OPTIONS = [ Jan, Feb, Mar, Apr, May, June, July, Aug, Sep, Oct, Nov, Dec] default_option = StringVar(self) default_option.set(OPTIONS[0]) self.month_option = OptionMenu(self, default_option, *OPTIONS) self.month_option.grid(row = 5, column = 2, sticky = W) -- http://mail.python.org/mailman/listinfo/python-list
Re: Beginner: Formatting text output (PyQt4)
On Wed, 18 Apr 2007 22:50:14 +, Glen wrote: Ok, obviously, my post didn't come out the way I wanted it to. In the first example from my text file below, the dictionary pairs, constructed from sorted tuples were in straight columns. When I write them to my QTextEdit, however, the columns are no longer straight. Some of the padding inserted by my call to rightJustified() are not equal to the actual size of the text, so some rows are longer than others in the text browser. I know I've encountered this before, perhaps with Java, but I can't remember the solution. How do I get the formatting of my output to the gui to reflect the output I would get to a file using the builtin write() function? Any help is appreciated. Sorry about the confusion. Thanks, G Hello again, I don't blame anyone for not answering my last post, since I obviously hadn't spent much time researching, but I've come a little ways and have another question. How can I better format text output to a QTextEdit object? I'm inserting 5 columns into each row. When I write the info to a file, it looks like the following: 42: 115 26: 114 35: 112 19: 108 16: 107 45: 107 40: 106 5: 105 41: 104 2: 103 9: 102 48: 102 15: 101 22: 101 27: 101 39: 101 43: 101 10: 100 6: 99 34: 99 32: 98 49: 98 20: 97 30: 97 8: 96 17: 96 38: 96 12: 95 14: 95 37: 95 4: 94 13: 94 44: 94 36: 93 3: 92 24: 92 28: 92 31: 91 29: 89 7: 88 1: 87 18: 85 46: 85 33: 84 11: 83 23: 83 47: 82 25: 80 21: 79 50: 56 52: 39 51: 38 53: 36 54: 25 55: 18 When I write the contents of the file to my TextEdit object it comes out uneven, something like this: 42: 11526: 11435: 11219: 10816: 107 45: 10740: 106 5: 10541: 104 2: 103 9: 10248: 10215: 10122: 101 27: 101 39: 10143: 10110: 1006: 9934: 99 32: 9849: 98 20: 9730: 978: 96 17: 9638: 9612: 9514: 95 37: 95 4: 9413: 9444: 9436: 933: 92 24: 92 28: 9231: 9129: 897: 88 1: 8718: 8546: 8533: 8411: 83 23: 8347: 8225: 8021: 7950: 56 52: 3951: 38 53: 3654: 2555: 18 What seems to be happening is that the font that pyqt is using is not fixed width, so I did this: qTxtFormat = QTextCharFormat() qTxtFormat.setFontFixedPitch(True) ui.textEdit.setCurrentCharFormat(qTxtFormat) Also, I tried using the pyqt formatting such as the following: qStr = QtCore.QString( QtCore.QString( str(tL2[i][0]) ).rightJustified(2) + ':' + QtCore.QString( str(tL2[i][1]) ).rightJustified(4) ) This still gives me uneven columns. Any suggestions? Thanks, Glen -- http://mail.python.org/mailman/listinfo/python-list
Weekly Python Patch/Bug Summary
Patch / Bug Summary ___ Patches : 357 open ( +8) / 3745 closed ( +8) / 4102 total (+16) Bugs: 958 open (+19) / 6657 closed ( +9) / 7615 total (+28) RFE : 251 open ( +2) / 280 closed ( +2) / 531 total ( +4) New / Reopened Patches __ Help with Python codebase (2007-04-11) CLOSED http://python.org/sf/1698723 opened by Munawar Update to Macintosh library documentation (2007-04-11) http://python.org/sf/1698768 opened by Kevin Walzer ZipFile.printdir fix (2.5) (2007-04-11) http://python.org/sf/1698915 opened by Alan McIntyre ZipFile.printdir fix (2.6) (2007-04-11) http://python.org/sf/1698917 opened by Alan McIntyre Bastion and rexec message out-of-date (2007-04-12) http://python.org/sf/1698951 opened by Gabriel Genellina getstate/setstate for incremental codecs (2007-04-12) CLOSED http://python.org/sf/1698994 opened by Walter Dörwald replacing char* with const char* in sysmodule.c/.h (2007-04-12) http://python.org/sf/1699259 opened by sebastinas Armin's method cache optimization updated for Python 2.6 (2007-04-13) http://python.org/sf/1700288 opened by Kevin Jacobs VC6 build patch for trunk (2007-04-14) http://python.org/sf/1700463 opened by Hirokazu Yamamoto stack size of python_d.exe on VC6 (2007-04-14) http://python.org/sf/1700467 opened by Hirokazu Yamamoto link_objects in setup.cfg crashes build (2007-04-18) http://python.org/sf/1703178 opened by Markus Schatten silenced a compiler warning (2007-04-18) http://python.org/sf/1703268 opened by Alexander Belopolsky missing declaration in readline.c (2007-04-18) http://python.org/sf/1703270 opened by Alexander Belopolsky bug fix: ctypes truncates 64-bit pointers (2007-04-18) http://python.org/sf/1703286 opened by Alexander Belopolsky fixes non ansi c declarations in libffi (2007-04-18) http://python.org/sf/1703300 opened by Alexander Belopolsky Refactor test_frozen.py to use unittest. (2007-04-18) http://python.org/sf/1703379 opened by Jerry Seutter Patches Closed __ Fix test_urllib on Windows buildbots (2007-04-07) http://python.org/sf/1695862 closed by zseil Don't block on Queue get/put when time is moved back (2007-03-29) http://python.org/sf/1690578 closed by loewis struct.pack() on 64bit architectures (2004-03-30) http://python.org/sf/925932 closed by zseil bug# 1607041: Condition.wait timeout fails on clock change (2006-12-01) http://python.org/sf/1607149 closed by loewis Add IllegalStateError (2007-03-21) http://python.org/sf/1685642 closed by gvanrossum Help with Python codebase (2007-04-11) http://python.org/sf/1698723 closed by gbrandl getstate/setstate for incremental codecs (2007-04-12) http://python.org/sf/1698994 closed by doerwalter Change *args from a tuple to list (2006-05-31) http://python.org/sf/1498441 closed by collinwinter New / Reopened Bugs ___ README is referencing obsolete? http://starship.python.net (2007-04-09) http://python.org/sf/1696740 opened by Jiri Navratil package.pth file name not used as described. (2007-04-09) http://python.org/sf/1697169 opened by cfk winreg module for cygwin? (2007-04-09) http://python.org/sf/1697175 opened by Zooko O'Whielacronx Property with - annotation triggers assert (2007-04-09) http://python.org/sf/1697248 opened by Guido van Rossum types.InstanceType is missing but used by pydoc (2007-04-10) http://python.org/sf/1697782 reopened by gbrandl types.InstanceType is missing but used by pydoc (2007-04-10) http://python.org/sf/1697782 opened by Christian Heimes __getslice__ still used in built-in types (2007-04-10) http://python.org/sf/1697820 opened by Torsten Bronger Segfaults on memory error (2007-04-10) http://python.org/sf/1697916 reopened by gbrandl Segfaults on memory error (2007-04-10) http://python.org/sf/1697916 opened by STINNER Victor msgfmt cannot cope with BOM (2007-04-10) http://python.org/sf/1697943 opened by Christoph Zwerschke xml.etree document element.tag (2007-04-11) http://python.org/sf/1698167 opened by paul rubin wrong % of params for format string in ZipFile.printdir() (2007-04-11) http://python.org/sf/1698398 opened by Szabolcs Berecz dtdparser discards last line (2007-04-11) CLOSED http://python.org/sf/1698944 opened by L. Peter Deutsch shlex fails to parse strings correctly (2007-04-12) http://python.org/sf/1699594 opened by Collin Winter pickle example contains errors (2007-04-13) http://python.org/sf/1699759 opened by Mark Edgington locale.getlocale() output fails as setlocale() input (2007-04-13) http://python.org/sf/1699853 opened by Bernhard Reiter import and capital
Text Suffix to Prefix Conversion
Dear all, I'm a postgraduate student in Hong Kong, studying english language. I wanna seek help from all of you about some plain text manipulation. I have already add part-of-speech (POS) tags with angle bracket by software tagger, right after every word in my file, as attribute. How could I change the tag suffix to tag prefix? Original Sentence: An apple for you. Present: AnAT0 appleNN1 forPRP youPNP .. Desire: AT0An NN1apple PRPfor PNPyou .. My file includes several hundred thousands of words. Manual editing is not possible. All suggestion are welcome!! EMC ROY 19/04/2007 -- http://mail.python.org/mailman/listinfo/python-list
Re: Text Suffix to Prefix Conversion
EMC ROY wrote: Original Sentence: An apple for you. Present: AnAT0 appleNN1 forPRP youPNP .. Desire:AT0An NN1apple PRPfor PNPyou .. text = 'AnAT0 appleNN1 forPRP youPNP ..' import re re.sub(r'(\S+)([^]+)(\s*)', r'\2\1\3', text) 'AT0An NN1apple PRPfor PNPyou ..' -- http://mail.python.org/mailman/listinfo/python-list
Re: What makes an iterator an iterator?
Hi, Thanks for the responses. 7stud [EMAIL PROTECTED] wrote: Can you explain some of the details of why this code fails: --- class Parrot(object): def __iter__(self): return self def __init__(self): self.next = self.next().next def next(self): for word in Norwegian Blue's have beautiful plumage!.split(): yield word P = Parrot() for word in P: print word -- On Apr 18, 8:45 pm, [EMAIL PROTECTED] (Alex Martelli) wrote: ...a loop like for x in y: binds an unnamed temporary variable (say _t) to iter(y) and then repeatedly calls _t.next() [or to be pedantic type(_t).next(t)] until that raises StopIteration. A. Isn't this the crux: repeatedly calls[type(_t).next(t)] As far as I can tell, if the call was actually _t.next(), the code I asked about would work. However, the name look up for 'next' when you call: P.next() is entirely different from the name look up for 'next' when you call: type(P).next(). In the first lookup, the instance attribute next hides the class attribute next. In the second lookup, the next attribute of the class is returned, i.e. the next() method. Yet, a generator-function- call returns an iterator object that wraps the generator function, so when the for loop makes repeated calls to type(P).next(), an iterator object is repeatedly returned--what you want is i.next() to be returned. I suspected next() might be called through the class, but after carefully parsing the section on iterators (Python in a Nutshell, p. 65) where it says iter() returns an object i, and then the for loop repeatedly calls i.next(), I dismissed that idea. I have to admit I'm still a little confused by why you only parenthetically noted that information and called it pedantic. On Apr 18, 8:38 pm, Terry Reedy [EMAIL PROTECTED] wrote: One very good way to get an iterator from an iterable is for .__iter__ to be a generator function. Ahhh. That eliminates having to deal with next().next constructs. Nice. snip all examples of bad code that violate the iterator rule by improperly writing .next as a generator function What iterator rule states that .next can't be a generator function? My book says an iterator is any object with a .next method that is callable without arguments (Python in a Nutshell(p.65) says the same thing). Also, my boos says an iterable is any object with an __iter__ method.As a result, next() and __iter__() don't have to be in the same object: lass MyIterator(object): def __init__(self, obj): self.toIterateOver = obj def next(self): for x in range(self.toIterateOver.age): print x raise StopIteration class Dog(object): def __init__(self, age): self.age = age def __iter__(self): return MyIterator(self) d = Dog(5) for year in d: print year I've read recommendations that an iterator should additionally contain an __iter__() method, but I'm not sure why that is. In particular PEP 234 says: -- Classes can define how they are iterated over by defining an __iter__() method; this should take no additional arguments and return a valid iterator object. A class that wants to be an iterator should implement two methods: a next() method that behaves as described above, and an __iter__() method that returns self. The two methods correspond to two distinct protocols: 1. An object can be iterated over with for if it implements __iter__() or __getitem__(). 2. An object can function as an iterator if it implements next(). Container-like objects usually support protocol 1. Iterators are currently required to support both protocols. The semantics of iteration come only from protocol 2; protocol 1 is present to make iterators behave like sequences; in particular so that code receiving an iterator can use a for-loop over the iterator. Classes can define how they are iterated over by defining an __iter__() method; this should take no additional arguments and return a valid iterator object. A class that wants to be an iterator should implement two methods: a next() method that behaves as described above, and an __iter__() method that returns self. The two methods correspond to two distinct protocols: 1. An object can be iterated over with for if it implements __iter__() or __getitem__(). 2. An object can function as an iterator if it implements next(). Container-like objects usually support protocol 1. Iterators are currently required to support both protocols. The semantics of iteration come only from protocol 2; protocol 1 is present to make iterators behave like sequences; in particular so that code receiving an iterator can use a for-loop over the iterator. The semantics of iteration come only from protocol 2 My example demonstrates that. protocol 1 is present to make
Re: Third party script debugging on remote server ...
Hi Graeme, Thanks for the suggestion. Unluckily for me, it doesn't seem to be working though ... I've tried it a number of different ways. I guess if I put the code after an exception, then the code won't be called. So I ran an error in the python script and then I called the sys.stderr.flush() from the python shell. No luck though. I called on it's own, still no luck, Then I tried ... try: raise Exception('Please log this error') except: import sys sys.stderr.flush() sys.stdout.flush() The error log still has no error info in it :-( Is this problem unique to me ? Those calls don't generate output themselves and exception details don't get output at the point of a try/except block. If you want to generate to Apache error log details of exception from try/except, use: import traceback import sys try: xxx except: traceback.print_exc() sys.stderr.flush() Using these flush functions from interactive debugger isn't going to show you anything as this trick is only needed with mod_python. All the functions do is force the output of any buffered data that was written out previously. Graham -- http://mail.python.org/mailman/listinfo/python-list
unicode and __repr__()
I am using repr() to pass arrays, dicts and combinations therof to javascript as it already returns a valid javascript expression (a string) right away. But for some reason it does not handle Umlaute correctly and those characters finally appear as two strange characters on the browser. I am using UTF-8 and assembling the string expression manually works okay and the umlaute appear correctly in the browser (so I could probably write my own serializer and it would work). The commandline shows a difference too: print [+'ö'+] ['ö'] -- this is openbracket quote oumlaut quote closebracket print [ö].__repr__() ['\xf6'] It works okay for all other chars, just the umlaute seem to be a problem. How can I get __repr__() to handle the umlauter correctly, or is there an easy way to postprocess the output ? -- http://mail.python.org/mailman/listinfo/python-list
Re: Beginner: Formatting text output (PyQt4)
Glen wrote: Hello again, I don't blame anyone for not answering my last post, since I obviously hadn't spent much time researching, but I've come a little ways and have another question. How can I better format text output to a QTextEdit object? I'm inserting 5 columns into each row. When I write the info to a file, it looks like the following: 42: 115 26: 114 35: 112 19: 108 16: 107 45: 107 40: 106 5: 105 41: 104 2: 103 9: 102 48: 102 15: 101 22: 101 27: 101 39: 101 43: 101 10: 100 6: 99 34: 99 32: 98 49: 98 20: 97 30: 97 8: 96 17: 96 38: 96 12: 95 14: 95 37: 95 4: 94 13: 94 44: 94 36: 93 3: 92 24: 92 28: 92 31: 91 29: 89 7: 88 1: 87 18: 85 46: 85 33: 84 11: 83 23: 83 47: 82 25: 80 21: 79 50: 56 52: 39 51: 38 53: 36 54: 25 55: 18 When I write the contents of the file to my TextEdit object it comes out uneven, something like this: 42: 11526: 11435: 11219: 10816: 107 45: 10740: 106 5: 10541: 104 2: 103 9: 10248: 10215: 10122: 101 27: 101 39: 10143: 10110: 1006: 9934: 99 32: 9849: 98 20: 9730: 978: 96 17: 9638: 9612: 9514: 95 37: 95 4: 9413: 9444: 9436: 933: 92 24: 92 28: 9231: 9129: 897: 88 1: 8718: 8546: 8533: 8411: 83 23: 8347: 8225: 8021: 7950: 56 52: 3951: 38 53: 3654: 2555: 18 What seems to be happening is that the font that pyqt is using is not fixed width, so I did this: qTxtFormat = QTextCharFormat() qTxtFormat.setFontFixedPitch(True) ui.textEdit.setCurrentCharFormat(qTxtFormat) Also, I tried using the pyqt formatting such as the following: qStr = QtCore.QString( QtCore.QString( str(tL2[i][0]) ).rightJustified(2) + ':' + QtCore.QString( str(tL2[i][1]) ).rightJustified(4) ) This still gives me uneven columns. Any suggestions? Thanks, Glen Do you need to use QTextEdit for the output? Sounds like maybe you should look at for example the QTableWidget or maybe the QTreeWidget? Tina -- http://mail.python.org/mailman/listinfo/python-list
[ python-Feature Requests-1702681 ] Prevent textwrap from breaking words at hyphens
Feature Requests item #1702681, was opened at 2007-04-17 23:40 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=355470aid=1702681group_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: Nobody/Anonymous (nobody) 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. -- You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=355470aid=1702681group_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
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=detailatid=105470aid=1701409group_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 Address 0x2a out of bounds) 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=detailatid=105470aid=1701409group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1701449 ] documentation bug in profile module
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=detailatid=105470aid=1701449group_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=detailatid=105470aid=1701449group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1303614 ] Bypassing __dict__ readonlyness
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=detailatid=105470aid=1303614group_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: Logged
[ python-Bugs-1699853 ] locale.getlocale() output fails as setlocale() input
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=detailatid=105470aid=1699853group_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 stdin, 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 converted in a wrong way in normalize
[ python-Feature Requests-1701452 ] Feature request: Comparing regexps
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=detailatid=355470aid=1701452group_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=detailatid=355470aid=1701452group_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()
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=detailatid=105470aid=1703110group_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=detailatid=105470aid=1703110group_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
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=detailatid=105470aid=1701409group_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 stdin, line 1, in module 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 Address 0x2a out of bounds) 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=detailatid=105470aid=1701409group_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
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=detailatid=105470aid=1124861group_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 pyshell#49, 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 1603907 1126208 1238747
[ python-Bugs-1700912 ] questionable results from IDLE, Windows, several built-in
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=detailatid=105470aid=1700912group_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=detailatid=105470aid=1700912group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1702036 ] Turtle isn't thread-safe (crashes)
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=detailatid=105470aid=1702036group_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=detailatid=105470aid=1702036group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com