From 82958e3fd1da7f69e19e70779cfca1e6cf2d3f12 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Mon, 31 Aug 2020 21:54:15 -0300 Subject: [PATCH 1/9] Doc: Fix the array.fromfile method doc The check about the f argument type was removed in this commit: https://github.com/python/cpython/commit/2c94aa567e525c82041ad68a3174d8c3acbf37e2 Thanks for Pedro Arthur Duarte (pedroarthur.jedi at gmail.com) by the help with this bug. --- Doc/library/array.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/Doc/library/array.rst b/Doc/library/array.rst index ad622627724217..4a4b657032bca1 100644 --- a/Doc/library/array.rst +++ b/Doc/library/array.rst @@ -266,4 +266,3 @@ Examples:: `NumPy `_ The NumPy package defines another array type. - From c178bdb4b29242b2d41c6b4bf77fb26101029bce Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Sun, 2 Jul 2023 18:11:45 +0200 Subject: [PATCH 2/9] gh-106320: Remove private _PyInterpreterState functions (#106335) Remove private _PyThreadState and _PyInterpreterState C API functions: move them to the internal C API (pycore_pystate.h and pycore_interp.h). Don't export most of these functions anymore, but still export functions used by tests. Remove _PyThreadState_Prealloc() and _PyThreadState_Init() from the C API, but keep it in the stable API. From e0a2693f1325c506b77e09b47b2db0575e42733b Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Fri, 29 Dec 2023 20:26:20 +0000 Subject: [PATCH 3/9] Add builtin functions/methods __self__ test --- Lib/test/test_funcattrs.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Lib/test/test_funcattrs.py b/Lib/test/test_funcattrs.py index b3fc5ad42e7fde..b8aaabe636edf1 100644 --- a/Lib/test/test_funcattrs.py +++ b/Lib/test/test_funcattrs.py @@ -473,6 +473,26 @@ def test_builtin__qualname__(self): self.assertEqual([1, 2, 3].append.__qualname__, 'list.append') self.assertEqual({'foo': 'bar'}.pop.__qualname__, 'dict.pop') + def test_builtin__self__(self): + import time + import builtins + + # builtin function: + self.assertEqual(len.__self__, builtins) + self.assertEqual(time.sleep.__self__, time) + + # builtin classmethod: + self.assertEqual(dict.fromkeys.__self__, dict) + self.assertEqual(float.__getformat__.__self__, float) + + # builtin staticmethod: + self.assertEqual(str.maketrans.__self__, None) + self.assertEqual(bytes.maketrans.__self__, None) + + # builtin bound instance method: + self.assertEqual([1, 2, 3].append.__self__, [1, 2, 3]) + self.assertEqual({'foo': 'bar'}.pop.__self__, {'foo': 'bar'}) + if __name__ == "__main__": unittest.main() From 5eb85ff85a8504251e65125aaa6a621a8a9a45a9 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sun, 16 Mar 2025 17:52:01 +0000 Subject: [PATCH 4/9] gh-58211: Add tests for __self__ attribute of builtins functions --- Lib/test/test_funcattrs.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Lib/test/test_funcattrs.py b/Lib/test/test_funcattrs.py index cec8eb27ac50b6..9756b858b5326c 100644 --- a/Lib/test/test_funcattrs.py +++ b/Lib/test/test_funcattrs.py @@ -3,6 +3,7 @@ import typing import unittest import warnings +from test import support def global_function(): @@ -478,6 +479,7 @@ def test_builtin__qualname__(self): self.assertEqual([1, 2, 3].append.__qualname__, 'list.append') self.assertEqual({'foo': 'bar'}.pop.__qualname__, 'dict.pop') + @support.cpython_only # See gh-58211 def test_builtin__self__(self): import time import builtins From c61e470a466df7d3e901a7057bdfaf446f1f15fe Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Thu, 10 Apr 2025 21:57:18 +0100 Subject: [PATCH 5/9] gh-58211: Put full URL to GH issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> --- Lib/test/test_funcattrs.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_funcattrs.py b/Lib/test/test_funcattrs.py index 9756b858b5326c..c4a6d99bd14440 100644 --- a/Lib/test/test_funcattrs.py +++ b/Lib/test/test_funcattrs.py @@ -479,8 +479,9 @@ def test_builtin__qualname__(self): self.assertEqual([1, 2, 3].append.__qualname__, 'list.append') self.assertEqual({'foo': 'bar'}.pop.__qualname__, 'dict.pop') - @support.cpython_only # See gh-58211 + @support.cpython_only def test_builtin__self__(self): + # See https://github.com/python/cpython/issues/58211. import time import builtins From 0fcf92afef5291c4ee7ff87d7d14fa1d82c8b433 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Thu, 10 Apr 2025 22:10:22 +0100 Subject: [PATCH 6/9] gh-58211: Put imports alphabetically sorted --- Lib/test/test_funcattrs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_funcattrs.py b/Lib/test/test_funcattrs.py index c4a6d99bd14440..2b741b54a3aeb0 100644 --- a/Lib/test/test_funcattrs.py +++ b/Lib/test/test_funcattrs.py @@ -482,8 +482,8 @@ def test_builtin__qualname__(self): @support.cpython_only def test_builtin__self__(self): # See https://github.com/python/cpython/issues/58211. - import time import builtins + import time # builtin function: self.assertEqual(len.__self__, builtins) From 0454ca44c9d49fb248f0161e7c36e6cf74c28e8c Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Thu, 10 Apr 2025 22:55:21 +0100 Subject: [PATCH 7/9] gh-58211: Use more strict assertions --- Lib/test/test_funcattrs.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Lib/test/test_funcattrs.py b/Lib/test/test_funcattrs.py index 2b741b54a3aeb0..d1687e03b654b6 100644 --- a/Lib/test/test_funcattrs.py +++ b/Lib/test/test_funcattrs.py @@ -486,20 +486,23 @@ def test_builtin__self__(self): import time # builtin function: - self.assertEqual(len.__self__, builtins) - self.assertEqual(time.sleep.__self__, time) + self.assertIs(len.__self__, builtins) + self.assertIs(time.sleep.__self__, time) # builtin classmethod: - self.assertEqual(dict.fromkeys.__self__, dict) - self.assertEqual(float.__getformat__.__self__, float) + self.assertIs(dict.fromkeys.__self__, dict) + self.assertIs(float.__getformat__.__self__, float) # builtin staticmethod: - self.assertEqual(str.maketrans.__self__, None) - self.assertEqual(bytes.maketrans.__self__, None) + self.assertIsNone(str.maketrans.__self__) + self.assertIsNone(bytes.maketrans.__self__) # builtin bound instance method: - self.assertEqual([1, 2, 3].append.__self__, [1, 2, 3]) - self.assertEqual({'foo': 'bar'}.pop.__self__, {'foo': 'bar'}) + l = [1, 2, 3] + self.assertIs(l.append.__self__, l) + + d = {'foo': 'bar'} + self.assertEqual(d.pop.__self__, d) if __name__ == "__main__": From c032a85ce6ecf483c12cd2db1ccdc12e10f2df9d Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Thu, 10 Apr 2025 23:44:05 +0100 Subject: [PATCH 8/9] gh-58211: Add test to builtin constants bound method --- Lib/test/test_funcattrs.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Lib/test/test_funcattrs.py b/Lib/test/test_funcattrs.py index d1687e03b654b6..9d357510bf6db5 100644 --- a/Lib/test/test_funcattrs.py +++ b/Lib/test/test_funcattrs.py @@ -504,6 +504,20 @@ def test_builtin__self__(self): d = {'foo': 'bar'} self.assertEqual(d.pop.__self__, d) + # builtin constants bound method: + self.assertFalse(False.__repr__.__self__) + self.assertIsNone(None.__repr__.__self__) + self.assertTrue(True.__repr__.__self__) + + ni = NotImplemented + self.assertIs(ni.__repr__.__self__, ni) + + e = Ellipsis + self.assertIs(e.__repr__.__self__, e) + + d = __debug__ + self.assertIs(d.__repr__.__self__, d) + if __name__ == "__main__": unittest.main() From c7f959ba921e12cef70efeb91b8a8d26978ffe74 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Fri, 11 Apr 2025 12:26:12 +0100 Subject: [PATCH 9/9] gh-58211: Remove redundant tests Co-authored-by: Serhiy Storchaka --- Lib/test/test_funcattrs.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Lib/test/test_funcattrs.py b/Lib/test/test_funcattrs.py index 9d357510bf6db5..375f456dfde834 100644 --- a/Lib/test/test_funcattrs.py +++ b/Lib/test/test_funcattrs.py @@ -504,19 +504,7 @@ def test_builtin__self__(self): d = {'foo': 'bar'} self.assertEqual(d.pop.__self__, d) - # builtin constants bound method: - self.assertFalse(False.__repr__.__self__) self.assertIsNone(None.__repr__.__self__) - self.assertTrue(True.__repr__.__self__) - - ni = NotImplemented - self.assertIs(ni.__repr__.__self__, ni) - - e = Ellipsis - self.assertIs(e.__repr__.__self__, e) - - d = __debug__ - self.assertIs(d.__repr__.__self__, d) if __name__ == "__main__":