Skip to content

gh-75723: Idempotent .pth execution in site.addsitedir#147951

Open
asottile wants to merge 2 commits intopython:mainfrom
asottile:asottile-gh-75723
Open

gh-75723: Idempotent .pth execution in site.addsitedir#147951
asottile wants to merge 2 commits intopython:mainfrom
asottile:asottile-gh-75723

Conversation

@asottile
Copy link
Copy Markdown
Contributor

@asottile asottile commented Mar 31, 2026

@tcely
Copy link
Copy Markdown

tcely commented Apr 1, 2026

@asottile

Do you have any ideas how to explain the test failure?

class DateTimeTestCase(unittest.TestCase):
def test_default(self):
with mock.patch('time.localtime') as localtime_mock:
time_struct = time.struct_time(
[2013, 7, 15, 0, 24, 49, 0, 196, 0])
localtime_mock.return_value = time_struct
localtime = time.localtime()
t = xmlrpclib.DateTime()
self.assertEqual(str(t),
time.strftime("%Y%m%dT%H:%M:%S", localtime))


   FAIL: test_default (test.test_xmlrpc.DateTimeTestCase.test_default)
   ----------------------------------------------------------------------
   Traceback (most recent call last):
     File "/Users/runner/Library/Developer/CoreSimulator/Devices/CED4C8DA-56B5-4FBF-A288-C5C2C197B3AD/data/Containers/Bundle/Application/4B219D99-CC21-4E94-B496-5F175FEC5822/iOSTestbed.app/python/lib/python3.15/test/test_xmlrpc.py", line 487, in test_default
       self.assertEqual(str(t),
       ~~~~~~~~~~~~~~~~^^^^^^^^
                        time.strftime("%Y%m%dT%H:%M:%S", localtime))
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   AssertionError: '20260331T20:39:38' != '20130715T00:24:49'
   - 20260331T20:39:38
   + 20130715T00:24:49
   
   
   ----------------------------------------------------------------------
   Ran 93 tests in 27.345s
   
   FAILED (failures=1)
   test test_xmlrpc failed

@FFY00 FFY00 added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Apr 2, 2026
@bedevere-bot
Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @FFY00 for commit 6c342df 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F147951%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Apr 2, 2026
@FFY00
Copy link
Copy Markdown
Member

FFY00 commented Apr 2, 2026

The test_xmlrpc failure on iOS only seems weird, I triggered a re-run.

@FFY00
Copy link
Copy Markdown
Member

FFY00 commented Apr 2, 2026

Well, the test is still failing. It seems like the time.localtime mock is not being installed in xmlrpc.client, or is losing the side effect after one call, weird.

I am gonna sync with main, just to be sure this is not a known issue.

Copy link
Copy Markdown
Member

@FFY00 FFY00 left a comment

Choose a reason for hiding this comment

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

This looks okay, overall. There is just the test_xmlrpc failure we need to fix, and the news text that should be updated.

@@ -0,0 +1 @@
Idempotent ``.pth`` file exection in :meth:`site.addsitedir`.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please re-write this to be more descriptive (eg. "Avoid re-executing .pth files when site.addsitedir is called for for a known directory")

@bedevere-app
Copy link
Copy Markdown

bedevere-app bot commented Apr 2, 2026

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

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.

4 participants