PySide Bugzilla Closed for New Bugs

PySide is now a Qt Add-on and uses the Qt Project's JIRA Bug Tracker instead of this Bugzilla instance. This Bugzilla is left for reference purposes.

Bug 572 - Giving unicode value as 'body' argument to WebView's load method crashes python
: Giving unicode value as 'body' argument to WebView's load method crashes python
Status: CLOSED FIXED
Product: PySide
Classification: Unclassified
Component: QtWebKit
: 1.0.0 beta2
: All All
: P2 critical
Assigned To: Marcelo Lira
:
:
:
  Show dependency treegraph
 
Reported: 2010-12-27 12:58 EET by Jukka Välimaa
Modified: 2011-01-06 16:19 EET (History)
9 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jukka Välimaa 2010-12-27 12:58:41 EET
The following code crashes python without explanation on Windows 7; on Linux
python also crashes with message 'Segmentation fault'. This is because the
'body' argument is in unicode. If it's str, the code works just fine.

It may be the method should not work with unicode, but application crashing
with no explanation can be very confusing. Tracking down this one took quite a
lot of time for me.
-----------------------------------------
from PySide.QtCore import QUrl
from PySide.QtGui import QApplication
from PySide.QtWebKit import QWebView
from PySide.QtNetwork import QNetworkRequest, QNetworkAccessManager

url = 'http://some_url_to_post_to'
post_params = (('param_one', 'Testy'), ('param_two', 'McTest'))

app = QApplication([])
view = QWebView()

request = QNetworkRequest(url=QUrl(url))
body = '&'.join([('%s=%s' % (name, value) ) for name, value in post_params])
view.load(request, operation=QNetworkAccessManager.PostOperation, 
          body=unicode(body))
-----------------------------------------
Comment 1 Hugo Parente Lima 2010-12-27 13:43:23 EET
A nice crash, when running with a debug build I got the assertion:

/usr/include/shiboken/conversions.h:194: static T
Shiboken::ValueTypeConverter<T>::toCpp(PyObject*) [with T = QByteArray,
PyObject = _object]: Assertion `false' failed.

The fix must be simple as the problem location is well known.
Comment 2 Hugo Parente Lima 2010-12-27 17:34:22 EET
This crash is caused by the way we are handling named args, as a workaround you
can just don't use the named args.
Comment 3 Hugo Parente Lima 2010-12-29 10:23:58 EET
Marking the bug as critical, as it can change the behaviour of any program
using keyword arguments.
Comment 4 Marcelo Lira 2011-01-03 19:48:56 EET
Fixed in Shiboken/7ed5767c.
Tests added in PySide/da1759fe.
Comment 5 renato filho 2011-01-06 16:19:35 EET
released on beta3