Cannot easily create soup.new_tag('meta', name="anything"...)

Bug #1779276 reported by griswolf
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Beautiful Soup
Fix Released
Undecided
Unassigned

Bug Description

BeautifulSoup already uses the "name" parameter to create the new tag. For searching, we can use the idiom find_all('meta',"attrs={"name":"something", ...}) but using that idiom with new_tag dosn't do what is needed. Allowing the attrs={...} hack would be an advantage. Alternative: a factory "new_meta_tag" method, since many meta tags need the "name" attribute. Or expanding the use of the 'class_' hack to new_tag, but generalizing it.

Work around:
m = soup.new_tag('meta',content='some-content')
m['name'] = 'some-name'

griswolf (griswolf)
description: updated
Revision history for this message
Leonard Richardson (leonardr) wrote :

Revision 464 allows a dictionary of 'attrs' to be passed into BeautifulSoup.new_tag.

Changed in beautifulsoup:
status: New → Fix Committed
Changed in beautifulsoup:
status: Fix Committed → Fix Released
Revision history for this message
griswolf (griswolf) wrote :

Thank you. However, alas:

% pip install -U beautifulsoup # also happens with pip3
Collecting beautifulsoup
  Using cached https://files.pythonhosted.org/packages/1e/ee/295988deca1a5a7accd783d0dfe14524867e31abb05b6c0eeceee49c759d/BeautifulSoup-3.2.1.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/r8/x2801mmx14l0mcnfxkk299zh0000gn/T/pip-install-g7qjdnv_/beautifulsoup/setup.py", line 22
        print "Unit tests have failed!"
                                      ^
    SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Unit tests have failed!")?

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/r8/x2801mmx14l0mcnfxkk299zh0000gn/T/pip-install-g7qjdnv_/beautifulsoup/
%

Revision history for this message
Leonard Richardson (leonardr) wrote :

You're installing version 3 of Beautiful Soup, an obsolete version which doesn't work in Python 3. The package name you want is beautifulsoup4.

Revision history for this message
griswolf (griswolf) wrote : Re: [Bug 1779276] Re: Cannot easily create soup.new_tag('meta', name="anything"...)

(blush)

thanks

On 2018-07-28 18:37, Leonard Richardson wrote:
> You're installing version 3 of Beautiful Soup, an obsolete version which
> doesn't work in Python 3. The package name you want is beautifulsoup4.
>

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.