[ python-Bugs-1589480 ] inspect.py imports local "tokenize.py" file
Bugs item #1589480, was opened at 2006-11-02 12:10 Message generated for change (Settings changed) made by drfarina You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1589480&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.4 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Daniel Farina (drfarina) Assigned to: Nobody/Anonymous (nobody) >Summary: inspect.py imports local "tokenize.py" file Initial Comment: urllib2 may do a relative import of tokenize.py, which can cause it to function abnormally when the user has a file named "tokenizer.py" in the directory as a script that utilizes urllib2. The attached tarball has a shell script called "showme.sh" that will give standard input to afile.py, which contains two import statements and nothing else. Code in the neighboring tokenize.py will be executed, resulting in printing those lines to standard output. Expected behavior: no code in tokenize.py should be executed. Reproducible on Ubuntu 6.10 -- Comment By: Daniel Farina (drfarina) Date: 2006-11-03 10:26 Message: Logged In: YES user_id=425987 I have a fresh Ubuntu Edgy install (although my home directory is quite old and persistent). I have installed the Python 2.5 package, but am not using it in this case. You are correct, urllib2 doesn't contain the import. I still get the behavior on my machine. On my machine, the following interaction takes place: [EMAIL PROTECTED]:~/urllib2_bug$ ls afile.py show.sh tokenize.py tokenize.pyc [EMAIL PROTECTED]:~/urllib2_bug$ ./show.sh import sys import urllib2 [EMAIL PROTECTED]:~/urllib2_bug$ more show.sh #!/bin/sh cat afile.py | python afile.py [EMAIL PROTECTED]:~/urllib2_bug$ more afile.py import sys import urllib2 [EMAIL PROTECTED]:~/urllib2_bug$ As we can see from the contents of afile.py, it shouldn't be printing anything. -- Comment By: Georg Brandl (gbrandl) Date: 2006-11-03 08:20 Message: Logged In: YES user_id=849994 I can't reproduce that here with your example code, and there's also no mention of "tokenize" in urllib2.py. In any case, "import tokenize" is not a relative import, and it's the only way a standard library module can import another standard library module. That this can interfere with user-defined modules is known and must be worked around by not naming them like builtin modules. -- Comment By: Daniel Farina (drfarina) Date: 2006-11-02 12:16 Message: Logged In: YES user_id=425987 Yet another typo: the script is called "show.sh" It's the only shell script in there, so no fear. -- Comment By: Daniel Farina (drfarina) Date: 2006-11-02 12:11 Message: Logged In: YES user_id=425987 Typo in the above: "tokenizer.py" should just be "tokenize.py" -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1589480&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1589480 ] inspect.py imports local "tokenize.py" file
Bugs item #1589480, was opened at 2006-11-02 12:10 Message generated for change (Comment added) made by drfarina You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1589480&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.4 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Daniel Farina (drfarina) Assigned to: Nobody/Anonymous (nobody) Summary: inspect.py imports local "tokenize.py" file Initial Comment: urllib2 may do a relative import of tokenize.py, which can cause it to function abnormally when the user has a file named "tokenizer.py" in the directory as a script that utilizes urllib2. The attached tarball has a shell script called "showme.sh" that will give standard input to afile.py, which contains two import statements and nothing else. Code in the neighboring tokenize.py will be executed, resulting in printing those lines to standard output. Expected behavior: no code in tokenize.py should be executed. Reproducible on Ubuntu 6.10 -- >Comment By: Daniel Farina (drfarina) Date: 2006-11-04 02:09 Message: Logged In: YES user_id=425987 I have done something slightly less lazy and had the tokenize.py file throw an exception. The result was not in fact stemming from urllib2, but the inspect.py file. I have duplicated this issue on a fresh install of Edgy on a VM at work (from scratch, no home directory preservation or anything). I'm perfectly willing to accept that I should file this in Ubuntu's launchpad instead. I pray I am not a complete crackpot. Here is a new transcription of my interactions (slightly edited for brevity): [EMAIL PROTECTED] ~/inspect_bug]$ more * :: afile.py :: import inspect #some random text. #more text. #maybe even some more. :: show.sh :: #!/bin/sh cat afile.py | python afile.py :: tokenize.py :: import sys for line in sys.stdin: print line raise Exception, 'Shouldn\'t be here' [EMAIL PROTECTED] ~/inspect_bug]$ ./show.sh import inspect #some random text. #more text. #maybe even some more. Traceback (most recent call last): File "afile.py", line 1, in ? import inspect File "/usr/lib/python2.4/inspect.py", line 31, in ? import sys, os, types, string, re, dis, imp, tokenize, linecache File "/home/fdr/inspect_bug/tokenize.py", line 6, in ? raise Exception, 'Shouldn\'t be here' Exception: Shouldn't be here [EMAIL PROTECTED] ~/inspect_bug]$ -- Comment By: Daniel Farina (drfarina) Date: 2006-11-03 10:26 Message: Logged In: YES user_id=425987 I have a fresh Ubuntu Edgy install (although my home directory is quite old and persistent). I have installed the Python 2.5 package, but am not using it in this case. You are correct, urllib2 doesn't contain the import. I still get the behavior on my machine. On my machine, the following interaction takes place: [EMAIL PROTECTED]:~/urllib2_bug$ ls afile.py show.sh tokenize.py tokenize.pyc [EMAIL PROTECTED]:~/urllib2_bug$ ./show.sh import sys import urllib2 [EMAIL PROTECTED]:~/urllib2_bug$ more show.sh #!/bin/sh cat afile.py | python afile.py [EMAIL PROTECTED]:~/urllib2_bug$ more afile.py import sys import urllib2 [EMAIL PROTECTED]:~/urllib2_bug$ As we can see from the contents of afile.py, it shouldn't be printing anything. -- Comment By: Georg Brandl (gbrandl) Date: 2006-11-03 08:20 Message: Logged In: YES user_id=849994 I can't reproduce that here with your example code, and there's also no mention of "tokenize" in urllib2.py. In any case, "import tokenize" is not a relative import, and it's the only way a standard library module can import another standard library module. That this can interfere with user-defined modules is known and must be worked around by not naming them like builtin modules. -- Comment By: Daniel Farina (drfarina) Date: 2006-11-02 12:16 Message: Logged In: YES user_id=425987 Yet another typo: the script is called "show.sh" It's the only shell script in there, so no fear. -- Comment By: Daniel Farina (drfarina) Date: 2006-11-02 12:11 Message: Logged In: YES user_id=425987 Typo in the above: "tokenizer.py" should just be "tokenize.py" -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1589480&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.py
[ python-Bugs-1589480 ] inspect.py imports local "tokenize.py" file
Bugs item #1589480, was opened at 2006-11-02 21:10 Message generated for change (Comment added) made by loewis You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1589480&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.4 >Status: Closed >Resolution: Invalid Priority: 5 Private: No Submitted By: Daniel Farina (drfarina) Assigned to: Nobody/Anonymous (nobody) Summary: inspect.py imports local "tokenize.py" file Initial Comment: urllib2 may do a relative import of tokenize.py, which can cause it to function abnormally when the user has a file named "tokenizer.py" in the directory as a script that utilizes urllib2. The attached tarball has a shell script called "showme.sh" that will give standard input to afile.py, which contains two import statements and nothing else. Code in the neighboring tokenize.py will be executed, resulting in printing those lines to standard output. Expected behavior: no code in tokenize.py should be executed. Reproducible on Ubuntu 6.10 -- >Comment By: Martin v. Löwis (loewis) Date: 2006-11-04 16:27 Message: Logged In: YES user_id=21627 As gbrandl explains, it is an error to name your own modules with the names of the modules of the standard library. As you have a module named tokenize, and as tokenize is also a module of the standard library, the bug is in your code. Closing this report as invalid. -- Comment By: Daniel Farina (drfarina) Date: 2006-11-04 11:09 Message: Logged In: YES user_id=425987 I have done something slightly less lazy and had the tokenize.py file throw an exception. The result was not in fact stemming from urllib2, but the inspect.py file. I have duplicated this issue on a fresh install of Edgy on a VM at work (from scratch, no home directory preservation or anything). I'm perfectly willing to accept that I should file this in Ubuntu's launchpad instead. I pray I am not a complete crackpot. Here is a new transcription of my interactions (slightly edited for brevity): [EMAIL PROTECTED] ~/inspect_bug]$ more * :: afile.py :: import inspect #some random text. #more text. #maybe even some more. :: show.sh :: #!/bin/sh cat afile.py | python afile.py :: tokenize.py :: import sys for line in sys.stdin: print line raise Exception, 'Shouldn\'t be here' [EMAIL PROTECTED] ~/inspect_bug]$ ./show.sh import inspect #some random text. #more text. #maybe even some more. Traceback (most recent call last): File "afile.py", line 1, in ? import inspect File "/usr/lib/python2.4/inspect.py", line 31, in ? import sys, os, types, string, re, dis, imp, tokenize, linecache File "/home/fdr/inspect_bug/tokenize.py", line 6, in ? raise Exception, 'Shouldn\'t be here' Exception: Shouldn't be here [EMAIL PROTECTED] ~/inspect_bug]$ -- Comment By: Daniel Farina (drfarina) Date: 2006-11-03 19:26 Message: Logged In: YES user_id=425987 I have a fresh Ubuntu Edgy install (although my home directory is quite old and persistent). I have installed the Python 2.5 package, but am not using it in this case. You are correct, urllib2 doesn't contain the import. I still get the behavior on my machine. On my machine, the following interaction takes place: [EMAIL PROTECTED]:~/urllib2_bug$ ls afile.py show.sh tokenize.py tokenize.pyc [EMAIL PROTECTED]:~/urllib2_bug$ ./show.sh import sys import urllib2 [EMAIL PROTECTED]:~/urllib2_bug$ more show.sh #!/bin/sh cat afile.py | python afile.py [EMAIL PROTECTED]:~/urllib2_bug$ more afile.py import sys import urllib2 [EMAIL PROTECTED]:~/urllib2_bug$ As we can see from the contents of afile.py, it shouldn't be printing anything. -- Comment By: Georg Brandl (gbrandl) Date: 2006-11-03 17:20 Message: Logged In: YES user_id=849994 I can't reproduce that here with your example code, and there's also no mention of "tokenize" in urllib2.py. In any case, "import tokenize" is not a relative import, and it's the only way a standard library module can import another standard library module. That this can interfere with user-defined modules is known and must be worked around by not naming them like builtin modules. -- Comment By: Daniel Farina (drfarina) Date: 2006-11-02 21:16 Message: Logged In: YES user_id=425987 Yet another typo: the script is called "show.sh" It's the only shell script in there, so no fear. -- Comment By:
[ python-Bugs-1589074 ] Unneeded constants left during optimization
Bugs item #1589074, was opened at 2006-11-02 06:55 Message generated for change (Comment added) made by loewis You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1589074&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: Parser/Compiler Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Daniel (kamek) Assigned to: Nobody/Anonymous (nobody) Summary: Unneeded constants left during optimization Initial Comment: At some point, when generating the bytecode, the parser/compiler pre-calculates operations on constants. However, the old values, which are often not needed anymore in the constants, are left there as garbage. To keep this description from being lengthy, I'm attaching a text file with several simple demonstrations that serve as testcases. -- >Comment By: Martin v. Löwis (loewis) Date: 2006-11-04 16:29 Message: Logged In: YES user_id=21627 Would you like to work on a patch to fix this problem? -- Comment By: Daniel (kamek) Date: 2006-11-02 06:58 Message: Logged In: YES user_id=539453 Sorry, I rushed and missed the File Description field. Should be "Interactive interpreter testcases". -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1589074&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1588287 ] python: Python/ast.c:541: seq_for_testlist: Assertion fails
Bugs item #1588287, was opened at 2006-10-31 15:05 Message generated for change (Comment added) made by nnorwitz You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1588287&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: Parser/Compiler Group: None >Status: Closed >Resolution: Fixed Priority: 5 Private: No Submitted By: Tom Epperly (tepperly) >Assigned to: Neal Norwitz (nnorwitz) Summary: python: Python/ast.c:541: seq_for_testlist: Assertion fails Initial Comment: I 1. downloaded Python 2.5 final wget 'http://www.python.org/ftp/python/2.5/Python-2.5.tar.bz2' 2. edited Python-2.5/Objects/obmalloc.c to uncomment the #define Py_USING_MEMORY_DEBUGGER line (I plan to run valgrind on this installation of Python) 3. ./configure --without-pymalloc --with-pydebug --prefix=/somewhere/python2_5 4. make and then "make install" 5. next I downloaded and extracted numpy-1.0.tar.gz from Sourceforge: http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=175103 When I try to run the setup.py for numpy-1.0, I get an assertion failure. [EMAIL PROTECTED] numpy-1.0]$ python setup.py install Running from numpy source directory. python: Python/ast.c:541: seq_for_testlist: Assertion `((n)->n_type) == 326 || ((n)->n_type) == 318 || ((n)->n_type) == 319 || ((n)->n_type) == 300' failed. Abort [EMAIL PROTECTED] numpy-1.0]$ -- >Comment By: Neal Norwitz (nnorwitz) Date: 2006-11-04 11:33 Message: Logged In: YES user_id=33168 Thanks for the report. My guess was close, the problem was: `1,2`. Committed revision 52621. (2.6) Committed revision 52622. (2.5.1) -- Comment By: Neal Norwitz (nnorwitz) Date: 2006-11-03 11:27 Message: Logged In: YES user_id=33168 Sorry, total brainfart. I saw the pymalloc line above and got that stuck in my mind. You are correct that assertions are only enabled with pydebug. Can you find the python code that causes the assertion to trigger. Once I have a simple test case I should be able to fix the problem fast. If my guess is correct, the code might look something like: `[]` (ie a list or generator expr inside back ticks). -- Comment By: Tom Epperly (tepperly) Date: 2006-11-03 10:58 Message: Logged In: YES user_id=94539 I think using --with-pydebug makes the assert statements live, and the default (--without-pydebug) skips the assert() statements. I think it would take a great deal of time to understand the implementation of Python well enough for me to debug this myself. Sorry, I don't think there is much I can do more than reporting it. -- Comment By: Neal Norwitz (nnorwitz) Date: 2006-11-03 00:48 Message: Logged In: YES user_id=33168 That's weird. This is definitely a non-standard configuration, but it should work. I don't understand why it would matter if using pydebug or not. It shouldn't make a diff. It would take quite a while to setup the same config. Can you debug this further? Either find the python code that's causing the problem or the problem in the C code? My guess is the only way this could happen based on the grammar is a list inside backticks ``. But I couldn't reproduce it. -- Comment By: Tom Epperly (tepperly) Date: 2006-10-31 15:16 Message: Logged In: YES user_id=94539 If I drop the --with-pydebug from the configure line, it runs the NumPy's setup.py without error. -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1588287&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1588287 ] python: Python/ast.c:541: seq_for_testlist: Assertion fails
Bugs item #1588287, was opened at 2006-10-31 15:05 Message generated for change (Comment added) made by nnorwitz You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1588287&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: Parser/Compiler Group: None Status: Closed Resolution: Fixed Priority: 5 Private: No Submitted By: Tom Epperly (tepperly) Assigned to: Neal Norwitz (nnorwitz) Summary: python: Python/ast.c:541: seq_for_testlist: Assertion fails Initial Comment: I 1. downloaded Python 2.5 final wget 'http://www.python.org/ftp/python/2.5/Python-2.5.tar.bz2' 2. edited Python-2.5/Objects/obmalloc.c to uncomment the #define Py_USING_MEMORY_DEBUGGER line (I plan to run valgrind on this installation of Python) 3. ./configure --without-pymalloc --with-pydebug --prefix=/somewhere/python2_5 4. make and then "make install" 5. next I downloaded and extracted numpy-1.0.tar.gz from Sourceforge: http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=175103 When I try to run the setup.py for numpy-1.0, I get an assertion failure. [EMAIL PROTECTED] numpy-1.0]$ python setup.py install Running from numpy source directory. python: Python/ast.c:541: seq_for_testlist: Assertion `((n)->n_type) == 326 || ((n)->n_type) == 318 || ((n)->n_type) == 319 || ((n)->n_type) == 300' failed. Abort [EMAIL PROTECTED] numpy-1.0]$ -- >Comment By: Neal Norwitz (nnorwitz) Date: 2006-11-04 11:36 Message: Logged In: YES user_id=33168 Note: If you change `1,2` to `(1,2)` the assertion won't trigger. -- Comment By: Neal Norwitz (nnorwitz) Date: 2006-11-04 11:33 Message: Logged In: YES user_id=33168 Thanks for the report. My guess was close, the problem was: `1,2`. Committed revision 52621. (2.6) Committed revision 52622. (2.5.1) -- Comment By: Neal Norwitz (nnorwitz) Date: 2006-11-03 11:27 Message: Logged In: YES user_id=33168 Sorry, total brainfart. I saw the pymalloc line above and got that stuck in my mind. You are correct that assertions are only enabled with pydebug. Can you find the python code that causes the assertion to trigger. Once I have a simple test case I should be able to fix the problem fast. If my guess is correct, the code might look something like: `[]` (ie a list or generator expr inside back ticks). -- Comment By: Tom Epperly (tepperly) Date: 2006-11-03 10:58 Message: Logged In: YES user_id=94539 I think using --with-pydebug makes the assert statements live, and the default (--without-pydebug) skips the assert() statements. I think it would take a great deal of time to understand the implementation of Python well enough for me to debug this myself. Sorry, I don't think there is much I can do more than reporting it. -- Comment By: Neal Norwitz (nnorwitz) Date: 2006-11-03 00:48 Message: Logged In: YES user_id=33168 That's weird. This is definitely a non-standard configuration, but it should work. I don't understand why it would matter if using pydebug or not. It shouldn't make a diff. It would take quite a while to setup the same config. Can you debug this further? Either find the python code that's causing the problem or the problem in the C code? My guess is the only way this could happen based on the grammar is a list inside backticks ``. But I couldn't reproduce it. -- Comment By: Tom Epperly (tepperly) Date: 2006-10-31 15:16 Message: Logged In: YES user_id=94539 If I drop the --with-pydebug from the configure line, it runs the NumPy's setup.py without error. -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1588287&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1590036 ] __getattr__ = getattr crash
Bugs item #1590036, was opened at 2006-11-03 08:44 Message generated for change (Comment added) made by nnorwitz You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1590036&group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Interpreter Core >Group: Python 2.5 Status: Open Resolution: None >Priority: 6 Private: No Submitted By: Brian Harring (ferringb) >Assigned to: Armin Rigo (arigo) Summary: __getattr__ = getattr crash Initial Comment: class c(object):__getattr__ = getattr c().spam Now granted... it's retarded to attempt this. But out of curiousity, I decided to be the retard, and noticed the interpreter crashes instead of triggering a RuntimeError for recursion. As far as I know, getattr is instrumented with Py_EnterRecursiveCall and Py_LEaveRecursiveCall... so a bit curious as to how it's occuring. -- >Comment By: Neal Norwitz (nnorwitz) Date: 2006-11-04 11:40 Message: Logged In: YES user_id=33168 The attached patch fixes this problem. However, I'm concerned there are more places like this. I hope Armin has some ideas if more things are needed to fix this problem. -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1590036&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1590592 ] where is zlib???
Bugs item #1590592, was opened at 2006-11-04 19:51 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=1590592&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: AKap (aleksey_kap) Assigned to: Nobody/Anonymous (nobody) Summary: where is zlib??? Initial Comment: Python2.5 for win32 msi-installer - where are zlib.dll and zlib.pyd ??? -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1590592&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1589480 ] inspect.py imports local "tokenize.py" file
Bugs item #1589480, was opened at 2006-11-02 12:10 Message generated for change (Comment added) made by drfarina You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1589480&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.4 Status: Closed Resolution: Invalid Priority: 5 Private: No Submitted By: Daniel Farina (drfarina) Assigned to: Nobody/Anonymous (nobody) Summary: inspect.py imports local "tokenize.py" file Initial Comment: urllib2 may do a relative import of tokenize.py, which can cause it to function abnormally when the user has a file named "tokenizer.py" in the directory as a script that utilizes urllib2. The attached tarball has a shell script called "showme.sh" that will give standard input to afile.py, which contains two import statements and nothing else. Code in the neighboring tokenize.py will be executed, resulting in printing those lines to standard output. Expected behavior: no code in tokenize.py should be executed. Reproducible on Ubuntu 6.10 -- >Comment By: Daniel Farina (drfarina) Date: 2006-11-04 12:40 Message: Logged In: YES user_id=425987 Oops. Sorry about that... -- Comment By: Martin v. Löwis (loewis) Date: 2006-11-04 07:27 Message: Logged In: YES user_id=21627 As gbrandl explains, it is an error to name your own modules with the names of the modules of the standard library. As you have a module named tokenize, and as tokenize is also a module of the standard library, the bug is in your code. Closing this report as invalid. -- Comment By: Daniel Farina (drfarina) Date: 2006-11-04 02:09 Message: Logged In: YES user_id=425987 I have done something slightly less lazy and had the tokenize.py file throw an exception. The result was not in fact stemming from urllib2, but the inspect.py file. I have duplicated this issue on a fresh install of Edgy on a VM at work (from scratch, no home directory preservation or anything). I'm perfectly willing to accept that I should file this in Ubuntu's launchpad instead. I pray I am not a complete crackpot. Here is a new transcription of my interactions (slightly edited for brevity): [EMAIL PROTECTED] ~/inspect_bug]$ more * :: afile.py :: import inspect #some random text. #more text. #maybe even some more. :: show.sh :: #!/bin/sh cat afile.py | python afile.py :: tokenize.py :: import sys for line in sys.stdin: print line raise Exception, 'Shouldn\'t be here' [EMAIL PROTECTED] ~/inspect_bug]$ ./show.sh import inspect #some random text. #more text. #maybe even some more. Traceback (most recent call last): File "afile.py", line 1, in ? import inspect File "/usr/lib/python2.4/inspect.py", line 31, in ? import sys, os, types, string, re, dis, imp, tokenize, linecache File "/home/fdr/inspect_bug/tokenize.py", line 6, in ? raise Exception, 'Shouldn\'t be here' Exception: Shouldn't be here [EMAIL PROTECTED] ~/inspect_bug]$ -- Comment By: Daniel Farina (drfarina) Date: 2006-11-03 10:26 Message: Logged In: YES user_id=425987 I have a fresh Ubuntu Edgy install (although my home directory is quite old and persistent). I have installed the Python 2.5 package, but am not using it in this case. You are correct, urllib2 doesn't contain the import. I still get the behavior on my machine. On my machine, the following interaction takes place: [EMAIL PROTECTED]:~/urllib2_bug$ ls afile.py show.sh tokenize.py tokenize.pyc [EMAIL PROTECTED]:~/urllib2_bug$ ./show.sh import sys import urllib2 [EMAIL PROTECTED]:~/urllib2_bug$ more show.sh #!/bin/sh cat afile.py | python afile.py [EMAIL PROTECTED]:~/urllib2_bug$ more afile.py import sys import urllib2 [EMAIL PROTECTED]:~/urllib2_bug$ As we can see from the contents of afile.py, it shouldn't be printing anything. -- Comment By: Georg Brandl (gbrandl) Date: 2006-11-03 08:20 Message: Logged In: YES user_id=849994 I can't reproduce that here with your example code, and there's also no mention of "tokenize" in urllib2.py. In any case, "import tokenize" is not a relative import, and it's the only way a standard library module can import another standard library module. That this can interfere with user-defined modules is known and must be worked around by not naming them like builtin modules. -- Comment By: Daniel Farina (drfarina) Date: 2006-11-02 12:16 Message: Logged In: YES
[ python-Bugs-1590036 ] __getattr__ = getattr crash
Bugs item #1590036, was opened at 2006-11-03 10:44 Message generated for change (Comment added) made by ferringb You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1590036&group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Interpreter Core Group: Python 2.5 Status: Open Resolution: None Priority: 6 Private: No Submitted By: Brian Harring (ferringb) Assigned to: Armin Rigo (arigo) Summary: __getattr__ = getattr crash Initial Comment: class c(object):__getattr__ = getattr c().spam Now granted... it's retarded to attempt this. But out of curiousity, I decided to be the retard, and noticed the interpreter crashes instead of triggering a RuntimeError for recursion. As far as I know, getattr is instrumented with Py_EnterRecursiveCall and Py_LEaveRecursiveCall... so a bit curious as to how it's occuring. -- >Comment By: Brian Harring (ferringb) Date: 2006-11-04 21:57 Message: Logged In: YES user_id=874085 can do the same trick with hasattr also (same type of fix)... -- Comment By: Neal Norwitz (nnorwitz) Date: 2006-11-04 13:40 Message: Logged In: YES user_id=33168 The attached patch fixes this problem. However, I'm concerned there are more places like this. I hope Armin has some ideas if more things are needed to fix this problem. -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1590036&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1574217 ] isinstance swallows exceptions
Bugs item #1574217, was opened at 2006-10-09 21:55 Message generated for change (Comment added) made by ferringb You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1574217&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.4 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Brian Harring (ferringb) Assigned to: Nobody/Anonymous (nobody) Summary: isinstance swallows exceptions Initial Comment: Attached is a simple example; yes, a bit contrived, but it's exactly what bit me in the ass for a week or two :) nestled within abstract.c's recursive_isinstance, is this lil nugget- icls = PyObject_GetAttr(inst, __class__); if (icls == NULL) { PyErr_Clear(); retval = 0; } else { No surrouding comments to indicate *why* it's swallowing exceptions, but best explanation I've heard was that it was attempting to swallow just AttributeError... which would make sense. So the question is, whats the purpose of it swallowing exceptions there? Bad form of AttributeError catching, or some unstated reason? -- >Comment By: Brian Harring (ferringb) Date: 2006-11-04 22:06 Message: Logged In: YES user_id=874085 quicky patch for this; basically, wipe the exception only if it's AttributeError, else let it bubble it's way up. -- Comment By: Brian Harring (ferringb) Date: 2006-10-09 21:56 Message: Logged In: YES user_id=874085 addition note; this is both 2.5 and 2.4, probably stretches bit further back also. -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1574217&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com