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
c0919c27
Commit
c0919c27
authored
Dec 22, 2017
by
Mariatta
Committed by
GitHub
Dec 22, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-26439: Convert %s in Lib/ctypes/_aix.py to f-strings. (GH-4986)
parent
d11e8e0d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
17 deletions
+17
-17
Lib/ctypes/_aix.py
Lib/ctypes/_aix.py
+9
-9
Lib/ctypes/util.py
Lib/ctypes/util.py
+8
-8
No files found.
Lib/ctypes/_aix.py
View file @
c0919c27
...
...
@@ -105,7 +105,7 @@ def get_ld_headers(file):
# 2. If "INDEX" in occurs in a following line - return ld_header
# 3. get info (lines starting with [0-9])
ldr_headers
=
[]
p
=
Popen
([
"/usr/bin/dump"
,
"-X%s"
%
AIX_ABI
,
"-H"
,
file
],
p
=
Popen
([
"/usr/bin/dump"
,
f"-X
{
AIX_ABI
}
"
,
"-H"
,
file
],
universal_newlines
=
True
,
stdout
=
PIPE
,
stderr
=
DEVNULL
)
# be sure to read to the end-of-file - getting all entries
while
True
:
...
...
@@ -140,7 +140,7 @@ def get_one_match(expr, lines):
When there is a match, strip leading "[" and trailing "]"
"""
# member names in the ld_headers output are between square brackets
expr
=
r
'\
[(%s)
\]'
%
expr
expr
=
r
f'\
[({exp
r})\
]
'
matches = list(filter(None, (re.search(expr, line) for line in lines)))
if len(matches) == 1:
return matches[0].group(1)
...
...
@@ -197,8 +197,8 @@ def get_version(name, members):
# any combination of additional '
dot
' digits pairs are accepted
# anything more than libFOO.so.digits.digits.digits
# should be seen as a member name outside normal expectations
exprs = [r
'
lib
%
s
\
.
so
\
.[
0
-
9
]
+
[
0
-
9.
]
*
' % name
,
r
'
lib
%
s_
?
64
\
.
so
\
.[
0
-
9
]
+
[
0
-
9.
]
*
' % name
]
exprs = [r
f'
lib
{
name
}
\
.
so
\
.[
0
-
9
]
+
[
0
-
9.
]
*
'
,
r
f'
lib
{
name
}
_
?
64
\
.
so
\
.[
0
-
9
]
+
[
0
-
9.
]
*
'
]
for expr in exprs:
versions = []
for line in members:
...
...
@@ -219,12 +219,12 @@ def get_member(name, members):
and finally, legacy AIX naming scheme.
"""
# look first for a generic match - prepend lib and append .so
expr = r
'
lib
%
s
\
.
so
' % name
expr = r
f'
lib
{
name
}
\
.
so
'
member = get_one_match(expr, members)
if member:
return member
elif AIX_ABI == 64:
expr = r
'
lib
%
s64
\
.
so
' % name
expr = r
f'
lib
{
name
}
64
\
.
so
'
member = get_one_match(expr, members)
if member:
return member
...
...
@@ -277,7 +277,7 @@ def find_shared(paths, name):
continue
# "lib" is prefixed to emulate compiler name resolution,
# e.g., -lc to libc
base =
'
lib
%
s
.
a
' % name
base =
f'
lib
{
name
}.
a
'
archive = path.join(dir, base)
if path.exists(archive):
members = get_shared(get_ld_headers(archive))
...
...
@@ -308,7 +308,7 @@ def find_library(name):
libpaths = get_libpaths()
(base, member) = find_shared(libpaths, name)
if base != None:
return
"%s(%s)" % (base, member)
return
f"{base}({member})"
# To get here, a member in an archive has not been found
# In other words, either:
...
...
@@ -319,7 +319,7 @@ def find_library(name):
# Note, the installation must prepare a link from a .so
# to a versioned file
# This is common practice by GNU libtool on other platforms
soname =
"lib%s.so" % name
soname =
f"lib{name}.so"
for dir in libpaths:
# /lib is a symbolic link to /usr/lib, skip it
if dir == "/lib":
...
...
Lib/ctypes/util.py
View file @
c0919c27
...
...
@@ -337,18 +337,18 @@ def test():
elif
sys
.
platform
.
startswith
(
"aix"
):
from
ctypes
import
CDLL
if
sys
.
maxsize
<
2
**
32
:
print
(
"Using CDLL(name, os.RTLD_MEMBER): %s"
%
CDLL
(
"libc.a(shr.o)"
,
os
.
RTLD_MEMBER
)
)
print
(
"Using cdll.LoadLibrary(): %s"
%
cdll
.
LoadLibrary
(
"libc.a(shr.o)"
)
)
print
(
f"Using CDLL(name, os.RTLD_MEMBER):
{
CDLL
(
'libc.a(shr.o)'
,
os
.
RTLD_MEMBER
)
}
"
)
print
(
f"Using cdll.LoadLibrary():
{
cdll
.
LoadLibrary
(
'libc.a(shr.o)'
)
}
"
)
# librpm.so is only available as 32-bit shared library
print
(
find_library
(
"rpm"
))
print
(
cdll
.
LoadLibrary
(
"librpm.so"
))
else
:
print
(
"Using CDLL(name, os.RTLD_MEMBER): %s"
%
CDLL
(
"libc.a(shr_64.o)"
,
os
.
RTLD_MEMBER
)
)
print
(
"Using cdll.LoadLibrary(): %s"
%
cdll
.
LoadLibrary
(
"libc.a(shr_64.o)"
)
)
print
(
"crypt
\
t
:: %s"
%
find_library
(
"crypt"
)
)
print
(
"crypt
\
t
:: %s"
%
cdll
.
LoadLibrary
(
find_library
(
"crypt"
))
)
print
(
"crypto
\
t
:: %s"
%
find_library
(
"crypto"
)
)
print
(
"crypto
\
t
:: %s"
%
cdll
.
LoadLibrary
(
find_library
(
"crypto"
))
)
print
(
f"Using CDLL(name, os.RTLD_MEMBER):
{
CDLL
(
'libc.a(shr_64.o)'
,
os
.
RTLD_MEMBER
)
}
"
)
print
(
f"Using cdll.LoadLibrary():
{
cdll
.
LoadLibrary
(
'libc.a(shr_64.o)'
)
}
"
)
print
(
f"crypt
\
t
::
{
find_library
(
'crypt'
)
}
"
)
print
(
f"crypt
\
t
::
{
cdll
.
LoadLibrary
(
find_library
(
'crypt'
))
}
"
)
print
(
f"crypto
\
t
::
{
find_library
(
'crypto'
)
}
"
)
print
(
f"crypto
\
t
::
{
cdll
.
LoadLibrary
(
find_library
(
'crypto'
))
}
"
)
else
:
print
(
cdll
.
LoadLibrary
(
"libm.so"
))
print
(
cdll
.
LoadLibrary
(
"libcrypt.so"
))
...
...
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