File tree 4 files changed +11
-7
lines changed
4 files changed +11
-7
lines changed Original file line number Diff line number Diff line change 1
1
Changelog
2
2
=========
3
+ v3.10.2 (2023-03-22)
4
+ --------------------
5
+ - Bug fix for using filelock with threaded programs causing undesired file permissions - by :user: `jahrules `.
6
+
3
7
v3.10.1 (2023-03-22)
4
8
--------------------
5
9
- Handle pickle for :class: `filelock.Timeout ` :pr: `203 ` - by :user: `TheMatt2 `.
Original file line number Diff line number Diff line change @@ -179,11 +179,7 @@ def acquire(
179
179
with self ._thread_lock :
180
180
if not self .is_locked :
181
181
_LOGGER .debug ("Attempting to acquire lock %s on %s" , lock_id , lock_filename )
182
- previous_umask = os .umask (0 )
183
- try :
184
- self ._acquire ()
185
- finally :
186
- os .umask (previous_umask ) # reset umask to initial value
182
+ self ._acquire ()
187
183
if self .is_locked :
188
184
_LOGGER .debug ("Lock %s acquired on %s" , lock_id , lock_filename )
189
185
break
Original file line number Diff line number Diff line change @@ -32,7 +32,8 @@ class UnixFileLock(BaseFileLock):
32
32
33
33
def _acquire (self ) -> None :
34
34
open_flags = os .O_RDWR | os .O_CREAT | os .O_TRUNC
35
- fd = os .open (self ._lock_file , open_flags , self ._mode )
35
+ fd = os .open (self ._lock_file , open_flags )
36
+ os .chmod (fd , self ._mode )
36
37
try :
37
38
fcntl .flock (fd , fcntl .LOCK_EX | fcntl .LOCK_NB )
38
39
except OSError :
Original file line number Diff line number Diff line change @@ -440,7 +440,10 @@ def test_lock_mode_soft(tmp_path: Path) -> None:
440
440
assert lock .is_locked
441
441
442
442
mode = filemode (os .stat (lock_path ).st_mode )
443
- assert mode == "-rw-rw-rw-"
443
+ if sys .platform == "win32" :
444
+ assert mode == "-rw-rw-rw-"
445
+ else :
446
+ assert mode == "-rw-r--r--"
444
447
445
448
lock .release ()
446
449
You can’t perform that action at this time.
0 commit comments