Skip to content

Commit c03fd16

Browse files
authored
SyntaxWarning: invalid escape sequence (#319)
* Fix Python 3.12 SyntaxWarnings by converting regex strings to raw strings in proj.py * Update for SyntaxWarning: invalid escape sequence in vplot2gif.py * Update vplot2png.py for SyntaxWarning: invalid escape sequence
1 parent 28cbbfe commit c03fd16

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

pens/scripts/vplot2gif.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
## along with this program; if not, write to the Free Software
1818
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1919

20+
# Python 3.12 Compatibility: Fixed regex SyntaxWarning by using raw strings (r'') for regex patterns
2021
# Modified from the original C-shell version by Joe Dellinger
2122

2223
import sys, os, time, string, re, shutil
@@ -39,7 +40,8 @@ def convert(infile,outfile,args=''):
3940
stat = lines[0].split()
4041

4142
# find the number of frames
42-
retot = re.compile('Total\s+(\d+)')
43+
# Fixed: Use raw string for regex to avoid Python 3.12 SyntaxWarning: invalid escape sequence '\s'
44+
retot = re.compile(r'Total\s+(\d+)')
4345
match = retot.search(lines[-1])
4446
if match:
4547
frames = int(match.group(1))

pens/scripts/vplot2png.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
## You should have received a copy of the GNU General Public License
1515
## along with this program; if not, write to the Free Software
1616
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17+
18+
# Python 3.12 Compatibility: Fixed regex SyntaxWarning by using raw strings (r'') for regex patterns
1719
import tempfile, os, sys, re
1820
import rsf.vplot2eps
1921

@@ -52,7 +54,8 @@ def convert(vpl,png,**kw):
5254
vpl = sys.argv.pop()
5355
else:
5456
vpl = png
55-
png = re.sub('\.[^\.]+$','.png',vpl)
57+
# Fixed: Use raw string for regex to avoid Python 3.12 SyntaxWarning: invalid escape sequence '\.'
58+
png = re.sub(r'\.[^\.]+$','.png',vpl)
5659

5760

5861
if sys.argv:

0 commit comments

Comments
 (0)