mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-08-28 14:53:40 +03:00
[cleanup] Remove obsolete Python compatibility code (#17357)
Authored by: doe1080
This commit is contained in:
+8
-15
@@ -238,11 +238,9 @@ def find_xpath_attr(node, xpath, key, val=None):
|
||||
expr = xpath + (f'[@{key}]' if val is None else f"[@{key}='{val}']")
|
||||
return node.find(expr)
|
||||
|
||||
# On python2.6 the xml.etree.ElementTree.Element methods don't support
|
||||
# the namespace parameter
|
||||
|
||||
|
||||
def xpath_with_ns(path, ns_map):
|
||||
"""Expand namespace-prefixed names to Clark notation."""
|
||||
components = [c.split(':') for c in path.split('/')]
|
||||
replaced = []
|
||||
for c in components:
|
||||
@@ -876,7 +874,7 @@ class Popen(subprocess.Popen):
|
||||
|
||||
self.__text_mode = kwargs.get('encoding') or kwargs.get('errors') or text or kwargs.get('universal_newlines')
|
||||
if text is True:
|
||||
kwargs['universal_newlines'] = True # For 3.6 compatibility
|
||||
kwargs['text'] = True
|
||||
kwargs.setdefault('encoding', 'utf-8')
|
||||
kwargs.setdefault('errors', 'replace')
|
||||
|
||||
@@ -1012,7 +1010,7 @@ class ExtractorError(YoutubeDLError):
|
||||
def format_traceback(self):
|
||||
return join_nonempty(
|
||||
self.traceback and ''.join(traceback.format_tb(self.traceback)),
|
||||
self.cause and ''.join(traceback.format_exception(None, self.cause, self.cause.__traceback__)[1:]),
|
||||
self.cause and ''.join(traceback.format_exception(self.cause)[1:]),
|
||||
delim='\n') or None
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
@@ -1960,11 +1958,7 @@ def setproctitle(title):
|
||||
libc = ctypes.cdll.LoadLibrary('libc.so.6')
|
||||
except OSError:
|
||||
return
|
||||
except TypeError:
|
||||
# LoadLibrary in Windows Python 2.7.13 only expects
|
||||
# a bytestring, but since unicode_literals turns
|
||||
# every string into a unicode string, it fails.
|
||||
return
|
||||
|
||||
title_bytes = title.encode()
|
||||
buf = ctypes.create_string_buffer(len(title_bytes))
|
||||
buf.value = title_bytes
|
||||
@@ -2655,11 +2649,10 @@ def multipart_encode(data, boundary=None):
|
||||
Encode a dict to RFC 7578-compliant form-data
|
||||
|
||||
data:
|
||||
A dict where keys and values can be either Unicode or bytes-like
|
||||
objects.
|
||||
A dict where keys and values can be either str or bytes-like objects.
|
||||
boundary:
|
||||
If specified a Unicode object, it's used as the boundary. Otherwise
|
||||
a random boundary is generated.
|
||||
An ASCII string to use as the boundary. If omitted, a random boundary
|
||||
is generated.
|
||||
|
||||
Reference: https://tools.ietf.org/html/rfc7578
|
||||
"""
|
||||
@@ -3422,7 +3415,7 @@ def ass_subtitles_timecode(seconds):
|
||||
def dfxp2srt(dfxp_data):
|
||||
"""
|
||||
@param dfxp_data A bytes-like object containing DFXP data
|
||||
@returns A unicode object containing converted SRT data
|
||||
@returns A string containing the converted SRT data
|
||||
"""
|
||||
LEGACY_NAMESPACES = (
|
||||
(b'http://www.w3.org/ns/ttml', [
|
||||
|
||||
Reference in New Issue
Block a user