Skip to content

gh-162128: Raise error_proto instead of ValueError on malformed port in ftplib.parse229 - #162132

Open
klnmurthi12345 wants to merge 2 commits into
python:mainfrom
klnmurthi12345:fix-ftplib-parse229-error
Open

klnmurthi12345 wants to merge 2 commits into
python:mainfrom
klnmurthi12345:fix-ftplib-parse229-error

Conversation

@klnmurthi12345

Copy link
Copy Markdown

When parsing a malformed 229 Entering Extended Passive Mode response where the port field is non-numeric or empty, ftplib.parse229 previously raised an unhandled ValueError instead of error_proto(resp).

As documented in the function docstring ("Raises error_proto if it does not contain '(|||port|)'"), malformed server responses should raise ftplib.error_proto(resp).

This PR wraps int(parts[3]) in a try/except block to raise error_proto(resp) from None when parts[3] is non-numeric, adds regression tests to test_ftplib.py, and includes a NEWS entry.

@python-cla-bot

python-cla-bot Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@klnmurthi12345
klnmurthi12345 force-pushed the fix-ftplib-parse229-error branch from f16292d to ae3fb81 Compare November 17, 2026 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant