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
c82208ee
Commit
c82208ee
authored
Mar 20, 2004
by
Brett Cannon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deal with case of when locale time values has characters that can be mistaken
for regex syntax. Fixes bug #883604 .
parent
4f653314
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
2 deletions
+14
-2
Lib/test/test_strftime.py
Lib/test/test_strftime.py
+14
-2
No files found.
Lib/test/test_strftime.py
View file @
c82208ee
...
...
@@ -28,6 +28,16 @@ def main():
for
i
in
range
(
25
):
strftest
(
now
+
(
i
+
j
*
100
)
*
23
*
3603
)
def
escapestr
(
text
,
ampm
):
"""Escape text to deal with possible locale values that have regex
syntax while allowing regex syntax used for the comparison."""
new_text
=
re
.
escape
(
text
)
new_text
=
new_text
.
replace
(
re
.
escape
(
ampm
),
ampm
)
new_text
=
new_text
.
replace
(
"
\
%
"
, "
%
")
new_text = new_text.replace("
\
:
", "
:
")
new_text = new_text.replace("
\
?
", "
?
")
return new_text
def strftest(now):
if verbose:
print "
strftime
test
for
", time.ctime(now)
...
...
@@ -50,6 +60,8 @@ def strftest(now):
elif now[3] > 0: clock12 = now[3]
else: clock12 = 12
# Make sure any characters that could be taken as regex syntax is
# escaped in escapestr()
expectations = (
('%a', calendar.day_abbr[now[6]], 'abbreviated weekday name'),
('%A', calendar.day_name[now[6]], 'full weekday name'),
...
...
@@ -110,7 +122,7 @@ def strftest(now):
except ValueError, error:
print "
Standard
'%s'
format
gave
error
:
" % e[0], error
continue
if
re
.
match
(
e
[
1
]
,
result
):
continue
if re.match(e
scapestr(e[1], ampm)
, result): continue
if not result or result[0] == '%':
print "
Does
not
support
standard
'%s'
format
(
%
s
)
" % (e[0], e[2])
else:
...
...
@@ -125,7 +137,7 @@ def strftest(now):
print "
Error
for
nonstandard
'%s'
format
(
%
s
):
%
s
" %
\
(e[0], e[2], str(result))
continue
if
re
.
match
(
e
[
1
]
,
result
):
if re.match(e
scapestr(e[1], ampm)
, result):
if verbose:
print "
Supports
nonstandard
'%s'
format
(
%
s
)
" % (e[0], e[2])
elif not result or result[0] == '%':
...
...
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