Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix early crash on python3 + PyQt5 #589

Merged
merged 2 commits into from Aug 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion cola/compat.py
Expand Up @@ -14,7 +14,12 @@

try:
# pylint: disable=bytes-builtin
bstr = bytes
bytes()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should work sans the ().... could even do b = bytes

if PY3:
def bstr(x):
return bytes(x, encoding='latin1')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is starting to look suspiciously like core.encode(). Shouldn't it be utf8?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it for human-readable strings? If so, definitely.

else:
bstr = bytes
except NameError:
# Python <= 2.5
bstr = str
Expand Down
6 changes: 5 additions & 1 deletion cola/widgets/standard.py
Expand Up @@ -2,6 +2,7 @@

import time

import qtpy
from qtpy import QtCore
from qtpy import QtGui
from qtpy import QtWidgets
Expand Down Expand Up @@ -128,9 +129,12 @@ def apply_state(self, state):
if windowstate is None:
result = False
else:
windowstate = str(windowstate)
if qtpy.PYQT5:
windowstate = str.encode(windowstate, encoding='us-ascii')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should probably use core.encode(...)

from_base64 = QtCore.QByteArray.fromBase64
result = self.restoreState(
from_base64(str(windowstate)),
from_base64(windowstate),
self.widget_version) and result
self.lock_layout = state.get('lock_layout', self.lock_layout)
self.update_dockwidget_lock_state()
Expand Down