Skip to content

Commit 26b8ef4

Browse files
committed
Fix fileobj I/O undeterministic behavior
Ever since the file-like object support was added in pytorch#1158, the test was occasionally failing in CI. This PR fixes this.
1 parent d0ae170 commit 26b8ef4

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

third_party/sox/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ ExternalProject_Add(sox
197197
URL https://downloads.sourceforge.net/project/sox/sox/14.4.2/sox-14.4.2.tar.bz2
198198
URL_HASH SHA256=81a6956d4330e75b5827316e44ae381e6f1e8928003c6aa45896da9041ea149c
199199
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env ${envs} ${CMAKE_CURRENT_BINARY_DIR}/src/sox/configure ${COMMON_ARGS} ${SOX_OPTIONS}
200+
PATCH_COMMAND patch < ${CMAKE_CURRENT_SOURCE_DIR}/patch/sox.patch
200201
BUILD_BYPRODUCTS ${SOX_LIBRARIES}
201202
DOWNLOAD_NO_PROGRESS ON
202203
LOG_DOWNLOAD ON

third_party/sox/patch/sox.patch

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
diff -ru src/formats.c src/formats.c
2+
--- src/formats.c 2014-10-26 19:55:50.000000000 -0700
3+
+++ src/formats.c 2021-02-22 16:01:02.833144070 -0800
4+
@@ -333,6 +333,9 @@
5+
assert(ft);
6+
if (!ft->fp)
7+
return sox_false;
8+
- fstat(fileno((FILE*)ft->fp), &st);
9+
+ int fd = fileno((FILE*)ft->fp);
10+
+ if (fd < 0)
11+
+ return sox_false;
12+
+ fstat(fd, &st);
13+
return ((st.st_mode & S_IFMT) == S_IFREG);
14+
}

0 commit comments

Comments
 (0)