The following issues were found
Lib/test/test_zoneinfo/_support.py
10 issues
Line: 65
Column: 21
class ZoneInfoTestBase(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.klass = cls.module.ZoneInfo
super().setUpClass()
@contextlib.contextmanager
def tzpath_context(self, tzpath, block_tzdata=True, lock=TZPATH_LOCK):
def pop_tzdata_modules():
Reported by Pylint.
Line: 90
Column: 24
tzdata_modules = pop_tzdata_modules()
sys.modules["tzdata"] = None
old_path = self.module.TZPATH
try:
self.module.reset_tzpath(tzpath)
yield
finally:
if block_tzdata:
Reported by Pylint.
Line: 92
Column: 17
old_path = self.module.TZPATH
try:
self.module.reset_tzpath(tzpath)
yield
finally:
if block_tzdata:
sys.modules.pop("tzdata")
for modname, module in tzdata_modules.items():
Reported by Pylint.
Line: 100
Column: 17
for modname, module in tzdata_modules.items():
sys.modules[modname] = module
self.module.reset_tzpath(old_path)
Reported by Pylint.
Line: 1
Column: 1
import contextlib
import functools
import sys
import threading
import unittest
from test.support.import_helper import import_fresh_module
OS_ENV_LOCK = threading.Lock()
TZPATH_LOCK = threading.Lock()
Reported by Pylint.
Line: 13
Column: 1
TZPATH_TEST_LOCK = threading.Lock()
def call_once(f):
"""Decorator that ensures a function is only ever called once."""
lock = threading.Lock()
cached = functools.lru_cache(None)(f)
@functools.wraps(f)
Reported by Pylint.
Line: 36
Column: 5
one time — in other words, when using this function you will only ever
get one copy of each module rather than a fresh import each time.
"""
import zoneinfo as c_module
py_module = import_fresh_module("zoneinfo", blocked=["_zoneinfo"])
return py_module, c_module
Reported by Pylint.
Line: 52
Column: 5
refers to the same object.
"""
NOT_PRESENT = object()
old_zoneinfo = sys.modules.get("zoneinfo", NOT_PRESENT)
sys.modules["zoneinfo"] = module
yield
if old_zoneinfo is not NOT_PRESENT:
sys.modules["zoneinfo"] = old_zoneinfo
Reported by Pylint.
Line: 62
Column: 1
sys.modules.pop("zoneinfo")
class ZoneInfoTestBase(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.klass = cls.module.ZoneInfo
super().setUpClass()
Reported by Pylint.
Line: 69
Column: 5
super().setUpClass()
@contextlib.contextmanager
def tzpath_context(self, tzpath, block_tzdata=True, lock=TZPATH_LOCK):
def pop_tzdata_modules():
tzdata_modules = {}
for modname in list(sys.modules):
if modname.split(".", 1)[0] != "tzdata": # pragma: nocover
continue
Reported by Pylint.
Python/pylifecycle.c
10 issues
Line: 325
Column: 9
CWE codes:
134
Suggestion:
Use a constant for the format specification
return 0;
}
if (warn) {
fprintf(stderr, C_LOCALE_COERCION_WARNING, newloc);
}
/* Reconfigure with the overridden environment variables */
_Py_SetLocaleFromEnv(LC_ALL);
return 1;
Reported by FlawFinder.
Line: 2798
Column: 5
CWE codes:
134
Suggestion:
Use a constant for the format specification
#else
va_start(vargs);
#endif
vfprintf(stream, format, vargs);
va_end(vargs);
fputs("\n", stream);
fflush(stream);
Reported by FlawFinder.
Line: 242
Column: 39
CWE codes:
807
20
Suggestion:
Check environment variables carefully before using them
{
#ifndef MS_WINDOWS
if (!warn) {
const char *locale_override = getenv("LC_ALL");
if (locale_override != NULL && *locale_override != '\0') {
/* Don't coerce C locale if the LC_ALL environment variable
is set */
return 0;
}
Reported by FlawFinder.
Line: 346
Column: 35
CWE codes:
807
20
Suggestion:
Check environment variables carefully before using them
return coerced;
}
const char *locale_override = getenv("LC_ALL");
if (locale_override == NULL || *locale_override == '\0') {
/* LC_ALL is also not set (or is set to an empty string) */
const _LocaleCoercionTarget *target = NULL;
for (target = _TARGET_LOCALES; target->locale_name; target++) {
const char *new_locale = setlocale(LC_CTYPE,
Reported by FlawFinder.
Line: 406
Column: 18
CWE codes:
807
20
Suggestion:
Check environment variables carefully before using them
* and incorrectly sets the "C" locale at API 24 and older APIs. We only
* check the environment variables listed in env_var_set. */
for (pvar=env_var_set; *pvar; pvar++) {
locale = getenv(*pvar);
if (locale != NULL && *locale != '\0') {
if (strcmp(locale, utf8_locale) == 0 ||
strcmp(locale, "en_US.UTF-8") == 0) {
return setlocale(category, utf8_locale);
}
Reported by FlawFinder.
Line: 423
Column: 23
CWE codes:
807
20
Suggestion:
Check environment variables carefully before using them
* string, the implementation-defined default locale shall be used." */
#ifdef PY_COERCE_C_LOCALE
coerce_c_locale = getenv("PYTHONCOERCECLOCALE");
if (coerce_c_locale == NULL || strcmp(coerce_c_locale, "0") != 0) {
/* Some other ported code may check the environment variables (e.g. in
* extension modules), so we make sure that they match the locale
* configuration */
if (setenv("LC_CTYPE", utf8_locale, 1)) {
Reported by FlawFinder.
Line: 2168
Column: 20
CWE codes:
362
const char* newline;
PyObject *line_buffering, *write_through;
int buffering, isatty;
_Py_IDENTIFIER(open);
_Py_IDENTIFIER(isatty);
_Py_IDENTIFIER(TextIOWrapper);
_Py_IDENTIFIER(mode);
const int buffered_stdio = config->buffered_stdio;
Reported by FlawFinder.
Line: 41
Column: 55
CWE codes:
126
(PyObject_TypeCheck((op), &PyWindowsConsoleIO_Type))
#endif
#define PUTS(fd, str) _Py_write_noraise(fd, str, (int)strlen(str))
_Py_IDENTIFIER(flush);
_Py_IDENTIFIER(name);
_Py_IDENTIFIER(stdin);
Reported by FlawFinder.
Line: 2512
Column: 14
CWE codes:
126
OutputDebugStringW(L"Fatal Python error: ");
msglen = strlen(msg);
while (msglen) {
size_t i;
if (buflen > msglen) {
buflen = msglen;
Reported by FlawFinder.
Modules/clinic/_localemodule.c.h
10 issues
Line: 43
Column: 13
CWE codes:
126
if (locale == NULL) {
goto exit;
}
if (strlen(locale) != (size_t)locale_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
}
else {
Reported by FlawFinder.
Line: 245
Column: 9
CWE codes:
126
if (in == NULL) {
goto exit;
}
if (strlen(in) != (size_t)in_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = _locale_gettext_impl(module, in);
Reported by FlawFinder.
Line: 292
Column: 13
CWE codes:
126
if (domain == NULL) {
goto exit;
}
if (strlen(domain) != (size_t)domain_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
}
else {
Reported by FlawFinder.
Line: 310
Column: 9
CWE codes:
126
if (in == NULL) {
goto exit;
}
if (strlen(in) != (size_t)in_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
return_value = _locale_dgettext_impl(module, domain, in);
Reported by FlawFinder.
Line: 357
Column: 13
CWE codes:
126
if (domain == NULL) {
goto exit;
}
if (strlen(domain) != (size_t)domain_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
}
else {
Reported by FlawFinder.
Line: 375
Column: 9
CWE codes:
126
if (msgid == NULL) {
goto exit;
}
if (strlen(msgid) != (size_t)msgid_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
category = _PyLong_AsInt(args[2]);
if (category == -1 && PyErr_Occurred()) {
Reported by FlawFinder.
Line: 420
Column: 13
CWE codes:
126
if (domain == NULL) {
goto exit;
}
if (strlen(domain) != (size_t)domain_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
}
else {
Reported by FlawFinder.
Line: 471
Column: 9
CWE codes:
126
if (domain == NULL) {
goto exit;
}
if (strlen(domain) != (size_t)domain_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
dirname_obj = args[1];
return_value = _locale_bindtextdomain_impl(module, domain, dirname_obj);
Reported by FlawFinder.
Line: 518
Column: 9
CWE codes:
126
if (domain == NULL) {
goto exit;
}
if (strlen(domain) != (size_t)domain_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
if (args[1] == Py_None) {
codeset = NULL;
Reported by FlawFinder.
Line: 531
Column: 13
CWE codes:
126
if (codeset == NULL) {
goto exit;
}
if (strlen(codeset) != (size_t)codeset_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
}
else {
Reported by FlawFinder.
Lib/turtledemo/two_canvases.py
10 issues
Line: 39
Column: 9
for t in p, q:
t.begin_fill()
for i in range(5):
for t in p, q:
t.fd(50)
t.lt(72)
for t in p,q:
t.end_fill()
Reported by Pylint.
Line: 11
Column: 1
from turtle import TurtleScreen, RawTurtle, TK
def main():
root = TK.Tk()
cv1 = TK.Canvas(root, width=300, height=200, bg="#ddffff")
cv2 = TK.Canvas(root, width=300, height=200, bg="#ffeeee")
cv1.pack()
cv2.pack()
Reported by Pylint.
Line: 18
Column: 5
cv1.pack()
cv2.pack()
s1 = TurtleScreen(cv1)
s1.bgcolor(0.85, 0.85, 1)
s2 = TurtleScreen(cv2)
s2.bgcolor(1, 0.85, 0.85)
p = RawTurtle(s1)
Reported by Pylint.
Line: 20
Column: 5
s1 = TurtleScreen(cv1)
s1.bgcolor(0.85, 0.85, 1)
s2 = TurtleScreen(cv2)
s2.bgcolor(1, 0.85, 0.85)
p = RawTurtle(s1)
q = RawTurtle(s2)
Reported by Pylint.
Line: 23
Column: 5
s2 = TurtleScreen(cv2)
s2.bgcolor(1, 0.85, 0.85)
p = RawTurtle(s1)
q = RawTurtle(s2)
p.color("red", (1, 0.85, 0.85))
p.width(3)
q.color("blue", (0.85, 0.85, 1))
Reported by Pylint.
Line: 24
Column: 5
s2.bgcolor(1, 0.85, 0.85)
p = RawTurtle(s1)
q = RawTurtle(s2)
p.color("red", (1, 0.85, 0.85))
p.width(3)
q.color("blue", (0.85, 0.85, 1))
q.width(3)
Reported by Pylint.
Line: 31
Column: 9
q.color("blue", (0.85, 0.85, 1))
q.width(3)
for t in p,q:
t.shape("turtle")
t.lt(36)
q.lt(180)
Reported by Pylint.
Line: 37
Column: 9
q.lt(180)
for t in p, q:
t.begin_fill()
for i in range(5):
for t in p, q:
t.fd(50)
t.lt(72)
Reported by Pylint.
Line: 40
Column: 13
for t in p, q:
t.begin_fill()
for i in range(5):
for t in p, q:
t.fd(50)
t.lt(72)
for t in p,q:
t.end_fill()
t.lt(54)
Reported by Pylint.
Line: 43
Column: 9
for t in p, q:
t.fd(50)
t.lt(72)
for t in p,q:
t.end_fill()
t.lt(54)
t.pu()
t.bk(50)
Reported by Pylint.
Lib/tkinter/test/test_tkinter/test_loadtk.py
10 issues
Line: 21
Column: 9
tcl.destroy()
def testLoadTkFailure(self):
old_display = None
if sys.platform.startswith(('win', 'darwin', 'cygwin')):
# no failure possible on windows?
# XXX Maybe on tk older than 8.4.13 it would be possible,
# see tkinter.h.
Reported by Pylint.
Line: 25
Column: 3
if sys.platform.startswith(('win', 'darwin', 'cygwin')):
# no failure possible on windows?
# XXX Maybe on tk older than 8.4.13 it would be possible,
# see tkinter.h.
return
with os_helper.EnvironmentVarGuard() as env:
if 'DISPLAY' in os.environ:
del env['DISPLAY']
Reported by Pylint.
Line: 1
Column: 1
import os
import sys
import unittest
import test.support as test_support
from test.support import os_helper
from tkinter import Tcl, TclError
test_support.requires('gui')
Reported by Pylint.
Line: 10
Column: 1
test_support.requires('gui')
class TkLoadTest(unittest.TestCase):
@unittest.skipIf('DISPLAY' not in os.environ, 'No $DISPLAY set.')
def testLoadTk(self):
tcl = Tcl()
self.assertRaises(TclError,tcl.winfo_geometry)
Reported by Pylint.
Line: 13
Column: 5
class TkLoadTest(unittest.TestCase):
@unittest.skipIf('DISPLAY' not in os.environ, 'No $DISPLAY set.')
def testLoadTk(self):
tcl = Tcl()
self.assertRaises(TclError,tcl.winfo_geometry)
tcl.loadtk()
self.assertEqual('1x1+0+0', tcl.winfo_geometry())
tcl.destroy()
Reported by Pylint.
Line: 13
Column: 5
class TkLoadTest(unittest.TestCase):
@unittest.skipIf('DISPLAY' not in os.environ, 'No $DISPLAY set.')
def testLoadTk(self):
tcl = Tcl()
self.assertRaises(TclError,tcl.winfo_geometry)
tcl.loadtk()
self.assertEqual('1x1+0+0', tcl.winfo_geometry())
tcl.destroy()
Reported by Pylint.
Line: 20
Column: 5
self.assertEqual('1x1+0+0', tcl.winfo_geometry())
tcl.destroy()
def testLoadTkFailure(self):
old_display = None
if sys.platform.startswith(('win', 'darwin', 'cygwin')):
# no failure possible on windows?
# XXX Maybe on tk older than 8.4.13 it would be possible,
Reported by Pylint.
Line: 20
Column: 5
self.assertEqual('1x1+0+0', tcl.winfo_geometry())
tcl.destroy()
def testLoadTkFailure(self):
old_display = None
if sys.platform.startswith(('win', 'darwin', 'cygwin')):
# no failure possible on windows?
# XXX Maybe on tk older than 8.4.13 it would be possible,
Reported by Pylint.
Line: 35
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b605_start_process_with_a_shell.html
# doesn't actually carry through to the process level
# because they don't support unsetenv
# If that's the case, abort.
with os.popen('echo $DISPLAY') as pipe:
display = pipe.read().strip()
if display:
return
tcl = Tcl()
Reported by Bandit.
Line: 35
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b607_start_process_with_partial_path.html
# doesn't actually carry through to the process level
# because they don't support unsetenv
# If that's the case, abort.
with os.popen('echo $DISPLAY') as pipe:
display = pipe.read().strip()
if display:
return
tcl = Tcl()
Reported by Bandit.
Lib/email/charset.py
10 issues
Line: 222
Column: 13
else:
input_charset = str(input_charset, 'ascii')
except UnicodeError:
raise errors.CharsetError(input_charset)
input_charset = input_charset.lower()
# Set the input charset after filtering through the aliases
self.input_charset = ALIASES.get(input_charset, input_charset)
# We can try to guess which encoding and conversion to use by the
# charset_map dictionary. Try that first, but let the user override
Reported by Pylint.
Line: 349
Column: 21
if not lines and not current_line:
lines.append(None)
else:
separator = (' ' if lines else '')
joined_line = EMPTYSTRING.join(current_line)
header_bytes = _encode(joined_line, codec)
lines.append(encoder(header_bytes))
current_line = [character]
maxlen = next(maxlengths) - extra
Reported by Pylint.
Line: 1
Column: 1
# Copyright (C) 2001-2007 Python Software Foundation
# Author: Ben Gertzfield, Barry Warsaw
# Contact: email-sig@python.org
__all__ = [
'Charset',
'add_alias',
'add_charset',
'add_codec',
Reported by Pylint.
Line: 160
Column: 5
# Convenience function for encoding strings, taking into account
# that they might be unknown-8bit (ie: have surrogate-escaped bytes)
def _encode(string, codec):
if codec == UNKNOWN8BIT:
return string.encode('ascii', 'surrogateescape')
else:
return string.encode(codec)
Reported by Pylint.
Line: 263
Suggestion:
https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html
Returns "base64" if self.body_encoding is BASE64.
Returns conversion function otherwise.
"""
assert self.body_encoding != SHORTEST
if self.body_encoding == QP:
return 'quoted-printable'
elif self.body_encoding == BASE64:
return 'base64'
else:
Reported by Bandit.
Line: 264
Column: 9
Returns conversion function otherwise.
"""
assert self.body_encoding != SHORTEST
if self.body_encoding == QP:
return 'quoted-printable'
elif self.body_encoding == BASE64:
return 'base64'
else:
return encode_7or8bit
Reported by Pylint.
Line: 298
Column: 5
return string
return encoder_module.header_encode(header_bytes, codec)
def header_encode_lines(self, string, maxlengths):
"""Header-encode a string by converting it first to bytes.
This is similar to `header_encode()` except that the string is fit
into maximum line lengths as given by the argument.
Reported by Pylint.
Line: 361
Column: 9
return lines
def _get_encoder(self, header_bytes):
if self.header_encoding == BASE64:
return email.base64mime
elif self.header_encoding == QP:
return email.quoprimime
elif self.header_encoding == SHORTEST:
len64 = email.base64mime.header_length(header_bytes)
Reported by Pylint.
Line: 368
Column: 13
elif self.header_encoding == SHORTEST:
len64 = email.base64mime.header_length(header_bytes)
lenqp = email.quoprimime.header_length(header_bytes)
if len64 < lenqp:
return email.base64mime
else:
return email.quoprimime
else:
return None
Reported by Pylint.
Line: 386
Column: 9
"""
if not string:
return string
if self.body_encoding is BASE64:
if isinstance(string, str):
string = string.encode(self.output_charset)
return email.base64mime.body_encode(string)
elif self.body_encoding is QP:
# quopromime.body_encode takes a string, but operates on it as if
Reported by Pylint.
Lib/encodings/utf_16_le.py
10 issues
Line: 15
Column: 12
encode = codecs.utf_16_le_encode
def decode(input, errors='strict'):
return codecs.utf_16_le_decode(input, errors, True)
class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input, final=False):
return codecs.utf_16_le_encode(input, self.errors)[0]
Reported by Pylint.
Line: 19
Column: 22
return codecs.utf_16_le_decode(input, errors, True)
class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input, final=False):
return codecs.utf_16_le_encode(input, self.errors)[0]
class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
_buffer_decode = codecs.utf_16_le_decode
Reported by Pylint.
Line: 25
Column: 1
class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
_buffer_decode = codecs.utf_16_le_decode
class StreamWriter(codecs.StreamWriter):
encode = codecs.utf_16_le_encode
class StreamReader(codecs.StreamReader):
decode = codecs.utf_16_le_decode
Reported by Pylint.
Line: 28
Column: 1
class StreamWriter(codecs.StreamWriter):
encode = codecs.utf_16_le_encode
class StreamReader(codecs.StreamReader):
decode = codecs.utf_16_le_decode
### encodings module API
def getregentry():
Reported by Pylint.
Line: 15
Column: 1
encode = codecs.utf_16_le_encode
def decode(input, errors='strict'):
return codecs.utf_16_le_decode(input, errors, True)
class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input, final=False):
return codecs.utf_16_le_encode(input, self.errors)[0]
Reported by Pylint.
Line: 18
Column: 1
def decode(input, errors='strict'):
return codecs.utf_16_le_decode(input, errors, True)
class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input, final=False):
return codecs.utf_16_le_encode(input, self.errors)[0]
class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
_buffer_decode = codecs.utf_16_le_decode
Reported by Pylint.
Line: 22
Column: 1
def encode(self, input, final=False):
return codecs.utf_16_le_encode(input, self.errors)[0]
class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
_buffer_decode = codecs.utf_16_le_decode
class StreamWriter(codecs.StreamWriter):
encode = codecs.utf_16_le_encode
Reported by Pylint.
Line: 25
Column: 1
class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
_buffer_decode = codecs.utf_16_le_decode
class StreamWriter(codecs.StreamWriter):
encode = codecs.utf_16_le_encode
class StreamReader(codecs.StreamReader):
decode = codecs.utf_16_le_decode
Reported by Pylint.
Line: 28
Column: 1
class StreamWriter(codecs.StreamWriter):
encode = codecs.utf_16_le_encode
class StreamReader(codecs.StreamReader):
decode = codecs.utf_16_le_decode
### encodings module API
def getregentry():
Reported by Pylint.
Line: 33
Column: 1
### encodings module API
def getregentry():
return codecs.CodecInfo(
name='utf-16-le',
encode=encode,
decode=decode,
incrementalencoder=IncrementalEncoder,
Reported by Pylint.
Lib/encodings/utf_16_be.py
10 issues
Line: 15
Column: 12
encode = codecs.utf_16_be_encode
def decode(input, errors='strict'):
return codecs.utf_16_be_decode(input, errors, True)
class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input, final=False):
return codecs.utf_16_be_encode(input, self.errors)[0]
Reported by Pylint.
Line: 19
Column: 22
return codecs.utf_16_be_decode(input, errors, True)
class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input, final=False):
return codecs.utf_16_be_encode(input, self.errors)[0]
class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
_buffer_decode = codecs.utf_16_be_decode
Reported by Pylint.
Line: 25
Column: 1
class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
_buffer_decode = codecs.utf_16_be_decode
class StreamWriter(codecs.StreamWriter):
encode = codecs.utf_16_be_encode
class StreamReader(codecs.StreamReader):
decode = codecs.utf_16_be_decode
Reported by Pylint.
Line: 28
Column: 1
class StreamWriter(codecs.StreamWriter):
encode = codecs.utf_16_be_encode
class StreamReader(codecs.StreamReader):
decode = codecs.utf_16_be_decode
### encodings module API
def getregentry():
Reported by Pylint.
Line: 15
Column: 1
encode = codecs.utf_16_be_encode
def decode(input, errors='strict'):
return codecs.utf_16_be_decode(input, errors, True)
class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input, final=False):
return codecs.utf_16_be_encode(input, self.errors)[0]
Reported by Pylint.
Line: 18
Column: 1
def decode(input, errors='strict'):
return codecs.utf_16_be_decode(input, errors, True)
class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input, final=False):
return codecs.utf_16_be_encode(input, self.errors)[0]
class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
_buffer_decode = codecs.utf_16_be_decode
Reported by Pylint.
Line: 22
Column: 1
def encode(self, input, final=False):
return codecs.utf_16_be_encode(input, self.errors)[0]
class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
_buffer_decode = codecs.utf_16_be_decode
class StreamWriter(codecs.StreamWriter):
encode = codecs.utf_16_be_encode
Reported by Pylint.
Line: 25
Column: 1
class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
_buffer_decode = codecs.utf_16_be_decode
class StreamWriter(codecs.StreamWriter):
encode = codecs.utf_16_be_encode
class StreamReader(codecs.StreamReader):
decode = codecs.utf_16_be_decode
Reported by Pylint.
Line: 28
Column: 1
class StreamWriter(codecs.StreamWriter):
encode = codecs.utf_16_be_encode
class StreamReader(codecs.StreamReader):
decode = codecs.utf_16_be_decode
### encodings module API
def getregentry():
Reported by Pylint.
Line: 33
Column: 1
### encodings module API
def getregentry():
return codecs.CodecInfo(
name='utf-16-be',
encode=encode,
decode=decode,
incrementalencoder=IncrementalEncoder,
Reported by Pylint.
Lib/lib2to3/fixes/fix_numliterals.py
10 issues
Line: 7
Column: 1
# Licensed to PSF under a Contributor Agreement.
# Local imports
from ..pgen2 import token
from .. import fixer_base
from ..fixer_util import Number
class FixNumliterals(fixer_base.BaseFix):
Reported by Pylint.
Line: 8
Column: 1
# Local imports
from ..pgen2 import token
from .. import fixer_base
from ..fixer_util import Number
class FixNumliterals(fixer_base.BaseFix):
# This is so simple that we don't need the pattern compiler.
Reported by Pylint.
Line: 9
Column: 1
# Local imports
from ..pgen2 import token
from .. import fixer_base
from ..fixer_util import Number
class FixNumliterals(fixer_base.BaseFix):
# This is so simple that we don't need the pattern compiler.
Reported by Pylint.
Line: 21
Column: 31
# Override
return (node.value.startswith("0") or node.value[-1] in "Ll")
def transform(self, node, results):
val = node.value
if val[-1] in 'Ll':
val = val[:-1]
elif val.startswith('0') and val.isdigit() and len(set(val)) > 1:
val = "0o" + val[1:]
Reported by Pylint.
Line: 12
Column: 1
from ..fixer_util import Number
class FixNumliterals(fixer_base.BaseFix):
# This is so simple that we don't need the pattern compiler.
_accept_type = token.NUMBER
def match(self, node):
Reported by Pylint.
Line: 17
Column: 5
_accept_type = token.NUMBER
def match(self, node):
# Override
return (node.value.startswith("0") or node.value[-1] in "Ll")
def transform(self, node, results):
val = node.value
Reported by Pylint.
Line: 17
Column: 5
_accept_type = token.NUMBER
def match(self, node):
# Override
return (node.value.startswith("0") or node.value[-1] in "Ll")
def transform(self, node, results):
val = node.value
Reported by Pylint.
Line: 19
Column: 1
def match(self, node):
# Override
return (node.value.startswith("0") or node.value[-1] in "Ll")
def transform(self, node, results):
val = node.value
if val[-1] in 'Ll':
val = val[:-1]
Reported by Pylint.
Line: 21
Column: 5
# Override
return (node.value.startswith("0") or node.value[-1] in "Ll")
def transform(self, node, results):
val = node.value
if val[-1] in 'Ll':
val = val[:-1]
elif val.startswith('0') and val.isdigit() and len(set(val)) > 1:
val = "0o" + val[1:]
Reported by Pylint.
Line: 21
Column: 5
# Override
return (node.value.startswith("0") or node.value[-1] in "Ll")
def transform(self, node, results):
val = node.value
if val[-1] in 'Ll':
val = val[:-1]
elif val.startswith('0') and val.isdigit() and len(set(val)) > 1:
val = "0o" + val[1:]
Reported by Pylint.
Lib/distutils/tests/test_install_lib.py
10 issues
Line: 14
Column: 1
from test.support import run_unittest
class InstallLibTestCase(support.TempdirManager,
support.LoggingSilencer,
support.EnvironGuard,
unittest.TestCase):
def test_finalize_options(self):
Reported by Pylint.
Line: 19
Column: 5
support.EnvironGuard,
unittest.TestCase):
def test_finalize_options(self):
dist = self.create_dist()[1]
cmd = install_lib(dist)
cmd.finalize_options()
self.assertEqual(cmd.compile, 1)
Reported by Pylint.
Line: 38
Column: 5
self.assertEqual(cmd.optimize, 2)
@unittest.skipIf(sys.dont_write_bytecode, 'byte-compile disabled')
def test_byte_compile(self):
project_dir, dist = self.create_dist()
os.chdir(project_dir)
cmd = install_lib(dist)
cmd.compile = cmd.optimize = 1
Reported by Pylint.
Line: 44
Column: 9
cmd = install_lib(dist)
cmd.compile = cmd.optimize = 1
f = os.path.join(project_dir, 'foo.py')
self.write_file(f, '# python file')
cmd.byte_compile([f])
pyc_file = importlib.util.cache_from_source('foo.py', optimization='')
pyc_opt_file = importlib.util.cache_from_source('foo.py',
optimization=cmd.optimize)
Reported by Pylint.
Line: 53
Column: 5
self.assertTrue(os.path.exists(pyc_file))
self.assertTrue(os.path.exists(pyc_opt_file))
def test_get_outputs(self):
project_dir, dist = self.create_dist()
os.chdir(project_dir)
os.mkdir('spam')
cmd = install_lib(dist)
Reported by Pylint.
Line: 62
Column: 9
# setting up a dist environment
cmd.compile = cmd.optimize = 1
cmd.install_dir = self.mkdtemp()
f = os.path.join(project_dir, 'spam', '__init__.py')
self.write_file(f, '# python package')
cmd.distribution.ext_modules = [Extension('foo', ['xxx'])]
cmd.distribution.packages = ['spam']
cmd.distribution.script_name = 'setup.py'
Reported by Pylint.
Line: 73
Column: 5
outputs = cmd.get_outputs()
self.assertEqual(len(outputs), 4, outputs)
def test_get_inputs(self):
project_dir, dist = self.create_dist()
os.chdir(project_dir)
os.mkdir('spam')
cmd = install_lib(dist)
Reported by Pylint.
Line: 82
Column: 9
# setting up a dist environment
cmd.compile = cmd.optimize = 1
cmd.install_dir = self.mkdtemp()
f = os.path.join(project_dir, 'spam', '__init__.py')
self.write_file(f, '# python package')
cmd.distribution.ext_modules = [Extension('foo', ['xxx'])]
cmd.distribution.packages = ['spam']
cmd.distribution.script_name = 'setup.py'
Reported by Pylint.
Line: 93
Column: 5
inputs = cmd.get_inputs()
self.assertEqual(len(inputs), 2, inputs)
def test_dont_write_bytecode(self):
# makes sure byte_compile is not used
dist = self.create_dist()[1]
cmd = install_lib(dist)
cmd.compile = 1
cmd.optimize = 1
Reported by Pylint.
Line: 111
Column: 1
self.logs[0][1] % self.logs[0][2])
def test_suite():
return unittest.makeSuite(InstallLibTestCase)
if __name__ == "__main__":
run_unittest(test_suite())
Reported by Pylint.