Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
a94414a2
Commit
a94414a2
authored
May 10, 2001
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove all remaining uses of the FCNTL module from the standard library.
parent
7c116d7a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
30 deletions
+29
-30
Lib/asyncore.py
Lib/asyncore.py
+3
-4
Lib/lib-old/lockfile.py
Lib/lib-old/lockfile.py
+5
-5
Lib/posixfile.py
Lib/posixfile.py
+21
-21
No files found.
Lib/asyncore.py
View file @
a94414a2
...
...
@@ -510,7 +510,6 @@ def close_all (map=None):
import
os
if
os
.
name
==
'posix'
:
import
fcntl
import
FCNTL
class
file_wrapper
:
# here we override just enough to make a file
...
...
@@ -538,9 +537,9 @@ if os.name == 'posix':
dispatcher
.
__init__
(
self
)
self
.
connected
=
1
# set it to non-blocking mode
flags
=
fcntl
.
fcntl
(
fd
,
FCNTL
.
F_GETFL
,
0
)
flags
=
flags
|
FCNTL
.
O_NONBLOCK
fcntl
.
fcntl
(
fd
,
FCNTL
.
F_SETFL
,
flags
)
flags
=
fcntl
.
fcntl
(
fd
,
fcntl
.
F_GETFL
,
0
)
flags
=
flags
|
os
.
O_NONBLOCK
fcntl
.
fcntl
(
fd
,
fcntl
.
F_SETFL
,
flags
)
self
.
set_file
(
fd
)
def
set_file
(
self
,
fd
):
...
...
Lib/lib-old/lockfile.py
View file @
a94414a2
import
struct
,
fcntl
,
FCNTL
import
struct
,
fcntl
def
writelock
(
f
):
_lock
(
f
,
FCNTL
.
F_WRLCK
)
_lock
(
f
,
fcntl
.
F_WRLCK
)
def
readlock
(
f
):
_lock
(
f
,
FCNTL
.
F_RDLCK
)
_lock
(
f
,
fcntl
.
F_RDLCK
)
def
unlock
(
f
):
_lock
(
f
,
FCNTL
.
F_UNLCK
)
_lock
(
f
,
fcntl
.
F_UNLCK
)
def
_lock
(
f
,
op
):
dummy
=
fcntl
.
fcntl
(
f
.
fileno
(),
FCNTL
.
F_SETLKW
,
dummy
=
fcntl
.
fcntl
(
f
.
fileno
(),
fcntl
.
F_SETLKW
,
struct
.
pack
(
'2h8l'
,
op
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
))
Lib/posixfile.py
View file @
a94414a2
...
...
@@ -107,7 +107,7 @@ class _posixfile_:
return
posix
.
fdopen
(
fd
,
self
.
_file_
.
mode
)
def
flags
(
self
,
*
which
):
import
fcntl
,
FCNTL
import
fcntl
if
which
:
if
len
(
which
)
>
1
:
...
...
@@ -116,44 +116,44 @@ class _posixfile_:
else
:
which
=
'?'
l_flags
=
0
if
'n'
in
which
:
l_flags
=
l_flags
|
FCNTL
.
O_NDELAY
if
'a'
in
which
:
l_flags
=
l_flags
|
FCNTL
.
O_APPEND
if
's'
in
which
:
l_flags
=
l_flags
|
FCNTL
.
O_SYNC
if
'n'
in
which
:
l_flags
=
l_flags
|
os
.
O_NDELAY
if
'a'
in
which
:
l_flags
=
l_flags
|
os
.
O_APPEND
if
's'
in
which
:
l_flags
=
l_flags
|
os
.
O_SYNC
file
=
self
.
_file_
if
'='
not
in
which
:
cur_fl
=
fcntl
.
fcntl
(
file
.
fileno
(),
FCNTL
.
F_GETFL
,
0
)
cur_fl
=
fcntl
.
fcntl
(
file
.
fileno
(),
fcntl
.
F_GETFL
,
0
)
if
'!'
in
which
:
l_flags
=
cur_fl
&
~
l_flags
else
:
l_flags
=
cur_fl
|
l_flags
l_flags
=
fcntl
.
fcntl
(
file
.
fileno
(),
FCNTL
.
F_SETFL
,
l_flags
)
l_flags
=
fcntl
.
fcntl
(
file
.
fileno
(),
fcntl
.
F_SETFL
,
l_flags
)
if
'c'
in
which
:
arg
=
(
'!'
not
in
which
)
# 0 is don't, 1 is do close on exec
l_flags
=
fcntl
.
fcntl
(
file
.
fileno
(),
FCNTL
.
F_SETFD
,
arg
)
l_flags
=
fcntl
.
fcntl
(
file
.
fileno
(),
fcntl
.
F_SETFD
,
arg
)
if
'?'
in
which
:
which
=
''
# Return current flags
l_flags
=
fcntl
.
fcntl
(
file
.
fileno
(),
FCNTL
.
F_GETFL
,
0
)
if
FCNTL
.
O_APPEND
&
l_flags
:
which
=
which
+
'a'
if
fcntl
.
fcntl
(
file
.
fileno
(),
FCNTL
.
F_GETFD
,
0
)
&
1
:
l_flags
=
fcntl
.
fcntl
(
file
.
fileno
(),
fcntl
.
F_GETFL
,
0
)
if
os
.
O_APPEND
&
l_flags
:
which
=
which
+
'a'
if
fcntl
.
fcntl
(
file
.
fileno
(),
fcntl
.
F_GETFD
,
0
)
&
1
:
which
=
which
+
'c'
if
FCNTL
.
O_NDELAY
&
l_flags
:
which
=
which
+
'n'
if
FCNTL
.
O_SYNC
&
l_flags
:
which
=
which
+
's'
if
os
.
O_NDELAY
&
l_flags
:
which
=
which
+
'n'
if
os
.
O_SYNC
&
l_flags
:
which
=
which
+
's'
return
which
def
lock
(
self
,
how
,
*
args
):
import
struct
,
fcntl
,
FCNTL
import
struct
,
fcntl
if
'w'
in
how
:
l_type
=
FCNTL
.
F_WRLCK
elif
'r'
in
how
:
l_type
=
FCNTL
.
F_RDLCK
elif
'u'
in
how
:
l_type
=
FCNTL
.
F_UNLCK
if
'w'
in
how
:
l_type
=
fcntl
.
F_WRLCK
elif
'r'
in
how
:
l_type
=
fcntl
.
F_RDLCK
elif
'u'
in
how
:
l_type
=
fcntl
.
F_UNLCK
else
:
raise
TypeError
,
'no type of lock specified'
if
'|'
in
how
:
cmd
=
FCNTL
.
F_SETLKW
elif
'?'
in
how
:
cmd
=
FCNTL
.
F_GETLK
else
:
cmd
=
FCNTL
.
F_SETLK
if
'|'
in
how
:
cmd
=
fcntl
.
F_SETLKW
elif
'?'
in
how
:
cmd
=
fcntl
.
F_GETLK
else
:
cmd
=
fcntl
.
F_SETLK
l_whence
=
0
l_start
=
0
...
...
@@ -203,8 +203,8 @@ class _posixfile_:
l_type
,
l_whence
,
l_start
,
l_len
,
l_sysid
,
l_pid
=
\
struct
.
unpack
(
'hhllhh'
,
flock
)
if
l_type
!=
FCNTL
.
F_UNLCK
:
if
l_type
==
FCNTL
.
F_RDLCK
:
if
l_type
!=
fcntl
.
F_UNLCK
:
if
l_type
==
fcntl
.
F_RDLCK
:
return
'r'
,
l_len
,
l_start
,
l_whence
,
l_pid
else
:
return
'w'
,
l_len
,
l_start
,
l_whence
,
l_pid
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment