gawel / pyquery

A jquery-like library for python
http://pyquery.rtfd.org/
Other
2.29k stars 182 forks source link

TypeError of .text() method with an empty textarea tag #210

Closed eshfield closed 3 years ago

eshfield commented 4 years ago
>>> from pyquery import PyQuery
>>> pq = PyQuery('<textarea></textarea>')
>>> pq.text()
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "<skipped>/python3.8/site-packages/pyquery/pyquery.py", line 1202, in text
    return ' '.join(
TypeError: sequence item 0: expected str instance, NoneType found

With non-empty textarea tag it works fine:

>>> pq = PyQuery('<textarea>hello</textarea>')
>>> pq.text()
>>> 'hello'

And it's ok with empty, let's say, div or label:

>>> pq = PyQuery('<div></div>')
>>> pq.text()
>>> ''
>>> pq = PyQuery('<label></label>')
>>> pq.text()
>>> ''

Seems like a bug I guess