Issue1263656
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2005-08-19 02:35 by bsherwood, last changed 2022-04-11 14:56 by admin. This issue is now closed.
Messages (6) | |||
---|---|---|---|
msg26083 - (view) | Author: Bruce Sherwood (bsherwood) | Date: 2005-08-19 02:35 | |
Copying code from some browsers into IDLE on the Mac can leave the file with only \r (13) at the ends of lines (Safari doesn't seem to have this problem). Then checksyntax() in ScriptBinding.py fails to convert these into \n (10), and compile() fails. The effect is that a program which Python is willing to run gets a syntax error in IDLE. I think the fix is in checksyntax() to add after source = re.sub(r"\r\n", "\n", source) the following statement, which converts unaccompanied \r's into \n's:: source = re.sub(r"\r", "\n", source) I've tried this and it works, but someone with a better overview of end-of-line issues in Python should think through whether this is the appropriate fix. |
|||
msg26084 - (view) | Author: Bruce Sherwood (bsherwood) | Date: 2005-08-19 04:23 | |
Logged In: YES user_id=34881 A footnote: Now I don't understand why the substitution searches for r"\r\n", since this would seem to be the raw string which represents slash, r, slash, n, not the two-character string "\r\n"....?? |
|||
msg26085 - (view) | Author: Bruce Sherwood (bsherwood) | Date: 2005-08-19 16:16 | |
Logged In: YES user_id=34881 I should have said that this is in the environment of running IDLE on Mac OSX 10.4 under X11, using the fink distribution. I should also say that there seem to be issues not only of compiling but also of editing/display. In a browser, click on a .py file, select all the text, copy, paste into IDLE. With Safari, it looks right and it runs. With NetScape, it displays all on one line, and it doesn't run (syntax error). I haven't studied the actual code to see what if anything IDLE does to attempt to detect the nature of text pasted into an edit window, but clearly it's different coming from two popular browsers. |
|||
msg26086 - (view) | Author: Kurt B. Kaiser (kbk) * | Date: 2005-08-23 02:48 | |
Logged In: YES user_id=149084 ScriptBinding 1.62. Backport to 2.4.2 Seems harmless. Please check. IDLE retains line endings when loading code from a file. In this case OS X uses \r in the GUI and \r\n in the OS. Heaven knows what happens with fink/X11. IDLE expects \n internally, line endings are converted on I/O. What is your os.linesep under the conditions you mentioned? Regular expression pattern elements like r'\n' match the corresponding special characters; both bytes have to be in the pattern. You can do it by escaping the backslash in a regular string, '\\n', which is also two bytes. But it's easier to use raw strings with regular expressions. |
|||
msg26087 - (view) | Author: Kurt B. Kaiser (kbk) * | Date: 2005-08-23 17:41 | |
Logged In: YES user_id=149084 Backported, ScriptBinding.py 1.28.4.1 |
|||
msg26088 - (view) | Author: Kurt B. Kaiser (kbk) * | Date: 2005-08-24 21:15 | |
Logged In: YES user_id=149084 That should be NEWS.txt 1.62 Scriptbinding 1.31 |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:56:12 | admin | set | github: 42291 |
2005-08-19 02:35:17 | bsherwood | create |