Skip to content

Commit d0d0afb

Browse files
authored
Merge pull request #354 from ckan/python3.13_support
Python 3.13 support
2 parents 01f41a9 + a1f77d1 commit d0d0afb

2 files changed

Lines changed: 5 additions & 11 deletions

File tree

ckanext/spatial/harvesters/base.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
from urllib.request import urlopen
33

44
import re
5-
import cgitb
6-
import warnings
5+
import traceback
76

87
import sys
98
import logging
@@ -41,12 +40,7 @@
4140

4241

4342
def text_traceback():
44-
with warnings.catch_warnings():
45-
warnings.simplefilter("ignore")
46-
res = 'the original traceback:'.join(
47-
cgitb.text(sys.exc_info()).split('the original traceback:')[1:]
48-
).strip()
49-
return res
43+
return "".join(traceback.format_exception(*sys.exc_info()))
5044

5145

5246
def guess_standard(content):
@@ -855,7 +849,7 @@ def _get_content_as_unicode(self, url):
855849
content = response.text
856850

857851
# Remove original XML declaration
858-
content = re.sub('<\?xml(.*)\?>', '', content)
852+
content = re.sub('<xml(.*)>', '', content)
859853

860854
# Get rid of the BOM and other rubbish at the beginning of the file
861855
content = re.sub('.*?<', '<', content, 1)
@@ -878,7 +872,7 @@ def _validate_document(self, document_string, harvest_object, validator=None):
878872
if not validator:
879873
validator = self._get_validator()
880874

881-
document_string = re.sub('<\?xml(.*)\?>', '', document_string)
875+
document_string = re.sub('<xml(.*)>', '', document_string)
882876

883877
try:
884878
xml = etree.fromstring(document_string)

ckanext/spatial/harvesters/csw.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def fetch_stage(self,harvest_object):
175175
# Save the fetch contents in the HarvestObject
176176
# Contents come from csw_client already declared and encoded as utf-8
177177
# Remove original XML declaration
178-
content = re.sub('<\?xml(.*)\?>', '', record['xml'])
178+
content = re.sub('<xml(.*)>', '', record['xml'])
179179

180180
harvest_object.content = content.strip()
181181
harvest_object.save()

0 commit comments

Comments
 (0)