Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

Commit

Permalink
merge from branch tom.brown.code-tempfile_kmlparser_utf8_fixes
Browse files Browse the repository at this point in the history
* kmlparser was attempting to decode a unicode string
* close the fd returned by tempfile.mkstemp so windows can delete it when the test finishes
  • Loading branch information
Tom Brown committed May 21, 2007
1 parent 44db0ce commit 46f8dd9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion kmlparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def ParsePlacemark(self, node):
def ExtractText(self, node):
for child in node.childNodes:
if child.nodeType == child.TEXT_NODE:
return child.wholeText.decode('utf-8')
return child.wholeText # is a unicode string
return ""

def ExtractCoordinates(self, node):
Expand Down
4 changes: 3 additions & 1 deletion test/testtransitfeed.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,9 @@ class TempFileTestCaseBase(unittest.TestCase):
file name and removes the file if it exists when the test is done.
"""
def setUp(self):
(_, self.tempfilepath) = tempfile.mkstemp(".zip")
(fd, self.tempfilepath) = tempfile.mkstemp(".zip")
# Open file handle causes an exception during remove in Windows
os.close(fd)

def tearDown(self):
if os.path.exists(self.tempfilepath):
Expand Down
5 changes: 4 additions & 1 deletion transitfeed.py
Original file line number Diff line number Diff line change
Expand Up @@ -2416,7 +2416,6 @@ def _LoadStopTimes(self):
departure_time, stop_headsign,
pickup_type, drop_off_type,
shape_dist_traveled)))

self._problems.SetContext(None)

for trip_id, sequence in stoptimes.iteritems():
Expand Down Expand Up @@ -2458,6 +2457,10 @@ def Load(self):
self._LoadFares()
self._LoadFareRules()

if self._zip:
self._zip.close()
self._zip = None

if self._extra_validation:
self._schedule.Validate(self._problems, validate_children=False)

Expand Down

0 comments on commit 46f8dd9

Please sign in to comment.