Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
29371c26
Commit
29371c26
authored
Jul 24, 2000
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merged better number conversion error messages from 2.2 branch
parent
e34591e0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
6 deletions
+19
-6
lib/python/ZPublisher/Converters.py
lib/python/ZPublisher/Converters.py
+19
-6
No files found.
lib/python/ZPublisher/Converters.py
View file @
29371c26
...
...
@@ -82,7 +82,7 @@
# attributions are listed in the accompanying credits file.
#
##############################################################################
__version__
=
'$Revision: 1.
8
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
9
$'
[
11
:
-
2
]
import
regex
from
string
import
atoi
,
atol
,
atof
,
join
,
split
,
strip
...
...
@@ -119,8 +119,12 @@ def field2int(v):
return
map
(
field2int
,
v
)
if
hasattr
(
v
,
'read'
):
v
=
v
.
read
()
else
:
v
=
str
(
v
)
# we can remove the check for an empty string when we go to python 1.4
if
v
:
return
atoi
(
v
)
if
v
:
try
:
return
atoi
(
v
)
except
ValueError
:
raise
ValueError
,
(
"An integer was expected in the value '%s'"
%
v
)
raise
ValueError
,
'Empty entry when <strong>integer</strong> expected'
def
field2float
(
v
):
...
...
@@ -128,8 +132,12 @@ def field2float(v):
return
map
(
field2float
,
v
)
if
hasattr
(
v
,
'read'
):
v
=
v
.
read
()
else
:
v
=
str
(
v
)
# we can remove the check for an empty string when we go to python 1.4
if
v
:
return
atof
(
v
)
if
v
:
try
:
return
atof
(
v
)
except
ValueError
:
raise
ValueError
,
(
"A floating-point number was expected in the value '%s'"
%
v
)
raise
ValueError
,
(
'Empty entry when <strong>floating-point number</strong> expected'
)
...
...
@@ -142,7 +150,12 @@ def field2long(v):
# handle trailing 'L' if present.
if
v
[
-
1
:]
in
(
'L'
,
'l'
):
v
=
v
[:
-
1
]
if
v
:
return
atol
(
v
)
if
v
:
try
:
return
atol
(
v
)
except
ValueError
:
raise
ValueError
,
(
"A long integer was expected in the value '%s'"
%
v
)
raise
ValueError
,
'Empty entry when <strong>integer</strong> expected'
def
field2tokens
(
v
):
...
...
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