Issue deprecation warning when trying to run Beautiful Soup 3 code under Python 3

Bug #1643256 reported by Boštjan
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Beautiful Soup
Fix Released
Undecided
Unassigned

Bug Description

In BeautifulSoup's code, there are some missing parentheses.

setup.py, line 22:
print "Unit tests have failed!"

Please fix line 22 in setup.py to
print("Unit tests have failed!")

The bug was discovered when I wanted to upgrade beautifulsoup by using this command in the Command Prompt:
pip install beautifulsoup --upgrade

Revision history for this message
Boštjan (pedantic-coder) wrote :

I get a nasty traceback when doing the aforementioned pip command. I am running the command in Windows 10 environment, but this still applies to Ubuntu.

The code print("Hello, world!") runs on Python 2.x and Python 3.x, so it's always a good idea to use parentheses with Python's print statements.

I'm sure you know that, but you missed one. ;)

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

Thanks for the bug report. You reported installing the "beautifulsoup" package, which is a discontinued version of the package that only works on Python 2. That print statement is only the first of many compatibility problems you'll have running Beautiful Soup version 3 under Python 3.

Beautiful Soup version 4 (available as the "beautifulsoup4" package) is the version that supports Python 3.

Changed in beautifulsoup:
status: New → Invalid
Revision history for this message
Diego (diego-for-launchpad) wrote :

Is it possible check for the python version in beautifulsoup and generate a proper error message?

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

It is possible, but I've discontinued the beautifulsoup package as a whole and it should not be used for new projects under any version of Python.

Perhaps the time has come to add a DeprecationWarning upon import of that package, in preparation for reclaiming the "beautifulsoup" package name for a more recent version of Beautiful Soup.

summary: - SyntaxError: Missing parentheses in call to 'print'
+ Issue deprecation warning when trying to run Beautiful Soup 3 code under
+ Python 3
Changed in beautifulsoup:
status: Invalid → Fix Committed
Revision history for this message
Leonard Richardson (leonardr) wrote :

Revision 47 on the 3.2 branch adds a helpful syntax error if you try to run any Beautiful Soup 3 code under Python 3, and a discontinuation warning for everyone else.

I've set the cutoff date to January 1, 2021, one year after the discontinuation date for Python 2 itself. At some point after that I'll reclaim the 'beautifulsoup' package name on pip by changing it to a more recent version.

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

I just released 3.2.2, which has the revision 47 change and will hopefully be the final release in the 3.x series.

Changed in beautifulsoup:
status: Fix Committed → Fix Released
Revision history for this message
Leonard Richardson (leonardr) wrote :

Here's the forum announcement for the discontinuation of the 3.x series: https://groups.google.com/d/msg/beautifulsoup/aNC2TBR7QHY/N7pmJmCeBwAJ

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.