Преглед изворни кода

- childutils.eventdata was buggy, it could not deal with carriage returns
in data. See http://www.plope.com/software/collector/257. Thanks
to Ian Bicking.

Chris McDonough пре 17 година
родитељ
комит
0f4c6412dc
3 измењених фајлова са 8 додато и 4 уклоњено
  1. 4 0
      CHANGES.txt
  2. 1 1
      src/supervisor/childutils.py
  3. 3 3
      src/supervisor/tests/test_childutils.py

+ 4 - 0
CHANGES.txt

@@ -1,5 +1,9 @@
 Next Release
 Next Release
 
 
+  - childutils.eventdata was buggy, it could not deal with carriage returns
+    in data.  See http://www.plope.com/software/collector/257.  Thanks
+    to Ian Bicking.
+
   - Per-process exitcodes= configuration now will not accept exit
   - Per-process exitcodes= configuration now will not accept exit
     codes that are integers above 255 (supervisord will not start when
     codes that are integers above 255 (supervisord will not start when
     one of the exit codes is outside the range of 0 - 255).
     one of the exit codes is outside the range of 0 - 255).

+ 1 - 1
src/supervisor/childutils.py

@@ -34,7 +34,7 @@ def get_headers(line):
     return dict([ x.split(':') for x in line.split() ])
     return dict([ x.split(':') for x in line.split() ])
 
 
 def eventdata(payload):
 def eventdata(payload):
-    headerinfo, data = payload.split('\n')
+    headerinfo, data = payload.split('\n', 1)
     headers = get_headers(headerinfo)
     headers = get_headers(headerinfo)
     return headers, data
     return headers, data
 
 

+ 3 - 3
src/supervisor/tests/test_childutils.py

@@ -33,11 +33,11 @@ class ChildUtilsTests(unittest.TestCase):
 
 
     def test_eventdata(self):
     def test_eventdata(self):
         from supervisor.childutils import eventdata
         from supervisor.childutils import eventdata
-        payload = 'a:1 b:2\nthedata'
+        payload = 'a:1 b:2\nthedata\n'
         headers, data = eventdata(payload)
         headers, data = eventdata(payload)
         self.assertEqual(headers, {'a':'1', 'b':'2'})
         self.assertEqual(headers, {'a':'1', 'b':'2'})
-        self.assertEqual(data, 'thedata')
-        
+        self.assertEqual(data, 'thedata\n')
+
 class TestProcessCommunicationsProtocol(unittest.TestCase):
 class TestProcessCommunicationsProtocol(unittest.TestCase):
     def test_send(self):
     def test_send(self):
         from supervisor.childutils import pcomm
         from supervisor.childutils import pcomm