You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1790 lines
48 KiB

Merged revisions 75149,75260-75263,75265-75267,75292,75300,75376,75405,75429-75433,75437,75445,75501,75551,75572,75589-75591,75657,75742,75868,75952-75957,76057,76105,76139,76143,76162,76223 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r75149 | gregory.p.smith | 2009-09-29 16:56:31 -0500 (Tue, 29 Sep 2009) | 3 lines Mention issue6972 in extractall docs about overwriting things outside of the supplied path. ........ r75260 | andrew.kuchling | 2009-10-05 16:24:20 -0500 (Mon, 05 Oct 2009) | 1 line Wording fix ........ r75261 | andrew.kuchling | 2009-10-05 16:24:35 -0500 (Mon, 05 Oct 2009) | 1 line Fix narkup ........ r75262 | andrew.kuchling | 2009-10-05 16:25:03 -0500 (Mon, 05 Oct 2009) | 1 line Document 'skip' parameter to constructor ........ r75263 | andrew.kuchling | 2009-10-05 16:25:35 -0500 (Mon, 05 Oct 2009) | 1 line Note side benefit of socket.create_connection() ........ r75265 | andrew.kuchling | 2009-10-05 17:31:11 -0500 (Mon, 05 Oct 2009) | 1 line Reword sentence ........ r75266 | andrew.kuchling | 2009-10-05 17:32:48 -0500 (Mon, 05 Oct 2009) | 1 line Use standard comma punctuation; reword some sentences in the docs ........ r75267 | andrew.kuchling | 2009-10-05 17:42:56 -0500 (Mon, 05 Oct 2009) | 1 line Backport r73983: Document the thousands separator. ........ r75292 | benjamin.peterson | 2009-10-08 22:11:36 -0500 (Thu, 08 Oct 2009) | 1 line death to old CVS keyword ........ r75300 | benjamin.peterson | 2009-10-09 16:48:14 -0500 (Fri, 09 Oct 2009) | 1 line fix some coding style ........ r75376 | benjamin.peterson | 2009-10-11 20:26:07 -0500 (Sun, 11 Oct 2009) | 1 line platform we don't care about ........ r75405 | neil.schemenauer | 2009-10-14 12:17:14 -0500 (Wed, 14 Oct 2009) | 4 lines Issue #1754094: Improve the stack depth calculation in the compiler. There should be no other effect than a small decrease in memory use. Patch by Christopher Tur Lesniewski-Laas. ........ r75429 | benjamin.peterson | 2009-10-14 20:47:28 -0500 (Wed, 14 Oct 2009) | 1 line pep8ify if blocks ........ r75430 | benjamin.peterson | 2009-10-14 20:49:37 -0500 (Wed, 14 Oct 2009) | 1 line use floor division and add a test that exercises the tabsize codepath ........ r75431 | benjamin.peterson | 2009-10-14 20:56:25 -0500 (Wed, 14 Oct 2009) | 1 line change test to what I intended ........ r75432 | benjamin.peterson | 2009-10-14 22:05:39 -0500 (Wed, 14 Oct 2009) | 1 line some cleanups ........ r75433 | benjamin.peterson | 2009-10-14 22:06:55 -0500 (Wed, 14 Oct 2009) | 1 line make inspect.isabstract() always return a boolean; add a test for it, too #7069 ........ r75437 | benjamin.peterson | 2009-10-15 10:44:46 -0500 (Thu, 15 Oct 2009) | 1 line only clear a module's __dict__ if the module is the only one with a reference to it #7140 ........ r75445 | vinay.sajip | 2009-10-16 09:06:44 -0500 (Fri, 16 Oct 2009) | 1 line Issue #7120: logging: Removed import of multiprocessing which is causing crash in GAE. ........ r75501 | antoine.pitrou | 2009-10-18 13:37:11 -0500 (Sun, 18 Oct 2009) | 3 lines Add a comment about unreachable code, and fix a typo ........ r75551 | benjamin.peterson | 2009-10-19 22:14:10 -0500 (Mon, 19 Oct 2009) | 1 line use property api ........ r75572 | benjamin.peterson | 2009-10-20 16:55:17 -0500 (Tue, 20 Oct 2009) | 1 line clarify buffer arg #7178 ........ r75589 | benjamin.peterson | 2009-10-21 21:26:47 -0500 (Wed, 21 Oct 2009) | 1 line whitespace ........ r75590 | benjamin.peterson | 2009-10-21 21:36:47 -0500 (Wed, 21 Oct 2009) | 1 line rewrite to be nice to other implementations ........ r75591 | benjamin.peterson | 2009-10-21 21:50:38 -0500 (Wed, 21 Oct 2009) | 4 lines rewrite for style, clarify, and comments Also, use the hasattr() like scheme of allowing BaseException exceptions through. ........ r75657 | antoine.pitrou | 2009-10-24 07:41:27 -0500 (Sat, 24 Oct 2009) | 3 lines Fix compilation error in debug mode. ........ r75742 | benjamin.peterson | 2009-10-26 17:51:16 -0500 (Mon, 26 Oct 2009) | 1 line use 'is' instead of id() ........ r75868 | benjamin.peterson | 2009-10-27 15:59:18 -0500 (Tue, 27 Oct 2009) | 1 line test expect base classes ........ r75952 | georg.brandl | 2009-10-29 15:38:32 -0500 (Thu, 29 Oct 2009) | 1 line Use the correct function name in docstring. ........ r75953 | georg.brandl | 2009-10-29 15:39:50 -0500 (Thu, 29 Oct 2009) | 1 line Remove mention of the old -X command line switch. ........ r75954 | georg.brandl | 2009-10-29 15:53:00 -0500 (Thu, 29 Oct 2009) | 1 line Use constants instead of magic integers for test result. Do not re-run with --verbose3 for environment changing tests. ........ r75955 | georg.brandl | 2009-10-29 15:54:03 -0500 (Thu, 29 Oct 2009) | 1 line Use a single style for all the docstrings in the math module. ........ r75956 | georg.brandl | 2009-10-29 16:16:34 -0500 (Thu, 29 Oct 2009) | 1 line I do not think the "railroad" program mentioned is still available. ........ r75957 | georg.brandl | 2009-10-29 16:44:56 -0500 (Thu, 29 Oct 2009) | 1 line Fix constant name. ........ r76057 | benjamin.peterson | 2009-11-02 09:06:45 -0600 (Mon, 02 Nov 2009) | 1 line prevent a rather unlikely segfault ........ r76105 | georg.brandl | 2009-11-04 01:38:12 -0600 (Wed, 04 Nov 2009) | 1 line #7259: show correct equivalent for operator.i* operations in docstring; fix minor issues in operator docs. ........ r76139 | benjamin.peterson | 2009-11-06 19:04:38 -0600 (Fri, 06 Nov 2009) | 1 line spelling ........ r76143 | georg.brandl | 2009-11-07 02:26:07 -0600 (Sat, 07 Nov 2009) | 1 line #7271: fix typo. ........ r76162 | benjamin.peterson | 2009-11-08 22:10:53 -0600 (Sun, 08 Nov 2009) | 1 line discuss how to use -p ........ r76223 | georg.brandl | 2009-11-12 02:29:46 -0600 (Thu, 12 Nov 2009) | 1 line Give the profile module a module directive. ........
16 years ago
Merged revisions 61003-61033 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r61004 | georg.brandl | 2008-02-23 19:47:04 +0100 (Sat, 23 Feb 2008) | 2 lines Documentation coverage builder, part 1. ........ r61006 | andrew.kuchling | 2008-02-23 20:02:33 +0100 (Sat, 23 Feb 2008) | 1 line #1389051: IMAP module tries to read entire message in one chunk. Patch by Fredrik Lundh. ........ r61008 | andrew.kuchling | 2008-02-23 20:28:58 +0100 (Sat, 23 Feb 2008) | 1 line #1389051, #1092502: fix excessively large allocations when using read() on a socket ........ r61011 | jeffrey.yasskin | 2008-02-23 20:40:54 +0100 (Sat, 23 Feb 2008) | 13 lines Prevent classes like: class RunSelfFunction(object): def __init__(self): self.thread = threading.Thread(target=self._run) self.thread.start() def _run(self): pass from creating a permanent cycle between the object and the thread by having the Thread delete its references to the object when it completes. As an example of the effect of this bug, paramiko.Transport inherits from Thread to avoid it. ........ r61013 | jeffrey.yasskin | 2008-02-23 21:40:35 +0100 (Sat, 23 Feb 2008) | 3 lines Followup to r61011: Also avoid the reference cycle when the Thread's target raises an exception. ........ r61017 | georg.brandl | 2008-02-23 22:59:11 +0100 (Sat, 23 Feb 2008) | 2 lines #2101: fix removeAttribute docs. ........ r61018 | georg.brandl | 2008-02-23 23:05:38 +0100 (Sat, 23 Feb 2008) | 2 lines Add examples to modulefinder docs. Written for GHOP by Josip Dzolonga. ........ r61019 | georg.brandl | 2008-02-23 23:09:24 +0100 (Sat, 23 Feb 2008) | 2 lines Use os.closerange() in popen2. ........ r61020 | georg.brandl | 2008-02-23 23:14:02 +0100 (Sat, 23 Feb 2008) | 2 lines Use os.closerange(). ........ r61021 | georg.brandl | 2008-02-23 23:35:33 +0100 (Sat, 23 Feb 2008) | 3 lines In test_heapq and test_bisect, test both the Python and the C implementation. Originally written for GHOP by Josip Dzolonga, heavily patched by me. ........ r61024 | facundo.batista | 2008-02-23 23:54:12 +0100 (Sat, 23 Feb 2008) | 3 lines Added simple test case. Thanks Benjamin Peterson. ........ r61025 | georg.brandl | 2008-02-23 23:55:18 +0100 (Sat, 23 Feb 2008) | 2 lines #1825: correctly document msilib.add_data. ........ r61027 | georg.brandl | 2008-02-24 00:02:23 +0100 (Sun, 24 Feb 2008) | 2 lines #1826: allow dotted attribute paths in operator.attrgetter. ........ r61028 | georg.brandl | 2008-02-24 00:04:35 +0100 (Sun, 24 Feb 2008) | 2 lines #1506171: added operator.methodcaller(). ........ r61029 | georg.brandl | 2008-02-24 00:25:26 +0100 (Sun, 24 Feb 2008) | 2 lines Document import ./. threading issues. #1720705. ........ r61032 | georg.brandl | 2008-02-24 00:43:01 +0100 (Sun, 24 Feb 2008) | 2 lines Specify what kind of warning -3 emits. ........ r61033 | christian.heimes | 2008-02-24 00:59:45 +0100 (Sun, 24 Feb 2008) | 1 line MS Windows doesn't have mode_t but stat.st_mode is defined as unsigned short. ........
18 years ago
Merged revisions 61003-61033 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r61004 | georg.brandl | 2008-02-23 19:47:04 +0100 (Sat, 23 Feb 2008) | 2 lines Documentation coverage builder, part 1. ........ r61006 | andrew.kuchling | 2008-02-23 20:02:33 +0100 (Sat, 23 Feb 2008) | 1 line #1389051: IMAP module tries to read entire message in one chunk. Patch by Fredrik Lundh. ........ r61008 | andrew.kuchling | 2008-02-23 20:28:58 +0100 (Sat, 23 Feb 2008) | 1 line #1389051, #1092502: fix excessively large allocations when using read() on a socket ........ r61011 | jeffrey.yasskin | 2008-02-23 20:40:54 +0100 (Sat, 23 Feb 2008) | 13 lines Prevent classes like: class RunSelfFunction(object): def __init__(self): self.thread = threading.Thread(target=self._run) self.thread.start() def _run(self): pass from creating a permanent cycle between the object and the thread by having the Thread delete its references to the object when it completes. As an example of the effect of this bug, paramiko.Transport inherits from Thread to avoid it. ........ r61013 | jeffrey.yasskin | 2008-02-23 21:40:35 +0100 (Sat, 23 Feb 2008) | 3 lines Followup to r61011: Also avoid the reference cycle when the Thread's target raises an exception. ........ r61017 | georg.brandl | 2008-02-23 22:59:11 +0100 (Sat, 23 Feb 2008) | 2 lines #2101: fix removeAttribute docs. ........ r61018 | georg.brandl | 2008-02-23 23:05:38 +0100 (Sat, 23 Feb 2008) | 2 lines Add examples to modulefinder docs. Written for GHOP by Josip Dzolonga. ........ r61019 | georg.brandl | 2008-02-23 23:09:24 +0100 (Sat, 23 Feb 2008) | 2 lines Use os.closerange() in popen2. ........ r61020 | georg.brandl | 2008-02-23 23:14:02 +0100 (Sat, 23 Feb 2008) | 2 lines Use os.closerange(). ........ r61021 | georg.brandl | 2008-02-23 23:35:33 +0100 (Sat, 23 Feb 2008) | 3 lines In test_heapq and test_bisect, test both the Python and the C implementation. Originally written for GHOP by Josip Dzolonga, heavily patched by me. ........ r61024 | facundo.batista | 2008-02-23 23:54:12 +0100 (Sat, 23 Feb 2008) | 3 lines Added simple test case. Thanks Benjamin Peterson. ........ r61025 | georg.brandl | 2008-02-23 23:55:18 +0100 (Sat, 23 Feb 2008) | 2 lines #1825: correctly document msilib.add_data. ........ r61027 | georg.brandl | 2008-02-24 00:02:23 +0100 (Sun, 24 Feb 2008) | 2 lines #1826: allow dotted attribute paths in operator.attrgetter. ........ r61028 | georg.brandl | 2008-02-24 00:04:35 +0100 (Sun, 24 Feb 2008) | 2 lines #1506171: added operator.methodcaller(). ........ r61029 | georg.brandl | 2008-02-24 00:25:26 +0100 (Sun, 24 Feb 2008) | 2 lines Document import ./. threading issues. #1720705. ........ r61032 | georg.brandl | 2008-02-24 00:43:01 +0100 (Sun, 24 Feb 2008) | 2 lines Specify what kind of warning -3 emits. ........ r61033 | christian.heimes | 2008-02-24 00:59:45 +0100 (Sun, 24 Feb 2008) | 1 line MS Windows doesn't have mode_t but stat.st_mode is defined as unsigned short. ........
18 years ago
Merged revisions 61003-61033 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r61004 | georg.brandl | 2008-02-23 19:47:04 +0100 (Sat, 23 Feb 2008) | 2 lines Documentation coverage builder, part 1. ........ r61006 | andrew.kuchling | 2008-02-23 20:02:33 +0100 (Sat, 23 Feb 2008) | 1 line #1389051: IMAP module tries to read entire message in one chunk. Patch by Fredrik Lundh. ........ r61008 | andrew.kuchling | 2008-02-23 20:28:58 +0100 (Sat, 23 Feb 2008) | 1 line #1389051, #1092502: fix excessively large allocations when using read() on a socket ........ r61011 | jeffrey.yasskin | 2008-02-23 20:40:54 +0100 (Sat, 23 Feb 2008) | 13 lines Prevent classes like: class RunSelfFunction(object): def __init__(self): self.thread = threading.Thread(target=self._run) self.thread.start() def _run(self): pass from creating a permanent cycle between the object and the thread by having the Thread delete its references to the object when it completes. As an example of the effect of this bug, paramiko.Transport inherits from Thread to avoid it. ........ r61013 | jeffrey.yasskin | 2008-02-23 21:40:35 +0100 (Sat, 23 Feb 2008) | 3 lines Followup to r61011: Also avoid the reference cycle when the Thread's target raises an exception. ........ r61017 | georg.brandl | 2008-02-23 22:59:11 +0100 (Sat, 23 Feb 2008) | 2 lines #2101: fix removeAttribute docs. ........ r61018 | georg.brandl | 2008-02-23 23:05:38 +0100 (Sat, 23 Feb 2008) | 2 lines Add examples to modulefinder docs. Written for GHOP by Josip Dzolonga. ........ r61019 | georg.brandl | 2008-02-23 23:09:24 +0100 (Sat, 23 Feb 2008) | 2 lines Use os.closerange() in popen2. ........ r61020 | georg.brandl | 2008-02-23 23:14:02 +0100 (Sat, 23 Feb 2008) | 2 lines Use os.closerange(). ........ r61021 | georg.brandl | 2008-02-23 23:35:33 +0100 (Sat, 23 Feb 2008) | 3 lines In test_heapq and test_bisect, test both the Python and the C implementation. Originally written for GHOP by Josip Dzolonga, heavily patched by me. ........ r61024 | facundo.batista | 2008-02-23 23:54:12 +0100 (Sat, 23 Feb 2008) | 3 lines Added simple test case. Thanks Benjamin Peterson. ........ r61025 | georg.brandl | 2008-02-23 23:55:18 +0100 (Sat, 23 Feb 2008) | 2 lines #1825: correctly document msilib.add_data. ........ r61027 | georg.brandl | 2008-02-24 00:02:23 +0100 (Sun, 24 Feb 2008) | 2 lines #1826: allow dotted attribute paths in operator.attrgetter. ........ r61028 | georg.brandl | 2008-02-24 00:04:35 +0100 (Sun, 24 Feb 2008) | 2 lines #1506171: added operator.methodcaller(). ........ r61029 | georg.brandl | 2008-02-24 00:25:26 +0100 (Sun, 24 Feb 2008) | 2 lines Document import ./. threading issues. #1720705. ........ r61032 | georg.brandl | 2008-02-24 00:43:01 +0100 (Sun, 24 Feb 2008) | 2 lines Specify what kind of warning -3 emits. ........ r61033 | christian.heimes | 2008-02-24 00:59:45 +0100 (Sun, 24 Feb 2008) | 1 line MS Windows doesn't have mode_t but stat.st_mode is defined as unsigned short. ........
18 years ago
Merged revisions 61003-61033 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r61004 | georg.brandl | 2008-02-23 19:47:04 +0100 (Sat, 23 Feb 2008) | 2 lines Documentation coverage builder, part 1. ........ r61006 | andrew.kuchling | 2008-02-23 20:02:33 +0100 (Sat, 23 Feb 2008) | 1 line #1389051: IMAP module tries to read entire message in one chunk. Patch by Fredrik Lundh. ........ r61008 | andrew.kuchling | 2008-02-23 20:28:58 +0100 (Sat, 23 Feb 2008) | 1 line #1389051, #1092502: fix excessively large allocations when using read() on a socket ........ r61011 | jeffrey.yasskin | 2008-02-23 20:40:54 +0100 (Sat, 23 Feb 2008) | 13 lines Prevent classes like: class RunSelfFunction(object): def __init__(self): self.thread = threading.Thread(target=self._run) self.thread.start() def _run(self): pass from creating a permanent cycle between the object and the thread by having the Thread delete its references to the object when it completes. As an example of the effect of this bug, paramiko.Transport inherits from Thread to avoid it. ........ r61013 | jeffrey.yasskin | 2008-02-23 21:40:35 +0100 (Sat, 23 Feb 2008) | 3 lines Followup to r61011: Also avoid the reference cycle when the Thread's target raises an exception. ........ r61017 | georg.brandl | 2008-02-23 22:59:11 +0100 (Sat, 23 Feb 2008) | 2 lines #2101: fix removeAttribute docs. ........ r61018 | georg.brandl | 2008-02-23 23:05:38 +0100 (Sat, 23 Feb 2008) | 2 lines Add examples to modulefinder docs. Written for GHOP by Josip Dzolonga. ........ r61019 | georg.brandl | 2008-02-23 23:09:24 +0100 (Sat, 23 Feb 2008) | 2 lines Use os.closerange() in popen2. ........ r61020 | georg.brandl | 2008-02-23 23:14:02 +0100 (Sat, 23 Feb 2008) | 2 lines Use os.closerange(). ........ r61021 | georg.brandl | 2008-02-23 23:35:33 +0100 (Sat, 23 Feb 2008) | 3 lines In test_heapq and test_bisect, test both the Python and the C implementation. Originally written for GHOP by Josip Dzolonga, heavily patched by me. ........ r61024 | facundo.batista | 2008-02-23 23:54:12 +0100 (Sat, 23 Feb 2008) | 3 lines Added simple test case. Thanks Benjamin Peterson. ........ r61025 | georg.brandl | 2008-02-23 23:55:18 +0100 (Sat, 23 Feb 2008) | 2 lines #1825: correctly document msilib.add_data. ........ r61027 | georg.brandl | 2008-02-24 00:02:23 +0100 (Sun, 24 Feb 2008) | 2 lines #1826: allow dotted attribute paths in operator.attrgetter. ........ r61028 | georg.brandl | 2008-02-24 00:04:35 +0100 (Sun, 24 Feb 2008) | 2 lines #1506171: added operator.methodcaller(). ........ r61029 | georg.brandl | 2008-02-24 00:25:26 +0100 (Sun, 24 Feb 2008) | 2 lines Document import ./. threading issues. #1720705. ........ r61032 | georg.brandl | 2008-02-24 00:43:01 +0100 (Sun, 24 Feb 2008) | 2 lines Specify what kind of warning -3 emits. ........ r61033 | christian.heimes | 2008-02-24 00:59:45 +0100 (Sun, 24 Feb 2008) | 1 line MS Windows doesn't have mode_t but stat.st_mode is defined as unsigned short. ........
18 years ago
Merged revisions 61003-61033 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r61004 | georg.brandl | 2008-02-23 19:47:04 +0100 (Sat, 23 Feb 2008) | 2 lines Documentation coverage builder, part 1. ........ r61006 | andrew.kuchling | 2008-02-23 20:02:33 +0100 (Sat, 23 Feb 2008) | 1 line #1389051: IMAP module tries to read entire message in one chunk. Patch by Fredrik Lundh. ........ r61008 | andrew.kuchling | 2008-02-23 20:28:58 +0100 (Sat, 23 Feb 2008) | 1 line #1389051, #1092502: fix excessively large allocations when using read() on a socket ........ r61011 | jeffrey.yasskin | 2008-02-23 20:40:54 +0100 (Sat, 23 Feb 2008) | 13 lines Prevent classes like: class RunSelfFunction(object): def __init__(self): self.thread = threading.Thread(target=self._run) self.thread.start() def _run(self): pass from creating a permanent cycle between the object and the thread by having the Thread delete its references to the object when it completes. As an example of the effect of this bug, paramiko.Transport inherits from Thread to avoid it. ........ r61013 | jeffrey.yasskin | 2008-02-23 21:40:35 +0100 (Sat, 23 Feb 2008) | 3 lines Followup to r61011: Also avoid the reference cycle when the Thread's target raises an exception. ........ r61017 | georg.brandl | 2008-02-23 22:59:11 +0100 (Sat, 23 Feb 2008) | 2 lines #2101: fix removeAttribute docs. ........ r61018 | georg.brandl | 2008-02-23 23:05:38 +0100 (Sat, 23 Feb 2008) | 2 lines Add examples to modulefinder docs. Written for GHOP by Josip Dzolonga. ........ r61019 | georg.brandl | 2008-02-23 23:09:24 +0100 (Sat, 23 Feb 2008) | 2 lines Use os.closerange() in popen2. ........ r61020 | georg.brandl | 2008-02-23 23:14:02 +0100 (Sat, 23 Feb 2008) | 2 lines Use os.closerange(). ........ r61021 | georg.brandl | 2008-02-23 23:35:33 +0100 (Sat, 23 Feb 2008) | 3 lines In test_heapq and test_bisect, test both the Python and the C implementation. Originally written for GHOP by Josip Dzolonga, heavily patched by me. ........ r61024 | facundo.batista | 2008-02-23 23:54:12 +0100 (Sat, 23 Feb 2008) | 3 lines Added simple test case. Thanks Benjamin Peterson. ........ r61025 | georg.brandl | 2008-02-23 23:55:18 +0100 (Sat, 23 Feb 2008) | 2 lines #1825: correctly document msilib.add_data. ........ r61027 | georg.brandl | 2008-02-24 00:02:23 +0100 (Sun, 24 Feb 2008) | 2 lines #1826: allow dotted attribute paths in operator.attrgetter. ........ r61028 | georg.brandl | 2008-02-24 00:04:35 +0100 (Sun, 24 Feb 2008) | 2 lines #1506171: added operator.methodcaller(). ........ r61029 | georg.brandl | 2008-02-24 00:25:26 +0100 (Sun, 24 Feb 2008) | 2 lines Document import ./. threading issues. #1720705. ........ r61032 | georg.brandl | 2008-02-24 00:43:01 +0100 (Sun, 24 Feb 2008) | 2 lines Specify what kind of warning -3 emits. ........ r61033 | christian.heimes | 2008-02-24 00:59:45 +0100 (Sun, 24 Feb 2008) | 1 line MS Windows doesn't have mode_t but stat.st_mode is defined as unsigned short. ........
18 years ago
Merged revisions 61003-61033 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r61004 | georg.brandl | 2008-02-23 19:47:04 +0100 (Sat, 23 Feb 2008) | 2 lines Documentation coverage builder, part 1. ........ r61006 | andrew.kuchling | 2008-02-23 20:02:33 +0100 (Sat, 23 Feb 2008) | 1 line #1389051: IMAP module tries to read entire message in one chunk. Patch by Fredrik Lundh. ........ r61008 | andrew.kuchling | 2008-02-23 20:28:58 +0100 (Sat, 23 Feb 2008) | 1 line #1389051, #1092502: fix excessively large allocations when using read() on a socket ........ r61011 | jeffrey.yasskin | 2008-02-23 20:40:54 +0100 (Sat, 23 Feb 2008) | 13 lines Prevent classes like: class RunSelfFunction(object): def __init__(self): self.thread = threading.Thread(target=self._run) self.thread.start() def _run(self): pass from creating a permanent cycle between the object and the thread by having the Thread delete its references to the object when it completes. As an example of the effect of this bug, paramiko.Transport inherits from Thread to avoid it. ........ r61013 | jeffrey.yasskin | 2008-02-23 21:40:35 +0100 (Sat, 23 Feb 2008) | 3 lines Followup to r61011: Also avoid the reference cycle when the Thread's target raises an exception. ........ r61017 | georg.brandl | 2008-02-23 22:59:11 +0100 (Sat, 23 Feb 2008) | 2 lines #2101: fix removeAttribute docs. ........ r61018 | georg.brandl | 2008-02-23 23:05:38 +0100 (Sat, 23 Feb 2008) | 2 lines Add examples to modulefinder docs. Written for GHOP by Josip Dzolonga. ........ r61019 | georg.brandl | 2008-02-23 23:09:24 +0100 (Sat, 23 Feb 2008) | 2 lines Use os.closerange() in popen2. ........ r61020 | georg.brandl | 2008-02-23 23:14:02 +0100 (Sat, 23 Feb 2008) | 2 lines Use os.closerange(). ........ r61021 | georg.brandl | 2008-02-23 23:35:33 +0100 (Sat, 23 Feb 2008) | 3 lines In test_heapq and test_bisect, test both the Python and the C implementation. Originally written for GHOP by Josip Dzolonga, heavily patched by me. ........ r61024 | facundo.batista | 2008-02-23 23:54:12 +0100 (Sat, 23 Feb 2008) | 3 lines Added simple test case. Thanks Benjamin Peterson. ........ r61025 | georg.brandl | 2008-02-23 23:55:18 +0100 (Sat, 23 Feb 2008) | 2 lines #1825: correctly document msilib.add_data. ........ r61027 | georg.brandl | 2008-02-24 00:02:23 +0100 (Sun, 24 Feb 2008) | 2 lines #1826: allow dotted attribute paths in operator.attrgetter. ........ r61028 | georg.brandl | 2008-02-24 00:04:35 +0100 (Sun, 24 Feb 2008) | 2 lines #1506171: added operator.methodcaller(). ........ r61029 | georg.brandl | 2008-02-24 00:25:26 +0100 (Sun, 24 Feb 2008) | 2 lines Document import ./. threading issues. #1720705. ........ r61032 | georg.brandl | 2008-02-24 00:43:01 +0100 (Sun, 24 Feb 2008) | 2 lines Specify what kind of warning -3 emits. ........ r61033 | christian.heimes | 2008-02-24 00:59:45 +0100 (Sun, 24 Feb 2008) | 1 line MS Windows doesn't have mode_t but stat.st_mode is defined as unsigned short. ........
18 years ago
Merged revisions 61003-61033 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r61004 | georg.brandl | 2008-02-23 19:47:04 +0100 (Sat, 23 Feb 2008) | 2 lines Documentation coverage builder, part 1. ........ r61006 | andrew.kuchling | 2008-02-23 20:02:33 +0100 (Sat, 23 Feb 2008) | 1 line #1389051: IMAP module tries to read entire message in one chunk. Patch by Fredrik Lundh. ........ r61008 | andrew.kuchling | 2008-02-23 20:28:58 +0100 (Sat, 23 Feb 2008) | 1 line #1389051, #1092502: fix excessively large allocations when using read() on a socket ........ r61011 | jeffrey.yasskin | 2008-02-23 20:40:54 +0100 (Sat, 23 Feb 2008) | 13 lines Prevent classes like: class RunSelfFunction(object): def __init__(self): self.thread = threading.Thread(target=self._run) self.thread.start() def _run(self): pass from creating a permanent cycle between the object and the thread by having the Thread delete its references to the object when it completes. As an example of the effect of this bug, paramiko.Transport inherits from Thread to avoid it. ........ r61013 | jeffrey.yasskin | 2008-02-23 21:40:35 +0100 (Sat, 23 Feb 2008) | 3 lines Followup to r61011: Also avoid the reference cycle when the Thread's target raises an exception. ........ r61017 | georg.brandl | 2008-02-23 22:59:11 +0100 (Sat, 23 Feb 2008) | 2 lines #2101: fix removeAttribute docs. ........ r61018 | georg.brandl | 2008-02-23 23:05:38 +0100 (Sat, 23 Feb 2008) | 2 lines Add examples to modulefinder docs. Written for GHOP by Josip Dzolonga. ........ r61019 | georg.brandl | 2008-02-23 23:09:24 +0100 (Sat, 23 Feb 2008) | 2 lines Use os.closerange() in popen2. ........ r61020 | georg.brandl | 2008-02-23 23:14:02 +0100 (Sat, 23 Feb 2008) | 2 lines Use os.closerange(). ........ r61021 | georg.brandl | 2008-02-23 23:35:33 +0100 (Sat, 23 Feb 2008) | 3 lines In test_heapq and test_bisect, test both the Python and the C implementation. Originally written for GHOP by Josip Dzolonga, heavily patched by me. ........ r61024 | facundo.batista | 2008-02-23 23:54:12 +0100 (Sat, 23 Feb 2008) | 3 lines Added simple test case. Thanks Benjamin Peterson. ........ r61025 | georg.brandl | 2008-02-23 23:55:18 +0100 (Sat, 23 Feb 2008) | 2 lines #1825: correctly document msilib.add_data. ........ r61027 | georg.brandl | 2008-02-24 00:02:23 +0100 (Sun, 24 Feb 2008) | 2 lines #1826: allow dotted attribute paths in operator.attrgetter. ........ r61028 | georg.brandl | 2008-02-24 00:04:35 +0100 (Sun, 24 Feb 2008) | 2 lines #1506171: added operator.methodcaller(). ........ r61029 | georg.brandl | 2008-02-24 00:25:26 +0100 (Sun, 24 Feb 2008) | 2 lines Document import ./. threading issues. #1720705. ........ r61032 | georg.brandl | 2008-02-24 00:43:01 +0100 (Sun, 24 Feb 2008) | 2 lines Specify what kind of warning -3 emits. ........ r61033 | christian.heimes | 2008-02-24 00:59:45 +0100 (Sun, 24 Feb 2008) | 1 line MS Windows doesn't have mode_t but stat.st_mode is defined as unsigned short. ........
18 years ago
Merged revisions 61003-61033 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r61004 | georg.brandl | 2008-02-23 19:47:04 +0100 (Sat, 23 Feb 2008) | 2 lines Documentation coverage builder, part 1. ........ r61006 | andrew.kuchling | 2008-02-23 20:02:33 +0100 (Sat, 23 Feb 2008) | 1 line #1389051: IMAP module tries to read entire message in one chunk. Patch by Fredrik Lundh. ........ r61008 | andrew.kuchling | 2008-02-23 20:28:58 +0100 (Sat, 23 Feb 2008) | 1 line #1389051, #1092502: fix excessively large allocations when using read() on a socket ........ r61011 | jeffrey.yasskin | 2008-02-23 20:40:54 +0100 (Sat, 23 Feb 2008) | 13 lines Prevent classes like: class RunSelfFunction(object): def __init__(self): self.thread = threading.Thread(target=self._run) self.thread.start() def _run(self): pass from creating a permanent cycle between the object and the thread by having the Thread delete its references to the object when it completes. As an example of the effect of this bug, paramiko.Transport inherits from Thread to avoid it. ........ r61013 | jeffrey.yasskin | 2008-02-23 21:40:35 +0100 (Sat, 23 Feb 2008) | 3 lines Followup to r61011: Also avoid the reference cycle when the Thread's target raises an exception. ........ r61017 | georg.brandl | 2008-02-23 22:59:11 +0100 (Sat, 23 Feb 2008) | 2 lines #2101: fix removeAttribute docs. ........ r61018 | georg.brandl | 2008-02-23 23:05:38 +0100 (Sat, 23 Feb 2008) | 2 lines Add examples to modulefinder docs. Written for GHOP by Josip Dzolonga. ........ r61019 | georg.brandl | 2008-02-23 23:09:24 +0100 (Sat, 23 Feb 2008) | 2 lines Use os.closerange() in popen2. ........ r61020 | georg.brandl | 2008-02-23 23:14:02 +0100 (Sat, 23 Feb 2008) | 2 lines Use os.closerange(). ........ r61021 | georg.brandl | 2008-02-23 23:35:33 +0100 (Sat, 23 Feb 2008) | 3 lines In test_heapq and test_bisect, test both the Python and the C implementation. Originally written for GHOP by Josip Dzolonga, heavily patched by me. ........ r61024 | facundo.batista | 2008-02-23 23:54:12 +0100 (Sat, 23 Feb 2008) | 3 lines Added simple test case. Thanks Benjamin Peterson. ........ r61025 | georg.brandl | 2008-02-23 23:55:18 +0100 (Sat, 23 Feb 2008) | 2 lines #1825: correctly document msilib.add_data. ........ r61027 | georg.brandl | 2008-02-24 00:02:23 +0100 (Sun, 24 Feb 2008) | 2 lines #1826: allow dotted attribute paths in operator.attrgetter. ........ r61028 | georg.brandl | 2008-02-24 00:04:35 +0100 (Sun, 24 Feb 2008) | 2 lines #1506171: added operator.methodcaller(). ........ r61029 | georg.brandl | 2008-02-24 00:25:26 +0100 (Sun, 24 Feb 2008) | 2 lines Document import ./. threading issues. #1720705. ........ r61032 | georg.brandl | 2008-02-24 00:43:01 +0100 (Sun, 24 Feb 2008) | 2 lines Specify what kind of warning -3 emits. ........ r61033 | christian.heimes | 2008-02-24 00:59:45 +0100 (Sun, 24 Feb 2008) | 1 line MS Windows doesn't have mode_t but stat.st_mode is defined as unsigned short. ........
18 years ago
Merged revisions 61003-61033 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r61004 | georg.brandl | 2008-02-23 19:47:04 +0100 (Sat, 23 Feb 2008) | 2 lines Documentation coverage builder, part 1. ........ r61006 | andrew.kuchling | 2008-02-23 20:02:33 +0100 (Sat, 23 Feb 2008) | 1 line #1389051: IMAP module tries to read entire message in one chunk. Patch by Fredrik Lundh. ........ r61008 | andrew.kuchling | 2008-02-23 20:28:58 +0100 (Sat, 23 Feb 2008) | 1 line #1389051, #1092502: fix excessively large allocations when using read() on a socket ........ r61011 | jeffrey.yasskin | 2008-02-23 20:40:54 +0100 (Sat, 23 Feb 2008) | 13 lines Prevent classes like: class RunSelfFunction(object): def __init__(self): self.thread = threading.Thread(target=self._run) self.thread.start() def _run(self): pass from creating a permanent cycle between the object and the thread by having the Thread delete its references to the object when it completes. As an example of the effect of this bug, paramiko.Transport inherits from Thread to avoid it. ........ r61013 | jeffrey.yasskin | 2008-02-23 21:40:35 +0100 (Sat, 23 Feb 2008) | 3 lines Followup to r61011: Also avoid the reference cycle when the Thread's target raises an exception. ........ r61017 | georg.brandl | 2008-02-23 22:59:11 +0100 (Sat, 23 Feb 2008) | 2 lines #2101: fix removeAttribute docs. ........ r61018 | georg.brandl | 2008-02-23 23:05:38 +0100 (Sat, 23 Feb 2008) | 2 lines Add examples to modulefinder docs. Written for GHOP by Josip Dzolonga. ........ r61019 | georg.brandl | 2008-02-23 23:09:24 +0100 (Sat, 23 Feb 2008) | 2 lines Use os.closerange() in popen2. ........ r61020 | georg.brandl | 2008-02-23 23:14:02 +0100 (Sat, 23 Feb 2008) | 2 lines Use os.closerange(). ........ r61021 | georg.brandl | 2008-02-23 23:35:33 +0100 (Sat, 23 Feb 2008) | 3 lines In test_heapq and test_bisect, test both the Python and the C implementation. Originally written for GHOP by Josip Dzolonga, heavily patched by me. ........ r61024 | facundo.batista | 2008-02-23 23:54:12 +0100 (Sat, 23 Feb 2008) | 3 lines Added simple test case. Thanks Benjamin Peterson. ........ r61025 | georg.brandl | 2008-02-23 23:55:18 +0100 (Sat, 23 Feb 2008) | 2 lines #1825: correctly document msilib.add_data. ........ r61027 | georg.brandl | 2008-02-24 00:02:23 +0100 (Sun, 24 Feb 2008) | 2 lines #1826: allow dotted attribute paths in operator.attrgetter. ........ r61028 | georg.brandl | 2008-02-24 00:04:35 +0100 (Sun, 24 Feb 2008) | 2 lines #1506171: added operator.methodcaller(). ........ r61029 | georg.brandl | 2008-02-24 00:25:26 +0100 (Sun, 24 Feb 2008) | 2 lines Document import ./. threading issues. #1720705. ........ r61032 | georg.brandl | 2008-02-24 00:43:01 +0100 (Sun, 24 Feb 2008) | 2 lines Specify what kind of warning -3 emits. ........ r61033 | christian.heimes | 2008-02-24 00:59:45 +0100 (Sun, 24 Feb 2008) | 1 line MS Windows doesn't have mode_t but stat.st_mode is defined as unsigned short. ........
18 years ago
Merged revisions 61003-61033 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r61004 | georg.brandl | 2008-02-23 19:47:04 +0100 (Sat, 23 Feb 2008) | 2 lines Documentation coverage builder, part 1. ........ r61006 | andrew.kuchling | 2008-02-23 20:02:33 +0100 (Sat, 23 Feb 2008) | 1 line #1389051: IMAP module tries to read entire message in one chunk. Patch by Fredrik Lundh. ........ r61008 | andrew.kuchling | 2008-02-23 20:28:58 +0100 (Sat, 23 Feb 2008) | 1 line #1389051, #1092502: fix excessively large allocations when using read() on a socket ........ r61011 | jeffrey.yasskin | 2008-02-23 20:40:54 +0100 (Sat, 23 Feb 2008) | 13 lines Prevent classes like: class RunSelfFunction(object): def __init__(self): self.thread = threading.Thread(target=self._run) self.thread.start() def _run(self): pass from creating a permanent cycle between the object and the thread by having the Thread delete its references to the object when it completes. As an example of the effect of this bug, paramiko.Transport inherits from Thread to avoid it. ........ r61013 | jeffrey.yasskin | 2008-02-23 21:40:35 +0100 (Sat, 23 Feb 2008) | 3 lines Followup to r61011: Also avoid the reference cycle when the Thread's target raises an exception. ........ r61017 | georg.brandl | 2008-02-23 22:59:11 +0100 (Sat, 23 Feb 2008) | 2 lines #2101: fix removeAttribute docs. ........ r61018 | georg.brandl | 2008-02-23 23:05:38 +0100 (Sat, 23 Feb 2008) | 2 lines Add examples to modulefinder docs. Written for GHOP by Josip Dzolonga. ........ r61019 | georg.brandl | 2008-02-23 23:09:24 +0100 (Sat, 23 Feb 2008) | 2 lines Use os.closerange() in popen2. ........ r61020 | georg.brandl | 2008-02-23 23:14:02 +0100 (Sat, 23 Feb 2008) | 2 lines Use os.closerange(). ........ r61021 | georg.brandl | 2008-02-23 23:35:33 +0100 (Sat, 23 Feb 2008) | 3 lines In test_heapq and test_bisect, test both the Python and the C implementation. Originally written for GHOP by Josip Dzolonga, heavily patched by me. ........ r61024 | facundo.batista | 2008-02-23 23:54:12 +0100 (Sat, 23 Feb 2008) | 3 lines Added simple test case. Thanks Benjamin Peterson. ........ r61025 | georg.brandl | 2008-02-23 23:55:18 +0100 (Sat, 23 Feb 2008) | 2 lines #1825: correctly document msilib.add_data. ........ r61027 | georg.brandl | 2008-02-24 00:02:23 +0100 (Sun, 24 Feb 2008) | 2 lines #1826: allow dotted attribute paths in operator.attrgetter. ........ r61028 | georg.brandl | 2008-02-24 00:04:35 +0100 (Sun, 24 Feb 2008) | 2 lines #1506171: added operator.methodcaller(). ........ r61029 | georg.brandl | 2008-02-24 00:25:26 +0100 (Sun, 24 Feb 2008) | 2 lines Document import ./. threading issues. #1720705. ........ r61032 | georg.brandl | 2008-02-24 00:43:01 +0100 (Sun, 24 Feb 2008) | 2 lines Specify what kind of warning -3 emits. ........ r61033 | christian.heimes | 2008-02-24 00:59:45 +0100 (Sun, 24 Feb 2008) | 1 line MS Windows doesn't have mode_t but stat.st_mode is defined as unsigned short. ........
18 years ago
Merged revisions 61003-61033 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r61004 | georg.brandl | 2008-02-23 19:47:04 +0100 (Sat, 23 Feb 2008) | 2 lines Documentation coverage builder, part 1. ........ r61006 | andrew.kuchling | 2008-02-23 20:02:33 +0100 (Sat, 23 Feb 2008) | 1 line #1389051: IMAP module tries to read entire message in one chunk. Patch by Fredrik Lundh. ........ r61008 | andrew.kuchling | 2008-02-23 20:28:58 +0100 (Sat, 23 Feb 2008) | 1 line #1389051, #1092502: fix excessively large allocations when using read() on a socket ........ r61011 | jeffrey.yasskin | 2008-02-23 20:40:54 +0100 (Sat, 23 Feb 2008) | 13 lines Prevent classes like: class RunSelfFunction(object): def __init__(self): self.thread = threading.Thread(target=self._run) self.thread.start() def _run(self): pass from creating a permanent cycle between the object and the thread by having the Thread delete its references to the object when it completes. As an example of the effect of this bug, paramiko.Transport inherits from Thread to avoid it. ........ r61013 | jeffrey.yasskin | 2008-02-23 21:40:35 +0100 (Sat, 23 Feb 2008) | 3 lines Followup to r61011: Also avoid the reference cycle when the Thread's target raises an exception. ........ r61017 | georg.brandl | 2008-02-23 22:59:11 +0100 (Sat, 23 Feb 2008) | 2 lines #2101: fix removeAttribute docs. ........ r61018 | georg.brandl | 2008-02-23 23:05:38 +0100 (Sat, 23 Feb 2008) | 2 lines Add examples to modulefinder docs. Written for GHOP by Josip Dzolonga. ........ r61019 | georg.brandl | 2008-02-23 23:09:24 +0100 (Sat, 23 Feb 2008) | 2 lines Use os.closerange() in popen2. ........ r61020 | georg.brandl | 2008-02-23 23:14:02 +0100 (Sat, 23 Feb 2008) | 2 lines Use os.closerange(). ........ r61021 | georg.brandl | 2008-02-23 23:35:33 +0100 (Sat, 23 Feb 2008) | 3 lines In test_heapq and test_bisect, test both the Python and the C implementation. Originally written for GHOP by Josip Dzolonga, heavily patched by me. ........ r61024 | facundo.batista | 2008-02-23 23:54:12 +0100 (Sat, 23 Feb 2008) | 3 lines Added simple test case. Thanks Benjamin Peterson. ........ r61025 | georg.brandl | 2008-02-23 23:55:18 +0100 (Sat, 23 Feb 2008) | 2 lines #1825: correctly document msilib.add_data. ........ r61027 | georg.brandl | 2008-02-24 00:02:23 +0100 (Sun, 24 Feb 2008) | 2 lines #1826: allow dotted attribute paths in operator.attrgetter. ........ r61028 | georg.brandl | 2008-02-24 00:04:35 +0100 (Sun, 24 Feb 2008) | 2 lines #1506171: added operator.methodcaller(). ........ r61029 | georg.brandl | 2008-02-24 00:25:26 +0100 (Sun, 24 Feb 2008) | 2 lines Document import ./. threading issues. #1720705. ........ r61032 | georg.brandl | 2008-02-24 00:43:01 +0100 (Sun, 24 Feb 2008) | 2 lines Specify what kind of warning -3 emits. ........ r61033 | christian.heimes | 2008-02-24 00:59:45 +0100 (Sun, 24 Feb 2008) | 1 line MS Windows doesn't have mode_t but stat.st_mode is defined as unsigned short. ........
18 years ago
Merged revisions 61003-61033 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r61004 | georg.brandl | 2008-02-23 19:47:04 +0100 (Sat, 23 Feb 2008) | 2 lines Documentation coverage builder, part 1. ........ r61006 | andrew.kuchling | 2008-02-23 20:02:33 +0100 (Sat, 23 Feb 2008) | 1 line #1389051: IMAP module tries to read entire message in one chunk. Patch by Fredrik Lundh. ........ r61008 | andrew.kuchling | 2008-02-23 20:28:58 +0100 (Sat, 23 Feb 2008) | 1 line #1389051, #1092502: fix excessively large allocations when using read() on a socket ........ r61011 | jeffrey.yasskin | 2008-02-23 20:40:54 +0100 (Sat, 23 Feb 2008) | 13 lines Prevent classes like: class RunSelfFunction(object): def __init__(self): self.thread = threading.Thread(target=self._run) self.thread.start() def _run(self): pass from creating a permanent cycle between the object and the thread by having the Thread delete its references to the object when it completes. As an example of the effect of this bug, paramiko.Transport inherits from Thread to avoid it. ........ r61013 | jeffrey.yasskin | 2008-02-23 21:40:35 +0100 (Sat, 23 Feb 2008) | 3 lines Followup to r61011: Also avoid the reference cycle when the Thread's target raises an exception. ........ r61017 | georg.brandl | 2008-02-23 22:59:11 +0100 (Sat, 23 Feb 2008) | 2 lines #2101: fix removeAttribute docs. ........ r61018 | georg.brandl | 2008-02-23 23:05:38 +0100 (Sat, 23 Feb 2008) | 2 lines Add examples to modulefinder docs. Written for GHOP by Josip Dzolonga. ........ r61019 | georg.brandl | 2008-02-23 23:09:24 +0100 (Sat, 23 Feb 2008) | 2 lines Use os.closerange() in popen2. ........ r61020 | georg.brandl | 2008-02-23 23:14:02 +0100 (Sat, 23 Feb 2008) | 2 lines Use os.closerange(). ........ r61021 | georg.brandl | 2008-02-23 23:35:33 +0100 (Sat, 23 Feb 2008) | 3 lines In test_heapq and test_bisect, test both the Python and the C implementation. Originally written for GHOP by Josip Dzolonga, heavily patched by me. ........ r61024 | facundo.batista | 2008-02-23 23:54:12 +0100 (Sat, 23 Feb 2008) | 3 lines Added simple test case. Thanks Benjamin Peterson. ........ r61025 | georg.brandl | 2008-02-23 23:55:18 +0100 (Sat, 23 Feb 2008) | 2 lines #1825: correctly document msilib.add_data. ........ r61027 | georg.brandl | 2008-02-24 00:02:23 +0100 (Sun, 24 Feb 2008) | 2 lines #1826: allow dotted attribute paths in operator.attrgetter. ........ r61028 | georg.brandl | 2008-02-24 00:04:35 +0100 (Sun, 24 Feb 2008) | 2 lines #1506171: added operator.methodcaller(). ........ r61029 | georg.brandl | 2008-02-24 00:25:26 +0100 (Sun, 24 Feb 2008) | 2 lines Document import ./. threading issues. #1720705. ........ r61032 | georg.brandl | 2008-02-24 00:43:01 +0100 (Sun, 24 Feb 2008) | 2 lines Specify what kind of warning -3 emits. ........ r61033 | christian.heimes | 2008-02-24 00:59:45 +0100 (Sun, 24 Feb 2008) | 1 line MS Windows doesn't have mode_t but stat.st_mode is defined as unsigned short. ........
18 years ago
Merged revisions 61003-61033 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r61004 | georg.brandl | 2008-02-23 19:47:04 +0100 (Sat, 23 Feb 2008) | 2 lines Documentation coverage builder, part 1. ........ r61006 | andrew.kuchling | 2008-02-23 20:02:33 +0100 (Sat, 23 Feb 2008) | 1 line #1389051: IMAP module tries to read entire message in one chunk. Patch by Fredrik Lundh. ........ r61008 | andrew.kuchling | 2008-02-23 20:28:58 +0100 (Sat, 23 Feb 2008) | 1 line #1389051, #1092502: fix excessively large allocations when using read() on a socket ........ r61011 | jeffrey.yasskin | 2008-02-23 20:40:54 +0100 (Sat, 23 Feb 2008) | 13 lines Prevent classes like: class RunSelfFunction(object): def __init__(self): self.thread = threading.Thread(target=self._run) self.thread.start() def _run(self): pass from creating a permanent cycle between the object and the thread by having the Thread delete its references to the object when it completes. As an example of the effect of this bug, paramiko.Transport inherits from Thread to avoid it. ........ r61013 | jeffrey.yasskin | 2008-02-23 21:40:35 +0100 (Sat, 23 Feb 2008) | 3 lines Followup to r61011: Also avoid the reference cycle when the Thread's target raises an exception. ........ r61017 | georg.brandl | 2008-02-23 22:59:11 +0100 (Sat, 23 Feb 2008) | 2 lines #2101: fix removeAttribute docs. ........ r61018 | georg.brandl | 2008-02-23 23:05:38 +0100 (Sat, 23 Feb 2008) | 2 lines Add examples to modulefinder docs. Written for GHOP by Josip Dzolonga. ........ r61019 | georg.brandl | 2008-02-23 23:09:24 +0100 (Sat, 23 Feb 2008) | 2 lines Use os.closerange() in popen2. ........ r61020 | georg.brandl | 2008-02-23 23:14:02 +0100 (Sat, 23 Feb 2008) | 2 lines Use os.closerange(). ........ r61021 | georg.brandl | 2008-02-23 23:35:33 +0100 (Sat, 23 Feb 2008) | 3 lines In test_heapq and test_bisect, test both the Python and the C implementation. Originally written for GHOP by Josip Dzolonga, heavily patched by me. ........ r61024 | facundo.batista | 2008-02-23 23:54:12 +0100 (Sat, 23 Feb 2008) | 3 lines Added simple test case. Thanks Benjamin Peterson. ........ r61025 | georg.brandl | 2008-02-23 23:55:18 +0100 (Sat, 23 Feb 2008) | 2 lines #1825: correctly document msilib.add_data. ........ r61027 | georg.brandl | 2008-02-24 00:02:23 +0100 (Sun, 24 Feb 2008) | 2 lines #1826: allow dotted attribute paths in operator.attrgetter. ........ r61028 | georg.brandl | 2008-02-24 00:04:35 +0100 (Sun, 24 Feb 2008) | 2 lines #1506171: added operator.methodcaller(). ........ r61029 | georg.brandl | 2008-02-24 00:25:26 +0100 (Sun, 24 Feb 2008) | 2 lines Document import ./. threading issues. #1720705. ........ r61032 | georg.brandl | 2008-02-24 00:43:01 +0100 (Sun, 24 Feb 2008) | 2 lines Specify what kind of warning -3 emits. ........ r61033 | christian.heimes | 2008-02-24 00:59:45 +0100 (Sun, 24 Feb 2008) | 1 line MS Windows doesn't have mode_t but stat.st_mode is defined as unsigned short. ........
18 years ago
  1. #include "Python.h"
  2. #include "clinic/_operator.c.h"
  3. /*[clinic input]
  4. module _operator
  5. [clinic start generated code]*/
  6. /*[clinic end generated code: output=da39a3ee5e6b4b0d input=672ecf48487521e7]*/
  7. PyDoc_STRVAR(operator_doc,
  8. "Operator interface.\n\
  9. \n\
  10. This module exports a set of functions implemented in C corresponding\n\
  11. to the intrinsic operators of Python. For example, operator.add(x, y)\n\
  12. is equivalent to the expression x+y. The function names are those\n\
  13. used for special methods; variants without leading and trailing\n\
  14. '__' are also provided for convenience.");
  15. /*[clinic input]
  16. _operator.truth -> bool
  17. a: object
  18. /
  19. Return True if a is true, False otherwise.
  20. [clinic start generated code]*/
  21. static int
  22. _operator_truth_impl(PyObject *module, PyObject *a)
  23. /*[clinic end generated code: output=eaf87767234fa5d7 input=bc74a4cd90235875]*/
  24. {
  25. return PyObject_IsTrue(a);
  26. }
  27. /*[clinic input]
  28. _operator.add
  29. a: object
  30. b: object
  31. /
  32. Same as a + b.
  33. [clinic start generated code]*/
  34. static PyObject *
  35. _operator_add_impl(PyObject *module, PyObject *a, PyObject *b)
  36. /*[clinic end generated code: output=8292984204f45164 input=5efe3bff856ac215]*/
  37. {
  38. return PyNumber_Add(a, b);
  39. }
  40. /*[clinic input]
  41. _operator.sub = _operator.add
  42. Same as a - b.
  43. [clinic start generated code]*/
  44. static PyObject *
  45. _operator_sub_impl(PyObject *module, PyObject *a, PyObject *b)
  46. /*[clinic end generated code: output=4adfc3b888c1ee2e input=6494c6b100b8e795]*/
  47. {
  48. return PyNumber_Subtract(a, b);
  49. }
  50. /*[clinic input]
  51. _operator.mul = _operator.add
  52. Same as a * b.
  53. [clinic start generated code]*/
  54. static PyObject *
  55. _operator_mul_impl(PyObject *module, PyObject *a, PyObject *b)
  56. /*[clinic end generated code: output=d24d66f55a01944c input=2368615b4358b70d]*/
  57. {
  58. return PyNumber_Multiply(a, b);
  59. }
  60. /*[clinic input]
  61. _operator.matmul = _operator.add
  62. Same as a @ b.
  63. [clinic start generated code]*/
  64. static PyObject *
  65. _operator_matmul_impl(PyObject *module, PyObject *a, PyObject *b)
  66. /*[clinic end generated code: output=a20d917eb35d0101 input=9ab304e37fb42dd4]*/
  67. {
  68. return PyNumber_MatrixMultiply(a, b);
  69. }
  70. /*[clinic input]
  71. _operator.floordiv = _operator.add
  72. Same as a // b.
  73. [clinic start generated code]*/
  74. static PyObject *
  75. _operator_floordiv_impl(PyObject *module, PyObject *a, PyObject *b)
  76. /*[clinic end generated code: output=df26b71a60589f99 input=bb2e88ba446c612c]*/
  77. {
  78. return PyNumber_FloorDivide(a, b);
  79. }
  80. /*[clinic input]
  81. _operator.truediv = _operator.add
  82. Same as a / b.
  83. [clinic start generated code]*/
  84. static PyObject *
  85. _operator_truediv_impl(PyObject *module, PyObject *a, PyObject *b)
  86. /*[clinic end generated code: output=0e6a959944d77719 input=ecbb947673f4eb1f]*/
  87. {
  88. return PyNumber_TrueDivide(a, b);
  89. }
  90. /*[clinic input]
  91. _operator.mod = _operator.add
  92. Same as a % b.
  93. [clinic start generated code]*/
  94. static PyObject *
  95. _operator_mod_impl(PyObject *module, PyObject *a, PyObject *b)
  96. /*[clinic end generated code: output=9519822f0bbec166 input=102e19b422342ac1]*/
  97. {
  98. return PyNumber_Remainder(a, b);
  99. }
  100. /*[clinic input]
  101. _operator.neg
  102. a: object
  103. /
  104. Same as -a.
  105. [clinic start generated code]*/
  106. static PyObject *
  107. _operator_neg(PyObject *module, PyObject *a)
  108. /*[clinic end generated code: output=36e08ecfc6a1c08c input=84f09bdcf27c96ec]*/
  109. {
  110. return PyNumber_Negative(a);
  111. }
  112. /*[clinic input]
  113. _operator.pos = _operator.neg
  114. Same as +a.
  115. [clinic start generated code]*/
  116. static PyObject *
  117. _operator_pos(PyObject *module, PyObject *a)
  118. /*[clinic end generated code: output=dad7a126221dd091 input=b6445b63fddb8772]*/
  119. {
  120. return PyNumber_Positive(a);
  121. }
  122. /*[clinic input]
  123. _operator.abs = _operator.neg
  124. Same as abs(a).
  125. [clinic start generated code]*/
  126. static PyObject *
  127. _operator_abs(PyObject *module, PyObject *a)
  128. /*[clinic end generated code: output=1389a93ba053ea3e input=341d07ba86f58039]*/
  129. {
  130. return PyNumber_Absolute(a);
  131. }
  132. /*[clinic input]
  133. _operator.inv = _operator.neg
  134. Same as ~a.
  135. [clinic start generated code]*/
  136. static PyObject *
  137. _operator_inv(PyObject *module, PyObject *a)
  138. /*[clinic end generated code: output=a56875ba075ee06d input=b01a4677739f6eb2]*/
  139. {
  140. return PyNumber_Invert(a);
  141. }
  142. /*[clinic input]
  143. _operator.invert = _operator.neg
  144. Same as ~a.
  145. [clinic start generated code]*/
  146. static PyObject *
  147. _operator_invert(PyObject *module, PyObject *a)
  148. /*[clinic end generated code: output=406b5aa030545fcc input=7f2d607176672e55]*/
  149. {
  150. return PyNumber_Invert(a);
  151. }
  152. /*[clinic input]
  153. _operator.lshift = _operator.add
  154. Same as a << b.
  155. [clinic start generated code]*/
  156. static PyObject *
  157. _operator_lshift_impl(PyObject *module, PyObject *a, PyObject *b)
  158. /*[clinic end generated code: output=37f7e52c41435bd8 input=746e8a160cbbc9eb]*/
  159. {
  160. return PyNumber_Lshift(a, b);
  161. }
  162. /*[clinic input]
  163. _operator.rshift = _operator.add
  164. Same as a >> b.
  165. [clinic start generated code]*/
  166. static PyObject *
  167. _operator_rshift_impl(PyObject *module, PyObject *a, PyObject *b)
  168. /*[clinic end generated code: output=4593c7ef30ec2ee3 input=d2c85bb5a64504c2]*/
  169. {
  170. return PyNumber_Rshift(a, b);
  171. }
  172. /*[clinic input]
  173. _operator.not_ = _operator.truth
  174. Same as not a.
  175. [clinic start generated code]*/
  176. static int
  177. _operator_not__impl(PyObject *module, PyObject *a)
  178. /*[clinic end generated code: output=743f9c24a09759ef input=854156d50804d9b8]*/
  179. {
  180. return PyObject_Not(a);
  181. }
  182. /*[clinic input]
  183. _operator.and_ = _operator.add
  184. Same as a & b.
  185. [clinic start generated code]*/
  186. static PyObject *
  187. _operator_and__impl(PyObject *module, PyObject *a, PyObject *b)
  188. /*[clinic end generated code: output=93c4fe88f7b76d9e input=4f3057c90ec4c99f]*/
  189. {
  190. return PyNumber_And(a, b);
  191. }
  192. /*[clinic input]
  193. _operator.xor = _operator.add
  194. Same as a ^ b.
  195. [clinic start generated code]*/
  196. static PyObject *
  197. _operator_xor_impl(PyObject *module, PyObject *a, PyObject *b)
  198. /*[clinic end generated code: output=b24cd8b79fde0004 input=3c5cfa7253d808dd]*/
  199. {
  200. return PyNumber_Xor(a, b);
  201. }
  202. /*[clinic input]
  203. _operator.or_ = _operator.add
  204. Same as a | b.
  205. [clinic start generated code]*/
  206. static PyObject *
  207. _operator_or__impl(PyObject *module, PyObject *a, PyObject *b)
  208. /*[clinic end generated code: output=58024867b8d90461 input=b40c6c44f7c79c09]*/
  209. {
  210. return PyNumber_Or(a, b);
  211. }
  212. /*[clinic input]
  213. _operator.iadd = _operator.add
  214. Same as a += b.
  215. [clinic start generated code]*/
  216. static PyObject *
  217. _operator_iadd_impl(PyObject *module, PyObject *a, PyObject *b)
  218. /*[clinic end generated code: output=07dc627832526eb5 input=d22a91c07ac69227]*/
  219. {
  220. return PyNumber_InPlaceAdd(a, b);
  221. }
  222. /*[clinic input]
  223. _operator.isub = _operator.add
  224. Same as a -= b.
  225. [clinic start generated code]*/
  226. static PyObject *
  227. _operator_isub_impl(PyObject *module, PyObject *a, PyObject *b)
  228. /*[clinic end generated code: output=4513467d23b5e0b1 input=4591b00d0a0ccafd]*/
  229. {
  230. return PyNumber_InPlaceSubtract(a, b);
  231. }
  232. /*[clinic input]
  233. _operator.imul = _operator.add
  234. Same as a *= b.
  235. [clinic start generated code]*/
  236. static PyObject *
  237. _operator_imul_impl(PyObject *module, PyObject *a, PyObject *b)
  238. /*[clinic end generated code: output=5e87dacd19a71eab input=0e01fb8631e1b76f]*/
  239. {
  240. return PyNumber_InPlaceMultiply(a, b);
  241. }
  242. /*[clinic input]
  243. _operator.imatmul = _operator.add
  244. Same as a @= b.
  245. [clinic start generated code]*/
  246. static PyObject *
  247. _operator_imatmul_impl(PyObject *module, PyObject *a, PyObject *b)
  248. /*[clinic end generated code: output=d603cbdf716ce519 input=bb614026372cd542]*/
  249. {
  250. return PyNumber_InPlaceMatrixMultiply(a, b);
  251. }
  252. /*[clinic input]
  253. _operator.ifloordiv = _operator.add
  254. Same as a //= b.
  255. [clinic start generated code]*/
  256. static PyObject *
  257. _operator_ifloordiv_impl(PyObject *module, PyObject *a, PyObject *b)
  258. /*[clinic end generated code: output=535336048c681794 input=9df3b5021cff4ca1]*/
  259. {
  260. return PyNumber_InPlaceFloorDivide(a, b);
  261. }
  262. /*[clinic input]
  263. _operator.itruediv = _operator.add
  264. Same as a /= b.
  265. [clinic start generated code]*/
  266. static PyObject *
  267. _operator_itruediv_impl(PyObject *module, PyObject *a, PyObject *b)
  268. /*[clinic end generated code: output=28017fbd3563952f input=9a1ee01608f5f590]*/
  269. {
  270. return PyNumber_InPlaceTrueDivide(a, b);
  271. }
  272. /*[clinic input]
  273. _operator.imod = _operator.add
  274. Same as a %= b.
  275. [clinic start generated code]*/
  276. static PyObject *
  277. _operator_imod_impl(PyObject *module, PyObject *a, PyObject *b)
  278. /*[clinic end generated code: output=f7c540ae0fc70904 input=d0c384a3ce38e1dd]*/
  279. {
  280. return PyNumber_InPlaceRemainder(a, b);
  281. }
  282. /*[clinic input]
  283. _operator.ilshift = _operator.add
  284. Same as a <<= b.
  285. [clinic start generated code]*/
  286. static PyObject *
  287. _operator_ilshift_impl(PyObject *module, PyObject *a, PyObject *b)
  288. /*[clinic end generated code: output=e73a8fee1ac18749 input=e21b6b310f54572e]*/
  289. {
  290. return PyNumber_InPlaceLshift(a, b);
  291. }
  292. /*[clinic input]
  293. _operator.irshift = _operator.add
  294. Same as a >>= b.
  295. [clinic start generated code]*/
  296. static PyObject *
  297. _operator_irshift_impl(PyObject *module, PyObject *a, PyObject *b)
  298. /*[clinic end generated code: output=97f2af6b5ff2ed81 input=6778dbd0f6e1ec16]*/
  299. {
  300. return PyNumber_InPlaceRshift(a, b);
  301. }
  302. /*[clinic input]
  303. _operator.iand = _operator.add
  304. Same as a &= b.
  305. [clinic start generated code]*/
  306. static PyObject *
  307. _operator_iand_impl(PyObject *module, PyObject *a, PyObject *b)
  308. /*[clinic end generated code: output=4599e9d40cbf7d00 input=71dfd8e70c156a7b]*/
  309. {
  310. return PyNumber_InPlaceAnd(a, b);
  311. }
  312. /*[clinic input]
  313. _operator.ixor = _operator.add
  314. Same as a ^= b.
  315. [clinic start generated code]*/
  316. static PyObject *
  317. _operator_ixor_impl(PyObject *module, PyObject *a, PyObject *b)
  318. /*[clinic end generated code: output=5ff881766872be03 input=695c32bec0604d86]*/
  319. {
  320. return PyNumber_InPlaceXor(a, b);
  321. }
  322. /*[clinic input]
  323. _operator.ior = _operator.add
  324. Same as a |= b.
  325. [clinic start generated code]*/
  326. static PyObject *
  327. _operator_ior_impl(PyObject *module, PyObject *a, PyObject *b)
  328. /*[clinic end generated code: output=48aac319445bf759 input=8f01d03eda9920cf]*/
  329. {
  330. return PyNumber_InPlaceOr(a, b);
  331. }
  332. /*[clinic input]
  333. _operator.concat = _operator.add
  334. Same as a + b, for a and b sequences.
  335. [clinic start generated code]*/
  336. static PyObject *
  337. _operator_concat_impl(PyObject *module, PyObject *a, PyObject *b)
  338. /*[clinic end generated code: output=80028390942c5f11 input=8544ccd5341a3658]*/
  339. {
  340. return PySequence_Concat(a, b);
  341. }
  342. /*[clinic input]
  343. _operator.iconcat = _operator.add
  344. Same as a += b, for a and b sequences.
  345. [clinic start generated code]*/
  346. static PyObject *
  347. _operator_iconcat_impl(PyObject *module, PyObject *a, PyObject *b)
  348. /*[clinic end generated code: output=3ea0a162ebb2e26d input=8f5fe5722fcd837e]*/
  349. {
  350. return PySequence_InPlaceConcat(a, b);
  351. }
  352. /*[clinic input]
  353. _operator.contains -> bool
  354. a: object
  355. b: object
  356. /
  357. Same as b in a (note reversed operands).
  358. [clinic start generated code]*/
  359. static int
  360. _operator_contains_impl(PyObject *module, PyObject *a, PyObject *b)
  361. /*[clinic end generated code: output=413b4dbe82b6ffc1 input=9122a69b505fde13]*/
  362. {
  363. return PySequence_Contains(a, b);
  364. }
  365. /*[clinic input]
  366. _operator.indexOf -> Py_ssize_t
  367. a: object
  368. b: object
  369. /
  370. Return the first index of b in a.
  371. [clinic start generated code]*/
  372. static Py_ssize_t
  373. _operator_indexOf_impl(PyObject *module, PyObject *a, PyObject *b)
  374. /*[clinic end generated code: output=c6226d8e0fb60fa6 input=8be2e43b6a6fffe3]*/
  375. {
  376. return PySequence_Index(a, b);
  377. }
  378. /*[clinic input]
  379. _operator.countOf = _operator.indexOf
  380. Return the number of times b occurs in a.
  381. [clinic start generated code]*/
  382. static Py_ssize_t
  383. _operator_countOf_impl(PyObject *module, PyObject *a, PyObject *b)
  384. /*[clinic end generated code: output=9e1623197daf3382 input=0c3a2656add252db]*/
  385. {
  386. return PySequence_Count(a, b);
  387. }
  388. /*[clinic input]
  389. _operator.getitem
  390. a: object
  391. b: object
  392. /
  393. Same as a[b].
  394. [clinic start generated code]*/
  395. static PyObject *
  396. _operator_getitem_impl(PyObject *module, PyObject *a, PyObject *b)
  397. /*[clinic end generated code: output=6c8d8101a676e594 input=6682797320e48845]*/
  398. {
  399. return PyObject_GetItem(a, b);
  400. }
  401. /*[clinic input]
  402. _operator.setitem
  403. a: object
  404. b: object
  405. c: object
  406. /
  407. Same as a[b] = c.
  408. [clinic start generated code]*/
  409. static PyObject *
  410. _operator_setitem_impl(PyObject *module, PyObject *a, PyObject *b,
  411. PyObject *c)
  412. /*[clinic end generated code: output=1324f9061ae99e25 input=ceaf453c4d3a58df]*/
  413. {
  414. if (-1 == PyObject_SetItem(a, b, c))
  415. return NULL;
  416. Py_RETURN_NONE;
  417. }
  418. /*[clinic input]
  419. _operator.delitem = _operator.getitem
  420. Same as del a[b].
  421. [clinic start generated code]*/
  422. static PyObject *
  423. _operator_delitem_impl(PyObject *module, PyObject *a, PyObject *b)
  424. /*[clinic end generated code: output=db18f61506295799 input=991bec56a0d3ec7f]*/
  425. {
  426. if (-1 == PyObject_DelItem(a, b))
  427. return NULL;
  428. Py_RETURN_NONE;
  429. }
  430. /*[clinic input]
  431. _operator.eq
  432. a: object
  433. b: object
  434. /
  435. Same as a == b.
  436. [clinic start generated code]*/
  437. static PyObject *
  438. _operator_eq_impl(PyObject *module, PyObject *a, PyObject *b)
  439. /*[clinic end generated code: output=8d7d46ed4135677c input=586fca687a95a83f]*/
  440. {
  441. return PyObject_RichCompare(a, b, Py_EQ);
  442. }
  443. /*[clinic input]
  444. _operator.ne = _operator.eq
  445. Same as a != b.
  446. [clinic start generated code]*/
  447. static PyObject *
  448. _operator_ne_impl(PyObject *module, PyObject *a, PyObject *b)
  449. /*[clinic end generated code: output=c99bd0c3a4c01297 input=5d88f23d35e9abac]*/
  450. {
  451. return PyObject_RichCompare(a, b, Py_NE);
  452. }
  453. /*[clinic input]
  454. _operator.lt = _operator.eq
  455. Same as a < b.
  456. [clinic start generated code]*/
  457. static PyObject *
  458. _operator_lt_impl(PyObject *module, PyObject *a, PyObject *b)
  459. /*[clinic end generated code: output=082d7c45c440e535 input=34a59ad6d39d3a2b]*/
  460. {
  461. return PyObject_RichCompare(a, b, Py_LT);
  462. }
  463. /*[clinic input]
  464. _operator.le = _operator.eq
  465. Same as a <= b.
  466. [clinic start generated code]*/
  467. static PyObject *
  468. _operator_le_impl(PyObject *module, PyObject *a, PyObject *b)
  469. /*[clinic end generated code: output=00970a2923d0ae17 input=b812a7860a0bef44]*/
  470. {
  471. return PyObject_RichCompare(a, b, Py_LE);
  472. }
  473. /*[clinic input]
  474. _operator.gt = _operator.eq
  475. Same as a > b.
  476. [clinic start generated code]*/
  477. static PyObject *
  478. _operator_gt_impl(PyObject *module, PyObject *a, PyObject *b)
  479. /*[clinic end generated code: output=8d373349ecf25641 input=9bdb45b995ada35b]*/
  480. {
  481. return PyObject_RichCompare(a, b, Py_GT);
  482. }
  483. /*[clinic input]
  484. _operator.ge = _operator.eq
  485. Same as a >= b.
  486. [clinic start generated code]*/
  487. static PyObject *
  488. _operator_ge_impl(PyObject *module, PyObject *a, PyObject *b)
  489. /*[clinic end generated code: output=7ce3882256d4b137 input=cf1dc4a5ca9c35f5]*/
  490. {
  491. return PyObject_RichCompare(a, b, Py_GE);
  492. }
  493. /*[clinic input]
  494. _operator.pow = _operator.add
  495. Same as a ** b.
  496. [clinic start generated code]*/
  497. static PyObject *
  498. _operator_pow_impl(PyObject *module, PyObject *a, PyObject *b)
  499. /*[clinic end generated code: output=09e668ad50036120 input=690b40f097ab1637]*/
  500. {
  501. return PyNumber_Power(a, b, Py_None);
  502. }
  503. /*[clinic input]
  504. _operator.ipow = _operator.add
  505. Same as a **= b.
  506. [clinic start generated code]*/
  507. static PyObject *
  508. _operator_ipow_impl(PyObject *module, PyObject *a, PyObject *b)
  509. /*[clinic end generated code: output=7189ff4d4367c808 input=f00623899d07499a]*/
  510. {
  511. return PyNumber_InPlacePower(a, b, Py_None);
  512. }
  513. /*[clinic input]
  514. _operator.index
  515. a: object
  516. /
  517. Same as a.__index__()
  518. [clinic start generated code]*/
  519. static PyObject *
  520. _operator_index(PyObject *module, PyObject *a)
  521. /*[clinic end generated code: output=d972b0764ac305fc input=6f54d50ea64a579c]*/
  522. {
  523. return PyNumber_Index(a);
  524. }
  525. /*[clinic input]
  526. _operator.is_ = _operator.add
  527. Same as a is b.
  528. [clinic start generated code]*/
  529. static PyObject *
  530. _operator_is__impl(PyObject *module, PyObject *a, PyObject *b)
  531. /*[clinic end generated code: output=bcd47a402e482e1d input=5fa9b97df03c427f]*/
  532. {
  533. PyObject *result;
  534. result = (a == b) ? Py_True : Py_False;
  535. Py_INCREF(result);
  536. return result;
  537. }
  538. /*[clinic input]
  539. _operator.is_not = _operator.add
  540. Same as a is not b.
  541. [clinic start generated code]*/
  542. static PyObject *
  543. _operator_is_not_impl(PyObject *module, PyObject *a, PyObject *b)
  544. /*[clinic end generated code: output=491a1f2f81f6c7f9 input=5a93f7e1a93535f1]*/
  545. {
  546. PyObject *result;
  547. result = (a != b) ? Py_True : Py_False;
  548. Py_INCREF(result);
  549. return result;
  550. }
  551. /* compare_digest **********************************************************/
  552. /*
  553. * timing safe compare
  554. *
  555. * Returns 1 of the strings are equal.
  556. * In case of len(a) != len(b) the function tries to keep the timing
  557. * dependent on the length of b. CPU cache locally may still alter timing
  558. * a bit.
  559. */
  560. static int
  561. _tscmp(const unsigned char *a, const unsigned char *b,
  562. Py_ssize_t len_a, Py_ssize_t len_b)
  563. {
  564. /* The volatile type declarations make sure that the compiler has no
  565. * chance to optimize and fold the code in any way that may change
  566. * the timing.
  567. */
  568. volatile Py_ssize_t length;
  569. volatile const unsigned char *left;
  570. volatile const unsigned char *right;
  571. Py_ssize_t i;
  572. unsigned char result;
  573. /* loop count depends on length of b */
  574. length = len_b;
  575. left = NULL;
  576. right = b;
  577. /* don't use else here to keep the amount of CPU instructions constant,
  578. * volatile forces re-evaluation
  579. * */
  580. if (len_a == length) {
  581. left = *((volatile const unsigned char**)&a);
  582. result = 0;
  583. }
  584. if (len_a != length) {
  585. left = b;
  586. result = 1;
  587. }
  588. for (i=0; i < length; i++) {
  589. result |= *left++ ^ *right++;
  590. }
  591. return (result == 0);
  592. }
  593. /*[clinic input]
  594. _operator.length_hint -> Py_ssize_t
  595. obj: object
  596. default: Py_ssize_t = 0
  597. /
  598. Return an estimate of the number of items in obj.
  599. This is useful for presizing containers when building from an iterable.
  600. If the object supports len(), the result will be exact.
  601. Otherwise, it may over- or under-estimate by an arbitrary amount.
  602. The result will be an integer >= 0.
  603. [clinic start generated code]*/
  604. static Py_ssize_t
  605. _operator_length_hint_impl(PyObject *module, PyObject *obj,
  606. Py_ssize_t default_value)
  607. /*[clinic end generated code: output=01d469edc1d612ad input=65ed29f04401e96a]*/
  608. {
  609. return PyObject_LengthHint(obj, default_value);
  610. }
  611. /*[clinic input]
  612. _operator._compare_digest = _operator.eq
  613. Return 'a == b'.
  614. This function uses an approach designed to prevent
  615. timing analysis, making it appropriate for cryptography.
  616. a and b must both be of the same type: either str (ASCII only),
  617. or any bytes-like object.
  618. Note: If a and b are of different lengths, or if an error occurs,
  619. a timing attack could theoretically reveal information about the
  620. types and lengths of a and b--but not their values.
  621. [clinic start generated code]*/
  622. static PyObject *
  623. _operator__compare_digest_impl(PyObject *module, PyObject *a, PyObject *b)
  624. /*[clinic end generated code: output=11d452bdd3a23cbc input=9ac7e2c4e30bc356]*/
  625. {
  626. int rc;
  627. /* ASCII unicode string */
  628. if(PyUnicode_Check(a) && PyUnicode_Check(b)) {
  629. if (PyUnicode_READY(a) == -1 || PyUnicode_READY(b) == -1) {
  630. return NULL;
  631. }
  632. if (!PyUnicode_IS_ASCII(a) || !PyUnicode_IS_ASCII(b)) {
  633. PyErr_SetString(PyExc_TypeError,
  634. "comparing strings with non-ASCII characters is "
  635. "not supported");
  636. return NULL;
  637. }
  638. rc = _tscmp(PyUnicode_DATA(a),
  639. PyUnicode_DATA(b),
  640. PyUnicode_GET_LENGTH(a),
  641. PyUnicode_GET_LENGTH(b));
  642. }
  643. /* fallback to buffer interface for bytes, bytesarray and other */
  644. else {
  645. Py_buffer view_a;
  646. Py_buffer view_b;
  647. if (PyObject_CheckBuffer(a) == 0 && PyObject_CheckBuffer(b) == 0) {
  648. PyErr_Format(PyExc_TypeError,
  649. "unsupported operand types(s) or combination of types: "
  650. "'%.100s' and '%.100s'",
  651. Py_TYPE(a)->tp_name, Py_TYPE(b)->tp_name);
  652. return NULL;
  653. }
  654. if (PyObject_GetBuffer(a, &view_a, PyBUF_SIMPLE) == -1) {
  655. return NULL;
  656. }
  657. if (view_a.ndim > 1) {
  658. PyErr_SetString(PyExc_BufferError,
  659. "Buffer must be single dimension");
  660. PyBuffer_Release(&view_a);
  661. return NULL;
  662. }
  663. if (PyObject_GetBuffer(b, &view_b, PyBUF_SIMPLE) == -1) {
  664. PyBuffer_Release(&view_a);
  665. return NULL;
  666. }
  667. if (view_b.ndim > 1) {
  668. PyErr_SetString(PyExc_BufferError,
  669. "Buffer must be single dimension");
  670. PyBuffer_Release(&view_a);
  671. PyBuffer_Release(&view_b);
  672. return NULL;
  673. }
  674. rc = _tscmp((const unsigned char*)view_a.buf,
  675. (const unsigned char*)view_b.buf,
  676. view_a.len,
  677. view_b.len);
  678. PyBuffer_Release(&view_a);
  679. PyBuffer_Release(&view_b);
  680. }
  681. return PyBool_FromLong(rc);
  682. }
  683. /* operator methods **********************************************************/
  684. static struct PyMethodDef operator_methods[] = {
  685. _OPERATOR_TRUTH_METHODDEF
  686. _OPERATOR_CONTAINS_METHODDEF
  687. _OPERATOR_INDEXOF_METHODDEF
  688. _OPERATOR_COUNTOF_METHODDEF
  689. _OPERATOR_IS__METHODDEF
  690. _OPERATOR_IS_NOT_METHODDEF
  691. _OPERATOR_INDEX_METHODDEF
  692. _OPERATOR_ADD_METHODDEF
  693. _OPERATOR_SUB_METHODDEF
  694. _OPERATOR_MUL_METHODDEF
  695. _OPERATOR_MATMUL_METHODDEF
  696. _OPERATOR_FLOORDIV_METHODDEF
  697. _OPERATOR_TRUEDIV_METHODDEF
  698. _OPERATOR_MOD_METHODDEF
  699. _OPERATOR_NEG_METHODDEF
  700. _OPERATOR_POS_METHODDEF
  701. _OPERATOR_ABS_METHODDEF
  702. _OPERATOR_INV_METHODDEF
  703. _OPERATOR_INVERT_METHODDEF
  704. _OPERATOR_LSHIFT_METHODDEF
  705. _OPERATOR_RSHIFT_METHODDEF
  706. _OPERATOR_NOT__METHODDEF
  707. _OPERATOR_AND__METHODDEF
  708. _OPERATOR_XOR_METHODDEF
  709. _OPERATOR_OR__METHODDEF
  710. _OPERATOR_IADD_METHODDEF
  711. _OPERATOR_ISUB_METHODDEF
  712. _OPERATOR_IMUL_METHODDEF
  713. _OPERATOR_IMATMUL_METHODDEF
  714. _OPERATOR_IFLOORDIV_METHODDEF
  715. _OPERATOR_ITRUEDIV_METHODDEF
  716. _OPERATOR_IMOD_METHODDEF
  717. _OPERATOR_ILSHIFT_METHODDEF
  718. _OPERATOR_IRSHIFT_METHODDEF
  719. _OPERATOR_IAND_METHODDEF
  720. _OPERATOR_IXOR_METHODDEF
  721. _OPERATOR_IOR_METHODDEF
  722. _OPERATOR_CONCAT_METHODDEF
  723. _OPERATOR_ICONCAT_METHODDEF
  724. _OPERATOR_GETITEM_METHODDEF
  725. _OPERATOR_SETITEM_METHODDEF
  726. _OPERATOR_DELITEM_METHODDEF
  727. _OPERATOR_POW_METHODDEF
  728. _OPERATOR_IPOW_METHODDEF
  729. _OPERATOR_EQ_METHODDEF
  730. _OPERATOR_NE_METHODDEF
  731. _OPERATOR_LT_METHODDEF
  732. _OPERATOR_LE_METHODDEF
  733. _OPERATOR_GT_METHODDEF
  734. _OPERATOR_GE_METHODDEF
  735. _OPERATOR__COMPARE_DIGEST_METHODDEF
  736. _OPERATOR_LENGTH_HINT_METHODDEF
  737. {NULL, NULL} /* sentinel */
  738. };
  739. /* itemgetter object **********************************************************/
  740. typedef struct {
  741. PyObject_HEAD
  742. Py_ssize_t nitems;
  743. PyObject *item;
  744. Py_ssize_t index; // -1 unless *item* is a single non-negative integer index
  745. } itemgetterobject;
  746. static PyTypeObject itemgetter_type;
  747. /* AC 3.5: treats first argument as an iterable, otherwise uses *args */
  748. static PyObject *
  749. itemgetter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
  750. {
  751. itemgetterobject *ig;
  752. PyObject *item;
  753. Py_ssize_t nitems;
  754. Py_ssize_t index;
  755. if (!_PyArg_NoKeywords("itemgetter", kwds))
  756. return NULL;
  757. nitems = PyTuple_GET_SIZE(args);
  758. if (nitems <= 1) {
  759. if (!PyArg_UnpackTuple(args, "itemgetter", 1, 1, &item))
  760. return NULL;
  761. } else
  762. item = args;
  763. /* create itemgetterobject structure */
  764. ig = PyObject_GC_New(itemgetterobject, &itemgetter_type);
  765. if (ig == NULL)
  766. return NULL;
  767. Py_INCREF(item);
  768. ig->item = item;
  769. ig->nitems = nitems;
  770. ig->index = -1;
  771. if (PyLong_CheckExact(item)) {
  772. index = PyLong_AsSsize_t(item);
  773. if (index < 0) {
  774. /* If we get here, then either the index conversion failed
  775. * due to being out of range, or the index was a negative
  776. * integer. Either way, we clear any possible exception
  777. * and fall back to the slow path, where ig->index is -1.
  778. */
  779. PyErr_Clear();
  780. }
  781. else {
  782. ig->index = index;
  783. }
  784. }
  785. PyObject_GC_Track(ig);
  786. return (PyObject *)ig;
  787. }
  788. static void
  789. itemgetter_dealloc(itemgetterobject *ig)
  790. {
  791. PyObject_GC_UnTrack(ig);
  792. Py_XDECREF(ig->item);
  793. PyObject_GC_Del(ig);
  794. }
  795. static int
  796. itemgetter_traverse(itemgetterobject *ig, visitproc visit, void *arg)
  797. {
  798. Py_VISIT(ig->item);
  799. return 0;
  800. }
  801. static PyObject *
  802. itemgetter_call(itemgetterobject *ig, PyObject *args, PyObject *kw)
  803. {
  804. PyObject *obj, *result;
  805. Py_ssize_t i, nitems=ig->nitems;
  806. assert(PyTuple_CheckExact(args));
  807. if (!_PyArg_NoKeywords("itemgetter", kw))
  808. return NULL;
  809. if (!_PyArg_CheckPositional("itemgetter", PyTuple_GET_SIZE(args), 1, 1))
  810. return NULL;
  811. obj = PyTuple_GET_ITEM(args, 0);
  812. if (nitems == 1) {
  813. if (ig->index >= 0
  814. && PyTuple_CheckExact(obj)
  815. && ig->index < PyTuple_GET_SIZE(obj))
  816. {
  817. result = PyTuple_GET_ITEM(obj, ig->index);
  818. Py_INCREF(result);
  819. return result;
  820. }
  821. return PyObject_GetItem(obj, ig->item);
  822. }
  823. assert(PyTuple_Check(ig->item));
  824. assert(PyTuple_GET_SIZE(ig->item) == nitems);
  825. result = PyTuple_New(nitems);
  826. if (result == NULL)
  827. return NULL;
  828. for (i=0 ; i < nitems ; i++) {
  829. PyObject *item, *val;
  830. item = PyTuple_GET_ITEM(ig->item, i);
  831. val = PyObject_GetItem(obj, item);
  832. if (val == NULL) {
  833. Py_DECREF(result);
  834. return NULL;
  835. }
  836. PyTuple_SET_ITEM(result, i, val);
  837. }
  838. return result;
  839. }
  840. static PyObject *
  841. itemgetter_repr(itemgetterobject *ig)
  842. {
  843. PyObject *repr;
  844. const char *reprfmt;
  845. int status = Py_ReprEnter((PyObject *)ig);
  846. if (status != 0) {
  847. if (status < 0)
  848. return NULL;
  849. return PyUnicode_FromFormat("%s(...)", Py_TYPE(ig)->tp_name);
  850. }
  851. reprfmt = ig->nitems == 1 ? "%s(%R)" : "%s%R";
  852. repr = PyUnicode_FromFormat(reprfmt, Py_TYPE(ig)->tp_name, ig->item);
  853. Py_ReprLeave((PyObject *)ig);
  854. return repr;
  855. }
  856. static PyObject *
  857. itemgetter_reduce(itemgetterobject *ig, PyObject *Py_UNUSED(ignored))
  858. {
  859. if (ig->nitems == 1)
  860. return Py_BuildValue("O(O)", Py_TYPE(ig), ig->item);
  861. return PyTuple_Pack(2, Py_TYPE(ig), ig->item);
  862. }
  863. PyDoc_STRVAR(reduce_doc, "Return state information for pickling");
  864. static PyMethodDef itemgetter_methods[] = {
  865. {"__reduce__", (PyCFunction)itemgetter_reduce, METH_NOARGS,
  866. reduce_doc},
  867. {NULL}
  868. };
  869. PyDoc_STRVAR(itemgetter_doc,
  870. "itemgetter(item, ...) --> itemgetter object\n\
  871. \n\
  872. Return a callable object that fetches the given item(s) from its operand.\n\
  873. After f = itemgetter(2), the call f(r) returns r[2].\n\
  874. After g = itemgetter(2, 5, 3), the call g(r) returns (r[2], r[5], r[3])");
  875. static PyTypeObject itemgetter_type = {
  876. PyVarObject_HEAD_INIT(NULL, 0)
  877. "operator.itemgetter", /* tp_name */
  878. sizeof(itemgetterobject), /* tp_basicsize */
  879. 0, /* tp_itemsize */
  880. /* methods */
  881. (destructor)itemgetter_dealloc, /* tp_dealloc */
  882. 0, /* tp_vectorcall_offset */
  883. 0, /* tp_getattr */
  884. 0, /* tp_setattr */
  885. 0, /* tp_as_async */
  886. (reprfunc)itemgetter_repr, /* tp_repr */
  887. 0, /* tp_as_number */
  888. 0, /* tp_as_sequence */
  889. 0, /* tp_as_mapping */
  890. 0, /* tp_hash */
  891. (ternaryfunc)itemgetter_call, /* tp_call */
  892. 0, /* tp_str */
  893. PyObject_GenericGetAttr, /* tp_getattro */
  894. 0, /* tp_setattro */
  895. 0, /* tp_as_buffer */
  896. Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
  897. itemgetter_doc, /* tp_doc */
  898. (traverseproc)itemgetter_traverse, /* tp_traverse */
  899. 0, /* tp_clear */
  900. 0, /* tp_richcompare */
  901. 0, /* tp_weaklistoffset */
  902. 0, /* tp_iter */
  903. 0, /* tp_iternext */
  904. itemgetter_methods, /* tp_methods */
  905. 0, /* tp_members */
  906. 0, /* tp_getset */
  907. 0, /* tp_base */
  908. 0, /* tp_dict */
  909. 0, /* tp_descr_get */
  910. 0, /* tp_descr_set */
  911. 0, /* tp_dictoffset */
  912. 0, /* tp_init */
  913. 0, /* tp_alloc */
  914. itemgetter_new, /* tp_new */
  915. 0, /* tp_free */
  916. };
  917. /* attrgetter object **********************************************************/
  918. typedef struct {
  919. PyObject_HEAD
  920. Py_ssize_t nattrs;
  921. PyObject *attr;
  922. } attrgetterobject;
  923. static PyTypeObject attrgetter_type;
  924. /* AC 3.5: treats first argument as an iterable, otherwise uses *args */
  925. static PyObject *
  926. attrgetter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
  927. {
  928. attrgetterobject *ag;
  929. PyObject *attr;
  930. Py_ssize_t nattrs, idx, char_idx;
  931. if (!_PyArg_NoKeywords("attrgetter", kwds))
  932. return NULL;
  933. nattrs = PyTuple_GET_SIZE(args);
  934. if (nattrs <= 1) {
  935. if (!PyArg_UnpackTuple(args, "attrgetter", 1, 1, &attr))
  936. return NULL;
  937. }
  938. attr = PyTuple_New(nattrs);
  939. if (attr == NULL)
  940. return NULL;
  941. /* prepare attr while checking args */
  942. for (idx = 0; idx < nattrs; ++idx) {
  943. PyObject *item = PyTuple_GET_ITEM(args, idx);
  944. Py_ssize_t item_len;
  945. const void *data;
  946. unsigned int kind;
  947. int dot_count;
  948. if (!PyUnicode_Check(item)) {
  949. PyErr_SetString(PyExc_TypeError,
  950. "attribute name must be a string");
  951. Py_DECREF(attr);
  952. return NULL;
  953. }
  954. if (PyUnicode_READY(item)) {
  955. Py_DECREF(attr);
  956. return NULL;
  957. }
  958. item_len = PyUnicode_GET_LENGTH(item);
  959. kind = PyUnicode_KIND(item);
  960. data = PyUnicode_DATA(item);
  961. /* check whethere the string is dotted */
  962. dot_count = 0;
  963. for (char_idx = 0; char_idx < item_len; ++char_idx) {
  964. if (PyUnicode_READ(kind, data, char_idx) == '.')
  965. ++dot_count;
  966. }
  967. if (dot_count == 0) {
  968. Py_INCREF(item);
  969. PyUnicode_InternInPlace(&item);
  970. PyTuple_SET_ITEM(attr, idx, item);
  971. } else { /* make it a tuple of non-dotted attrnames */
  972. PyObject *attr_chain = PyTuple_New(dot_count + 1);
  973. PyObject *attr_chain_item;
  974. Py_ssize_t unibuff_from = 0;
  975. Py_ssize_t unibuff_till = 0;
  976. Py_ssize_t attr_chain_idx = 0;
  977. if (attr_chain == NULL) {
  978. Py_DECREF(attr);
  979. return NULL;
  980. }
  981. for (; dot_count > 0; --dot_count) {
  982. while (PyUnicode_READ(kind, data, unibuff_till) != '.') {
  983. ++unibuff_till;
  984. }
  985. attr_chain_item = PyUnicode_Substring(item,
  986. unibuff_from,
  987. unibuff_till);
  988. if (attr_chain_item == NULL) {
  989. Py_DECREF(attr_chain);
  990. Py_DECREF(attr);
  991. return NULL;
  992. }
  993. PyUnicode_InternInPlace(&attr_chain_item);
  994. PyTuple_SET_ITEM(attr_chain, attr_chain_idx, attr_chain_item);
  995. ++attr_chain_idx;
  996. unibuff_till = unibuff_from = unibuff_till + 1;
  997. }
  998. /* now add the last dotless name */
  999. attr_chain_item = PyUnicode_Substring(item,
  1000. unibuff_from, item_len);
  1001. if (attr_chain_item == NULL) {
  1002. Py_DECREF(attr_chain);
  1003. Py_DECREF(attr);
  1004. return NULL;
  1005. }
  1006. PyUnicode_InternInPlace(&attr_chain_item);
  1007. PyTuple_SET_ITEM(attr_chain, attr_chain_idx, attr_chain_item);
  1008. PyTuple_SET_ITEM(attr, idx, attr_chain);
  1009. }
  1010. }
  1011. /* create attrgetterobject structure */
  1012. ag = PyObject_GC_New(attrgetterobject, &attrgetter_type);
  1013. if (ag == NULL) {
  1014. Py_DECREF(attr);
  1015. return NULL;
  1016. }
  1017. ag->attr = attr;
  1018. ag->nattrs = nattrs;
  1019. PyObject_GC_Track(ag);
  1020. return (PyObject *)ag;
  1021. }
  1022. static void
  1023. attrgetter_dealloc(attrgetterobject *ag)
  1024. {
  1025. PyObject_GC_UnTrack(ag);
  1026. Py_XDECREF(ag->attr);
  1027. PyObject_GC_Del(ag);
  1028. }
  1029. static int
  1030. attrgetter_traverse(attrgetterobject *ag, visitproc visit, void *arg)
  1031. {
  1032. Py_VISIT(ag->attr);
  1033. return 0;
  1034. }
  1035. static PyObject *
  1036. dotted_getattr(PyObject *obj, PyObject *attr)
  1037. {
  1038. PyObject *newobj;
  1039. /* attr is either a tuple or instance of str.
  1040. Ensured by the setup code of attrgetter_new */
  1041. if (PyTuple_CheckExact(attr)) { /* chained getattr */
  1042. Py_ssize_t name_idx = 0, name_count;
  1043. PyObject *attr_name;
  1044. name_count = PyTuple_GET_SIZE(attr);
  1045. Py_INCREF(obj);
  1046. for (name_idx = 0; name_idx < name_count; ++name_idx) {
  1047. attr_name = PyTuple_GET_ITEM(attr, name_idx);
  1048. newobj = PyObject_GetAttr(obj, attr_name);
  1049. Py_DECREF(obj);
  1050. if (newobj == NULL) {
  1051. return NULL;
  1052. }
  1053. /* here */
  1054. obj = newobj;
  1055. }
  1056. } else { /* single getattr */
  1057. newobj = PyObject_GetAttr(obj, attr);
  1058. if (newobj == NULL)
  1059. return NULL;
  1060. obj = newobj;
  1061. }
  1062. return obj;
  1063. }
  1064. static PyObject *
  1065. attrgetter_call(attrgetterobject *ag, PyObject *args, PyObject *kw)
  1066. {
  1067. PyObject *obj, *result;
  1068. Py_ssize_t i, nattrs=ag->nattrs;
  1069. if (!_PyArg_NoKeywords("attrgetter", kw))
  1070. return NULL;
  1071. if (!_PyArg_CheckPositional("attrgetter", PyTuple_GET_SIZE(args), 1, 1))
  1072. return NULL;
  1073. obj = PyTuple_GET_ITEM(args, 0);
  1074. if (ag->nattrs == 1) /* ag->attr is always a tuple */
  1075. return dotted_getattr(obj, PyTuple_GET_ITEM(ag->attr, 0));
  1076. assert(PyTuple_Check(ag->attr));
  1077. assert(PyTuple_GET_SIZE(ag->attr) == nattrs);
  1078. result = PyTuple_New(nattrs);
  1079. if (result == NULL)
  1080. return NULL;
  1081. for (i=0 ; i < nattrs ; i++) {
  1082. PyObject *attr, *val;
  1083. attr = PyTuple_GET_ITEM(ag->attr, i);
  1084. val = dotted_getattr(obj, attr);
  1085. if (val == NULL) {
  1086. Py_DECREF(result);
  1087. return NULL;
  1088. }
  1089. PyTuple_SET_ITEM(result, i, val);
  1090. }
  1091. return result;
  1092. }
  1093. static PyObject *
  1094. dotjoinattr(PyObject *attr, PyObject **attrsep)
  1095. {
  1096. if (PyTuple_CheckExact(attr)) {
  1097. if (*attrsep == NULL) {
  1098. *attrsep = PyUnicode_FromString(".");
  1099. if (*attrsep == NULL)
  1100. return NULL;
  1101. }
  1102. return PyUnicode_Join(*attrsep, attr);
  1103. } else {
  1104. Py_INCREF(attr);
  1105. return attr;
  1106. }
  1107. }
  1108. static PyObject *
  1109. attrgetter_args(attrgetterobject *ag)
  1110. {
  1111. Py_ssize_t i;
  1112. PyObject *attrsep = NULL;
  1113. PyObject *attrstrings = PyTuple_New(ag->nattrs);
  1114. if (attrstrings == NULL)
  1115. return NULL;
  1116. for (i = 0; i < ag->nattrs; ++i) {
  1117. PyObject *attr = PyTuple_GET_ITEM(ag->attr, i);
  1118. PyObject *attrstr = dotjoinattr(attr, &attrsep);
  1119. if (attrstr == NULL) {
  1120. Py_XDECREF(attrsep);
  1121. Py_DECREF(attrstrings);
  1122. return NULL;
  1123. }
  1124. PyTuple_SET_ITEM(attrstrings, i, attrstr);
  1125. }
  1126. Py_XDECREF(attrsep);
  1127. return attrstrings;
  1128. }
  1129. static PyObject *
  1130. attrgetter_repr(attrgetterobject *ag)
  1131. {
  1132. PyObject *repr = NULL;
  1133. int status = Py_ReprEnter((PyObject *)ag);
  1134. if (status != 0) {
  1135. if (status < 0)
  1136. return NULL;
  1137. return PyUnicode_FromFormat("%s(...)", Py_TYPE(ag)->tp_name);
  1138. }
  1139. if (ag->nattrs == 1) {
  1140. PyObject *attrsep = NULL;
  1141. PyObject *attr = dotjoinattr(PyTuple_GET_ITEM(ag->attr, 0), &attrsep);
  1142. if (attr != NULL) {
  1143. repr = PyUnicode_FromFormat("%s(%R)", Py_TYPE(ag)->tp_name, attr);
  1144. Py_DECREF(attr);
  1145. }
  1146. Py_XDECREF(attrsep);
  1147. }
  1148. else {
  1149. PyObject *attrstrings = attrgetter_args(ag);
  1150. if (attrstrings != NULL) {
  1151. repr = PyUnicode_FromFormat("%s%R",
  1152. Py_TYPE(ag)->tp_name, attrstrings);
  1153. Py_DECREF(attrstrings);
  1154. }
  1155. }
  1156. Py_ReprLeave((PyObject *)ag);
  1157. return repr;
  1158. }
  1159. static PyObject *
  1160. attrgetter_reduce(attrgetterobject *ag, PyObject *Py_UNUSED(ignored))
  1161. {
  1162. PyObject *attrstrings = attrgetter_args(ag);
  1163. if (attrstrings == NULL)
  1164. return NULL;
  1165. return Py_BuildValue("ON", Py_TYPE(ag), attrstrings);
  1166. }
  1167. static PyMethodDef attrgetter_methods[] = {
  1168. {"__reduce__", (PyCFunction)attrgetter_reduce, METH_NOARGS,
  1169. reduce_doc},
  1170. {NULL}
  1171. };
  1172. PyDoc_STRVAR(attrgetter_doc,
  1173. "attrgetter(attr, ...) --> attrgetter object\n\
  1174. \n\
  1175. Return a callable object that fetches the given attribute(s) from its operand.\n\
  1176. After f = attrgetter('name'), the call f(r) returns r.name.\n\
  1177. After g = attrgetter('name', 'date'), the call g(r) returns (r.name, r.date).\n\
  1178. After h = attrgetter('name.first', 'name.last'), the call h(r) returns\n\
  1179. (r.name.first, r.name.last).");
  1180. static PyTypeObject attrgetter_type = {
  1181. PyVarObject_HEAD_INIT(NULL, 0)
  1182. "operator.attrgetter", /* tp_name */
  1183. sizeof(attrgetterobject), /* tp_basicsize */
  1184. 0, /* tp_itemsize */
  1185. /* methods */
  1186. (destructor)attrgetter_dealloc, /* tp_dealloc */
  1187. 0, /* tp_vectorcall_offset */
  1188. 0, /* tp_getattr */
  1189. 0, /* tp_setattr */
  1190. 0, /* tp_as_async */
  1191. (reprfunc)attrgetter_repr, /* tp_repr */
  1192. 0, /* tp_as_number */
  1193. 0, /* tp_as_sequence */
  1194. 0, /* tp_as_mapping */
  1195. 0, /* tp_hash */
  1196. (ternaryfunc)attrgetter_call, /* tp_call */
  1197. 0, /* tp_str */
  1198. PyObject_GenericGetAttr, /* tp_getattro */
  1199. 0, /* tp_setattro */
  1200. 0, /* tp_as_buffer */
  1201. Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
  1202. attrgetter_doc, /* tp_doc */
  1203. (traverseproc)attrgetter_traverse, /* tp_traverse */
  1204. 0, /* tp_clear */
  1205. 0, /* tp_richcompare */
  1206. 0, /* tp_weaklistoffset */
  1207. 0, /* tp_iter */
  1208. 0, /* tp_iternext */
  1209. attrgetter_methods, /* tp_methods */
  1210. 0, /* tp_members */
  1211. 0, /* tp_getset */
  1212. 0, /* tp_base */
  1213. 0, /* tp_dict */
  1214. 0, /* tp_descr_get */
  1215. 0, /* tp_descr_set */
  1216. 0, /* tp_dictoffset */
  1217. 0, /* tp_init */
  1218. 0, /* tp_alloc */
  1219. attrgetter_new, /* tp_new */
  1220. 0, /* tp_free */
  1221. };
  1222. /* methodcaller object **********************************************************/
  1223. typedef struct {
  1224. PyObject_HEAD
  1225. PyObject *name;
  1226. PyObject *args;
  1227. PyObject *kwds;
  1228. } methodcallerobject;
  1229. static PyTypeObject methodcaller_type;
  1230. /* AC 3.5: variable number of arguments, not currently support by AC */
  1231. static PyObject *
  1232. methodcaller_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
  1233. {
  1234. methodcallerobject *mc;
  1235. PyObject *name;
  1236. if (PyTuple_GET_SIZE(args) < 1) {
  1237. PyErr_SetString(PyExc_TypeError, "methodcaller needs at least "
  1238. "one argument, the method name");
  1239. return NULL;
  1240. }
  1241. name = PyTuple_GET_ITEM(args, 0);
  1242. if (!PyUnicode_Check(name)) {
  1243. PyErr_SetString(PyExc_TypeError,
  1244. "method name must be a string");
  1245. return NULL;
  1246. }
  1247. /* create methodcallerobject structure */
  1248. mc = PyObject_GC_New(methodcallerobject, &methodcaller_type);
  1249. if (mc == NULL)
  1250. return NULL;
  1251. name = PyTuple_GET_ITEM(args, 0);
  1252. Py_INCREF(name);
  1253. PyUnicode_InternInPlace(&name);
  1254. mc->name = name;
  1255. Py_XINCREF(kwds);
  1256. mc->kwds = kwds;
  1257. mc->args = PyTuple_GetSlice(args, 1, PyTuple_GET_SIZE(args));
  1258. if (mc->args == NULL) {
  1259. Py_DECREF(mc);
  1260. return NULL;
  1261. }
  1262. PyObject_GC_Track(mc);
  1263. return (PyObject *)mc;
  1264. }
  1265. static void
  1266. methodcaller_dealloc(methodcallerobject *mc)
  1267. {
  1268. PyObject_GC_UnTrack(mc);
  1269. Py_XDECREF(mc->name);
  1270. Py_XDECREF(mc->args);
  1271. Py_XDECREF(mc->kwds);
  1272. PyObject_GC_Del(mc);
  1273. }
  1274. static int
  1275. methodcaller_traverse(methodcallerobject *mc, visitproc visit, void *arg)
  1276. {
  1277. Py_VISIT(mc->args);
  1278. Py_VISIT(mc->kwds);
  1279. return 0;
  1280. }
  1281. static PyObject *
  1282. methodcaller_call(methodcallerobject *mc, PyObject *args, PyObject *kw)
  1283. {
  1284. PyObject *method, *obj, *result;
  1285. if (!_PyArg_NoKeywords("methodcaller", kw))
  1286. return NULL;
  1287. if (!_PyArg_CheckPositional("methodcaller", PyTuple_GET_SIZE(args), 1, 1))
  1288. return NULL;
  1289. obj = PyTuple_GET_ITEM(args, 0);
  1290. method = PyObject_GetAttr(obj, mc->name);
  1291. if (method == NULL)
  1292. return NULL;
  1293. result = PyObject_Call(method, mc->args, mc->kwds);
  1294. Py_DECREF(method);
  1295. return result;
  1296. }
  1297. static PyObject *
  1298. methodcaller_repr(methodcallerobject *mc)
  1299. {
  1300. PyObject *argreprs, *repr = NULL, *sep, *joinedargreprs;
  1301. Py_ssize_t numtotalargs, numposargs, numkwdargs, i;
  1302. int status = Py_ReprEnter((PyObject *)mc);
  1303. if (status != 0) {
  1304. if (status < 0)
  1305. return NULL;
  1306. return PyUnicode_FromFormat("%s(...)", Py_TYPE(mc)->tp_name);
  1307. }
  1308. numkwdargs = mc->kwds != NULL ? PyDict_GET_SIZE(mc->kwds) : 0;
  1309. numposargs = PyTuple_GET_SIZE(mc->args);
  1310. numtotalargs = numposargs + numkwdargs;
  1311. if (numtotalargs == 0) {
  1312. repr = PyUnicode_FromFormat("%s(%R)", Py_TYPE(mc)->tp_name, mc->name);
  1313. Py_ReprLeave((PyObject *)mc);
  1314. return repr;
  1315. }
  1316. argreprs = PyTuple_New(numtotalargs);
  1317. if (argreprs == NULL) {
  1318. Py_ReprLeave((PyObject *)mc);
  1319. return NULL;
  1320. }
  1321. for (i = 0; i < numposargs; ++i) {
  1322. PyObject *onerepr = PyObject_Repr(PyTuple_GET_ITEM(mc->args, i));
  1323. if (onerepr == NULL)
  1324. goto done;
  1325. PyTuple_SET_ITEM(argreprs, i, onerepr);
  1326. }
  1327. if (numkwdargs != 0) {
  1328. PyObject *key, *value;
  1329. Py_ssize_t pos = 0;
  1330. while (PyDict_Next(mc->kwds, &pos, &key, &value)) {
  1331. PyObject *onerepr = PyUnicode_FromFormat("%U=%R", key, value);
  1332. if (onerepr == NULL)
  1333. goto done;
  1334. if (i >= numtotalargs) {
  1335. i = -1;
  1336. Py_DECREF(onerepr);
  1337. break;
  1338. }
  1339. PyTuple_SET_ITEM(argreprs, i, onerepr);
  1340. ++i;
  1341. }
  1342. if (i != numtotalargs) {
  1343. PyErr_SetString(PyExc_RuntimeError,
  1344. "keywords dict changed size during iteration");
  1345. goto done;
  1346. }
  1347. }
  1348. sep = PyUnicode_FromString(", ");
  1349. if (sep == NULL)
  1350. goto done;
  1351. joinedargreprs = PyUnicode_Join(sep, argreprs);
  1352. Py_DECREF(sep);
  1353. if (joinedargreprs == NULL)
  1354. goto done;
  1355. repr = PyUnicode_FromFormat("%s(%R, %U)", Py_TYPE(mc)->tp_name,
  1356. mc->name, joinedargreprs);
  1357. Py_DECREF(joinedargreprs);
  1358. done:
  1359. Py_DECREF(argreprs);
  1360. Py_ReprLeave((PyObject *)mc);
  1361. return repr;
  1362. }
  1363. static PyObject *
  1364. methodcaller_reduce(methodcallerobject *mc, PyObject *Py_UNUSED(ignored))
  1365. {
  1366. PyObject *newargs;
  1367. if (!mc->kwds || PyDict_GET_SIZE(mc->kwds) == 0) {
  1368. Py_ssize_t i;
  1369. Py_ssize_t callargcount = PyTuple_GET_SIZE(mc->args);
  1370. newargs = PyTuple_New(1 + callargcount);
  1371. if (newargs == NULL)
  1372. return NULL;
  1373. Py_INCREF(mc->name);
  1374. PyTuple_SET_ITEM(newargs, 0, mc->name);
  1375. for (i = 0; i < callargcount; ++i) {
  1376. PyObject *arg = PyTuple_GET_ITEM(mc->args, i);
  1377. Py_INCREF(arg);
  1378. PyTuple_SET_ITEM(newargs, i + 1, arg);
  1379. }
  1380. return Py_BuildValue("ON", Py_TYPE(mc), newargs);
  1381. }
  1382. else {
  1383. PyObject *functools;
  1384. PyObject *partial;
  1385. PyObject *constructor;
  1386. PyObject *newargs[2];
  1387. _Py_IDENTIFIER(partial);
  1388. functools = PyImport_ImportModule("functools");
  1389. if (!functools)
  1390. return NULL;
  1391. partial = _PyObject_GetAttrId(functools, &PyId_partial);
  1392. Py_DECREF(functools);
  1393. if (!partial)
  1394. return NULL;
  1395. newargs[0] = (PyObject *)Py_TYPE(mc);
  1396. newargs[1] = mc->name;
  1397. constructor = PyObject_VectorcallDict(partial, newargs, 2, mc->kwds);
  1398. Py_DECREF(partial);
  1399. return Py_BuildValue("NO", constructor, mc->args);
  1400. }
  1401. }
  1402. static PyMethodDef methodcaller_methods[] = {
  1403. {"__reduce__", (PyCFunction)methodcaller_reduce, METH_NOARGS,
  1404. reduce_doc},
  1405. {NULL}
  1406. };
  1407. PyDoc_STRVAR(methodcaller_doc,
  1408. "methodcaller(name, ...) --> methodcaller object\n\
  1409. \n\
  1410. Return a callable object that calls the given method on its operand.\n\
  1411. After f = methodcaller('name'), the call f(r) returns r.name().\n\
  1412. After g = methodcaller('name', 'date', foo=1), the call g(r) returns\n\
  1413. r.name('date', foo=1).");
  1414. static PyTypeObject methodcaller_type = {
  1415. PyVarObject_HEAD_INIT(NULL, 0)
  1416. "operator.methodcaller", /* tp_name */
  1417. sizeof(methodcallerobject), /* tp_basicsize */
  1418. 0, /* tp_itemsize */
  1419. /* methods */
  1420. (destructor)methodcaller_dealloc, /* tp_dealloc */
  1421. 0, /* tp_vectorcall_offset */
  1422. 0, /* tp_getattr */
  1423. 0, /* tp_setattr */
  1424. 0, /* tp_as_async */
  1425. (reprfunc)methodcaller_repr, /* tp_repr */
  1426. 0, /* tp_as_number */
  1427. 0, /* tp_as_sequence */
  1428. 0, /* tp_as_mapping */
  1429. 0, /* tp_hash */
  1430. (ternaryfunc)methodcaller_call, /* tp_call */
  1431. 0, /* tp_str */
  1432. PyObject_GenericGetAttr, /* tp_getattro */
  1433. 0, /* tp_setattro */
  1434. 0, /* tp_as_buffer */
  1435. Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
  1436. methodcaller_doc, /* tp_doc */
  1437. (traverseproc)methodcaller_traverse, /* tp_traverse */
  1438. 0, /* tp_clear */
  1439. 0, /* tp_richcompare */
  1440. 0, /* tp_weaklistoffset */
  1441. 0, /* tp_iter */
  1442. 0, /* tp_iternext */
  1443. methodcaller_methods, /* tp_methods */
  1444. 0, /* tp_members */
  1445. 0, /* tp_getset */
  1446. 0, /* tp_base */
  1447. 0, /* tp_dict */
  1448. 0, /* tp_descr_get */
  1449. 0, /* tp_descr_set */
  1450. 0, /* tp_dictoffset */
  1451. 0, /* tp_init */
  1452. 0, /* tp_alloc */
  1453. methodcaller_new, /* tp_new */
  1454. 0, /* tp_free */
  1455. };
  1456. static int
  1457. operator_exec(PyObject *module)
  1458. {
  1459. PyTypeObject *types[] = {
  1460. &itemgetter_type,
  1461. &attrgetter_type,
  1462. &methodcaller_type
  1463. };
  1464. for (size_t i = 0; i < Py_ARRAY_LENGTH(types); i++) {
  1465. if (PyModule_AddType(module, types[i]) < 0) {
  1466. return -1;
  1467. }
  1468. }
  1469. return 0;
  1470. }
  1471. static struct PyModuleDef_Slot operator_slots[] = {
  1472. {Py_mod_exec, operator_exec},
  1473. {0, NULL}
  1474. };
  1475. static struct PyModuleDef operatormodule = {
  1476. PyModuleDef_HEAD_INIT,
  1477. "_operator",
  1478. operator_doc,
  1479. 0,
  1480. operator_methods,
  1481. operator_slots,
  1482. NULL,
  1483. NULL,
  1484. NULL
  1485. };
  1486. PyMODINIT_FUNC
  1487. PyInit__operator(void)
  1488. {
  1489. return PyModuleDef_Init(&operatormodule);
  1490. }