apport-hackers team mailing list archive
-
apport-hackers team
-
Mailing list archive
-
Message #00256
[Merge] lp:~mwhudson/apport/regexp-raw-strings into lp:apport
Michael Hudson-Doyle has proposed merging lp:~mwhudson/apport/regexp-raw-strings into lp:apport.
Requested reviews:
Apport upstream developers (apport-hackers)
For more details, see:
https://code.launchpad.net/~mwhudson/apport/regexp-raw-strings/+merge/325543
The ones in the hooks cause autopkgtest failures in innocent packages, thought I might as well fix this others while I was here for when this starts to be an error and not a warning.
--
Your team Apport upstream developers is requested to review the proposed merge of lp:~mwhudson/apport/regexp-raw-strings into lp:apport.
=== modified file 'apport/crashdb_impl/launchpad.py'
--- apport/crashdb_impl/launchpad.py 2017-04-17 23:00:33 +0000
+++ apport/crashdb_impl/launchpad.py 2017-06-12 23:45:56 +0000
@@ -169,7 +169,7 @@
for t in tasks:
if t.bug_target_name.lower() == self.distro or \
- re.match('^.+\(%s.*\)$' % self.distro, t.bug_target_name.lower()):
+ re.match(r'^.+\(%s.*\)$' % self.distro, t.bug_target_name.lower()):
yield t
@property
@@ -461,7 +461,7 @@
# update bug title with retraced function name
fn = report.stacktrace_top_function()
if fn:
- m = re.match('^(.*crashed with SIG.* in )([^( ]+)(\(\).*$)', bug.title)
+ m = re.match(r'^(.*crashed with SIG.* in )([^( ]+)(\(\).*$)', bug.title)
if m and m.group(2) != fn:
bug.title = m.group(1) + fn + m.group(3)
try:
=== modified file 'apport/hookutils.py'
--- apport/hookutils.py 2017-03-24 20:50:39 +0000
+++ apport/hookutils.py 2017-06-12 23:45:56 +0000
@@ -515,7 +515,7 @@
return ''
if not pattern:
- pattern = re.compile('^(\(.*:\d+\): \w+-(WARNING|CRITICAL|ERROR))|(Error: .*No Symbols named)|([^ ]+\[\d+\]: ([A-Z]+):)|([^ ]-[A-Z]+ \*\*:)|(received an X Window System error)|(^The error was \')|(^ \(Details: serial \d+ error_code)')
+ pattern = re.compile(r'^(\(.*:\d+\): \w+-(WARNING|CRITICAL|ERROR))|(Error: .*No Symbols named)|([^ ]+\[\d+\]: ([A-Z]+):)|([^ ]-[A-Z]+ \*\*:)|(received an X Window System error)|(^The error was \')|(^ \(Details: serial \d+ error_code)')
lines = ''
with open(path, 'rb') as f:
@@ -684,7 +684,7 @@
ppds = glob.glob('/etc/cups/ppd/*.ppd')
if ppds:
nicknames = command_output(['fgrep', '-H', '*NickName'] + ppds)
- report['PpdFiles'] = re.sub('/etc/cups/ppd/(.*).ppd:\*NickName: *"(.*)"', '\g<1>: \g<2>', nicknames)
+ report['PpdFiles'] = re.sub(r'/etc/cups/ppd/(.*).ppd:\*NickName: *"(.*)"', r'\g<1>: \g<2>', nicknames)
report['PrintingPackages'] = package_versions(
'foo2zjs', 'foomatic-db', 'foomatic-db-engine',
@@ -705,7 +705,7 @@
if isinstance(profiles, str):
profiles = [profiles]
- mac_regex = 'audit\(|apparmor|selinux|security'
+ mac_regex = r'audit\(|apparmor|selinux|security'
mac_re = re.compile(mac_regex, re.IGNORECASE)
aa_regex = 'apparmor="DENIED".+?profile=([^ ]+?)[ ]'
aa_re = re.compile(aa_regex, re.IGNORECASE)
=== modified file 'apport/packaging.py'
--- apport/packaging.py 2017-03-24 16:57:24 +0000
+++ apport/packaging.py 2017-06-12 23:45:56 +0000
@@ -181,7 +181,7 @@
# if the file does not exist, assume it's enabled
return True
- return re.search('^\s*enabled\s*=\s*0\s*$', conf, re.M) is None
+ return re.search(r'^\s*enabled\s*=\s*0\s*$', conf, re.M) is None
def get_kernel_package(self):
'''Return the actual Linux kernel package name.
=== modified file 'apport/report.py'
--- apport/report.py 2017-03-30 22:39:09 +0000
+++ apport/report.py 2017-06-12 23:45:56 +0000
@@ -731,7 +731,7 @@
raise IOError(reason)
# split the output into the various fields
- part_re = re.compile('^\$\d+\s*=\s*-99$', re.MULTILINE)
+ part_re = re.compile(r'^\$\d+\s*=\s*-99$', re.MULTILINE)
parts = part_re.split(out)
# drop the gdb startup text prior to first separator
parts.pop(0)
@@ -754,7 +754,7 @@
# clean up AssertionMessage
if 'AssertionMessage' in self:
# chop off "$n = 0x...." prefix, drop empty ones
- m = re.match('^\$\d+\s+=\s+0x[0-9a-fA-F]+\s+"(.*)"\s*$',
+ m = re.match(r'^\$\d+\s+=\s+0x[0-9a-fA-F]+\s+"(.*)"\s*$',
self['AssertionMessage'])
if m:
self['AssertionMessage'] = m.group(1)
@@ -783,10 +783,10 @@
unwound = False
unwinding = False
unwinding_xerror = False
- bt_fn_re = re.compile('^#(\d+)\s+(?:0x(?:\w+)\s+in\s+\*?(.*)|(<signal handler called>)\s*)$')
- bt_fn_noaddr_re = re.compile('^#(\d+)\s+(?:(.*)|(<signal handler called>)\s*)$')
+ bt_fn_re = re.compile(r'^#(\d+)\s+(?:0x(?:\w+)\s+in\s+\*?(.*)|(<signal handler called>)\s*)$')
+ bt_fn_noaddr_re = re.compile(r'^#(\d+)\s+(?:(.*)|(<signal handler called>)\s*)$')
# some internal functions like the SSE stubs cause unnecessary jitter
- ignore_functions_re = re.compile('^(__.*_s?sse\d+(?:_\w+)?|__kernel_vsyscall)$')
+ ignore_functions_re = re.compile(r'^(__.*_s?sse\d+(?:_\w+)?|__kernel_vsyscall)$')
for line in self['Stacktrace'].splitlines():
m = bt_fn_re.match(line)
@@ -916,7 +916,7 @@
<re key="Foo">ba.*r</re>
</pattern>
<pattern url="http://bugtracker.net/bugs/2">
- <re key="Package">^\S* 1-2$</re> <!-- test for a particular version -->
+ <re key="Package">^\\S* 1-2$</re> <!-- test for a particular version -->
<re key="Foo">write_(hello|goodbye)</re>
</pattern>
</patterns>
@@ -1167,7 +1167,7 @@
os.path.basename(self['ExecutablePath']),
trace[0])
- trace_re = re.compile('^\s*File\s*"(\S+)".* in (.+)$')
+ trace_re = re.compile(r'^\s*File\s*"(\S+)".* in (.+)$')
i = len(trace) - 1
function = 'unknown'
while i >= 0:
@@ -1284,7 +1284,7 @@
# kernel crash
if 'Stacktrace' in self and self['ProblemType'] == 'KernelCrash':
sig = 'kernel'
- regex = re.compile('^\s*\#\d+\s\[\w+\]\s(\w+)')
+ regex = re.compile(r'^\s*\#\d+\s\[\w+\]\s(\w+)')
for line in self['Stacktrace'].splitlines():
m = regex.match(line)
if m:
@@ -1300,7 +1300,7 @@
# signal crashes
if 'StacktraceTop' in self and 'Signal' in self:
sig = '%s:%s' % (self['ExecutablePath'], self['Signal'])
- bt_fn_re = re.compile('^(?:([\w:~]+).*|(<signal handler called>)\s*)$')
+ bt_fn_re = re.compile(r'^(?:([\w:~]+).*|(<signal handler called>)\s*)$')
lines = self['StacktraceTop'].splitlines()
if len(lines) < 2:
@@ -1322,7 +1322,7 @@
sig = ''
if len(trace) == 1:
# sometimes, Python exceptions do not have file references
- m = re.match('(\w+): ', trace[0])
+ m = re.match(r'(\w+): ', trace[0])
if m:
return self['ExecutablePath'] + ':' + m.group(1)
else:
@@ -1330,7 +1330,7 @@
elif len(trace) < 3:
return None
- loc_re = re.compile('^\s+File "([^"]+).*line (\d+).*\sin (.*)$')
+ loc_re = re.compile(r'^\s+File "([^"]+).*line (\d+).*\sin (.*)$')
for line in trace:
m = loc_re.match(line)
if m:
@@ -1396,7 +1396,7 @@
return None
def _extract_function_and_address(self, line):
- parsed = re.search('\[.*\] (.*)$', line)
+ parsed = re.search(r'\[.*\] (.*)$', line)
if parsed:
match = parsed.group(1)
assert match, 'could not parse expected call trace line: %s' % line
@@ -1633,8 +1633,8 @@
# data field and the path there are many spaces, while between the
# other data fields there is only one. So we take 2 or more spaces as
# the separator of the last data field and the path.
- fmt = re.compile('^([0-9a-fA-F]+)-([0-9a-fA-F]+).*\s{2,}(\S.*$)')
- fmt_unknown = re.compile('^([0-9a-fA-F]+)-([0-9a-fA-F]+)\s')
+ fmt = re.compile(r'^([0-9a-fA-F]+)-([0-9a-fA-F]+).*\s{2,}(\S.*$)')
+ fmt_unknown = re.compile(r'^([0-9a-fA-F]+)-([0-9a-fA-F]+)\s')
for line in self['ProcMaps'].splitlines():
if not line.strip():
=== modified file 'apport/sandboxutils.py'
--- apport/sandboxutils.py 2017-01-25 18:37:23 +0000
+++ apport/sandboxutils.py 2017-06-12 23:45:56 +0000
@@ -192,7 +192,7 @@
origins = None
if dynamic_origins:
pkg_list = report.get('Package', '') + '\n' + report.get('Dependencies', '')
- m = re.compile('\[origin: ([a-zA-Z0-9][a-zA-Z0-9\+\.\-]+)\]')
+ m = re.compile(r'\[origin: ([a-zA-Z0-9][a-zA-Z0-9\+\.\-]+)\]')
origins = set(m.findall(pkg_list))
if origins:
apport.log("Origins: %s" % origins)
=== modified file 'apport_python_hook.py'
--- apport_python_hook.py 2016-03-16 22:10:48 +0000
+++ apport_python_hook.py 2017-06-12 23:45:56 +0000
@@ -25,7 +25,7 @@
try:
with open(CONFIG) as f:
conf = f.read()
- return re.search('^\s*enabled\s*=\s*0\s*$', conf, re.M) is None
+ return re.search(r'^\s*enabled\s*=\s*0\s*$', conf, re.M) is None
except IOError:
# if the file does not exist, assume it's enabled
return True
@@ -163,7 +163,7 @@
from ConfigParser import ConfigParser, NoSectionError, NoOptionError
# determine D-BUS name
- m = re.search('name\s+(\S+)\s+was not provided by any .service',
+ m = re.search(r'name\s+(\S+)\s+was not provided by any .service',
exc_obj.get_dbus_message())
if not m:
if sys.stderr:
=== modified file 'bin/apport-retrace'
--- bin/apport-retrace 2017-04-12 21:54:26 +0000
+++ bin/apport-retrace 2017-06-12 23:45:56 +0000
@@ -176,8 +176,8 @@
if not srcdir:
return
- src_frame = re.compile('^#\d+\s.* at (.*):(\d+)$')
- other_frame = re.compile('^#\d+')
+ src_frame = re.compile(r'^#\d+\s.* at (.*):(\d+)$')
+ other_frame = re.compile(r'^#\d+')
result = ''
for frame in report['Stacktrace'].splitlines():
m = src_frame.match(frame)
=== modified file 'data/general-hooks/parse_segv.py'
--- data/general-hooks/parse_segv.py 2015-09-24 12:19:28 +0000
+++ data/general-hooks/parse_segv.py 2017-06-12 23:45:56 +0000
@@ -121,7 +121,7 @@
else:
logging.debug('args: "%s"', args_str)
- for m in re.finditer('([^,\(]*(\(:?[^\)]+\))*)', args_str):
+ for m in re.finditer(r'([^,\(]*(\(:?[^\)]+\))*)', args_str):
if len(m.group(0)):
args.append(m.group(0))
if len(args) > 0:
=== modified file 'test/test_hookutils.py'
--- test/test_hookutils.py 2016-12-10 11:28:27 +0000
+++ test/test_hookutils.py 2017-06-12 23:45:56 +0000
@@ -377,7 +377,7 @@
pattern = re.compile('notfound')
self.assertEqual(apport.hookutils.xsession_errors(pattern), '')
- pattern = re.compile('^\w+-CRITICAL')
+ pattern = re.compile(r'^\w+-CRITICAL')
res = apport.hookutils.xsession_errors(pattern).splitlines()
self.assertEqual(len(res), 2)
self.assertTrue(res[0].startswith('EggSMClient-CRITICAL'))
=== modified file 'test/test_report.py'
--- test/test_report.py 2017-05-12 20:01:12 +0000
+++ test/test_report.py 2017-06-12 23:45:56 +0000
@@ -133,7 +133,7 @@
pr.add_proc_info(pid=p.pid)
self.assertEqual(pr.pid, p.pid)
p.communicate(b'\n')
- self.assertEqual(pr['ProcCmdline'], 'cat /foo\ bar \\\\h \\\\\\ \\\\ -')
+ self.assertEqual(pr['ProcCmdline'], 'cat /foo\\ bar \\\\h \\\\\\ \\\\ -')
self.assertEqual(pr['ExecutablePath'], '/bin/cat')
self.assertNotIn('InterpreterPath', pr)
self.assertIn('/bin/cat', pr['ProcMaps'])
=== modified file 'test/test_signal_crashes.py'
--- test/test_signal_crashes.py 2016-12-10 11:28:27 +0000
+++ test/test_signal_crashes.py 2017-06-12 23:45:56 +0000
@@ -485,7 +485,7 @@
self.assertFalse('CoreDump' in pr)
# FIXME: sometimes this is empty!?
if err:
- self.assertRegex(err, b'core dump exceeded.*dropped from .*yes\..*\.crash')
+ self.assertRegex(err, rb'core dump exceeded.*dropped from .*yes\..*\.crash')
def test_ignore(self):
'''ignoring executables'''
Follow ups