Feature proposal: unittest.mock.NAN

2024-01-24 Thread Kerrick Staley via Python-list
I think we should define a unittest.mock.NAN constant that can be used with
Mock.assert_called_with() to assert that an argument passed to a Mock was
NaN. NaNs are special in that math.nan != math.nan, so you can't just do
assert_called_with(math.nan). The naming is meant to parallel
unittest.mock.ANY.

Here is a reference implementation:

class _EqNaN:
def __eq__(self, other):
return math.isnan(other)

NAN = _EqNaN()

The alternative is that users can just define this EqNaN class themselves
as needed in test code. I encountered the need to test for a NaN argument
today and was surprised to find that (as far as I can tell) there is no
pre-built solution to this in unittest or pytest. It feels like it should
be included in some standard library.

- Kerrick
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue41930] Wrap sqlite3_serialize API in sqlite3 module

2020-10-04 Thread Kerrick Staley


New submission from Kerrick Staley :

It would be useful to provide a wrapper (in the Python sqlite3 stdlib module) 
for the sqlite3_serialize API. This API allows you to get a database's content 
as a byte string, as if you had called open('foo.sqlite3', 'rb').read(). 
sqlite3_serialize can even be used for :memory: databases, which I think is the 
most interesting use-case.

Concretely, I'd propose adding a .serialize() method on sqlite3.Connection 
objects that returns a bytes object representing the serialized database. It 
would be similar to the .iterdump() method except that it would use the binary 
format instead of the text format, and it would return all the data at once 
instead of an iterator (because that's how the underlying sqlite API works).

--
components: Library (Lib)
messages: 377935
nosy: Kerrick Staley
priority: normal
severity: normal
status: open
title: Wrap sqlite3_serialize API in sqlite3 module
type: enhancement

___
Python tracker 
<https://bugs.python.org/issue41930>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41096] Need command to exit PDB interactive shell

2020-06-24 Thread Kerrick Staley


Kerrick Staley  added the comment:

Serhiy: I'm referring to the interactive mode that can be entered by typing 
"interact" in PDB.

Here are reproduction instructions:
1. Run "python3" command.
2. In Python shell, type "import pdb; pdb.set_trace()".
3. In PDB shell, type "interact".

Now, in this "PDB InteractiveConsole" shell (I'm not sure what it's called), 
the only way to go back to PDB is to press Ctrl+D. If you type "quit()" or 
"exit()" it exits the entire Python process. If you type "q" it says 
"NameError: name 'q' is not defined".

In Jupyter, I get different (but still undesirable) behavior: "quit()" raises 
"NameError: name 'quit' is not defined" (and similar for "exit()").

I think "quit()"/"exit()" in these contexts should return you back to the PDB 
shell.

--

___
Python tracker 
<https://bugs.python.org/issue41096>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41096] Need command to exit PDB interactive shell

2020-06-23 Thread Kerrick Staley


New submission from Kerrick Staley :

In PDB, when you use "interact" to enter an interactive shell, the only way to 
exit that shell is to send an end-of-transmission (Ctrl+D) character. In some 
environments, such as Jupyter, this is awkward to do. Here is a StackOverflow 
post where a user encountered this issue:
https://stackoverflow.com/questions/47522316/exit-pdb-interactive-mode-from-jupyter-notebook/62546186

I think that the user should be able to type quit() in order to exit the 
interactive Python shell and go back to the PDB shell, similar to a regular 
interactive Python session. I think you should also support exit() because the 
Python shell supports that one as well (quit() and exit() do the same thing, I 
think the alias exists to help discoverability for new users).

I confirmed this issue on Python 3.6.9 and 3.8.3.

--
components: Library (Lib)
messages: 372226
nosy: Kerrick Staley
priority: normal
severity: normal
status: open
title: Need command to exit PDB interactive shell
type: enhancement
versions: Python 3.6, Python 3.7, Python 3.8

___
Python tracker 
<https://bugs.python.org/issue41096>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40403] pdb does not drop into debugger upon SyntaxError caused by ast.literal_eval

2020-04-26 Thread Kerrick Staley


New submission from Kerrick Staley :

Summary:
When you call ast.literal_eval on a string that does not contain valid Python 
code, it raises a SyntaxError. This causes pdb to exit instead of stopping 
execution at the point that the SyntaxError was raised.

To reproduce:
1. Create a Python file foo.py with these contents:

import ast
ast.literal_eval('')

2. Run python -m pdb foo.py
3. Type 'c' and hit enter.

Expected behavior:
pdb drops into a shell in ast.py at the point where the SyntaxError occurred.

Actual behavior:
The program exits, and a SyntaxError traceback is displayed.

System configuration:
Python 3.8.2 on Arch Linux.

--
components: Library (Lib)
messages: 367363
nosy: Kerrick Staley
priority: normal
severity: normal
status: open
title: pdb does not drop into debugger upon SyntaxError caused by 
ast.literal_eval
type: behavior
versions: Python 3.8

___
Python tracker 
<https://bugs.python.org/issue40403>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12627] Implement PEP 394: The python Command on Unix-Like Systems

2011-07-23 Thread Kerrick Staley

New submission from Kerrick Staley m...@kerrickstaley.com:

This issue was opened to track the implementation of PEP 394, which governs the 
way the python command and commands like python2 and python3 work on Unix-like 
systems.

--
components: Installation
messages: 141034
nosy: Kerrick.Staley
priority: normal
severity: normal
status: open
title: Implement PEP 394: The python Command on Unix-Like Systems
type: feature request
versions: Python 2.7, Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12627
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12627] Implement PEP 394: The python Command on Unix-Like Systems

2011-07-23 Thread Kerrick Staley

Kerrick Staley m...@kerrickstaley.com added the comment:

Here is a patch that will update the Makefile.pre.in file for 2.7, causing it 
to install python2 and python2-config when run with make install (or just 
make bininstall). This does not update any documentation. Also, it appears 
that Idle and PyDoc are not installed by the 2.7 Makefile, so I didn't do 
anything about those, even though the PEP mentions them.

--
keywords: +patch
Added file: http://bugs.python.org/file22737/version27_links.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12627
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12627] Implement PEP 394: The python Command on Unix-Like Systems

2011-07-23 Thread Kerrick Staley

Kerrick Staley m...@kerrickstaley.com added the comment:

This updates the links created by make install or make bininstall in Python 
3 so that they're in agreement with the recommendations of PEP 394; it's the 
equivalent of version27_links.patch but is for Python 3.

--
Added file: http://bugs.python.org/file22738/version33_links.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12627
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com