Weird Python Error "TypeError: an integer is required" on a List - Only in Debugger - Fixed by adding print -

I have a rather strange error in the following code:CUSTOMER_ORDER = ["Some", "Customer

I have a rather strange error in the following code:

CUSTOMER_ORDER = ["Some", "Customers"]
ticket_types = ["analysis_tickets"] # is list because copied from legacy code and only need 1 type here (TODO replace with str.)

[...]

# Get all  tickets of each type for each customer of the month
for customer in CUSTOMER_ORDER:
    all_tickets[customer] = {}

    for ticket_type in ticket_types:
        logger.info("Getting '" + ticket_type + "' for customer " + customer + "...")

        if ticket_type == "analysis_tickets":
            suffix = ANALYSIS_TICKETS_SUFFIX
        elif ticket_type == "support_tickets":
            suffix = SUPPORT_TICKETS_SUFFIX
        elif ticket_type == "engineering_tickets":
            suffix = ENGINEERING_TICKETS_SUFFIX

        all_tickets[customer][ticket_type] = {}
        all_tickets[customer][ticket_type]["tickets"] = []

        try:
            response = requests.get(
                OTRS_URL + "/TicketSearch",
                params={
                    "UserLogin": OTRS_USER,
                    "Password": OTRS_PW,
                    "Queues": customer + suffix,
                    time_older: datetime.datetime.now(),
                    time_newer: datetime.datetime.now() - datetime.timedelta(days=TIME_RANGE_DAYS),
                    "Limit": 3000,
                },
                verify=False,
            )
            if response.status_code != 200:
                logger.error("Could not get tickets for customer " + customer + ". Error: " + str(response.status_code))
                sys.exit(1)

            if "TicketID" not in response.json():
                logger.warning("No tickets found for customer " + customer + " amd ticket type '" + ticket_type + "'.")
                all_tickets[customer][ticket_type]["tickets"] = []
            else:
                all_tickets[customer][ticket_type]["tickets"] = response.json()["TicketID"]
                logger.info("Found " + str(len(all_tickets[customer][ticket_type]["tickets"])) + " tickets for customer " + customer + " and ticket type '" + ticket_type + "'.")
                ticket_count += len(all_tickets[customer][ticket_type]["tickets"])

            # print(ticket_type + " " + ticket_types)
        except Exception as e:
            logger.error("Could not get tickets for customer " + customer + ". Error: " + traceback.format_exc())
            sys.exit(1)

Error:

Code errors: Exception has occurred: TypeError
an integer is required  File "C:\Users\user\Documents\GitLab\various-scripts\OTRS Auto-Reporting\Analysts-Locked\otrs_reporting_analysts_locked.py", line 160, in <module>
    for ticket_type in ticket_types:
                       ^^^^^^^^^^^^
TypeError: an integer is required

However I was able to fix the issue by either:

  • uncomment the print statement at the end of the try block
  • removing the try/except block
  • running the script directly without debugger

And now I am completely confused. Why is the print statement doing anything? Why does it error with the debugger but works fine without? What has all this to do with an expected integer?

Can anyone make sense of this?

I am using Python 3.12.7 64 bit ( Microsoft Store) and the respective VS-Code plugin.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745624476a4636721.html

相关推荐

  • UMIT:统一多模态多任务视觉

    随着深度学习的迅速发展,尤其是在医学影像分析领域的应用,越来越多的视觉-语言模型(VLMs)被广泛应用于解决复杂的健康和生物医学挑战。然而,现有研究主要集中在特定任务或单一模态上,这限制了它们在多种医学场景中的适用性和泛化能力。为了解决这

    1小时前
    00
  • 聊聊Spring AI Alibaba的ObsidianDocumentReader

    序本文主要研究一下Spring AI Alibaba的ObsidianDocumentReaderObsidianDocumentReadercommunitydocument-readersspring-ai-alibaba-star

    1小时前
    00
  • 万字图解 Java 并发框架:ForkJoin、CountDownLatch、Semaphore、CyclicBarrier

    本文图多,内容硬核,建议收藏。在第一章节《1.6w 字图解 Java 并发:多线程挑战、线程状态和通信、死锁;AQS、ReentrantLock、Condition 使用和原理》,我们开启了 Java 高并发系列的学习,透彻理解 Java

    1小时前
    00
  • 1.8w字图解Java并发容器: CHM、ConcurrentLinkedQueue、7 种阻塞队列的使用场景和原理

    文章多图且内容硬核,建议大家收藏上一章《1.6w 字图解 Java 并发:多线程挑战、线程状态和通信、死锁;AQS、ReentrantLock、Condition 使用和原理》,我们开启了 Java 高并发系列的学习,透彻理解 Java 并

    1小时前
    00
  • 电脑密码在哪里设置win11,win11电脑开机密码怎么设置

    Win11系统由于许多设置和以前系统不一样了&#xff0c;所以很多用户们操作非常不习惯&#xff0c;有很多的小伙伴不知道win11系统怎么设置开机密码。给电脑设置密码&#xff0c;只有自己能打开进入系统桌面&a

    1小时前
    00
  • 如何打造高效AI智能体?

    作者|Barry Zhang, Anthropic地址|出品|码个蛋(ID:codeegg)整理|陈宇明最近看到了 Anthropic 那篇著名的《Building effective agents》作者之一 Barry Zhang 在 2

    54分钟前
    00
  • 国产车载通信测试方案:车规级CAN SIC芯片测试技术解析

    随着智能网联汽车的快速发展,车辆内部电子控制单元(ECU)数量激增,动力总成、高级驾驶辅助系统(ADAS)、车身控制等功能对车载通信网络的稳定性与速率提出了更高要求。传统CAN FD总线在复杂拓扑中面临信号振铃、通信速率受限(实际速率通常低

    46分钟前
    00
  • OWASP TOP10

    什么是OWASP?它的全称是 Open Web Application Security Project(开放式 Web 应用程序 安全 项目)TOP 10OWASP Top 10的意思就是10项最严重的Web 应用程序安全风险列表 ,它总

    45分钟前
    00
  • 最简 Odoo 部署方法:Websoft9 企业应用托管平台

    传统方式部署 Odoo 通常依赖 Docker 技术,主要分为以下步骤:1 . 安装 Docker需在服务器上安装 Docker 引擎,涉及操作系统兼容性检查、依赖包安装、镜像源配置等操作。代码语言:bash复制 # 以 Ubu

    43分钟前
    00
  • 什么是docker?它是如何工作的?

    想象一个场景,你要部署一个服务,然后它对环境有很多依赖,不同的操作系统又是不同的需求,而且还可能遇到有些源不能使用,又得一番折腾,折腾完上线后,假设要在新的环境再来一套,又得再来一遍。那么有没有什么办法可以解决呢?有办法,docker就是干

    27分钟前
    00
  • UCB的硅光MEMS OCS控制技术

    昨天写的旭创与nEye合作了一个64端口硅光OCS一、光电路交换技术概述(一)电交换与分组交换电路交换的概念源于早期的电话交换机,通过物理连接实现设备间的通信,就像早期打电话时,接线员手动连接线路一样。而分组交换则是

    26分钟前
    00
  • 大模型驱动金融数据应用的实战探索

    近年来,人工智能技术的飞速发展正在重塑全球各行各业的生态格局,金融行业作为数据密集型领域,更是首当其冲。大模型凭借其强大的自然语言处理、逻辑推理和生成能力,逐渐成为金融数据应用的核心驱动力。本文将从行业背景与趋势、核心场景重构、产品能力提升

    19分钟前
    00
  • 拥抱国产化:转转APP的鸿蒙NEXT端开发尝鲜之旅

    本文由转转技术团队赵卫兵分享,原题“鸿蒙新篇章:转转 APP 的 HarmonyOS Next 开发之旅”,下文进行了排版优化和内容修订。1、引言2023 年在华为开发者大会(HDC.Together)上,除了面向消费者的 HarmonyO

    18分钟前
    00
  • maxwell遇到的一则问题

    结论和原因maxwell的元数据库里面没有存储全部的schema数据(就是少数据了),导致相关表的DDL校验失败。PS:我这里maxwell的作用只是采集库表修改情况的统计粗粒度指标,因为之前maxwell在运行报错的时候,直接修改了pos

    16分钟前
    00
  • 人工智能与ai有什么区别

    一、引言:概念之辨的必要性在科技浪潮席卷全球的当下,人工智能(Artificial Intelligence,简称AI)已成为人们耳熟能详的词汇。然而,当我们深入探讨时,会发现“人工智能”与“AI”这两个表述在语义和使用场景上存在微妙差异。

    14分钟前
    00
  • 在VMware虚拟机中安装Windows 7全攻略(避坑指南)

    ⚠️写在前面 最近发现很多开发者在调试老旧系统时都需要用到Windows 7环境&#xff08;特别是银行、医疗等行业的遗留系统&#xff09;&#xff0c;但实体机安装既不现实也不安全。今天就手把手教你在虚拟机

    12分钟前
    00
  • Nat. Mater.

    大家好,今天给大家分享一篇近期发表在Nat. Mater.上的研究进展,题为:De novo design of self-assembling peptides with antimicrobial activity guided

    11分钟前
    00
  • 雨晨 22635.5170 Windows 11 企业版 23H2 轻装版

    文件: 雨晨 22635.5170 Windows 11 企业版 23H2 轻装版 install.esd 大小: 2920270404 字节 修改时间: 2025年4月8日, 星期二, 11 : 04 : 59 MD5: D5F8F0AD

    10分钟前
    00
  • 1.54G 雨晨 26100.3775 Windows 11 IoT 企业版 LTSC 24H2 极速版

    精简AERO外主题并增加一套壁纸主题&#xff08;默认启用&#xff09;误杀导致功能界面空白、因WMIC被默认移除系统可能会多次重启。 拒止连接 www.5909 拒止连接 www.mnpc 拒止连接 quark 拒止

    6分钟前
    00
  • 人工智能应用领域有哪些

    人工智能应用领域有哪些一、引言随着科技的飞速发展,人工智能(AI)已经逐渐渗透到我们生活的方方面面,成为推动社会进步的重要力量。从医疗健康到金融服务,从教育学习到智能制造,人工智能以其独特的技术优势,为各行各业带来了前所未有的变革。本文旨在

    37秒前
    00

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信