View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0003209 | Scribus | Scripter | public | 2006-02-10 08:43 | 2010-12-13 15:18 |
Reporter | michaelcole | Assigned To | h_a_j_s | ||
Priority | normal | Severity | crash | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Platform | Linux | OS | Mandriva 2006 | OS Version | Mandriva 2006 |
Product Version | 1.3.2 | ||||
Fixed in Version | 1.5.0svn | ||||
Summary | 0003209: Python crashes constantly Scripter and documentation is wrong. | ||||
Description | Scripter.. Sig 11 or Sig 6 errors constantly. Run the hello world First script works. Run the second one crashes.. Open the Examples they crash as well.. Only the calendar and the font sample work.. The documentation is poorly would be an understatement. It starts with a hello world which then breaks the Scribus then does not even attempt to create a document or edit one.. | ||||
Steps To Reproduce | Copy these and run them.. This will run but closes Scribus on close #!/usr/bin/env Python import sys import qt a = qt.qApp hello = qt.QPushButton("Hello world!", None) hello.resize(100, 30) a.setMainWidget(hello) hello.show() sys.exit(a.exec_loop()) This will run then run again and then die with sig 6... #!/usr/bin/env Python import sys import qt a = qt.qApp hello = qt.QPushButton("Hello world!", None) hello.resize(100, 30) #a.setMainWidget(hello) hello.show() sys.exit(a.exec_loop()) This will crash.. below #!/usr/bin/env Python import sys import qt a = qt.qApp hello = qt.QPushButton("Hello world!", None) hello.resize(100, 30) #a.setMainWidget(hello) hello.show() #sys.exit(a.exec_loop()) Quote.py #!/usr/bin/env python # -*- coding: iso-8859-1 -*- """ This script changes quotation marks from " " to french style """ import sys try: from scribus import * except ImportError: print "This script only runs from within Scribus." sys.exit(1) import re TITLE = "Text quoting" # These need to be declared as unicode strings until some # charset issues in the scripter are worked out. QUOTE_START = u"" QUOTE_END = u"" def quote(textobj): quoted_re = re.compile('"[^"]*"') try: text = getText(textobj) except WrongFrameTypeError: messageBox("quote.py", "Cannot quote text in a non-text frame", ICON_INFORMATION); sys.exit(1) if len(text) == 0: return 0 # We can't very well change anything in an empty frame count = 0 i = 0 selectText(0, 0, textobj) while i < len(text): match = quoted_re.match(text[i:]) if match: end = match.end() selectText(i, 1, textobj) deleteText(textobj) insertText(QUOTE_START, i, textobj) selectText(i + end - 1, 1, textobj) deleteText(textobj) insertText(QUOTE_END, i + end - 1, textobj) count += 1 i = i + end else: i = i + 1 return count def main(): changed = 0 sel_count = selectionCount() if sel_count: for i in range(sel_count): changed += quote(getSelectedObject(i)) else: for page in range(pageCount()): gotoPage(page) for obj in getAllObjects(): changed += quote(obj) messageBox(TITLE, "%s quotations changed" % changed, ICON_INFORMATION, BUTTON_OK) if __name__ == '__main__': if haveDoc(): try: setRedraw(False) main() finally: setRedraw(True) redrawAll() else: messageBox(TITLE, "No document open", ICON_WARNING, BUTTON_OK) | ||||
Tags | No tags attached. | ||||
Patch | |||||
|
Reminder sent to: michaelcole Scripter Bugs.. |
|
Reminder sent to: Thoughts on this ? |
|
ad PyQt: Fatal Python error: PyThreadState_Get: no current thread it's due the problematic PyQt interpretters init etc. It's under slow development. Please, consult the scribus documentation for using PyQt in your scripts (chapter Scripter Extensions). There is small tutorial to get Scribus working with PyQt. Anyway I have no problems with sample scripts (quote.py etc. here). Which Python version you have on Mandriva? Is this right one with is Scribus built? |
|
Scripts using PyQt *will* *not* *work* under the normal execution mode for scripts. They must be run with the "extension script" option. This is due to Scribus's use of sub-interpreters for normal scripts, which PyQt doesn't seem to like (at least not the bodgy way we use them - they're not made for single-threaded execution). It has proved difficult to reliably prevent the user from trying to load scripts that use PyQt. Suggestions on how to accomplish this would be much appreciated. I actually can't remember if I ended up committing the check-and-abort for the module name "PyQt" or not, and I don't have any sane access to CVS right now (on holiday with intermittent 56k access). Additonally, that example is just wrong. I really hope that's not in CVS, because it (a) calls sys.exit and (b) sets the main widget. If it is in CVS, then my apologies - it should never have made it there, and there was a correct one in my local tree. I'll review the examples and documentation when I get back from holiday. We do need to try to prevent users from running scripts that'll crash Scribus, but the scripts should work correctly if run as "extension scripts". |
|
The only real fix here is to remove support for the use of subinterpreters. That'd probably be the "most correct" fix as the way we use subinterpreters is actually not designed to work ... but it'd introduce bunch of potential issues. The biggest would be memory leakage after each script run (from the objects the script creates in the __main__ scope and does not destroy at exit). Another would be that scripts would be less independent in some ways. I'm increasingly coming to think that it's a good idea anyway. Failing that, I have an __import__() wrapper almost ready. It replaces __builtin__.__import__ with a new import implementation that blacklists certain modules except in extension script mode. It's a dirty hack at best IMO, and I'd at this point I'd much prefer to just remove support for subinterpreters (they might be able to go back in with Qt4, where threading restrictions are less harsh). Petr, any strong opinions either way re subinterpreters? |
|
Petr, any comments re the future use of sub-interpreters? |
|
I need to ensure there's a better way for scripts to detect that they're running under the 'extension script' mode and abort otherwise. A functional blacklist of modules would also be good, but it proving harder to get working than I expected. Beyond that it's not clear if there's anything to be done about this issue at present. |
|
Scripter2 was written to overcome this. |
Date Modified | Username | Field | Change |
---|---|---|---|
2006-02-10 08:43 | michaelcole | New Issue | |
2006-02-10 08:44 | michaelcole | Note Added: 0008683 | |
2006-02-10 09:05 |
|
Note Added: 0008684 | |
2006-02-14 11:49 | subik | Note Added: 0008742 | |
2006-02-15 00:45 |
|
Note Added: 0008754 | |
2006-02-15 20:55 |
|
Status | new => assigned |
2006-02-15 20:55 |
|
Assigned To | => ringerc |
2006-03-05 09:00 |
|
Note Added: 0009059 | |
2006-03-13 03:09 |
|
Note Added: 0009231 | |
2006-04-02 05:49 |
|
Note Added: 0009585 | |
2006-05-13 21:06 | christoph_s | Relationship added | child of 0003813 |
2008-03-14 06:54 |
|
Assigned To | ringerc => |
2008-03-14 06:54 |
|
Status | assigned => confirmed |
2009-03-17 07:32 | jghali | Relationship added | has duplicate 0007879 |
2010-12-13 15:17 |
|
Status | confirmed => resolved |
2010-12-13 15:17 |
|
Fixed in Version | => 1.5.0svn |
2010-12-13 15:17 |
|
Resolution | open => fixed |
2010-12-13 15:17 |
|
Assigned To | => h_a_j_s |
2010-12-13 15:18 |
|
Note Added: 0025117 | |
2010-12-13 15:18 |
|
Status | resolved => closed |