Skip to content

Commit

Permalink
[analyzer] Remove Python 2 code (#243).
Browse files Browse the repository at this point in the history
Support for Python 2 in IKOS was removed in a prior commit dealing with python
package installation.

This commit adjusts Python modules to remove any logic pertaining to Python 2.
More specifically:

- The imports in `http` are adjusted.
- The module `html`, which was a wrapper around the standard `html`, is removed.
- Other modules that were importing `ikos.html` now import `html` directly.
- Remove a comment in `output_db` referring to Python 2.
  • Loading branch information
ivanperez-keera committed Dec 13, 2023
1 parent b2cdfd2 commit 58660a6
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 62 deletions.
3 changes: 2 additions & 1 deletion analyzer/python/ikos/highlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
# UNILATERAL TERMINATION OF THIS AGREEMENT.
#
###############################################################################
from ikos import html
import html

from ikos import log


Expand Down
47 changes: 0 additions & 47 deletions analyzer/python/ikos/html.py

This file was deleted.

16 changes: 4 additions & 12 deletions analyzer/python/ikos/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,13 @@
# UNILATERAL TERMINATION OF THIS AGREEMENT.
#
###############################################################################
try:
# Python 3
from http.server import HTTPServer, BaseHTTPRequestHandler
from urllib.parse import parse_qs, urlencode
from urllib.request import urlopen
except ImportError:
# Python 2
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from urlparse import parse_qs
from urllib import urlencode
from urllib2 import urlopen

import os
from errno import EAFNOSUPPORT
from http.server import HTTPServer, BaseHTTPRequestHandler
from socket import AF_INET, AF_INET6
import os
from urllib.parse import parse_qs, urlencode
from urllib.request import urlopen

class HTTPServerIPv6(HTTPServer):
'''
Expand Down
2 changes: 1 addition & 1 deletion analyzer/python/ikos/output_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __init__(self, path):
self.con = sqlite3.connect(path)

# Use 'str' as text factory since it's the type of string literals
# This is bytes in python 2 and unicode in python 3
# This is unicode
self.con.text_factory = str

def close(self):
Expand Down
2 changes: 1 addition & 1 deletion analyzer/python/ikos/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
###############################################################################
import argparse
import collections
import html
import io
import json
import operator
Expand All @@ -56,7 +57,6 @@

from ikos import args
from ikos import colors
from ikos import html
from ikos import log
from ikos import report
from ikos import settings
Expand Down

0 comments on commit 58660a6

Please sign in to comment.