Skip to content

Commit 2fe6d12

Browse files
committed
upgrade parsel and using promoted root attribute
1 parent 67c98b1 commit 2fe6d12

File tree

5 files changed

+10
-4
lines changed

5 files changed

+10
-4
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ queuelib
77
six>=1.5.2
88
PyDispatcher>=2.0.5
99
service_identity
10-
parsel>=0.9.1
10+
parsel>=0.9.2

scrapy/linkextractors/lxmlhtml.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def _iter_links(self, document):
4747
def _extract_links(self, selector, response_url, response_encoding, base_url):
4848
links = []
4949
# hacky way to get the underlying lxml parsed document
50-
for el, attr, attr_val in self._iter_links(selector._root):
50+
for el, attr, attr_val in self._iter_links(selector.root):
5151
# pseudo lxml.html.HtmlElement.make_links_absolute(base_url)
5252
attr_val = urljoin(base_url, attr_val)
5353
url = self.process_attr(attr_val)

scrapy/selector/unified.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ def __init__(self, response=None, text=None, type=None, root=None, _root=None, *
4848
super(Selector, self).__init__(text=text, type=st, root=root, **kwargs)
4949

5050
# Deprecated api
51+
@property
52+
def _root(self):
53+
warnings.warn("Attribute `_root` is deprecated, use `root` instead",
54+
ScrapyDeprecationWarning, stacklevel=2)
55+
return self.root
56+
5157
@deprecated(use_instead='.xpath()')
5258
def select(self, xpath):
5359
return self.xpath(xpath)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
'pyOpenSSL',
4545
'cssselect>=0.9',
4646
'six>=1.5.2',
47-
'parsel>=0.9.1',
47+
'parsel>=0.9.2',
4848
'PyDispatcher>=2.0.5',
4949
'service_identity',
5050
],

tests/test_selector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def test_simple_selection(self):
4343
def test_deprecated_root_argument(self, warnings):
4444
root = etree.fromstring(u'<html/>')
4545
sel = self.sscls(_root=root)
46-
self.assertIs(root, sel._root)
46+
self.assertIs(root, sel.root)
4747
warnings.warn.assert_called_once_with(
4848
'Argument `_root` is deprecated, use `root` instead',
4949
mock.ANY, stacklevel=2)

0 commit comments

Comments
 (0)