mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-75593: Add support of bytes and path-like paths in wave.open() (GH-140951)
This commit is contained in:
parent
f1b7961ccf
commit
35908265b0
4 changed files with 33 additions and 4 deletions
|
|
@ -69,6 +69,7 @@
|
|||
|
||||
from collections import namedtuple
|
||||
import builtins
|
||||
import os
|
||||
import struct
|
||||
import sys
|
||||
|
||||
|
|
@ -274,7 +275,7 @@ def initfp(self, file):
|
|||
|
||||
def __init__(self, f):
|
||||
self._i_opened_the_file = None
|
||||
if isinstance(f, str):
|
||||
if isinstance(f, (bytes, str, os.PathLike)):
|
||||
f = builtins.open(f, 'rb')
|
||||
self._i_opened_the_file = f
|
||||
# else, assume it is an open file object already
|
||||
|
|
@ -431,7 +432,7 @@ class Wave_write:
|
|||
|
||||
def __init__(self, f):
|
||||
self._i_opened_the_file = None
|
||||
if isinstance(f, str):
|
||||
if isinstance(f, (bytes, str, os.PathLike)):
|
||||
f = builtins.open(f, 'wb')
|
||||
self._i_opened_the_file = f
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue