File: 0006-Invoke-mentos-directly-on-GNU-Linux.patch

package info (click to toggle)
ruby-pygments.rb 0.6.3-2%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 8,628 kB
  • sloc: python: 46,993; ansic: 8,115; lisp: 3,703; cobol: 2,961; pascal: 2,750; ruby: 2,700; sh: 2,362; java: 1,755; cpp: 1,549; haskell: 926; ml: 831; csh: 681; f90: 459; php: 260; cs: 258; perl: 177; makefile: 174; ada: 161; objc: 145; erlang: 104; awk: 94; asm: 68; jsp: 21
file content (45 lines) | stat: -rw-r--r-- 1,652 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
From cf77a917f7e4d21b03397b39278357c3e9650b72 Mon Sep 17 00:00:00 2001
From: Per Andersson <avtobiff@gmail.com>
Date: Wed, 2 Apr 2014 23:30:58 +0200
Subject: [PATCH] Invoke mentos directly on GNU/Linux

Invoking the script on GNU/Linux by passing it as an argument to
python(2) makes the process use 100% CPU for about tens of seconds when
it is supposed to timeout (test_returns_nil_on_timeout reproduces this).

On current Debian Sid python2 exists, so this can be used in mentos.py
shebang.

Brought back script invocation for windows.

This is forwarded upstream https://github.com/tmm1/pygments.rb/pull/119
---
 lib/pygments/mentos.py |  2 +-
 lib/pygments/popen.rb  | 13 ++-----------
 2 files changed, 3 insertions(+), 12 deletions(-)

--- a/lib/pygments/popen.rb
+++ b/lib/pygments/popen.rb
@@ -37,20 +37,12 @@
 
       # A pipe to the mentos python process. #popen4 gives us
       # the pid and three IO objects to write and read.
-      python_path = python_binary(is_windows)
-      script = "#{python_path} #{File.expand_path('../mentos.py', __FILE__)}"
+      script = "#{File.expand_path('../mentos.py', __FILE__)}"
+      script = "python " + script if is_windows
       @pid, @in, @out, @err = popen4(script)
       @log.info "[#{Time.now.iso8601}] Starting pid #{@pid.to_s} with fd #{@out.to_i.to_s}."
     end
 
-    # Detect a suitable Python binary to use.
-    def python_binary(is_windows)
-      if is_windows && which('py')
-        return 'py -2'
-      end
-      return which('python2') || 'python'
-    end
-
     # Cross platform which command
     # from http://stackoverflow.com/a/5471032/284795
     def which(command)