The following issues were found
Lib/pty.py
11 issues
Line: 56
Column: 9
def _open_terminal():
"""Open pty master and return (master_fd, tty_name)."""
for x in 'pqrstuvwxyzPQRST':
for y in '0123456789abcdef':
pty_name = '/dev/pty' + x + y
try:
fd = os.open(pty_name, os.O_RDWR)
except OSError:
Reported by Pylint.
Line: 57
Column: 13
def _open_terminal():
"""Open pty master and return (master_fd, tty_name)."""
for x in 'pqrstuvwxyzPQRST':
for y in '0123456789abcdef':
pty_name = '/dev/pty' + x + y
try:
fd = os.open(pty_name, os.O_RDWR)
except OSError:
continue
Reported by Pylint.
Line: 60
Column: 17
for y in '0123456789abcdef':
pty_name = '/dev/pty' + x + y
try:
fd = os.open(pty_name, os.O_RDWR)
except OSError:
continue
return (fd, '/dev/tty' + x + y)
raise OSError('out of pty devices')
Reported by Pylint.
Line: 74
Column: 9
result = os.open(tty_name, os.O_RDWR)
try:
from fcntl import ioctl, I_PUSH
except ImportError:
return result
try:
ioctl(result, I_PUSH, "ptem")
ioctl(result, I_PUSH, "ldterm")
Reported by Pylint.
Line: 89
Column: 14
Fork and make the child a session leader with a controlling terminal."""
try:
pid, fd = os.forkpty()
except (AttributeError, OSError):
pass
else:
if pid == CHILD:
try:
Reported by Pylint.
Line: 124
Column: 1
# Parent and child process.
return pid, master_fd
def _writen(fd, data):
"""Write all the data to a descriptor."""
while data:
n = os.write(fd, data)
data = data[n:]
Reported by Pylint.
Line: 127
Column: 9
def _writen(fd, data):
"""Write all the data to a descriptor."""
while data:
n = os.write(fd, data)
data = data[n:]
def _read(fd):
"""Default read function."""
return os.read(fd, 1024)
Reported by Pylint.
Line: 130
Column: 1
n = os.write(fd, data)
data = data[n:]
def _read(fd):
"""Default read function."""
return os.read(fd, 1024)
def _copy(master_fd, master_read=_read, stdin_read=_read):
"""Parent copy loop.
Reported by Pylint.
Line: 150
Column: 13
data = master_read(master_fd)
except OSError:
data = b""
if not data: # Reached EOF.
return # Assume the child process has exited and is
# unreachable, so we clean up.
else:
os.write(STDOUT_FILENO, data)
Reported by Pylint.
Line: 165
Column: 8
def spawn(argv, master_read=_read, stdin_read=_read):
"""Create a spawned process."""
if type(argv) == type(''):
argv = (argv,)
sys.audit('pty.spawn', argv)
pid, master_fd = fork()
if pid == CHILD:
Reported by Pylint.
Lib/test/test_importlib/extension/test_finder.py
11 issues
Line: 1
Column: 1
from .. import abc
from .. import util
machinery = util.import_importlib('importlib.machinery')
import unittest
import warnings
Reported by Pylint.
Line: 2
Column: 1
from .. import abc
from .. import util
machinery = util.import_importlib('importlib.machinery')
import unittest
import warnings
Reported by Pylint.
Line: 7
Column: 1
machinery = util.import_importlib('importlib.machinery')
import unittest
import warnings
class FinderTests(abc.FinderTests):
"""Test the finder for extension modules."""
Reported by Pylint.
Line: 1
Column: 1
from .. import abc
from .. import util
machinery = util.import_importlib('importlib.machinery')
import unittest
import warnings
Reported by Pylint.
Line: 6
Column: 1
machinery = util.import_importlib('importlib.machinery')
import unittest
import warnings
class FinderTests(abc.FinderTests):
Reported by Pylint.
Line: 6
Column: 1
machinery = util.import_importlib('importlib.machinery')
import unittest
import warnings
class FinderTests(abc.FinderTests):
Reported by Pylint.
Line: 7
Column: 1
machinery = util.import_importlib('importlib.machinery')
import unittest
import warnings
class FinderTests(abc.FinderTests):
"""Test the finder for extension modules."""
Reported by Pylint.
Line: 7
Column: 1
machinery = util.import_importlib('importlib.machinery')
import unittest
import warnings
class FinderTests(abc.FinderTests):
"""Test the finder for extension modules."""
Reported by Pylint.
Line: 14
Column: 5
"""Test the finder for extension modules."""
def find_spec(self, fullname):
importer = self.machinery.FileFinder(util.EXTENSIONS.path,
(self.machinery.ExtensionFileLoader,
self.machinery.EXTENSION_SUFFIXES))
return importer.find_spec(fullname)
Reported by Pylint.
Line: 21
Column: 5
return importer.find_spec(fullname)
def test_module(self):
self.assertTrue(self.find_spec(util.EXTENSIONS.name))
# No extension module as an __init__ available for testing.
test_package = test_package_in_package = None
Reported by Pylint.
Lib/test/crashers/trace_at_recursion_limit.py
10 issues
Line: 13
Column: 1
def x():
pass
def g(*args):
if True: # change to True to crash interpreter
try:
x()
except:
pass
Reported by Pylint.
Line: 14
Column: 5
pass
def g(*args):
if True: # change to True to crash interpreter
try:
x()
except:
pass
return g
Reported by Pylint.
Line: 17
Column: 9
if True: # change to True to crash interpreter
try:
x()
except:
pass
return g
def f():
print(sys.getrecursionlimit())
Reported by Pylint.
Line: 10
Column: 1
import sys
def x():
pass
def g(*args):
if True: # change to True to crash interpreter
try:
Reported by Pylint.
Line: 10
Column: 1
import sys
def x():
pass
def g(*args):
if True: # change to True to crash interpreter
try:
Reported by Pylint.
Line: 13
Column: 1
def x():
pass
def g(*args):
if True: # change to True to crash interpreter
try:
x()
except:
pass
Reported by Pylint.
Line: 13
Column: 1
def x():
pass
def g(*args):
if True: # change to True to crash interpreter
try:
x()
except:
pass
Reported by Pylint.
Line: 17
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b110_try_except_pass.html
if True: # change to True to crash interpreter
try:
x()
except:
pass
return g
def f():
print(sys.getrecursionlimit())
Reported by Bandit.
Line: 21
Column: 1
pass
return g
def f():
print(sys.getrecursionlimit())
f()
sys.settrace(g)
Reported by Pylint.
Line: 21
Column: 1
pass
return g
def f():
print(sys.getrecursionlimit())
f()
sys.settrace(g)
Reported by Pylint.
Lib/test/double_const.py
10 issues
Line: 21
Column: 10
# Verify that the double x is within a few bits of eval(x_str).
def check_ok(x, x_str):
assert x > 0.0
x2 = eval(x_str)
assert x2 > 0.0
diff = abs(x - x2)
# If diff is no larger than 3 ULP (wrt x2), then diff/8 is no larger
# than 0.375 ULP, so adding diff/8 to x2 should have no effect.
if x2 + (diff / 8.) != x2:
Reported by Pylint.
Line: 21
Suggestion:
https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b307-eval
# Verify that the double x is within a few bits of eval(x_str).
def check_ok(x, x_str):
assert x > 0.0
x2 = eval(x_str)
assert x2 > 0.0
diff = abs(x - x2)
# If diff is no larger than 3 ULP (wrt x2), then diff/8 is no larger
# than 0.375 ULP, so adding diff/8 to x2 should have no effect.
if x2 + (diff / 8.) != x2:
Reported by Bandit.
Line: 1
Column: 1
from test.support import TestFailed
# A test for SF bug 422177: manifest float constants varied way too much in
# precision depending on whether Python was loading a module for the first
# time, or reloading it from a precompiled .pyc. The "expected" failure
# mode is that when test_import imports this after all .pyc files have been
# erased, it passes, but when test_import imports this from
# double_const.pyc, it fails. This indicates a woeful loss of precision in
# the marshal format for doubles. It's also possible that repr() doesn't
Reported by Pylint.
Line: 15
Column: 1
PI = 3.14159265358979324
TWOPI = 6.28318530717958648
PI_str = "3.14159265358979324"
TWOPI_str = "6.28318530717958648"
# Verify that the double x is within a few bits of eval(x_str).
def check_ok(x, x_str):
assert x > 0.0
Reported by Pylint.
Line: 16
Column: 1
TWOPI = 6.28318530717958648
PI_str = "3.14159265358979324"
TWOPI_str = "6.28318530717958648"
# Verify that the double x is within a few bits of eval(x_str).
def check_ok(x, x_str):
assert x > 0.0
x2 = eval(x_str)
Reported by Pylint.
Line: 19
Column: 1
TWOPI_str = "6.28318530717958648"
# Verify that the double x is within a few bits of eval(x_str).
def check_ok(x, x_str):
assert x > 0.0
x2 = eval(x_str)
assert x2 > 0.0
diff = abs(x - x2)
# If diff is no larger than 3 ULP (wrt x2), then diff/8 is no larger
Reported by Pylint.
Line: 19
Column: 1
TWOPI_str = "6.28318530717958648"
# Verify that the double x is within a few bits of eval(x_str).
def check_ok(x, x_str):
assert x > 0.0
x2 = eval(x_str)
assert x2 > 0.0
diff = abs(x - x2)
# If diff is no larger than 3 ULP (wrt x2), then diff/8 is no larger
Reported by Pylint.
Line: 20
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
# Verify that the double x is within a few bits of eval(x_str).
def check_ok(x, x_str):
assert x > 0.0
x2 = eval(x_str)
assert x2 > 0.0
diff = abs(x - x2)
# If diff is no larger than 3 ULP (wrt x2), then diff/8 is no larger
# than 0.375 ULP, so adding diff/8 to x2 should have no effect.
Reported by Bandit.
Line: 21
Column: 5
# Verify that the double x is within a few bits of eval(x_str).
def check_ok(x, x_str):
assert x > 0.0
x2 = eval(x_str)
assert x2 > 0.0
diff = abs(x - x2)
# If diff is no larger than 3 ULP (wrt x2), then diff/8 is no larger
# than 0.375 ULP, so adding diff/8 to x2 should have no effect.
if x2 + (diff / 8.) != x2:
Reported by Pylint.
Line: 22
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
def check_ok(x, x_str):
assert x > 0.0
x2 = eval(x_str)
assert x2 > 0.0
diff = abs(x - x2)
# If diff is no larger than 3 ULP (wrt x2), then diff/8 is no larger
# than 0.375 ULP, so adding diff/8 to x2 should have no effect.
if x2 + (diff / 8.) != x2:
raise TestFailed("Manifest const %s lost too much precision " % x_str)
Reported by Bandit.
Lib/test/inspect_stringized_annotations_2.py
10 issues
Line: 3
Column: 12
from __future__ import annotations
def foo(a, b, c): pass
Reported by Pylint.
Line: 3
Column: 9
from __future__ import annotations
def foo(a, b, c): pass
Reported by Pylint.
Line: 3
Column: 15
from __future__ import annotations
def foo(a, b, c): pass
Reported by Pylint.
Line: 1
Column: 1
from __future__ import annotations
def foo(a, b, c): pass
Reported by Pylint.
Line: 3
Column: 1
from __future__ import annotations
def foo(a, b, c): pass
Reported by Pylint.
Line: 3
Column: 1
from __future__ import annotations
def foo(a, b, c): pass
Reported by Pylint.
Line: 3
Column: 1
from __future__ import annotations
def foo(a, b, c): pass
Reported by Pylint.
Line: 3
Column: 1
from __future__ import annotations
def foo(a, b, c): pass
Reported by Pylint.
Line: 3
Column: 1
from __future__ import annotations
def foo(a, b, c): pass
Reported by Pylint.
Line: 3
Column: 20
from __future__ import annotations
def foo(a, b, c): pass
Reported by Pylint.
Lib/test/libregrtest/setup.py
10 issues
Line: 68
Column: 9
module.__file__ = os.path.abspath(module.__file__)
if ns.huntrleaks:
unittest.BaseTestSuite._cleanup = False
if ns.memlimit is not None:
support.set_memlimit(ns.memlimit)
if ns.threshold is not None:
Reported by Pylint.
Line: 82
Column: 30
if hasattr(sys, 'addaudithook'):
# Add an auditing hook for all tests to ensure PySys_Audit is tested
def _test_audit_hook(name, args):
pass
sys.addaudithook(_test_audit_hook)
setup_unraisable_hook()
setup_threading_excepthook()
Reported by Pylint.
Line: 82
Column: 36
if hasattr(sys, 'addaudithook'):
# Add an auditing hook for all tests to ensure PySys_Audit is tested
def _test_audit_hook(name, args):
pass
sys.addaudithook(_test_audit_hook)
setup_unraisable_hook()
setup_threading_excepthook()
Reported by Pylint.
Line: 1
Column: 1
import atexit
import faulthandler
import os
import signal
import sys
import unittest
from test import support
try:
import gc
Reported by Pylint.
Line: 13
Column: 1
except ImportError:
gc = None
from test.libregrtest.utils import (setup_unraisable_hook,
setup_threading_excepthook)
UNICODE_GUARD_ENV = "PYTHONREGRTEST_UNICODE_GUARD"
Reported by Pylint.
Line: 20
Column: 1
UNICODE_GUARD_ENV = "PYTHONREGRTEST_UNICODE_GUARD"
def setup_tests(ns):
try:
stderr_fd = sys.__stderr__.fileno()
except (ValueError, AttributeError):
# Catch ValueError to catch io.UnsupportedOperation on TextIOBase
# and ValueError on a closed stream.
Reported by Pylint.
Line: 20
Column: 1
UNICODE_GUARD_ENV = "PYTHONREGRTEST_UNICODE_GUARD"
def setup_tests(ns):
try:
stderr_fd = sys.__stderr__.fileno()
except (ValueError, AttributeError):
# Catch ValueError to catch io.UnsupportedOperation on TextIOBase
# and ValueError on a closed stream.
Reported by Pylint.
Line: 20
Column: 1
UNICODE_GUARD_ENV = "PYTHONREGRTEST_UNICODE_GUARD"
def setup_tests(ns):
try:
stderr_fd = sys.__stderr__.fileno()
except (ValueError, AttributeError):
# Catch ValueError to catch io.UnsupportedOperation on TextIOBase
# and ValueError on a closed stream.
Reported by Pylint.
Line: 101
Column: 9
support.LONG_TIMEOUT = min(support.LONG_TIMEOUT, ns.timeout)
if ns.xmlpath:
from test.support.testresult import RegressionTestResult
RegressionTestResult.USE_XML = True
# Ensure there's a non-ASCII character in env vars at all times to force
# tests consider this case. See BPO-44647 for details.
os.environ.setdefault(
Reported by Pylint.
Line: 117
Column: 9
handler) to avoid UnicodeEncodeError when printing a traceback"""
stdout = sys.stdout
try:
fd = stdout.fileno()
except ValueError:
# On IDLE, sys.stdout has no file descriptor and is not a TextIOWrapper
# object. Leaving sys.stdout unchanged.
#
# Catch ValueError to catch io.UnsupportedOperation on TextIOBase
Reported by Pylint.
Lib/test/test_code_module.py
10 issues
Line: 13
Column: 1
code = import_helper.import_module('code')
class TestInteractiveConsole(unittest.TestCase):
def setUp(self):
self.console = code.InteractiveConsole()
self.mock_sys()
Reported by Pylint.
Line: 35
Column: 5
del self.sysmod.ps1
del self.sysmod.ps2
def test_ps1(self):
self.infunc.side_effect = EOFError('Finished')
self.console.interact()
self.assertEqual(self.sysmod.ps1, '>>> ')
self.sysmod.ps1 = 'custom1> '
self.console.interact()
Reported by Pylint.
Line: 43
Column: 5
self.console.interact()
self.assertEqual(self.sysmod.ps1, 'custom1> ')
def test_ps2(self):
self.infunc.side_effect = EOFError('Finished')
self.console.interact()
self.assertEqual(self.sysmod.ps2, '... ')
self.sysmod.ps1 = 'custom2> '
self.console.interact()
Reported by Pylint.
Line: 51
Column: 5
self.console.interact()
self.assertEqual(self.sysmod.ps1, 'custom2> ')
def test_console_stderr(self):
self.infunc.side_effect = ["'antioch'", "", EOFError('Finished')]
self.console.interact()
for call in list(self.stdout.method_calls):
if 'antioch' in ''.join(call[1]):
break
Reported by Pylint.
Line: 60
Column: 5
else:
raise AssertionError("no console stdout")
def test_syntax_error(self):
self.infunc.side_effect = ["undefined", EOFError('Finished')]
self.console.interact()
for call in self.stderr.method_calls:
if 'NameError' in ''.join(call[1]):
break
Reported by Pylint.
Line: 69
Column: 5
else:
raise AssertionError("No syntax error from console")
def test_sysexcepthook(self):
self.infunc.side_effect = ["raise ValueError('')",
EOFError('Finished')]
hook = mock.Mock()
self.sysmod.excepthook = hook
self.console.interact()
Reported by Pylint.
Line: 77
Column: 5
self.console.interact()
self.assertTrue(hook.called)
def test_banner(self):
# with banner
self.infunc.side_effect = EOFError('Finished')
self.console.interact(banner='Foo')
self.assertEqual(len(self.stderr.method_calls), 3)
banner_call = self.stderr.method_calls[0]
Reported by Pylint.
Line: 91
Column: 5
self.console.interact(banner='')
self.assertEqual(len(self.stderr.method_calls), 2)
def test_exit_msg(self):
# default exit message
self.infunc.side_effect = EOFError('Finished')
self.console.interact(banner='')
self.assertEqual(len(self.stderr.method_calls), 2)
err_msg = self.stderr.method_calls[1]
Reported by Pylint.
Line: 119
Column: 5
self.assertEqual(err_msg, ['write', (expected,), {}])
def test_cause_tb(self):
self.infunc.side_effect = ["raise ValueError('') from AttributeError",
EOFError('Finished')]
self.console.interact()
output = ''.join(''.join(call[1]) for call in self.stderr.method_calls)
expected = dedent("""
Reported by Pylint.
Line: 135
Column: 5
""")
self.assertIn(expected, output)
def test_context_tb(self):
self.infunc.side_effect = ["try: ham\nexcept: eggs\n",
EOFError('Finished')]
self.console.interact()
output = ''.join(''.join(call[1]) for call in self.stderr.method_calls)
expected = dedent("""
Reported by Pylint.
Lib/lib2to3/pgen2/token.py
10 issues
Line: 75
Column: 8
tok_name = {}
for _name, _value in list(globals().items()):
if type(_value) is type(0):
tok_name[_value] = _name
def ISTERMINAL(x):
return x < NT_OFFSET
Reported by Pylint.
Line: 79
Column: 1
tok_name[_value] = _name
def ISTERMINAL(x):
return x < NT_OFFSET
def ISNONTERMINAL(x):
return x >= NT_OFFSET
Reported by Pylint.
Line: 79
Column: 1
tok_name[_value] = _name
def ISTERMINAL(x):
return x < NT_OFFSET
def ISNONTERMINAL(x):
return x >= NT_OFFSET
Reported by Pylint.
Line: 79
Column: 1
tok_name[_value] = _name
def ISTERMINAL(x):
return x < NT_OFFSET
def ISNONTERMINAL(x):
return x >= NT_OFFSET
Reported by Pylint.
Line: 82
Column: 1
def ISTERMINAL(x):
return x < NT_OFFSET
def ISNONTERMINAL(x):
return x >= NT_OFFSET
def ISEOF(x):
return x == ENDMARKER
Reported by Pylint.
Line: 82
Column: 1
def ISTERMINAL(x):
return x < NT_OFFSET
def ISNONTERMINAL(x):
return x >= NT_OFFSET
def ISEOF(x):
return x == ENDMARKER
Reported by Pylint.
Line: 82
Column: 1
def ISTERMINAL(x):
return x < NT_OFFSET
def ISNONTERMINAL(x):
return x >= NT_OFFSET
def ISEOF(x):
return x == ENDMARKER
Reported by Pylint.
Line: 85
Column: 1
def ISNONTERMINAL(x):
return x >= NT_OFFSET
def ISEOF(x):
return x == ENDMARKER
Reported by Pylint.
Line: 85
Column: 1
def ISNONTERMINAL(x):
return x >= NT_OFFSET
def ISEOF(x):
return x == ENDMARKER
Reported by Pylint.
Line: 85
Column: 1
def ISNONTERMINAL(x):
return x >= NT_OFFSET
def ISEOF(x):
return x == ENDMARKER
Reported by Pylint.
Lib/sched.py
10 issues
Line: 62
Column: 24
self.delayfunc = delayfunc
self._sequence_generator = count()
def enterabs(self, time, priority, action, argument=(), kwargs=_sentinel):
"""Enter a new event in the queue at an absolute time.
Returns an ID for the event which can be used to remove it,
if necessary.
Reported by Pylint.
Line: 84
Column: 9
This is actually the more commonly used interface.
"""
time = self.timefunc() + delay
return self.enterabs(time, priority, action, argument, kwargs)
def cancel(self, event):
"""Remove an event from the queue.
Reported by Pylint.
Line: 138
Column: 24
with lock:
if not q:
break
(time, priority, sequence, action,
argument, kwargs) = q[0]
now = timefunc()
if time > now:
delay = True
else:
Reported by Pylint.
Line: 138
Column: 34
with lock:
if not q:
break
(time, priority, sequence, action,
argument, kwargs) = q[0]
now = timefunc()
if time > now:
delay = True
else:
Reported by Pylint.
Line: 138
Column: 18
with lock:
if not q:
break
(time, priority, sequence, action,
argument, kwargs) = q[0]
now = timefunc()
if time > now:
delay = True
else:
Reported by Pylint.
Line: 51
Column: 1
_sentinel = object()
class scheduler:
def __init__(self, timefunc=_time, delayfunc=time.sleep):
"""Initialize a new instance, passing the time and delay
functions"""
self._queue = []
Reported by Pylint.
Line: 51
Column: 1
_sentinel = object()
class scheduler:
def __init__(self, timefunc=_time, delayfunc=time.sleep):
"""Initialize a new instance, passing the time and delay
functions"""
self._queue = []
Reported by Pylint.
Line: 62
Column: 5
self.delayfunc = delayfunc
self._sequence_generator = count()
def enterabs(self, time, priority, action, argument=(), kwargs=_sentinel):
"""Enter a new event in the queue at an absolute time.
Returns an ID for the event which can be used to remove it,
if necessary.
Reported by Pylint.
Line: 78
Column: 5
heapq.heappush(self._queue, event)
return event # The ID
def enter(self, delay, priority, action, argument=(), kwargs=_sentinel):
"""A variant that specifies the time as a relative time.
This is actually the more commonly used interface.
"""
Reported by Pylint.
Line: 130
Column: 9
# localize variable access to minimize overhead
# and to improve thread safety
lock = self._lock
q = self._queue
delayfunc = self.delayfunc
timefunc = self.timefunc
pop = heapq.heappop
while True:
with lock:
Reported by Pylint.
Lib/test/test_email/test_asian_codecs.py
10 issues
Line: 17
Column: 5
try:
str(b'foo', 'euc-jp')
except LookupError:
raise unittest.SkipTest
class TestEmailAsianCodecs(TestEmailBase):
def test_japanese_codecs(self):
Reported by Pylint.
Line: 1
Column: 1
# Copyright (C) 2002-2006 Python Software Foundation
# Contact: email-sig@python.org
# email package unit tests for (optional) Asian codecs
import unittest
from test.test_email import TestEmailBase
from email.charset import Charset
from email.header import Header, decode_header
Reported by Pylint.
Line: 21
Column: 1
class TestEmailAsianCodecs(TestEmailBase):
def test_japanese_codecs(self):
eq = self.ndiffAssertEqual
jcode = "euc-jp"
gcode = "iso-8859-1"
j = Charset(jcode)
Reported by Pylint.
Line: 22
Column: 5
class TestEmailAsianCodecs(TestEmailBase):
def test_japanese_codecs(self):
eq = self.ndiffAssertEqual
jcode = "euc-jp"
gcode = "iso-8859-1"
j = Charset(jcode)
g = Charset(gcode)
Reported by Pylint.
Line: 23
Column: 9
class TestEmailAsianCodecs(TestEmailBase):
def test_japanese_codecs(self):
eq = self.ndiffAssertEqual
jcode = "euc-jp"
gcode = "iso-8859-1"
j = Charset(jcode)
g = Charset(gcode)
h = Header("Hello World!")
Reported by Pylint.
Line: 27
Column: 9
jcode = "euc-jp"
gcode = "iso-8859-1"
j = Charset(jcode)
g = Charset(gcode)
h = Header("Hello World!")
jhello = str(b'\xa5\xcf\xa5\xed\xa1\xbc\xa5\xef\xa1\xbc'
b'\xa5\xeb\xa5\xc9\xa1\xaa', jcode)
ghello = str(b'Gr\xfc\xdf Gott!', gcode)
h.append(jhello, j)
Reported by Pylint.
Line: 28
Column: 9
gcode = "iso-8859-1"
j = Charset(jcode)
g = Charset(gcode)
h = Header("Hello World!")
jhello = str(b'\xa5\xcf\xa5\xed\xa1\xbc\xa5\xef\xa1\xbc'
b'\xa5\xeb\xa5\xc9\xa1\xaa', jcode)
ghello = str(b'Gr\xfc\xdf Gott!', gcode)
h.append(jhello, j)
h.append(ghello, g)
Reported by Pylint.
Line: 51
Column: 9
b'\xf1\xbc\xd4\xa4\xce\xbe\xb5\xc7\xa7\xa4\xf2\xc2\xd4\xa4\xc3'
b'\xa4\xc6\xa4\xa4\xa4\xde\xa4\xb9')
subject = str(subject_bytes, jcode)
h = Header(subject, j, header_name="Subject")
# test a very long header
enc = h.encode()
# TK: splitting point may differ by codec design and/or Header encoding
eq(enc , """\
=?iso-2022-jp?b?dGVzdC1qYSAbJEIkWEVqOUYkNSRsJD8lYSE8JWskTztKGyhC?=
Reported by Pylint.
Line: 61
Column: 5
# TK: full decode comparison
eq(str(h).encode(jcode), subject_bytes)
def test_payload_encoding_utf8(self):
jhello = str(b'\xa5\xcf\xa5\xed\xa1\xbc\xa5\xef\xa1\xbc'
b'\xa5\xeb\xa5\xc9\xa1\xaa', 'euc-jp')
msg = Message()
msg.set_payload(jhello, 'utf-8')
ustr = msg.get_payload(decode=True).decode(msg.get_content_charset())
Reported by Pylint.
Line: 69
Column: 5
ustr = msg.get_payload(decode=True).decode(msg.get_content_charset())
self.assertEqual(jhello, ustr)
def test_payload_encoding(self):
jcode = 'euc-jp'
jhello = str(b'\xa5\xcf\xa5\xed\xa1\xbc\xa5\xef\xa1\xbc'
b'\xa5\xeb\xa5\xc9\xa1\xaa', jcode)
msg = Message()
msg.set_payload(jhello, jcode)
Reported by Pylint.