traceback

I keep getting the following error django.db.utils.ProgrammingError: column “name” of relation “blog_post” already exists in my django app

时光毁灭记忆、已成空白 提交于 2019-12-09 01:01:36
When I try to Migrate I get the following error django.db.utils.ProgrammingError: column "name" of relation "blog_post" already exists now I have assumed that the message means that I am trying to make a column named "name" and one with the same name already exists. So I looked at my model to make sure one didn't exist and it doesn't. I don't understand what the issue is. Here is my model. Oh and I ran migrations first before I ran migrate. so that's not the issue class Post(models.Model): STATUS_CHOICES = ( ('draft', 'Draft'), ('published', 'Published'), ) title = models.CharField(max_length

Access specifics of ValueError in pandas.read_excel() converters

社会主义新天地 提交于 2019-12-08 12:52:44
问题 I'm using the following to ensure a dataframe column has the correct data type before I proceed with operations: >>> cfun = lambda x: float(x) >>> df = pd.read_excel(xl, converters={'column1': cfun}) Using converters instead of dtype so that the traceback will tell me explicitly what value caused the issue: ValueError: could not convert string to float: '100%' What I would like to do is take that information (that the string "100%" was the problem) and tell the user where it occurred in the

I keep getting the following error django.db.utils.ProgrammingError: column “name” of relation “blog_post” already exists in my django app

旧巷老猫 提交于 2019-12-08 08:50:59
问题 When I try to Migrate I get the following error django.db.utils.ProgrammingError: column "name" of relation "blog_post" already exists now I have assumed that the message means that I am trying to make a column named "name" and one with the same name already exists. So I looked at my model to make sure one didn't exist and it doesn't. I don't understand what the issue is. Here is my model. Oh and I ran migrations first before I ran migrate. so that's not the issue class Post(models.Model):

traceback.print_stack() using IPython's ultratb

雨燕双飞 提交于 2019-12-07 18:46:28
问题 For debugging/logging purposes, I would like to write the full stack to a file (such as in this question). I can do this using traceback.format_stack(). However, I would like it to look like the more verbose tracebacks that IPython outputs, for example, formatting with IPython.core.ultratb.VerboseTB. It appears the classes and methods in IPython.core.ultratb require information on exceptions, as they are designed for tracebacks. But I have no exception: I just want to display the stack in a

traceback.print_stack() using IPython's ultratb

被刻印的时光 ゝ 提交于 2019-12-06 08:14:33
For debugging/logging purposes, I would like to write the full stack to a file (such as in this question ). I can do this using traceback.format_stack() . However, I would like it to look like the more verbose tracebacks that IPython outputs, for example, formatting with IPython.core.ultratb.VerboseTB . It appears the classes and methods in IPython.core.ultratb require information on exceptions, as they are designed for tracebacks. But I have no exception: I just want to display the stack in a verbose way. How can I use the output methods of IPython.core.ultratb.VerboseTB to format the stack

Why can't I pickle an error's Traceback in Python?

天大地大妈咪最大 提交于 2019-12-05 11:52:53
问题 I've since found a work around, but still want to know the answer. 回答1: The traceback holds references to the stack frames of each function/method that was called on the current thread, from the topmost-frame on down to the point where the error was raised. Each stack frame also holds references to the local and global variables in effect at the time each function in the stack was called. Since there is no way for pickle to know what to serialize and what to ignore, if you were able to pickle

How to imitate Python 3's raise … from in Python 2?

ぃ、小莉子 提交于 2019-12-05 09:47:18
问题 Python 3 has the neat try: raise OneException('sorry') except OneException as e: # after a failed attempt of mitigation: raise AnotherException('I give up') from e syntax which allows raising a followup exception without loosing context. The best analogy I could come up with in Python 2 is raise AnotherException((e,'I give up')), None, sys.exc_info()[2] where the (e,'') is an ugly hack to have the original exception's name included in the message. But isn't there a better way? 回答1: There's a

Getting traceback information from IronPython exceptions

泄露秘密 提交于 2019-12-05 00:28:28
I have IronPython hosted within my application, whenever I catch an exception thrown from a script, I get unhelpful gibberish like this: IronPython.NewTypes.System.Exception_1$1: Error occurred during conversion ---> Microsoft.Scripting.ArgumentTypeException: expected int, got DispMethod at _stub_$245##245(Closure , CallSite , Object ) at Microsoft.Scripting.Actions.MatchCaller.Call1[T0,TRet](Func`3 target, CallSite site, Object[] args) at Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] args) at Microsoft.Scripting.Actions.UpdateDelegates.Update1[T,T0,TRet](CallSite site, T0

How to rewrite a specific frame in a traceback?

早过忘川 提交于 2019-12-04 16:48:48
In python you can compile() string to be executed faster with exec(). But as soon as i use it, we lost information when an exception happen in the exec. For example, here is a code snippet that calling a unknown method (for demo purposes): code = 'my_unknown_method()' bytecode = compile(code, '<string>', 'exec') And later, i'm calling exec on that bytecode: exec bytecode The traceback showed is: Traceback (most recent call last): File "test.py", line 3, in <module> exec bytecode File "<string>", line 1, in <module> NameError: name 'my_unknown_method' is not defined The "exec()" frame is now

How can you programmatically inspect the stack trace of an exception in Python?

早过忘川 提交于 2019-12-04 08:20:40
问题 When an exception occurs in Python, can you inspect the stack? Can you determine its depth? I've looked at the traceback module, but I can't figure out how to use it. My goal is to catch any exceptions that occur during the parsing of an eval expression, without catching exceptions thrown by any functions it may have called. Don't berate me for using eval. It wasn't my decision. NOTE: I want to do this programmatically, not interactively. 回答1: You can use the inspect module which has some