Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork947
Commit36b7433
committed
Remove unused TASKKILL fallback in AutoInterrupt
When Git.AutoInterrupt was first implemented inead94f2, it usedos.kill (sending SIGINT to the process to terminate it). This wasin 2009, and not all supported versions of Python provided os.killon Windows, since it was added for Windows in 2.7 and 3.2 (2.6 and3.1 reached EoL in 2013 and 2012, respectively). CatchingAttributeError and running TASKKILL provided a fallback for Pythonversions in which os.kill was absent on Windows.Since then, all supported versions have os.kill on Windows, andalso the code of GitPython, in the try-block, has changed, and nolonger uses os.kill. It now contains four attribute accessexpressions:- proc.terminate. All currently suppported versions of Python (including 3.7, which GitPython still supports, and some before that) have Popen.terminate.- proc.wait. Same situation as proc.terminate. Popen.wait exists.- self._status_code_if_terminate. This is a class attribute of AutoInterrupt, accessible through its instances.- self.status. This is assigned to. AutoInterrupt is slotted, but "status" appears in __slots__, so this isn't an AttributeError either.The "except AttributeError" clause is thus no longer used and canbe removed, which is done here. Removing it shortens and simplifiesthe code, better expresses the logic for how the wrapped process isactually being terminated, and eliminates the need to engage withany subtleties of TASKKILL (and of how it is called) when readingthe code to verify its correctness.In addition, because they are now expected always to be available,if somehow an AttributeError managed to be raised in the terminateor wait calls, this would be very strange and we probably shouldn'tsilently catch that.(Because this AutoInterrupt._terminate method is sometimes calleddue to __del__ methods running as the interpreter is shutting down,it is possible for some attributes to unexpectedly be absent, whichthe _terminate method handles where relevant. But the TASKKILLfallback removed here seems unrelated to that, which affects moduleattributes and global variables. The names used in the try-blockare proc, status, and self, which are local variables; the exceptclause itself accessed os.name, which uses a global variable and amodule attribute, indicating that the intent is not to handle thisinterpreter shutdown scenario; and this whole issue, while not gonecompletely, is much less significant since Python 3.4, due tohttps://docs.python.org/3/whatsnew/3.4.html#whatsnew-pep-442.)1 parenta30b3b7 commit36b7433
1 file changed
+1
-11
lines changedLines changed: 1 addition & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
11 | 11 |
| |
12 | 12 |
| |
13 | 13 |
| |
14 |
| - | |
| 14 | + | |
15 | 15 |
| |
16 | 16 |
| |
17 | 17 |
| |
| |||
544 | 544 |
| |
545 | 545 |
| |
546 | 546 |
| |
547 |
| - | |
548 |
| - | |
549 |
| - | |
550 |
| - | |
551 |
| - | |
552 |
| - | |
553 |
| - | |
554 |
| - | |
555 |
| - | |
556 |
| - | |
557 | 547 |
| |
558 | 548 |
| |
559 | 549 |
| |
|
0 commit comments
Comments
(0)