Skip to content

Commit

Permalink
Merge pull request #953 from earthgecko/patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
deniszh authored Aug 24, 2024
2 parents ef419d0 + fdc56f6 commit 66aee51
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/carbon/log.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import time
from sys import stdout
from sys import stdout, version_info
from zope.interface import implementer
from twisted.python.log import startLoggingWithObserver, textFromEventDict, msg, err, ILogObserver # NOQA
from twisted.python.syslog import SyslogObserver
Expand All @@ -20,8 +20,13 @@ def _openFile(self):
Fix Umask Issue https://twistedmatrix.com/trac/ticket/7026
"""
openMode = self.defaultMode or 0o777
# Fix >= Python3.8 raises RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode # NOQA
python_version = '%s.%s.%s' % (str(version_info[0]), str(version_info[1]), str(version_info[2]))
use_buffering = 0
if python_version < '3.8.0':
use_buffering = 1
self._file = os.fdopen(os.open(
self.path, os.O_CREAT | os.O_RDWR, openMode), 'rb+', 1)
self.path, os.O_CREAT | os.O_RDWR, openMode), 'rb+', use_buffering)
self.closed = False
# Try our best to update permissions for files which already exist.
if self.defaultMode:
Expand Down

0 comments on commit 66aee51

Please sign in to comment.