GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-50720: Set errno and strerror on URLError wrapping an OSError by vasiliyk · Pull Request #160938 · python/cpython

Conversation

@vasiliyk

@vasiliyk vasiliyk commented Oct 30, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

URLError wrapping an OSError such as socket.gaierror always had errno and strerror set to None.

This PR copies errno and strerror from the reason when it is an OSError.
A string reason leaves both attributes None, as before.

  • Issue: errno and strerror attributes incorrectly set on socket errors wrapped by urllib #50720

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vasiliyk
pythongh-50720: Set errno and strerror on URLError wrapping an OSError
fd2a709
@bedevere-app bedevere-app Bot added the awaiting review label Oct 30, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Oct 30, 2026
errno and strerror attributes incorrectly set on socket errors wrapped by urllib #50720
Closed
@read-the-docs-community

read-the-docs-community Bot commented Oct 30, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #35546919 | 📁 Comparing e10e451 against main (ef1fce0)

  🔍 Preview build  

30 files changed · ± 30 modified

± Modified

  • builtins/exceptions.html
  • builtins/functions.html
  • builtins/stdtypes.html
  • c-api/code.html
  • c-api/codec.html
  • c-api/extension-modules.html
  • c-api/gcsupport.html
  • deprecations/index.html
  • deprecations/pending-removal-in-3.20.html
  • extending/extending.html
  • and 20 more...
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

orsenthil
orsenthil reviewed Oct 31, 2026
View reviewed changes
Comment thread Lib/urllib/error.py
self.reason = reason
if filename is not None:
self.filename = filename
if isinstance(reason, OSError):

@orsenthil orsenthil Oct 31, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only question is winerror Should we handle that?
We don't have a great on windows and if winerror will be different than errno for the scenarios that URLError will capture.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@orsenthil orsenthil Oct 31, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping this just as thought. Not a blocker.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@vasiliyk vasiliyk Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, winerror stays None on Windows while the wrapped error carries the code. For socket errors it equals errno, but it differs for non-socket errors wrapped by FileHandler.

Should I open a separate improvement issue for it?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@orsenthil orsenthil Oct 31, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have a windows system, could you verify it with a some tests?
Exposing winerror gated by system check will be good.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@vasiliyk vasiliyk Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only have macOS and Linux.

The CI runs the test suite on Windows, so a Windows-only test would be verified there. I can open a follow-up PR that copies winerror behind a platform check, with the test skipped elsewhere.

What do you think?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@orsenthil orsenthil Oct 31, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sounds good to me.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vasiliyk reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@orsenthil
Merge branch 'main' into pythongh-50720-urllib
e10e451
orsenthil
orsenthil approved these changes Oct 31, 2026
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Oct 31, 2026
@orsenthil
orsenthil enabled auto-merge (squash) October 31, 2026 15:58
@orsenthil
orsenthil merged commit 2cf2dd6 into python:main Oct 31, 2026
101 of 103 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label Oct 31, 2026
@bedevere-bot

bedevere-bot commented Oct 31, 2026

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot x86 Debian Installed with X 3.x (tierless) has failed when building commit 2cf2dd6.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/1244/builds/10167) and take a look at the build logs.
  4. Check if the failure is related to this commit (2cf2dd6) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/1244/builds/10167

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.installed/build/target/lib/python3.16/urllib/request.py"�[0m, line �[35m1575�[0m, in �[35mftp_open�[0m
    fp, retrlen = �[31mfw.retrfile�[0m�[1;31m(file, type)�[0m
                  �[31m~~~~~~~~~~~�[0m�[1;31m^^^^^^^^^^^^�[0m
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.installed/build/target/lib/python3.16/urllib/request.py"�[0m, line �[35m1845�[0m, in �[35mretrfile�[0m
    conn, retrlen = �[31mself.ftp.ntransfercmd�[0m�[1;31m(cmd)�[0m
                    �[31m~~~~~~~~~~~~~~~~~~~~~�[0m�[1;31m^^^^^�[0m
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.installed/build/target/lib/python3.16/ftplib.py"�[0m, line �[35m359�[0m, in �[35mntransfercmd�[0m
    resp = self.sendcmd(cmd)
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.installed/build/target/lib/python3.16/ftplib.py"�[0m, line �[35m281�[0m, in �[35msendcmd�[0m
    return �[31mself.getresp�[0m�[1;31m()�[0m
           �[31m~~~~~~~~~~~~�[0m�[1;31m^^�[0m
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.installed/build/target/lib/python3.16/ftplib.py"�[0m, line �[35m252�[0m, in �[35mgetresp�[0m
    raise error_temp(resp)
�[1;35mftplib.error_temp�[0m: �[35m425 Security: Bad IP connecting.�[0m


Traceback (most recent call last):
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.installed/build/target/lib/python3.16/test/test_urllib2net.py"�[0m, line �[35m381�[0m, in �[35mtest_ftp_no_timeout�[0m
    u = _urlopen_with_retry(self.FTP_HOST, timeout=None)
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.installed/build/target/lib/python3.16/test/test_urllib2net.py"�[0m, line �[35m32�[0m, in �[35mwrapped�[0m
    return _retry_thrice(func, exc, *args, **kwargs)
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.installed/build/target/lib/python3.16/test/test_urllib2net.py"�[0m, line �[35m28�[0m, in �[35m_retry_thrice�[0m
    raise last_exc
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.installed/build/target/lib/python3.16/test/test_urllib2net.py"�[0m, line �[35m24�[0m, in �[35m_retry_thrice�[0m
    return func(*args, **kwargs)
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.installed/build/target/lib/python3.16/urllib/request.py"�[0m, line �[35m187�[0m, in �[35murlopen�[0m
    return �[31mopener.open�[0m�[1;31m(url, data, timeout)�[0m
           �[31m~~~~~~~~~~~�[0m�[1;31m^^^^^^^^^^^^^^^^^^^^�[0m
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.installed/build/target/lib/python3.16/urllib/request.py"�[0m, line �[35m489�[0m, in �[35mopen�[0m
    response = self._open(req, data)
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.installed/build/target/lib/python3.16/urllib/request.py"�[0m, line �[35m506�[0m, in �[35m_open�[0m
    result = self._call_chain(self.handle_open, protocol, protocol +
                              '_open', req)
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.installed/build/target/lib/python3.16/urllib/request.py"�[0m, line �[35m466�[0m, in �[35m_call_chain�[0m
    result = func(*args)
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.installed/build/target/lib/python3.16/urllib/request.py"�[0m, line �[35m1588�[0m, in �[35mftp_open�[0m
    raise URLError(f"ftp error: {exp}") from exp
�[1;35murllib.error.URLError�[0m: �[35m<urlopen error ftp error: 425 Security: Bad IP connecting.>�[0m


Traceback (most recent call last):
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.installed/build/target/lib/python3.16/urllib/request.py"�[0m, line �[35m1575�[0m, in �[35mftp_open�[0m
    fp, retrlen = �[31mfw.retrfile�[0m�[1;31m(file, type)�[0m
                  �[31m~~~~~~~~~~~�[0m�[1;31m^^^^^^^^^^^^�[0m
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.installed/build/target/lib/python3.16/urllib/request.py"�[0m, line �[35m1865�[0m, in �[35mretrfile�[0m
    conn, retrlen = �[31mself.ftp.ntransfercmd�[0m�[1;31m(cmd)�[0m
                    �[31m~~~~~~~~~~~~~~~~~~~~~�[0m�[1;31m^^^^^�[0m
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.installed/build/target/lib/python3.16/ftplib.py"�[0m, line �[35m359�[0m, in �[35mntransfercmd�[0m
    resp = self.sendcmd(cmd)
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.installed/build/target/lib/python3.16/ftplib.py"�[0m, line �[35m281�[0m, in �[35msendcmd�[0m
    return �[31mself.getresp�[0m�[1;31m()�[0m
           �[31m~~~~~~~~~~~~�[0m�[1;31m^^�[0m
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.installed/build/target/lib/python3.16/ftplib.py"�[0m, line �[35m252�[0m, in �[35mgetresp�[0m
    raise error_temp(resp)
�[1;35mftplib.error_temp�[0m: �[35m425 Security: Bad IP connecting.�[0m


Traceback (most recent call last):
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.installed/build/target/lib/python3.16/test/test_urllib2net.py"�[0m, line �[35m286�[0m, in �[35m_test_urls�[0m
    f = urlopen(url, req, support.INTERNET_TIMEOUT)
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.installed/build/target/lib/python3.16/test/test_urllib2net.py"�[0m, line �[35m32�[0m, in �[35mwrapped�[0m
    return _retry_thrice(func, exc, *args, **kwargs)
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.installed/build/target/lib/python3.16/test/test_urllib2net.py"�[0m, line �[35m28�[0m, in �[35m_retry_thrice�[0m
    raise last_exc
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.installed/build/target/lib/python3.16/test/test_urllib2net.py"�[0m, line �[35m24�[0m, in �[35m_retry_thrice�[0m
    return func(*args, **kwargs)
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.installed/build/target/lib/python3.16/urllib/request.py"�[0m, line �[35m489�[0m, in �[35mopen�[0m
    response = self._open(req, data)
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.installed/build/target/lib/python3.16/urllib/request.py"�[0m, line �[35m506�[0m, in �[35m_open�[0m
    result = self._call_chain(self.handle_open, protocol, protocol +
                              '_open', req)
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.installed/build/target/lib/python3.16/urllib/request.py"�[0m, line �[35m466�[0m, in �[35m_call_chain�[0m
    result = func(*args)
  File �[35m"/buildbot/buildarea/3.x.ware-debian-x86.installed/build/target/lib/python3.16/urllib/request.py"�[0m, line �[35m1588�[0m, in �[35mftp_open�[0m
    raise URLError(f"ftp error: {exp}") from exp
�[1;35murllib.error.URLError�[0m: �[35m<urlopen error ftp error: 425 Security: Bad IP connecting.>�[0m
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@orsenthil

orsenthil commented Oct 31, 2026

Copy link
Copy Markdown
Member

You can take a look at the buildbot page here:
https://buildbot.python.org/#/builders/1244/builds/10167

The buildbot failures are not related.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vasiliyk vasiliyk mentioned this pull request Oct 31, 2026
gh-50720: Copy winerror to URLError on Windows #161047
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@orsenthil orsenthil orsenthil approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@vasiliyk @bedevere-bot @orsenthil
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.