Compare commits

...

5 Commits
osx ... v0.5.1

Author SHA1 Message Date
Florian Bruhin
b46f15a995 Release v0.5.1. 2016-01-18 21:45:28 +01:00
Florian Bruhin
57e9708940 Update changelog for v0.5.1. 2016-01-18 21:41:37 +01:00
Florian Bruhin
0be44fd420 Avoid trying to load .netrc if $HOME isn't set.
This logged an error on Windows:

ERROR    misc       networkmanager:on_authentication_required:269 Unable to read the netrc file
Traceback (most recent call last):
  File "c:\python34\Lib\netrc.py", line 27, in __init__
    file = os.path.join(os.environ['HOME'], ".netrc")
  File "C:\Users\florian\buildbot\slave\win8\build\.tox\py34\lib\os.py", line 633, in __getitem__
    raise KeyError(key) from None
KeyError: 'HOME'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\florian\buildbot\slave\win8\build\qutebrowser\browser\network\networkmanager.py", line 262, in on_authentication_required
    net = netrc.netrc()
  File "c:\python34\Lib\netrc.py", line 29, in __init__
    raise OSError("Could not find .netrc: $HOME is not set")

Since this case is pretty common, we don't want to log it - and checking the
variable beforehand is easier than parsing the exception message.

This should fix the failing tests on Windows.
2016-01-18 21:39:29 +01:00
Florian Bruhin
d9539ca6d8 Fix config validation for String types.
Fixes #1231.
2016-01-18 21:36:10 +01:00
Florian Bruhin
a362efaa56 Fix completion for String config type.
Since 2a705e2eb6 non-specialized config types are
String. However, String had an overloaded complete() which defaulted to
returning None.

Now we use the normal complete() which relies on valid_values if completions
isn't given instead.

Fixes #1223.
2016-01-18 21:35:29 +01:00
6 changed files with 42 additions and 4 deletions

View File

@@ -14,6 +14,17 @@ This project adheres to http://semver.org/[Semantic Versioning].
// `Fixed` for any bug fixes.
// `Security` to invite users to upgrade in case of vulnerabilities.
v0.5.1
------
Fixed
~~~~~
- Fixed completion for various config values when using `:set`.
- Fixed config validation for various config values.
- Prevented an error being logged when a website with HTTP authentication was
opened on Windows.
v0.5.0
------

View File

@@ -28,7 +28,7 @@ __copyright__ = "Copyright 2014-2016 Florian Bruhin (The Compiler)"
__license__ = "GPL"
__maintainer__ = __author__
__email__ = "mail@qutebrowser.org"
__version_info__ = (0, 5, 0)
__version_info__ = (0, 5, 1)
__version__ = '.'.join(str(e) for e in __version_info__)
__description__ = "A keyboard-driven, vim-like browser based on PyQt5 and QtWebKit."

View File

@@ -19,6 +19,7 @@
"""Our own QNetworkAccessManager."""
import os
import collections
import netrc
@@ -244,7 +245,10 @@ class NetworkManager(QNetworkAccessManager):
def on_authentication_required(self, reply, authenticator):
"""Called when a website needs authentication."""
user, password = None, None
if not hasattr(reply, "netrc_used"):
if not hasattr(reply, "netrc_used") and 'HOME' in os.environ:
# We'll get an OSError by netrc if 'HOME' isn't available in
# os.environ. We don't want to log that, so we prevent it
# altogether.
reply.netrc_used = True
try:
net = netrc.netrc()

View File

@@ -258,6 +258,13 @@ class String(BaseType):
self._basic_validation(value)
if not value:
return
if self.valid_values is not None:
if value not in self.valid_values:
raise configexc.ValidationError(
value, "valid values: {}".format(', '.join(
self.valid_values)))
if self.forbidden is not None and any(c in value
for c in self.forbidden):
raise configexc.ValidationError(value, "may not contain the chars "
@@ -270,7 +277,10 @@ class String(BaseType):
"long!".format(self.maxlen))
def complete(self):
return self._completions
if self._completions is not None:
return self._completions
else:
return super().complete()
class List(BaseType):

View File

@@ -321,7 +321,7 @@ class TestDefaultConfig:
If it did change, place a new qutebrowser-vx.y.z.conf in old_configs
and then increment the version.
"""
assert qutebrowser.__version__ == '0.5.0'
assert qutebrowser.__version__ == '0.5.1'
@pytest.mark.parametrize('filename',
os.listdir(os.path.join(os.path.dirname(__file__), 'old_configs')),

View File

@@ -305,6 +305,8 @@ class TestString:
({'minlen': 2}, 'fo'),
({'minlen': 2, 'maxlen': 3}, 'fo'),
({'minlen': 2, 'maxlen': 3}, 'foo'),
# valid_values
({'valid_values': configtypes.ValidValues('fooo')}, 'fooo'),
])
def test_validate_valid(self, klass, kwargs, val):
klass(**kwargs).validate(val)
@@ -319,6 +321,8 @@ class TestString:
({'maxlen': 2}, 'fob'),
({'minlen': 2, 'maxlen': 3}, 'f'),
({'minlen': 2, 'maxlen': 3}, 'fooo'),
# valid_values
({'valid_values': configtypes.ValidValues('blah')}, 'fooo'),
])
def test_validate_invalid(self, klass, kwargs, val):
with pytest.raises(configexc.ValidationError):
@@ -335,6 +339,15 @@ class TestString:
def test_complete(self, klass, value):
assert klass(completions=value).complete() == value
@pytest.mark.parametrize('valid_values, expected', [
(configtypes.ValidValues('one', 'two'),
[('one', ''), ('two', '')]),
(configtypes.ValidValues(('1', 'one'), ('2', 'two')),
[('1', 'one'), ('2', 'two')]),
])
def test_complete_valid_values(self, klass, valid_values, expected):
assert klass(valid_values=valid_values).complete() == expected
class TestList: