Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ca0fbc0

Browse files
committed
branch merge
2 parents c1b65d1 + ca6befb commit ca0fbc0

38 files changed

Lines changed: 202 additions & 259 deletions

Doc/library/shutil.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ Archiving operations
295295
*owner* and *group* are used when creating a tar archive. By default,
296296
uses the current owner and group.
297297

298-
*logger* is an instance of :class:`logging.Logger`.
298+
*logger* must be an object compatible with :pep:`282`, usually an instance of
299+
:class:`logging.Logger`.
299300

300301
.. versionadded:: 3.2
301302

Lib/fileinput.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,9 +398,8 @@ def hook_compressed(filename, mode):
398398

399399

400400
def hook_encoded(encoding):
401-
import codecs
402401
def openhook(filename, mode):
403-
return codecs.open(filename, mode, encoding)
402+
return open(filename, mode, encoding=encoding)
404403
return openhook
405404

406405

Lib/http/cookiejar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""HTTP cookie handling for web clients.
1+
r"""HTTP cookie handling for web clients.
22
33
This module has (now fairly distant) origins in Gisle Aas' Perl module
44
HTTP::Cookies, from the libwww-perl library.

Lib/logging/__init__.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@
3535
'info', 'log', 'makeLogRecord', 'setLoggerClass', 'warn', 'warning',
3636
'getLogRecordFactory', 'setLogRecordFactory', 'lastResort']
3737

38-
try:
39-
import codecs
40-
except ImportError: #pragma: no cover
41-
codecs = None
42-
4338
try:
4439
import threading
4540
except ImportError: #pragma: no cover
@@ -954,8 +949,6 @@ def __init__(self, filename, mode='a', encoding=None, delay=False):
954949
"""
955950
#keep the absolute path, otherwise derived classes which use this
956951
#may come a cropper when the current directory changes
957-
if codecs is None: #pragma: no cover
958-
encoding = None
959952
self.baseFilename = os.path.abspath(filename)
960953
self.mode = mode
961954
self.encoding = encoding
@@ -983,11 +976,7 @@ def _open(self):
983976
Open the current base file with the (original) mode and encoding.
984977
Return the resulting stream.
985978
"""
986-
if self.encoding is None:
987-
stream = open(self.baseFilename, self.mode)
988-
else:
989-
stream = codecs.open(self.baseFilename, self.mode, self.encoding)
990-
return stream
979+
return open(self.baseFilename, self.mode, encoding=self.encoding)
991980

992981
def emit(self, record):
993982
"""

Lib/logging/config.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
To use, simply 'import logging' and log away!
2525
"""
2626

27-
import sys, logging, logging.handlers, socket, struct, os, traceback, re
28-
import types, io
27+
import sys, logging, logging.handlers, socket, struct, traceback, re
28+
import io
2929

3030
try:
3131
import _thread as thread
@@ -98,9 +98,6 @@ def _resolve(name):
9898
def _strip_spaces(alist):
9999
return map(lambda x: x.strip(), alist)
100100

101-
def _encoded(s):
102-
return s if isinstance(s, str) else s.encode('utf-8')
103-
104101
def _create_formatters(cp):
105102
"""Create and return formatters"""
106103
flist = cp["formatters"]["keys"]
@@ -215,7 +212,7 @@ def _install_loggers(cp, handlers, disable_existing):
215212
#avoid disabling child loggers of explicitly
216213
#named loggers. With a sorted list it is easier
217214
#to find the child loggers.
218-
existing.sort(key=_encoded)
215+
existing.sort()
219216
#We'll keep the list of existing loggers
220217
#which are children of named loggers here...
221218
child_loggers = []
@@ -588,7 +585,7 @@ def configure(self):
588585
#avoid disabling child loggers of explicitly
589586
#named loggers. With a sorted list it is easier
590587
#to find the child loggers.
591-
existing.sort(key=_encoded)
588+
existing.sort()
592589
#We'll keep the list of existing loggers
593590
#which are children of named loggers here...
594591
child_loggers = []
@@ -804,7 +801,6 @@ def handle(self):
804801
struct.pack(">L", n), followed by the config file.
805802
Uses fileConfig() to do the grunt work.
806803
"""
807-
import tempfile
808804
try:
809805
conn = self.connection
810806
chunk = conn.recv(4)

Lib/logging/handlers.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,14 @@
2525
"""
2626

2727
import logging, socket, os, pickle, struct, time, re
28+
from codecs import BOM_UTF8
2829
from stat import ST_DEV, ST_INO, ST_MTIME
2930
import queue
3031
try:
3132
import threading
3233
except ImportError: #pragma: no cover
3334
threading = None
3435

35-
try:
36-
import codecs
37-
except ImportError: #pragma: no cover
38-
codecs = None
39-
4036
#
4137
# Some constants...
4238
#
@@ -60,8 +56,6 @@ def __init__(self, filename, mode, encoding=None, delay=0):
6056
"""
6157
Use the specified filename for streamed logging
6258
"""
63-
if codecs is None: #pragma: no cover
64-
encoding = None
6559
logging.FileHandler.__init__(self, filename, mode, encoding, delay)
6660
self.mode = mode
6761
self.encoding = encoding
@@ -793,9 +787,7 @@ def emit(self, record):
793787
prio = prio.encode('utf-8')
794788
# Message is a string. Convert to bytes as required by RFC 5424
795789
msg = msg.encode('utf-8')
796-
if codecs:
797-
msg = codecs.BOM_UTF8 + msg
798-
msg = prio + msg
790+
msg = prio + BOM_UTF8 + msg
799791
try:
800792
if self.unixsocket:
801793
try:

Lib/packaging/command/bdist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def run(self):
126126
# Reinitialize and run each command.
127127
for i in range(len(self.formats)):
128128
cmd_name = commands[i]
129-
sub_cmd = self.get_reinitialized_command(cmd_name)
129+
sub_cmd = self.reinitialize_command(cmd_name)
130130
sub_cmd.format = self.formats[i]
131131

132132
# passing the owner and group names for tar archiving

Lib/packaging/command/bdist_dumb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ def run(self):
8080
if not self.skip_build:
8181
self.run_command('build')
8282

83-
install = self.get_reinitialized_command('install_dist',
84-
reinit_subcommands=True)
83+
install = self.reinitialize_command('install_dist',
84+
reinit_subcommands=True)
8585
install.root = self.bdist_dir
8686
install.skip_build = self.skip_build
8787
install.warn_dir = False

Lib/packaging/command/bdist_msi.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,13 @@ def run(self):
183183
if not self.skip_build:
184184
self.run_command('build')
185185

186-
install = self.get_reinitialized_command('install_dist',
187-
reinit_subcommands=True)
186+
install = self.reinitialize_command('install_dist',
187+
reinit_subcommands=True)
188188
install.prefix = self.bdist_dir
189189
install.skip_build = self.skip_build
190190
install.warn_dir = False
191191

192-
install_lib = self.get_reinitialized_command('install_lib')
192+
install_lib = self.reinitialize_command('install_lib')
193193
# we do not want to include pyc or pyo files
194194
install_lib.compile = False
195195
install_lib.optimize = 0

Lib/packaging/command/bdist_wininst.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,13 @@ def run(self):
115115
if not self.skip_build:
116116
self.run_command('build')
117117

118-
install = self.get_reinitialized_command('install',
119-
reinit_subcommands=True)
118+
install = self.reinitialize_command('install', reinit_subcommands=True)
120119
install.root = self.bdist_dir
121120
install.skip_build = self.skip_build
122121
install.warn_dir = False
123122
install.plat_name = self.plat_name
124123

125-
install_lib = self.get_reinitialized_command('install_lib')
124+
install_lib = self.reinitialize_command('install_lib')
126125
# we do not want to include pyc or pyo files
127126
install_lib.compile = False
128127
install_lib.optimize = 0

0 commit comments

Comments
 (0)