python3.patch 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. From b6484282f85bf7f11451b2441599c241d302ad9d Mon Sep 17 00:00:00 2001
  2. From: Raul Tambre <raul@tambre.ee>
  3. Date: Sat, 4 May 2019 15:48:17 -0400
  4. Subject: [PATCH] Fix incorrect use of 'is' operator for comparison in
  5. python/lib/gdb/command/prompt.py
  6. The 'is' operator is not meant to be used for comparisons. It currently working
  7. is an implementation detail of CPython. CPython 3.8 has added a SyntaxWarning
  8. for this.
  9. diff --git a/gdb/python/lib/gdb/command/prompt.py b/gdb/python/lib/gdb/command/prompt.py
  10. index 3d662a7..04b9e49 100644
  11. --- a/gdb/python/lib/gdb/command/prompt.py
  12. +++ b/gdb/python/lib/gdb/command/prompt.py
  13. @@ -45,7 +45,7 @@ The currently defined substitutions are:
  14. self.hook_set = False
  15. def get_show_string (self, pvalue):
  16. - if self.value is not '':
  17. + if self.value:
  18. return "The extended prompt is: " + self.value
  19. else:
  20. return "The extended prompt is not set."
  21. @@ -57,7 +57,7 @@ The currently defined substitutions are:
  22. return ""
  23. def before_prompt_hook(self, current):
  24. - if self.value is not '':
  25. + if self.value:
  26. return gdb.prompt.substitute_prompt(self.value)
  27. else:
  28. return None
  29. From d9c4ba536c522b8dc2194d4100270a159be7894a Mon Sep 17 00:00:00 2001
  30. From: Sergio Durigan Junior <sergiodj@redhat.com>
  31. Date: Sun, 25 Aug 2019 12:10:35 -0400
  32. Subject: [PATCH] Use raw strings on gdb.python/py-xmethods.exp (and fix Python
  33. 3.8's "SyntaxWarning: invalid escape sequence")
  34. The way unrecognized escape sequences are handled has changed in
  35. Python 3.8: users now see a SyntaxWarning message, which will
  36. eventually become a SyntaxError in future versions of Python:
  37. (gdb) source /blabla/gdb.python/py-xmethods/py-xmethods.py
  38. /blabla/gdb.python/py-xmethods/py-xmethods.py:204: SyntaxWarning: invalid escape seque
  39. nce \+
  40. 'operator\+',
  41. /blabla/gdb.python/py-xmethods/py-xmethods.py:211: SyntaxWarning: invalid escape seque
  42. nce \+
  43. 'operator\+\+',
  44. One of our testcases, gdb.python/py-xmethods.exp, contains strings in
  45. the form of "operator\+". This is not recognized by Python, but is
  46. still needed by the testsuite to work properly. The solution is
  47. simple: we just have to make sure these strings are marked as
  48. raw (i.e, r""). This is what this patch does. I took the opportunity
  49. to also convert other strings to raw, which, in two cases, allowed the
  50. removal of an extra backslash.
  51. I tested this using Python 3.7 and Python 3.8, and everything works
  52. fine.
  53. I think I could push this as obvious, but decided to send it to
  54. gdb-patches just in case.
  55. gdb/testsuite/ChangeLog:
  56. 2019-08-26 Sergio Durigan Junior <sergiodj@redhat.com>
  57. * gdb.python/py-xmethods.exp: Use raw strings when passing
  58. arguments to SimpleXMethodMatcher.
  59. diff --git a/gdb/testsuite/gdb.python/py-xmethods.py b/gdb/testsuite/gdb.python/py-xmethods.py
  60. index 587842d7360..cea48b80d8c 100644
  61. --- a/gdb/testsuite/gdb.python/py-xmethods.py
  62. +++ b/gdb/testsuite/gdb.python/py-xmethods.py
  63. @@ -199,34 +199,34 @@ def match(self, class_type, method_name):
  64. global_dm_list = [
  65. - SimpleXMethodMatcher('A_plus_A',
  66. - '^dop::A$',
  67. - 'operator\+',
  68. + SimpleXMethodMatcher(r'A_plus_A',
  69. + r'^dop::A$',
  70. + r'operator\+',
  71. A_plus_A,
  72. # This is a replacement, hence match the arg type
  73. # exactly!
  74. type_A.const().reference()),
  75. - SimpleXMethodMatcher('plus_plus_A',
  76. - '^dop::A$',
  77. - 'operator\+\+',
  78. + SimpleXMethodMatcher(r'plus_plus_A',
  79. + r'^dop::A$',
  80. + r'operator\+\+',
  81. plus_plus_A),
  82. - SimpleXMethodMatcher('A_geta',
  83. - '^dop::A$',
  84. - '^geta$',
  85. + SimpleXMethodMatcher(r'A_geta',
  86. + r'^dop::A$',
  87. + r'^geta$',
  88. A_geta),
  89. - SimpleXMethodMatcher('A_getarrayind',
  90. - '^dop::A$',
  91. - '^getarrayind$',
  92. + SimpleXMethodMatcher(r'A_getarrayind',
  93. + r'^dop::A$',
  94. + r'^getarrayind$',
  95. A_getarrayind,
  96. type_int),
  97. - SimpleXMethodMatcher('A_indexoper',
  98. - '^dop::A$',
  99. - 'operator\\[\\]',
  100. + SimpleXMethodMatcher(r'A_indexoper',
  101. + r'^dop::A$',
  102. + r'operator\[\]',
  103. A_indexoper,
  104. type_int),
  105. - SimpleXMethodMatcher('B_indexoper',
  106. - '^dop::B$',
  107. - 'operator\\[\\]',
  108. + SimpleXMethodMatcher(r'B_indexoper',
  109. + r'^dop::B$',
  110. + r'operator\[\]',
  111. B_indexoper,
  112. type_int)
  113. ]