Skip to content
GitLab
Explore
Sign in
Register
Commits on Source (2)
Replace file() with open() for Python 3 compatability
· dbeca9f7
Brian May
authored
Mar 04, 2019
dbeca9f7
Merge branch 'bam/security-tracker-fix_file_open'
· e41e6b51
Salvatore Bonaccorso
authored
Mar 04, 2019
e41e6b51
Show whitespace changes
Inline
Side-by-side
bin/check-syntax
View file @
e41e6b51
...
...
@@ -49,7 +49,7 @@ def construct(c, name):
f
=
sys
.
stdin
name
=
'
<stdin>
'
else
:
f
=
file
(
name
)
f
=
open
(
name
)
return
c
(
name
,
f
)
sources
=
debian_support
.
getconfig
()[
"
sources
"
]
...
...
bin/list-queue
View file @
e41e6b51
...
...
@@ -176,7 +176,7 @@ def updatechanges(db, ondisk):
need_update
=
prepareupdate
(
db
,
ondisk
,
indb
,
"
changes
"
)
def
do_update
():
for
(
path
,
stat
)
in
need_update
:
changes
=
Changes
(
file
(
path
))
changes
=
Changes
(
open
(
path
))
try
:
dist
=
changes
[
"
Distribution
"
]
debs
=
set
(
pkg
[
"
name
"
]
for
pkg
in
changes
[
"
Checksums-Sha1
"
])
...
...
bin/mass-bug-filer
View file @
e41e6b51
...
...
@@ -11,7 +11,7 @@ if len(sys.argv) < 3:
print
(
"
usage: %s FILE PACKAGE...
"
%
sys
.
argv
[
0
],
file
=
sys
.
stderr
)
sys
.
exit
(
1
)
message_file
=
file
(
sys
.
argv
[
1
])
message_file
=
open
(
sys
.
argv
[
1
])
packages
=
sys
.
argv
[
2
:]
cache
=
apt
.
Cache
()
...
...
bin/update-nvd
View file @
e41e6b51
...
...
@@ -30,7 +30,7 @@ for name in sys.argv[1:]:
if
name
==
'
-i
'
:
incremental
=
True
continue
f
=
file
(
name
)
f
=
open
(
name
)
data
+=
nvd
.
parse
(
f
)
f
.
close
()
...
...
lib/python/debian_support.py
View file @
e41e6b51
...
...
@@ -131,7 +131,7 @@ class PackageFile:
file with the indicated name.
"""
if
fileObj
is
None
:
fileObj
=
file
(
name
)
fileObj
=
open
(
name
)
self
.
name
=
name
self
.
file
=
fileObj
self
.
lineno
=
0
...
...
@@ -274,7 +274,7 @@ def replaceFile(lines, local):
import
os.path
local_new
=
local
+
'
.new
'
new_file
=
file
(
local_new
,
'
w+
'
)
new_file
=
open
(
local_new
,
'
w+
'
)
try
:
for
l
in
lines
:
...
...
@@ -318,7 +318,7 @@ def updateFile(remote, local, verbose=None):
"""
try
:
local_file
=
file
(
local
)
local_file
=
open
(
local
)
except
IOError
:
if
verbose
:
print
(
"
updateFile: no local copy, downloading full file
"
)
...
...
@@ -521,7 +521,7 @@ def getconfig():
global
_config
if
_config
is
not
None
:
return
_config
_config
=
json
.
load
(
file
(
findresource
(
"
data
"
,
"
config.json
"
)))
_config
=
json
.
load
(
open
(
findresource
(
"
data
"
,
"
config.json
"
)))
return
_config
_releasecodename
=
None
...
...
lib/python/nvd.py
View file @
e41e6b51
...
...
@@ -125,4 +125,4 @@ def parse(file):
if
__name__
==
"
__main__
"
:
import
sys
for
name
in
sys
.
argv
[
1
:]:
parse
(
file
(
name
))
parse
(
open
(
name
))
lib/python/secmaster.py
View file @
e41e6b51
...
...
@@ -34,7 +34,7 @@ def listqueue():
"""
ssh
=
subprocess
.
Popen
(
(
"
ssh
"
,
HOST
,
"
secure-testing/bin/list-queue
"
),
stdin
=
file
(
"
/dev/null
"
),
stdin
=
open
(
"
/dev/null
"
),
stdout
=
subprocess
.
PIPE
)
data
=
ssh
.
stdout
.
read
()
ssh
.
wait
()
...
...
lib/python/sectracker/repo.py
View file @
e41e6b51
...
...
@@ -132,7 +132,7 @@ class RepoCollection(object):
_os
.
makedirs
(
root
)
l
=
_os
.
listdir
(
root
)
if
len
(
l
)
==
0
:
file
(
root
+
"
/
"
+
MARKER_NAME
,
"
w
"
).
close
()
open
(
root
+
"
/
"
+
MARKER_NAME
,
"
w
"
).
close
()
elif
MARKER_NAME
not
in
l
:
raise
ValueError
(
"
not a Debian repository mirror directory:
"
+
repr
(
root
))
...
...
@@ -197,7 +197,7 @@ class RepoCollection(object):
def
release
(
self
,
name
):
if
name
not
in
self
.
repos
:
raise
ValueError
(
"
name not registered:
"
+
repr
(
name
))
with
file
(
self
.
_relname
(
name
))
as
f
:
with
open
(
self
.
_relname
(
name
))
as
f
:
return
_parserelease
(
name
,
f
)
def
filemap
(
self
,
load
=
False
):
...
...
@@ -255,7 +255,7 @@ class RepoCollection(object):
class
Config
(
object
):
def
__init__
(
self
,
config
,
root
):
with
file
(
config
)
as
f
:
with
open
(
config
)
as
f
:
self
.
config
=
_cjson
.
decode
(
f
.
read
())
self
.
repositories
=
self
.
config
[
"
repositories
"
]
self
.
distributions
=
self
.
config
[
"
distributions
"
]
...
...
lib/python/sectracker/xpickle.py
View file @
e41e6b51
...
...
@@ -63,7 +63,7 @@ def _wraploader(typ, parser):
def
safeload
(
path
):
try
:
with
file
(
path
+
EXTENSION
)
as
f
:
with
open
(
path
+
EXTENSION
,
"
rb
"
)
as
f
:
return
(
_pickle
.
load
(
f
),
True
)
except
(
EOFError
,
IOError
,
_pickle
.
PickleError
):
return
(
None
,
False
)
...
...
@@ -78,7 +78,7 @@ def _wraploader(typ, parser):
return
(
None
,
False
)
def
reparse
(
path
,
st
):
with
file
(
path
)
as
f
:
with
open
(
path
)
as
f
:
obj
=
parser
(
path
,
f
)
data
=
_pickle
.
dumps
(
((
typ
,
st
.
st_size
,
st
.
st_mtime
,
st
.
st_ino
),
obj
),
-
1
)
...
...
lib/python/security_db.py
View file @
e41e6b51
...
...
@@ -1921,7 +1921,7 @@ class DB:
"""
Reads a file of removed packages and stores it in the database.
The original contents of the removed_packages table is preserved.
"""
f
=
file
(
filename
)
f
=
open
(
filename
)
re_package
=
re
.
compile
(
r
'
^\s*([a-z0-9]\S+)\s*$
'
)
...
...