【问题处理】cgi的parse_qs和escape问题

前言

碰到个升级的问题,原python3.6存在安全漏洞,升级处理后,早期部分代码无法运行。

问题1

ImportError: cannot import name 'parse_qs' from 'cgi'

处理1

Earlier Python versions allowed using both ; and & as query parameter separators in urllib.parse.parse_qs() and urllib.parse.parse_qsl(). Due to security concerns, and to conform with newer W3C recommendations, this has been changed to allow only a single separator key, with & as the default. This change also affects cgi.parse() and cgi.parse_multipart() as they use the affected functions internally. For more details, please see their respective documentation. (Contributed by Adam Goldschmidt, Senthil Kumaran and Ken Jin in bpo-42967.)

根据这个描述,cgi中的parse_qsurllib.parse.parse_qs() 替代。

from urllib.parse import parse_qs

问题2

ImportError: cannot import name 'escape' from 'cgi'

处理2

使用html进行替换

from html import escape

问题3

sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:oracle

处理3

使用cx_freeze对python代码打包后总是导致无法加载插件,到cx_frezz脚本的构建选项中,在setup参数build_exe中的packages中添加'sqlalchemy', 'pyodbc'.

from cx_Freeze import setup, Executable

buildOptions = dict(excludes = [],
                    packages = ['sqlalchemy', 'pyodbc'] # 需要包含的两个包,其他按需添加
                    namespace_packages = []
                    )
 setup(name='',
 version = '0.1',
 description = '',
 options = dict(build_exe = buildOptions),
 executables = executables)

参考

【1】cx_freeze 部署:sqlalchemy.exc.NoSuchModuleError:无法加载插件:sqlalchemy.dialects:mssql.pyodbc
【2】cgi — Common Gateway Interface support

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值