[issue46036] Single-phase initialized modules gets initialized multiple times in 3.10.0

2021-12-10 Thread Daniel

New submission from Daniel :

The documentation 
(https://docs.python.org/3/c-api/init.html#c.Py_NewInterpreter) states:


For modules using single-phase initialization, e.g. PyModule_Create(), the 
first time a particular extension is imported, it is initialized normally, and 
a (shallow) copy of its module’s dictionary is squirreled away. When the same 
extension is imported by another (sub-)interpreter, a new module is initialized 
and filled with the contents of this copy; the extension’s init function is not 
called. Objects in the module’s dictionary thus end up shared across 
(sub-)interpreters, which might cause unwanted behavior (see Bugs and caveats 
below).


This does however seem to have changed (sometime between 3.6.9 and 3.10.0). 
Consider the following code:


#include 

/*
 * Create a module "my_spam" that uses single-phase initialization
 */
static PyModuleDef EmbModule = {
  PyModuleDef_HEAD_INIT, "my_spam", NULL, -1,
  NULL,
  NULL, NULL, NULL, NULL
};

/*
 * According to the docs this function is only called once when dealing with
 * subinterpreters, the next time a shallow copy of the initial state is
 * returned. This does however not seem to be the case in Python 3.10.0..
 */
static PyObject* PyInit_emb(void) {
  PyObject *module = PyModule_Create(&EmbModule);
  PyModule_AddObject(module, "test", PyDict_New());

  printf("Init my_spam module %p\n", module);
  return module;
}

/*
 * Main program
 */

int main(int argc, char *argv[]) {
  PyImport_AppendInittab("my_spam", &PyInit_emb);
  Py_Initialize();

  // Save the main state
  PyThreadState *mainstate = PyThreadState_Get();

  // Create two new interpreters
  PyThreadState *inter1 = Py_NewInterpreter();
  PyThreadState *inter2 = Py_NewInterpreter();

  // Import the my_spam module into the first subinterpreter
  // and change the global variable of it
  PyThreadState_Swap(inter1);
  PyRun_SimpleString("import sys; print(sys.version_info)");
  PyRun_SimpleString("import my_spam; print('my_spam.test: ', my_spam.test)");
  PyRun_SimpleString("my_spam.test[1]=1; print('my_spam.test: ', 
my_spam.test)");

  // Import the my_spam module into the second subinterpreter
  // and change the global variable of it
  PyThreadState_Swap(inter2);
  PyRun_SimpleString("import sys; print(sys.version_info)");
  PyRun_SimpleString("import my_spam; print('my_spam.test: ', my_spam.test)");
  PyRun_SimpleString("my_spam.test[2]=2; print('my_spam.test: ', 
my_spam.test)");

  // Close the subinterpreters
  Py_EndInterpreter(inter2);
  PyThreadState_Swap(inter1);
  Py_EndInterpreter(inter1);

  // Swap back to the main state and finalize python
  PyThreadState_Swap(mainstate);
  if (Py_FinalizeEx() < 0) {
  exit(120);
  }

  return 0;
}



Compiled with python 3.6.9 this does act according to the documentation:


$ gcc test_subinterpreters.c 
-I/home/daniel/.pyenv/versions/3.6.9/include/python3.6m 
-L/home/daniel/.pyenv/versions/3.6.9/lib -lpython3.6m && 
LD_LIBRARY_PATH=/home/daniel/.pyenv/versions/3.6.9/lib ./a.out
sys.version_info(major=3, minor=6, micro=9, releaselevel='final', serial=0)
Init my_spam module 0x7ff7a63d1ef8
my_spam.test:  {}
my_spam.test:  {1: 1}
sys.version_info(major=3, minor=6, micro=9, releaselevel='final', serial=0)
my_spam.test:  {1: 1}
my_spam.test:  {1: 1, 2: 2}


But compiled with 3.10.0 the module is reinitialized and thus objects in the 
module are not shared between the subinterpreters:


$ gcc test_subinterpreters.c 
-I/home/daniel/.pyenv/versions/3.10.0/include/python3.10 
-L/home/daniel/.pyenv/versions/3.10.0/lib -lpython3.10 && 
LD_LIBRARY_PATH=/home/daniel/.pyenv/versions/3.10.0/lib ./a.out
sys.version_info(major=3, minor=10, micro=0, releaselevel='final', serial=0)
Init my_spam module 0x7f338a9a9530
my_spam.test:  {}
my_spam.test:  {1: 1}
sys.version_info(major=3, minor=10, micro=0, releaselevel='final', serial=0)
Init my_spam module 0x7f338a9a96c0
my_spam.test:  {}
my_spam.test:  {2: 2}


To me the new behavior seems nicer, but at the very least the documentation 
should be updated. It also seems like if this could break integrations, albeit 
it is an unlikely "feature" to rely on.

--
components: C API
messages: 408209
nosy: daniel-falk
priority: normal
severity: normal
status: open
title: Single-phase initialized modules gets initialized multiple times in 
3.10.0
type: behavior
versions: Python 3.10

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



[issue1398] Can't pickle partial functions

2007-11-07 Thread Daniel

New submission from Daniel:

Creating a function using functools.partial results in a function which
cannot be pickled.

Attached is a small testcase.

--
components: Library (Lib)
files: partial_bug.py
messages: 57200
nosy: danhs
severity: normal
status: open
title: Can't pickle partial functions
type: behavior
versions: Python 2.5
Added file: http://bugs.python.org/file8705/partial_bug.py

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1398>
__from functools import partial
import pickle


def f(a, b):
print a, b

partial_f = partial(f, b = 'hello')


pickle.dumps(partial_f)___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3869] Arrow keys not working with Python 2.6rc1

2008-09-14 Thread Daniel

New submission from Daniel <[EMAIL PROTECTED]>:

On Xubuntu 8.04. In Python2.5 arrow keys allowed you to scroll through
previous lines typed but with 2.6rc1 this stopped working and it's now
just typing the ^[[A^[[B^[[D^[[C characters.

--
messages: 73229
nosy: Chewie
severity: normal
status: open
title: Arrow keys not working with Python 2.6rc1
type: behavior
versions: Python 2.6

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3869>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3869] Arrow keys not working with Python 2.6rc1

2008-09-14 Thread Daniel

Daniel <[EMAIL PROTECTED]> added the comment:

Yes I did the configure / compile myself.

After reading about readline in setup I am still unable to enable it but
I guess it is not a bug in Python but more a user problem.

I am quite puzzled as to why something like this would stop being
enabled by defualt tho, pretty sure I don't know anyone who doesn't use
input history.

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3869>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3869] Arrow keys not working with Python 2.6rc1

2008-09-14 Thread Daniel

Daniel <[EMAIL PROTECTED]> added the comment:

That was it.

Needed to install libreadline5-dev.

Then the default settings for readline in Modules/setup needs
uncommented (line 165 in the current version) and it works.

Thank you kindly.

___
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3869>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2698] Extension module build fails for MinGW: missing vcvarsall.bat

2010-01-18 Thread Daniel

Daniel  added the comment:

Sorry, I am on others problems and i don't have any time to look at a solution 
:(

Daniel.

--

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



[issue46958] json dump/dumps prints each array element on a new line (bad for readability)

2022-03-08 Thread Daniel


Change by Daniel :


--
components: Library (Lib)
nosy: Entirity
priority: normal
severity: normal
status: open
title: json dump/dumps prints each array element on a new line (bad for 
readability)
type: enhancement
versions: Python 3.11

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



[issue46958] json dump/dumps prints each array element on a new line (bad for readability)

2022-03-08 Thread Daniel


Change by Daniel :


--
keywords: +patch
pull_requests: +29873
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/31762

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



[issue38014] Python 3.7 does not compile

2019-09-02 Thread Daniel


New submission from Daniel :

Hi, I use macOS Catalina 10.15. I use Xcode 10 and Xcode 11, but with that 
configuration, compiling Python 3.7.14 does not work for me. Any idea whats 
causing this issue?

user@Users-MacBook-Pro Python-3.7.4 % ./configure 
--with-framework-name=python36 --with-universal-archs=64-bit 
--enable-universalsdk=/ --enable-optimizations 
--enable-framework=/Users/user/Desktop/Python-3.7 
checking build system type... x86_64-apple-darwin19.0.0
checking host system type... x86_64-apple-darwin19.0.0
checking for python3.7... python3.7
checking for --enable-universalsdk... /
checking for --with-universal-archs... 64-bit
checking MACHDEP... checking for --without-gcc... no
checking for --with-icc... no
Configured with: --prefix=/Applications/Xcode-beta.app/Contents/Developer/usr 
--with-gxx-include-dir=/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for a sed that does not truncate output... /usr/bin/sed
checking for --with-cxx-main=... no
checking for g++... no
configure:

  By default, distutils will build C++ extension modules with "g++".
  If this is not intended, then set CXX on the configure command line.
  
checking for the platform triplet based on compiler characteristics... darwin
checking for -Wl,--no-as-needed... no
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for the Android API level... not Android
checking for --with-suffix... 
checking for case-insensitive build directory... yes
checking LIBRARY... libpython$(VERSION)$(ABIFLAGS).a
checking LINKCC... $(PURIFY) $(MAINCC)
checking for GNU ld... no
checking for --enable-shared... no
checking for --enable-profiling... no
checking LDLIBRARY... 
$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)
checking for ar... ar
checking for readelf... no
checking for a BSD-compatible install... /usr/bin/install -c
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for --with-pydebug... no
checking for --with-assertions... no
checking for --enable-optimizations... yes
checking for --with-lto... no
checking for -llvm-profdata... no
configure: llvm-profdata found via xcrun: /usr/bin/xcrun llvm-profdata
checking for -Wextra... yes
checking whether gcc accepts and needs -fno-strict-aliasing... no
checking if we can turn off gcc unused result warning... yes
checking if we can turn off gcc unused parameter warning... yes
checking if we can turn off gcc missing field initializers warning... yes
checking if we can turn off gcc invalid function cast warning... no
checking if we can turn on gcc mixed sign comparison warning... yes
checking if we can turn on gcc unreachable code warning... yes
checking if we can turn on gcc strict-prototypes warning... yes
checking if we can make implicit function declaration an error in gcc... yes
checking which compiler should be used... gcc
checking which MACOSX_DEPLOYMENT_TARGET to use... 10.15
checking whether pthreads are available without options... no
checking whether gcc accepts -Kpthread... no
checking whether gcc accepts -Kthread... no
checking whether gcc accepts -pthread... no
checking whether g++ also accepts flags for thread support... no
checking for ANSI C header files... (cached) yes
checking asm/types.h usability... no
checking asm/types.h presence... no
checking for asm/types.h... no
checking crypt.h usability... no
checking crypt.h presence... no
checking for crypt.h... no
checking conio.h usability... no
checking conio.h presence... no
checking for conio.h... no
checking direct.h usability... no
checking direct.h presence... no
checking for direct.h... no
checking dlfcn.h usability... no
checking dlfcn.h presence... yes
configure: WARNING: dlfcn.h: present but cannot be compiled
configure: WARNING: dlfcn.h: check for missing prerequisite headers?
configure: WARNING: dlfcn.h: see the Autoconf documentation
configure: WARNING: dlfcn.h: section "Present But Cannot Be Compiled"

[issue45737] assertLogs to optionally not disable existing handlers

2021-11-06 Thread Daniel


New submission from Daniel <3dan...@hotmail.com>:

At the moment, assertLogs removes the handlers attached to the logger.
In general this is good, because it reduces message spamming in the test logs.
However, if the code being tested is relying on a handler to do something, then 
the test fails because the handler is being removed.
This leads to the situation that the same exact test must be run twice:
- first time within the context manager, to assert that specific messages were 
logged (using `with self.assertLogs()`)
- second time, without the assertLogs to ensure the code that uses a handler 
does the right thing

The proposal is to have `self.assertLogs()` accept a key word argument such as 
`keep_handlers=False`, which can be set to True, whenever the handlers should 
be preserved.
It would probably be also useful to add a note in the documentation that makes 
users aware that the existing handlers will be removed.

--
messages: 405858
nosy: dandiez
priority: normal
severity: normal
status: open
title: assertLogs to optionally not disable existing handlers
versions: Python 3.10, Python 3.7, Python 3.8, Python 3.9

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



[issue45737] assertLogs to optionally not disable existing handlers

2021-11-06 Thread Daniel


Change by Daniel <3dan...@hotmail.com>:


--
components: +Library (Lib)
versions: +Python 3.11

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



[issue45737] assertLogs to optionally not disable existing handlers

2021-11-06 Thread Daniel


Change by Daniel <3dan...@hotmail.com>:


--
type:  -> enhancement

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



[issue45973] Not possible to clear PyImport_Inittab after PyImport_AppendInittab

2021-12-03 Thread Daniel


New submission from Daniel :

Hello,

When embedding Python into a C application and not using Py_RunMain it is not 
possible to remove a module added to PyImport_Inittab even if the interpreter 
is finalized and a new is created.

One reason for not using Py_RunMain is to use python as a subprocessor to my 
primary C application by initializing an interpreter, run some python code, 
then go back to execute some C code and again execute some python code in the 
same interpreter. After a while I might want to finalize the interpreter and 
create a new one without the module added to inittab, still being in the same 
process.

See example:

#include 


/*
 * Create a python interpreter, run a command and delete the interpreter
 */
void run_in_new_interpreter(char *cmd) {
Py_Initialize();

PyRun_SimpleString(cmd);

if (Py_FinalizeEx() < 0) {
exit(120);
}
}

/*
 * Create a module "my_spam" but do not append it to inittab
 */
static PyModuleDef EmbModule = {
  PyModuleDef_HEAD_INIT, "my_spam", NULL, -1,
  NULL,
  NULL, NULL, NULL, NULL
};

static PyObject* PyInit_emb(void) {
return PyModule_Create(&EmbModule);
}

/*
 * Main program
 */
char *LIST_MODULES_CMD="try:\n import my_spam; print('SPAM!');\nexcept:\n 
print('no mod my_spam')";

int main(int argc, char *argv[]) {
// Run with no "my_spam" module
run_in_new_interpreter(LIST_MODULES_CMD);

// Run with "my_spam" module
PyImport_AppendInittab("my_spam", &PyInit_emb);
run_in_new_interpreter(LIST_MODULES_CMD);

// How to run without my_spam? The module is still in the PyImport_Inittab
// despite the Py_FinalizeEx() call. This list is not reset until
// _PyImport_Fini2() is called, but that is never exposed in anyi public 
header,
// only in Include/internal/pycore_pylifecycle.h
run_in_new_interpreter(LIST_MODULES_CMD);
return 0;
}



The output of the program is:

>>> gcc test_embed.c `pkg-config --cflags --libs python-3.6` && ./a.out
no mod my_spam
SPAM!
SPAM!

--
components: C API
messages: 407590
nosy: daniel-falk
priority: normal
severity: normal
status: open
title: Not possible to clear PyImport_Inittab after PyImport_AppendInittab
type: behavior

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



[issue40026] Create render_*_diff variants to the *_diff functions in difflib

2020-03-20 Thread Daniel


New submission from Daniel :

Currently difflib offers no way to synthesize a diff output without having to 
assemble the original and modified strings and then asking difflib to calculate 
the diff.

It would be nice if I could just call a `render_unified_diff(a, b, 
grouped_opcodes)` and get a diff output. This is useful when I'm synthesizing a 
patch dynamically and I don't necessarily want to load the entire original file 
and apply the changes.

One example usage would be something like:

```
def make_patch(self):
# simplified input for synthesizing the diff
a = []
b = []
include_lines = []
for header, _ in self.missing.items():
include_lines.append(f"#include <{header}>\n")
while len(b) < self.line:
b.append(None)
b.extend(include_lines)
opcodes = [
[('insert',
  self.line, self.line,
  self.line, self.line + len(include_lines))]
]
diff = render_unified_diff(
a, b, opcodes,
fromfile=os.path.join('a', self.filename),
tofile=os.path.join('b', self.filename),
)
return ''.join(diff)
```

--
components: Library (Lib)
messages: 364669
nosy: pablogsal, ruoso
priority: normal
severity: normal
status: open
title: Create render_*_diff variants to the *_diff functions in difflib

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



[issue37625] Class variable is still accessible after class instance has been overwritten out

2019-07-18 Thread Daniel


New submission from Daniel :

Not sure if this is the desired behavior but wanted to bring it up anyways.
When you have a class and have a variable in like:
class TestClass(object):
variable = []

then you run it through a loop like:
for num in range(10):
test = TestClass()
test.variable.append(num)

even if you assign another variable to it or none like:
test = "blah"
test = None

then reassign the class:
test = TestClass()
print(test.variable)

will return all the numbers in the list.
also doesn't seem to matter if garbage collection was manually ran.

Attached is a small example code.
This was found on Macos and tested with both python 3.7 and 2.7 Subsequently 
same on ubuntu with python 3.5 and python 2.7

--
components: Interpreter Core
files: variabletest.py
messages: 348130
nosy: moird
priority: normal
severity: normal
status: open
title: Class variable is still accessible after class instance has been 
overwritten out
type: behavior
versions: Python 2.7, Python 3.5, Python 3.7
Added file: https://bugs.python.org/file48490/variabletest.py

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



[issue37625] Class variable is still accessible after class instance has been overwritten out

2019-07-19 Thread Daniel


Daniel  added the comment:

Thanks, just didn't expect that behavior.

--

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



[issue31298] Error when calling numpy.astype

2017-08-28 Thread Daniel

New submission from Daniel:

Ubuntu 16.04.3
Python 3.5.2
Numpy version 1.11.0

Running the following two commands causes Python to crash:
import numpy as np
np.array([[1, 2],[3,4]]).astype(np.dtype([("a", np.float), ("b", np.str_)]))

The error occurs when running in an interactive session and when running those 
two commands as a script.

The error I get is:
*** Error in `python3': free(): invalid next size (normal): 0x01a088f0 
***

A memory map printed after the error is attached.

The backtrace is
=== Backtrace: =
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7f55ac35e7e5]
/lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7f55ac36737a]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7f55ac36b53c]
/usr/lib/python3/dist-packages/numpy/core/multiarray.cpython-35m-x86_64-linux-gnu.so(+0x6d35e)[0x7f55ab0fa35e]
/usr/lib/python3/dist-packages/numpy/core/multiarray.cpython-35m-x86_64-linux-gnu.so(+0x45a29)[0x7f55ab0d2a29]
/usr/lib/python3/dist-packages/numpy/core/multiarray.cpython-35m-x86_64-linux-gnu.so(+0x461a2)[0x7f55ab0d31a2]
/usr/lib/python3/dist-packages/numpy/core/multiarray.cpython-35m-x86_64-linux-gnu.so(+0xcf828)[0x7f55ab15c828]
python3(PyCFunction_Call+0x77)[0x4e9bc7]
python3(PyEval_EvalFrameEx+0x614)[0x524414]
python3[0x52d2e3]
python3(PyEval_EvalCode+0x1f)[0x52dfdf]
python3[0x5fd2c2]
python3(PyRun_FileExFlags+0x9a)[0x5ff76a]
python3(PyRun_SimpleFileExFlags+0x1bc)[0x5ff95c]
python3(Py_Main+0x456)[0x63e7d6]
python3(main+0xe1)[0x4cfe41]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f55ac307830]
python3(_start+0x29)[0x5d5f29]

--
components: Interpreter Core
files: memdump.txt
messages: 300970
nosy: droth
priority: normal
severity: normal
status: open
title: Error when calling numpy.astype
type: crash
versions: Python 3.5
Added file: http://bugs.python.org/file47105/memdump.txt

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



[issue9033] cmd module tab misbehavior

2018-01-17 Thread Daniel

Daniel  added the comment:

I can confirm this behaviour for python 3.6.0 on Mac OS X 10.12.6

--
nosy: +boompig
versions: +Python 3.6 -Python 2.7, Python 3.3, Python 3.4

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



[issue32035] Documentation of zipfile.ZipFile().writestr() fails to mention that 'data' may also be bytes

2017-11-15 Thread Daniel

New submission from Daniel :

The documentation for "ZipFile.writestr(zinfo_or_arcname, data[, 
compress_type])" says: "Write the string data to the archive; [...]"
--> https://docs.python.org/3/library/zipfile.html

I fails to mention that data could also be bytes.

The source code does mention it however, that is how I found out:

def writestr(self, zinfo_or_arcname, data, compress_type=None):
"""Write a file into the archive.  The contents is 'data', which
may be either a 'str' or a 'bytes' instance; if it is a 'str',
it is encoded as UTF-8 first.
'zinfo_or_arcname' is either a ZipInfo instance or
the name of the file in the archive."""

I believe this should be added to the documentation as it's an important 
information to those who try to add non-UTF8 StringIO data to in-memory 
ZipFiles using BytesIO.

--
assignee: docs@python
components: Documentation
messages: 306271
nosy: Daniel5148, docs@python
priority: normal
severity: normal
status: open
title: Documentation of zipfile.ZipFile().writestr() fails to mention that 
'data' may also be bytes
versions: Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8

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



[issue13214] Cmd: list available completions from the cmd.Cmd subclass and filter out EOF handler(s)

2018-01-10 Thread Daniel

Daniel  added the comment:

If you write a handler for EOF like so:

from cmd import Cmd

class FooShell(Cmd):
def do_EOF(self, args):
# exit on EOF
raise SystemExit()

shell = FooShell()
shell.cmdloop()

Then when running the shell, you can see "EOF" as an undocumented command in 
the help screen. You can see this when typing "?".

$ python fooshell.py
(Cmd) ?

Documented commands (type help ):

help

Undocumented commands:
==
EOF

I believe the correct behaviour should be (1) don't show it in the undocumented 
commands, since it's not really a command; and (2) maybe create a built-in 
command for this, since the literal string "EOF" is also caught by this handler.

--
nosy: +boompig
versions: +Python 3.6 -Python 3.3

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



[issue17797] Visual C++ 11.0 reports fileno(stdin) == 0 for non-console program

2013-09-10 Thread Daniel

Daniel added the comment:

After contacting Microsoft they answered that they cannot fix that within the 
VS2012 or VS2013 cycle. Very bad. Any ideas?

--
nosy: +m_python

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



[issue17797] Visual C++ 11.0 reports fileno(stdin) == 0 for non-console program

2013-09-10 Thread Daniel

Daniel added the comment:

Here are some solutions which might help you until MS fixed the bug.

1) Even if the subsystem is Windows one solution is to call AllocConsole() 
before Py_Initialize() to create a console.

2) Second Solution: If you don't want to open a console and your application 
has its own output window you could redirect stdout/stderr/stdin with freopen 
to a temp file first. (e.g: freopen("file.txt","w",stdout);) Call freopen for 
all std handles before you call Py_Initialize(). You can keep the redirection 
to the file or after Py_Initialize() succeeded you change the redirection now 
in Python by redirect sys.stdout to the place you want.

--

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



[issue17797] Visual C++ 11.0 reports fileno(stdin) == 0 for non-console program

2013-09-11 Thread Daniel

Daniel added the comment:

Sorry, I used the latest Python3.4 branch, I haven't tested this with prior 
versions.

--

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



[issue19120] shlex.shlex.lineno reports a different number depending on the previous token

2013-09-28 Thread Daniel

New submission from Daniel:

See the example below (also attached).

First example: The lineno reported just after "word2" is pulled is 2.
Second example: The lineno reported just after "," is pulled is still 1.

This behaviour seems inconsistent. The lineno should increment either when the 
last token of a line is pulled, or after the first token from the next line (in 
my opinion preferably the former). It should not have different bahaviour 
depending on what type of token that is (alpha vs. comma).

I have repeated this on 

Also, does Issue 16121 relate to this?


#!/usr/bin/env python
import shlex

first = shlex.shlex("word1 word2\nword3")
print (first.get_token())
print (first.get_token())
print ("line no", first.lineno)
print ("")

second = shlex.shlex("word1 word2,\nword3")
print (second.get_token())
print (second.get_token())
print (second.get_token())
print ("line no", second.lineno)


# Output:
# word1
# word2
# line no 2
#
# word1
# word2
# ,
# line no 1

--
files: shlex_line.py
messages: 198561
nosy: daniel-s
priority: normal
severity: normal
status: open
title: shlex.shlex.lineno reports a different number depending on the previous 
token
type: behavior
versions: Python 2.6, Python 2.7, Python 3.2, Python 3.3
Added file: http://bugs.python.org/file31900/shlex_line.py

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



[issue19120] shlex.shlex.lineno reports a different number depending on the previous token

2013-09-28 Thread Daniel

Daniel added the comment:

>From the unfinished sentence:

I have repeated this on all versions of shlex on which I have tried. Including 
Python 2.6, 2.7, 3.2 and 3.3.

--

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



[issue19372] getaddrinfo() bug

2013-10-23 Thread Daniel

New submission from Daniel:

I have two systems, one is CentOS 5.9 with kernel 2.6.18-348, 
the other is CentOS 6.4 with kernel 2.6.32-358. 
Python ver is 2.7.5. 
both configure ok if no other option give, 
But if I want configure with --enable-shared, CentOS 6.4 get a 
You must get working getaddrinfo() function.
   or you can specify "--disable-ipv6".

while the other system 5.9 is ok.

I try to use --disable-ipv6, then it configure ok, but make
got a lot of error , such as must define PY_FORMAT_LONG_LONG 
int pyconfig.h .

--
components: Build
messages: 201088
nosy: Daniel
priority: normal
severity: normal
status: open
title: getaddrinfo() bug
type: compile error
versions: Python 2.7

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



[issue20723] Make test (Python 3.3.4)

2014-02-21 Thread Daniel

New submission from Daniel:

5 Error to make test with Python v.3.3.4

--
files: makeTest-python3-3-4.log
messages: 211867
nosy: datienzalopez
priority: normal
severity: normal
status: open
title: Make test (Python 3.3.4)
type: compile error
versions: Python 3.3
Added file: http://bugs.python.org/file34175/makeTest-python3-3-4.log

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



[issue2698] Extension module build fails for MinGW: missing vcvarsall.bat

2009-12-23 Thread Daniel

Daniel  added the comment:

Hello,

I confirm : Python3.1.1 
.../...
running build
running build_py
running build_ext
building 'cx_Freeze.util' extension
error: Unable to find vcvarsall.bat

I've got the r73896 file correction.
:(
D.

--
nosy: +Daniel26
versions:  -Python 2.6

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



[issue2698] Extension module build fails for MinGW: missing vcvarsall.bat

2009-12-24 Thread Daniel

Daniel  added the comment:

Thank you :)

Daniel.

--

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



[issue2698] Extension module build fails for MinGW: missing vcvarsall.bat

2010-01-04 Thread Daniel

Daniel  added the comment:

Thanks for your response!
I'm back after holidays :)

Yappy new year everybody!!!

Conserning our problem:
.../...
adding base module named weakref
running build
running build_py
running build_ext
Traceback (most recent call last):
  File "setup.py", line 240, in 
license = "Python Software Foundation License")
  File "c:\python31\lib\distutils\core.py", line 149, in setup 
dist.run_commands()
  File "c:\python31\lib\distutils\dist.py", line 919, in run_commands 
self.run_command(cmd)
  File "c:\python31\lib\distutils\dist.py", line 938, in run_command 
cmd_obj.run()
  File "c:\python31\lib\distutils\command\build.py", line 128, in run 
self.run_command(cmd_name)
  File "c:\python31\lib\distutils\cmd.py", line 315, in run_command 
self.distribution.run_command(command)
  File "c:\python31\lib\distutils\dist.py", line 938, in run_command 
cmd_obj.run()
  File "c:\python31\lib\distutils\command\build_ext.py", line 358, in run 
force=self.force)
  File "c:\python31\lib\distutils\ccompiler.py", line 1106, in new_compiler 
return klass(None, dry_run, force)
  File "c:\python31\lib\distutils\cygwinccompiler.py", line 280, in __init__ 
CygwinCCompiler.__init__ (self, verbose, dry_run, force)
  File "c:\python31\lib\distutils\cygwinccompiler.py", line 124, in __init__ if 
self.ld_version >= "2.10.90": TypeError: unorderable types: NoneType() >= str()

I will also analyse and look at a solution.


Daniel.

--

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



[issue23471] 404 Not Found when downloading Python 3.4.3rc1 Documentation

2015-02-16 Thread Daniel

New submission from Daniel:

Via Chrome on Android 4.4.

--
assignee: docs@python
components: Documentation
messages: 236095
nosy: docs@python, stringsonfire
priority: normal
severity: normal
status: open
title: 404 Not Found when downloading Python 3.4.3rc1 Documentation
type: behavior
versions: Python 3.4

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



[issue24366] Simple indentation

2015-06-02 Thread Daniel

Changes by Daniel :


--
files: indent.patch
keywords: patch
nosy: li4ick
priority: normal
severity: normal
status: open
title: Simple indentation
versions: Python 3.6
Added file: http://bugs.python.org/file39597/indent.patch

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



[issue17703] Trashcan mechanism segfault during interpreter finalization in Python 2.7.4

2015-04-18 Thread Daniel

Daniel added the comment:

Guillaume already mentioned this, its still causing a Fatal Error. To fix this 
PyThreadState_GET() in Py_TRASHCAN_SAFE_BEGIN must be replaced with 
_PyThreadState_Current

#define Py_TRASHCAN_SAFE_BEGIN(op) \
do { \
PyThreadState *_tstate = _PyThreadState_Current; \

--
nosy: +m_python

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



[issue4733] Add a "decode to declared encoding" version of urlopen to urllib

2021-12-10 Thread Daniel Diniz


Daniel Diniz  added the comment:

As Victor notes, this is a controversial issue. And I'll add that the need for 
this feature seems not to have been brought up up in over a decade. So I'm 
closing this.

--
resolution:  -> rejected
stage: patch review -> resolved
status: open -> closed

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



[issue1182143] making builtin exceptions more informative

2021-12-10 Thread Daniel Diniz


Change by Daniel Diniz :


--
nosy: +iritkatriel

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



[issue766910] fix one or two bugs in trace.py

2021-12-10 Thread Daniel Diniz


Change by Daniel Diniz :


--
nosy: +ajaksu2
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 2.7, Python 3.7

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



[issue44413] OverflowError: mktime argument out of range after 2019

2021-12-15 Thread Daniel McDonald


Daniel McDonald  added the comment:

I'd like to politely request this issue be reopened. 

We recently observed a similar, if not the same, OverflowError during 
continuous integration using Github Actions on ubuntu-latest (20.04). We can 
produce the error using pure Python without pytz.

We have been unable to replicate the error using Github Actions on 
macos-latest, Centos 7.9, Ubuntu 18.04 or OSX 11.6.1.

Specifically, the following code, which I believe is pure python, will trigger 
the overflow. We've observed this using Python 3.7 and 3.9. 

import time
print(time.mktime((2017,5,26,15,30,16,4,146,1)))

Exact error output from CI can be found at the link below: 

https://github.com/biocore/microsetta-private-api/runs/4536611219?check_suite_focus=true#step:4:117

On a passing system, we receive "1495837816.0" as output. On a failing system, 
we observe "OverflowError: mktime argument out of range". 

More detail can be found on our issue with pytz and stub42 who helped guide a 
more definitive example of the bug showing it could be pure Python. That issue 
can be found here:

https://github.com/stub42/pytz/issues/66

Last, I apologize in advance if any detail is missing here or if this is not 
formatted as well as it should be. This is my first bug report with Python and 
am unfamiliar with the norms. Please let me know if further information may be 
helpful.

--
nosy: +wasade
versions: +Python 3.7, Python 3.9

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



[issue44413] OverflowError: mktime argument out of range after 2019

2021-12-15 Thread Daniel McDonald


Daniel McDonald  added the comment:

Thank you, Terry. I'm currently exploring modifications to the test Andrei made 
within a fork of CPython using Github Actions (ubuntu-latest). These 
modifications include debug prints in the CPython mktime call, and some 
parameter exploration. I expect to have a summary of the observations this 
afternoon.

--

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



[issue44413] OverflowError: mktime argument out of range after 2019

2021-12-15 Thread Daniel McDonald


Daniel McDonald  added the comment:

The use of tm_isdst=1 appears to trigger the overflow, and occurs when varying 
other aspects of the timetuple.  

Python's mktime wrapper can throw OverflowError in two places. The thrown error 
is the second location, following the call to glibc's mktime occurring in this 
specific if block:

https://github.com/python/cpython/blob/f62420c3d3f5d87f2b57e54b2a98682bc835f7b6/Modules/timemodule.c#L1038-L1046

Modification of Modules/timemodule.c as to printf tm struct members confirms 
that when tm_isdst=1, the result from mktime() is -1, and the tm_wday member is 
set to -1, the combination of which triggers the conditional. 

mktime within the Github Action ubuntu-latest (20.04) environment is sourced 
from glibc 2.31 as confirmed by ldd and nm on the compiled Python binary.

As a proof of concept, C program was written that calls mktime independent of 
CPython (can be compiled with "gcc bug.c -o bug"). The code below succeeds on 
both OSX 11.6.1 and Centos 7.9:

#include 
#include 

void do_test() {
  struct tm tm_works = { .tm_year=117,
 .tm_mon=4,
 .tm_mday=26,
 .tm_hour=15,
 .tm_min=30,
 .tm_sec=16,
 .tm_wday=4,
 .tm_yday=145,
 .tm_isdst=-1 };
  
  struct tm tm_fails = { .tm_year=117,
 .tm_mon=4,
 .tm_mday=26,
 .tm_hour=15,
 .tm_min=30,
 .tm_sec=16,
 .tm_wday=4,
 .tm_yday=145,
 .tm_isdst=1 };

  time_t works = mktime(&tm_works);
  time_t fails = mktime(&tm_fails);

  if(works == -1) {
  printf("Unexpected failure\n");
  } else {
  if(works == fails) {
  printf("Test passed\n");
  } else {
  printf("Test failed: works=%d; fails=%d\n", (int)works, (int)fails);
  }
  }
}

int main(int argc, char **argv) {
do_test();
}

When compiled and run within in the Github Actions ubuntu-latest (20.04) 
environment, the erroneous behavior occurs:

https://github.com/wasade/cpython/runs/4541212472?check_suite_focus=true#step:17:57

The use of tm_isdst=1 is valid according to multiple sources, a few examples 
are linked below. The sources are consistent, and indicate a positive value 
means Daylight Savings Time is in effect. 

https://www.gnu.org/software/libc/manual/html_node/Broken_002ddown-Time.html
https://www.cplusplus.com/reference/ctime/tm/

At this time, I believe this remains unexpected behavior, however the source 
appears upstream of CPython as mktime is part of glibc. Unless suggested 
otherwise, I'll open an issue with on the glibc tracker.

--

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



[issue44413] OverflowError: mktime argument out of range after 2019

2021-12-15 Thread Daniel McDonald


Daniel McDonald  added the comment:

Thank you, Christian, I apologize for missing your reply. That is great advice, 
and I will do so.

--

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



[issue44413] OverflowError: mktime argument out of range after 2019

2021-12-15 Thread Daniel McDonald


Daniel McDonald  added the comment:

For reference, the bug reports with Debian and Ubuntu are at the following URLs:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1001774
https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/1954963

--

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



[issue45959] Teach pprint about dict views

2021-12-16 Thread Daniel Diniz


Change by Daniel Diniz :


--
keywords: +patch
nosy: +ajaksu2
nosy_count: 4.0 -> 5.0
pull_requests: +28355
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/30135

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



[issue45959] Teach pprint about dict views

2021-12-16 Thread Daniel Diniz


Daniel Diniz  added the comment:

I have tried to add this. The PR adds:
- PrettyPrinter._pprint_dict_view to handle dict_keys and dict_values (sorted 
with _safe_key).
= PrettyPrinter._pprint_dict_items_view to handle dict_items (sorted using 
_safe_tuple).
- Tests.

Would a NEWS entry or other form of documentation be necessary?

--

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



[issue1062277] Pickle breakage with reduction of recursive structures

2021-12-16 Thread Daniel Diniz


Change by Daniel Diniz :


--
versions: +Python 3.11 -Python 3.5

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



[issue9917] resource max value represented as signed when should be unsigned

2021-12-16 Thread Daniel Diniz


Change by Daniel Diniz :


--
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 2.7, Python 3.4, Python 
3.5

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



[issue678264] test_resource fails when file size is limited

2021-12-16 Thread Daniel Diniz


Change by Daniel Diniz :


--
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 2.7, Python 3.4, Python 
3.5

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



[issue41033] readline.c: endless loop on SIGWINCH when loaded twice

2021-12-17 Thread daniel hahler


daniel hahler  added the comment:

Yes, the example also does not segfault for me either (also with Python 3.8.12 
I have now as `python3.8`), so this was likely only happening in the more 
complex setup, and/or maybe with some specific version of readline back then.

--
title: readline.c: SEGFAULT on SIGWINCH when loaded twice -> readline.c: 
endless loop on SIGWINCH when loaded twice

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



[issue41033] readline.c: endless loop on SIGWINCH when loaded twice

2021-12-17 Thread daniel hahler


Change by daniel hahler :


--
versions: +Python 3.11

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



[issue46127] Missing HTML span element in exceptions.html

2021-12-19 Thread Daniel Diniz


Daniel Diniz  added the comment:

That happens because EncodingWarning isn't highlighted as an Exception by 
Pygments[0]. The doc page gets its exceptions diagram by:
".. literalinclude:: ../../Lib/test/exception_hierarchy.txt"
and all other entries are recognized by Pygments, so we get the "ne" class for 
them.

A PR for Pygments adding EncodingWarning could be interesting, but I'm not sure 
the doc build process would pick it up and fix the 3.10 docs issue.

For 3.11, the diagram drawing was changed so no highlighting happens anymore, 
which fixes the issue for us in the long run.

[0] 
https://github.com/pygments/pygments/blob/8630e033313647d9579e314f3e8e2882f4558933/pygments/lexers/python.py#L225

--
nosy: +ajaksu2

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



[issue23224] bz2/lzma: Compressor/Decompressor objects are only initialized in __init__

2021-12-19 Thread Daniel Diniz


Change by Daniel Diniz :


--
versions: +Python 3.10, Python 3.11 -Python 3.7, Python 3.8

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



[issue46138] Strange behavior with lists

2021-12-20 Thread Daniel Frey


New submission from Daniel Frey :

Hi

I found a strange behavior with lists. When I want to save the list {3,1,8}, it 
saves the 8 at the first entry. Only when I add the integers 7 and 9, the 8 is 
placed correctly. (See the attached picture)

Can anyone help me understand what is going on here?

Thanks in advance!

--
files: python_strange_behavior.png
messages: 408960
nosy: daniel.frey
priority: normal
severity: normal
status: open
title: Strange behavior with lists
type: behavior
versions: Python 3.10
Added file: https://bugs.python.org/file50505/python_strange_behavior.png

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



[issue44413] OverflowError: mktime argument out of range after 2019

2021-12-20 Thread Daniel McDonald


Daniel McDonald  added the comment:

A definitive assessment was obtained by Aurelien with Debian:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1001774

In brief, the OverflowError is expected and correct. 

Two factors contribute to the difference in observed behavior. First, the 
production of the -1 from mktime which Python uses to raise OverflowError 
depends on whether timezone is or is not set (e.g. "Etc/UTC"). This was 
confirmed on the Github Actions 20.04 ubuntu instance independent of Python 
directly with the mktime() function from C. Second, mktime returning -1 to 
indicate overflow is dependent on glibc >= 2.29, and versions prior "do not 
report any error if the date is not representable." This second factor is 
supported by testing the lack of the -1 (and subsequent OverflowError) on 
Github Actions ubuntu 18.04, which uses an older version of glibc.

The full thread with Debian is here:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1001774

With regards to CPython, a possible change to consider would be to test if 
tm_isdst < 0 prior to the mktime call, and if that evaluates true to provide an 
error indicating use requires a timezone being set. I think that change would 
make Python's behavior consistent with glibc >= 2.29, and smooth over a 
potential platform dependency, while also providing an informative error 
message. However, I have limited knowledge of how timezones are implemented and 
am unsure if more than "Etc/UTC" would result in tm_isdst being < 0. 

If that change makes sense, I'd be happy to submit a pull request to that 
effect. However, I recognize there may be considerations not accounted for here 
particularly as this is a central module, so I'll hold off issuing a pull 
request until hearing back from on this matter.

--

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



[issue44413] Improvement mktime error reporting

2021-12-20 Thread Daniel McDonald


Daniel McDonald  added the comment:

Sounds good, thank you, Terry

--
type: enhancement -> behavior

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



[issue46168] Incorrect format specified for the "style" key in the configuration file format formatter example

2021-12-23 Thread Daniel Diniz


Daniel Diniz  added the comment:

This example was added in issue 43047. It only seems to affect 3.10+ docs. Ian, 
is this something you'd like to tackle?

--
keywords: +easy
nosy: +ajaksu2, iwienand
stage:  -> needs patch
versions: +Python 3.10, Python 3.11 -Python 3.8

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



[issue504219] locale.resetlocale is broken

2021-12-23 Thread Daniel Diniz


Change by Daniel Diniz :


--
nosy: +ajaksu2
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 2.7, Python 3.3, Python 
3.4

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



[issue46169] Same-moment datetimes with different ZoneInfo timezones are not considered ==

2021-12-23 Thread Daniel Diniz


Daniel Diniz  added the comment:

Confirmed for 3.11 in Windows. 

The C datetime code can be trivially fixed so your equality test returns True, 
but there are two Python tests that depend on current behavior so it might not 
be so easy. They were added with current code in issue 24773, to implement PEP 
495 -- Local Time Disambiguation.

Also, using a timezone implementation from the test suite makes the equality 
work, so maybe the bug depends on zoneinfo.

If you change datetimemodule.c line 5761 from "diff = 1;" to "diff = 0;", two 
tests fail and your code works.

See attached file for the tests that fail and using the timezone implementation 
mentioned above.

--
nosy: +ajaksu2
Added file: https://bugs.python.org/file50517/dt_equality.py

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



[issue46169] Same-moment datetimes with different ZoneInfo timezones are not considered ==

2021-12-24 Thread Daniel Diniz


Change by Daniel Diniz :


--
nosy: +belopolsky

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



[issue978604] wait_variable hangs at exit

2021-12-25 Thread Daniel Diniz


Daniel Diniz  added the comment:

Confirmed on Python 3.11.0a3+, assuming older versions also affected. This 
issue has different versions of tests to confirm it, but I think not in a test 
suite-friendly format yet.

There's also a patch and detailed analysis by gpolo indicating that it might 
need editing _tkinter.c to handle fallout from his proposed Python-side patch.

--
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 2.7, Python 3.2, Python 
3.3

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



[issue1438480] shutil.move raises OSError when copystat fails

2021-12-26 Thread Daniel Diniz


Change by Daniel Diniz :


--
keywords:  -easy
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 3.3

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



[issue14844] netrc does not handle accentuated characters

2021-12-26 Thread Daniel Diniz


Daniel Diniz  added the comment:

Now that a PR has landed in #28806 to improve shlex, we need to check whether 
this issue can/needs to move forward.

--
nosy: +ajaksu2, asvetlov
type:  -> behavior
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 3.2

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



[issue7687] Bluetooth support untested

2021-12-26 Thread Daniel Diniz


Change by Daniel Diniz :


--
versions: +Python 3.10, Python 3.11

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



[issue25044] bring BTPROTO_SCO inline with other Bluetooth protocols

2021-12-26 Thread Daniel Diniz


Change by Daniel Diniz :


--
versions: +Python 3.11 -Python 3.4, Python 3.5, Python 3.6

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



[issue22833] The decode_header() function decodes raw part to bytes or str, depending on encoded part

2021-12-30 Thread Daniel Lenski

Daniel Lenski  added the comment:

I recently ran into this bug as well.

For those looking for a reliable workaround, here's an implementation of a 
'decode_header_to_string' function which should Just Work™ in all possible 
cases:

#!/usr/bin/python3
import email.header

# Workaround for https://bugs.python.org/issue22833
def decode_header_to_string(header):
'''Decodes an email message header (possibly RFC2047-encoded)
into a string, while working around 
https://bugs.python.org/issue22833'''

return ''.join(
alleged_string if isinstance(alleged_string, str) else 
alleged_string.decode(
alleged_charset or 'ascii')
for alleged_string, alleged_charset in 
email.header.decode_header(header))


for header in ('=?utf-8?B?ZsOzbw==',
   '=?ascii?Q?hello?==?utf-8?B?ZsOzbw==?=',
   'bar=?ascii?Q?hello?==?utf-8?B?ZsOzbw==?=',
   'plain string',):
print("Header value: %r" % header)
print("email.header.decode_header(...) -> %r" % 
email.header.decode_header(header))
print("decode_header_to_string(...)-> %r" % 
decode_header_to_string(header))
print("---")

Outputs:

Header value: '=?utf-8?B?ZsOzbw=='
email.header.decode_header(...) -> [('=?utf-8?B?ZsOzbw==', None)]
decode_header_to_string(...)-> '=?utf-8?B?ZsOzbw=='
---
Header value: '=?ascii?Q?hello?==?utf-8?B?ZsOzbw==?='
email.header.decode_header(...) -> [(b'hello', 'ascii'), (b'f\xc3\xb3o', 
'utf-8')]
decode_header_to_string(...)-> 'hellofóo'
---
Header value: 'bar=?ascii?Q?hello?==?utf-8?B?ZsOzbw==?='
email.header.decode_header(...) -> [(b'bar', None), (b'hello', 'ascii'), 
(b'f\xc3\xb3o', 'utf-8')]
decode_header_to_string(...)-> 'barhellofóo'
---
Header value: 'plain string'
email.header.decode_header(...) -> [('plain string', None)]
decode_header_to_string(...)-> 'plain string'
---
Header value: 'foo=?blah?Q??='
email.header.decode_header(...) -> [(b'foo', None), (b'', 'blah')]
decode_header_to_string(...)-> 'foo'
---

--
nosy: +dlenski

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



[issue22833] The decode_header() function decodes raw part to bytes or str, depending on encoded part

2021-12-30 Thread Daniel Lenski


Daniel Lenski  added the comment:

Due to this bug, any user of this function in Python 3.0+ *already* has to be 
able to handle all of the following outputs in order to use it reliably:

   decode_header(...) -> [(str, None)]
or decode_header(...) -> [(bytes, str)]
or decode_header(...) -> [(bytes, (str|None)), (bytes, (str|None)), ...]

== Fix str/bytes inconsistency ==

We could eliminate the inconsistency, and make the function only ever return 
bytes instead of str, with the following changes to 
https://github.com/python/cpython/blob/3.10/Lib/email/header.py.

```
diff --git a/Lib/email/header.py.orig b/Lib/email/header.py
index 4ab0032..41e91f2 100644
--- a/Lib/email/header.py
+++ b/Lib/email/header.py
@@ -61,7 +61,7 @@ _max_append = email.quoprimime._max_append
 def decode_header(header):
 """Decode a message header value without converting charset.
 
-Returns a list of (string, charset) pairs containing each of the decoded
+Returns a list of (bytes, charset) pairs containing each of the decoded
 parts of the header.  Charset is None for non-encoded parts of the header,
 otherwise a lower-case string containing the name of the character set
 specified in the encoded string.
@@ -78,7 +78,7 @@ def decode_header(header):
 for string, charset in header._chunks]
 # If no encoding, just return the header with no charset.
 if not ecre.search(header):
-return [(header, None)]
+return [header.encode(), None)]
 # First step is to parse all the encoded parts into triplets of the form
 # (encoded_string, encoding, charset).  For unencoded strings, the last
 # two parts will be None.
```

With these changes, decode_header() would return one of the following:

   decode_header(...) -> [(bytes, None)]
or decode_header(...) -> [(bytes, str)]
or decode_header(...) -> [(bytes, (str|None)), (bytes, (str|None)), ...]


== Ensure that charset is always str, never None ==

A couple more small changes:

```
@@ -92,7 +92,7 @@ def decode_header(header):
 unencoded = unencoded.lstrip()
 first = False
 if unencoded:
-words.append((unencoded, None, None))
+words.append((unencoded, None, 'ascii'))
 if parts:
 charset = parts.pop(0).lower()
 encoding = parts.pop(0).lower()
@@ -133,7 +133,8 @@ def decode_header(header):
 # Now convert all words to bytes and collapse consecutive runs of
 # similarly encoded words.
 collapsed = []
-last_word = last_charset = None
+last_word = None
+last_charset = 'ascii'
 for word, charset in decoded_words:
 if isinstance(word, str):
 word = bytes(word, 'raw-unicode-escape')
```

With these changes, decode_header() would return only:

   decode_header(...) -> List[(bytes, str)]

--

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



[issue46236] PyFunction_GetAnnotations returning Tuple vs Dict

2022-01-02 Thread Daniel McCarney


New submission from Daniel McCarney :

Hi there,

This is my first Python bug, hope I haven't missed anything important.

I noticed that the PyFunction_GetAnnotations function from the C API is 
returning a PyTuple when I link Python 3.10 where historically it returned a 
PyDict.

The documentation for PyFunction_GetAnnotations for 3.10 (here[0]) says its 
return can be:
> a mutable dictionary or NULL

I'm not sure if:
* This is user error and I should adapt to this case in my dependent code when 
using Python 3.10+.
* This is a documentation error, and it should say "a mutable dictionary, set, 
or NULL"
* This is a regression in the C API that should be fixed.

I've made a small reproduction program (here[1]) that can be used to quickly 
demonstrate the difference in return type between the two Python versions for 
the same C program and .py inputs.

I also noticed that issue42202 (here[2]) landed an optimization in 3.10.x that 
changed the internal representation of annotations to a set - could that 
possibly be related? I'm not 100% sure!

Thanks!

[0]: https://docs.python.org/3/c-api/function.html#c.PyFunction_GetAnnotations
[1]: https://github.com/cpu/pyfunction_getannotations_test
[2]: https://bugs.python.org/issue42202

--
components: C API
messages: 409555
nosy: cpu
priority: normal
severity: normal
status: open
title: PyFunction_GetAnnotations returning Tuple vs Dict
versions: Python 3.10

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



[issue22833] The decode_header() function decodes raw part to bytes or str, depending on encoded part

2022-01-11 Thread Daniel Lenski


Change by Daniel Lenski :


--
keywords: +patch
pull_requests: +28748
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/30548

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



[issue32912] Raise non-silent warning for invalid escape sequences

2022-01-13 Thread Daniel Carpenter


Daniel Carpenter  added the comment:

I'm not sure if this is an issue or by design, but this DeprecationWarning 
behaves differently to other DeprecationWarnings.

A normal DeprecationWarning triggered by code in __main__ is printed by default:

$ python -c 'import warnings; warnings.warn("test", DeprecationWarning)'
:1: DeprecationWarning: test

But this one is silent:

$ python -c '"\,"'
[no output]

To see this DeprecationWarning at all, I need to type:

$ python -Wdefault -c '"\,"'
:1: DeprecationWarning: invalid escape sequence '\,'

But that enables this DeprecationWarning for all modules, not just __main__ .

I've tested this with Python 3.9 on debian bullseye and the 3.10 docker image.

--
nosy: +dansebcar

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



[issue46440] ArgumentParser.parse_args exits on missing required argument with exit_on_error=False

2022-01-19 Thread Daniel Schulte


New submission from Daniel Schulte :

When calling ArgumentParser.parse_args(list_of_things_to_parse) sys.exit gets 
called even though the parser was constructed with exit_on_error=False. It 
doesn't matter if the parser has any subparsers added or not.

The docs say
> Normally, when you pass an invalid argument list to the parse_args() 
> method of an ArgumentParser, it will exit with error info.

> If the user would like to catch errors manually, the feature can be 
> enabled by setting exit_on_error to False:
> [example code follows]

The docs make me believe what I'm trying to do should work.
I've attached a minimal working example to show what happens (with and without 
subparsers).

--
components: Library (Lib)
files: bug.py
messages: 410984
nosy: trilader
priority: normal
severity: normal
status: open
title: ArgumentParser.parse_args exits on missing required argument with 
exit_on_error=False
type: behavior
versions: Python 3.10
Added file: https://bugs.python.org/file50567/bug.py

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



[issue1108] Problem with doctest and decorated functions

2007-09-05 Thread Daniel Larsson

New submission from Daniel Larsson:

Seems like doctest won't recognize functions inside the module under
test are actually in that module, if the function is decorated by a
decorator that wraps the function in an externally defined function,
such as in this silly example:

# decorator.py
import functools

def simplelog(f):
@functools.wraps(f)
def new_f(*args, **kwds):
print "Wrapper calling func"
return f(*args, **kwds)
return new_f

# test.py
from decorator import simplelog

@simplelog
def test():
"""
This test should fail, since the decorator prints output.
Seems I don't get called though
>>> test()
'works!'
"""
return "works!"

if __name__ == '__main__':
import doctest
doctest.testmod()

--

The problem lies in DocTestFinder._from_module, which checks if the
function's func_globals attribute is the same as the module's __dict__
attribute.

I'd propose to do the __module__/inspect.getmodule() checks (aren't they
 both checking the same thing btw?) before the inspect.isfunction check.

--
components: Library (Lib)
messages: 55660
nosy: danilo
severity: normal
status: open
title: Problem with doctest and decorated functions
type: behavior
versions: Python 2.5

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1108>
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1108] Problem with doctest and decorated functions

2007-09-06 Thread Daniel Larsson

Daniel Larsson added the comment:

Here's a patch that alters the order of checks in DocTestFinder._from_module

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1108>
__--- doctest.py.orig	2007-09-05 17:14:55.0 +0200
+++ doctest.py	2007-09-05 17:10:23.0 +0200
@@ -835,12 +835,12 @@
 """
 if module is None:
 return True
+elif inspect.getmodule(object) is not None:
+return module is inspect.getmodule(object)
 elif inspect.isfunction(object):
 return module.__dict__ is object.func_globals
 elif inspect.isclass(object):
 return module.__name__ == object.__module__
-elif inspect.getmodule(object) is not None:
-return module is inspect.getmodule(object)
 elif hasattr(object, '__module__'):
 return module.__name__ == object.__module__
 elif isinstance(object, property):
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1312] doctest EXCEPTION_RE can't handle preceding output

2007-10-22 Thread Daniel Nouri

New submission from Daniel Nouri:

doctest.DocTestParser._EXCEPTION_RE does not allow for output before the
actual traceback.

Attached is a simple test that demonstrates the problem.  This patch
fixes it:

--- /usr/lib/python2.5/doctest.py 2007-10-22 21:45:21.0 +0200
+++ /home/daniel/tmp/doctest.py   2007-10-22 22:19:12.0 +0200
@@ -513,7 +513,7 @@
 _EXCEPTION_RE = re.compile(r"""
 # Grab the traceback header.  Different versions of Python have
 # said different things on the first traceback line.
-^(?P Traceback\ \(
+.*^(?P Traceback\ \(
 (?: most\ recent\ call\ last
 |   innermost\ last
 ) \) :


_EXCEPTION_RE = re.compile(r"""
# Grab the traceback header.  Different versions of Python have
# said different things on the first traceback line.
^(?P Traceback\ \(
(?: most\ recent\ call\ last
|   innermost\ last
) \) :
)
\s* $# toss trailing whitespace on the header.
(?P .*?)  # don't blink: absorb stuff until...
^ (?P \w+ .*)   # a line *starts* with alphanum.
""", re.VERBOSE | re.MULTILINE | re.DOTALL)

--
components: Library (Lib)
files: doctest-bug.py
messages: 56655
nosy: nouri
severity: normal
status: open
title: doctest EXCEPTION_RE can't handle preceding output
versions: Python 2.5
Added file: http://bugs.python.org/file8591/doctest-bug.py

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1312>
__def f():
"""
  >>> f() # doctest: +ELLIPSIS
  Hello, World!
  Traceback (most recent call last):
  ...
  ValueError: foo
"""
print "Hello, World!"
raise ValueError("foo")

def _test():
import doctest
doctest.testmod()

if __name__ == "__main__":
_test()
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8654] Improve ABI compatibility between UCS2 and UCS4 builds

2011-09-29 Thread Daniel Stutzbach

Daniel Stutzbach  added the comment:

Gladly. :-)

--
resolution:  -> out of date
stage: patch review -> committed/rejected
status: open -> closed

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



[issue13062] Introspection generator and function closure state

2011-09-30 Thread Daniel Urban

Changes by Daniel Urban :


--
nosy: +durban

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



[issue13264] Monkeypatching using metaclass

2011-10-25 Thread Daniel Urban

Changes by Daniel Urban :


--
nosy: +durban

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



[issue13264] Monkeypatching using metaclass

2011-10-25 Thread Daniel Urban

Daniel Urban  added the comment:

> class Meta(ABCMeta):
> def __instancecheck__(cls, instance):
> # monkeypatching class method
> cls.__subclasscheck__ = super(Meta, cls).__subclasscheck__

This line is approximately the same as:
cls.__dict__['__subclasscheck__'] = ...
So it will put the object in the namespace of cls. The function in the 
namespace of type(cls) will remain there. (Also, the object you put in there is 
a bound method, so this is probably not what you want.)


> return super(Meta, cls).__instancecheck__(instance)
> 
> def __subclasscheck__(cls, sub):
> return cls in sub.mro()
> 
> class A(object):
> __metaclass__ = Meta
> 
> class B(object): pass
> 
> # registering class 'B' as a virtual subclass of 'A'
> A.register(B)
> 
> >>> issubclass(B, A)
> False
> >>> isinstance(B(), A) # => method __subclasscheck__ is now
> monkeypatched

A.__dict__['__subclasscheck__'] is now indeed the other method you put in 
there, but issubclass will call  type(A).__dict__['__subclasscheck__'] which 
remain the same. (Because __special__ methods a looked up directly in the 
namespace of the type of an object, see 
http://docs.python.org/dev/py3k/reference/datamodel#special-lookup).

--

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



[issue13266] Add inspect.unwrap(f) to easily unravel "__wrapped__" chains

2011-10-26 Thread Daniel Urban

Changes by Daniel Urban :


--
nosy: +durban

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



[issue13264] Monkeypatching using metaclass

2011-11-12 Thread Daniel Urban

Daniel Urban  added the comment:

> It seems to me this is not a bug.

+1

--

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



[issue13496] bisect module: Overflow at index computation

2011-11-28 Thread Daniel Sturm

New submission from Daniel Sturm :

The mid index computation in _bisectmodule.c in both internal_bisect_right and 
internal_bisect_left is done with:

mid = (lo + hi) / 2; // all three variables Py_ssize_t

which is  susceptible to overflows for large arrays, which would lead to 
undefined behavior (and in practice almost certainly a crash with a negative 
index)

The fix is trivial - mid = lo + (hi - lo) / 2; - but since I'm just starting to 
look into the code base I may be missing some undocumented assertions that 
guarantee this can't happen.

--
components: Extension Modules
messages: 148517
nosy: Voo
priority: normal
severity: normal
status: open
title: bisect module: Overflow at index computation
type: behavior
versions: Python 3.4

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



[issue13496] bisect module: Overflow at index computation

2011-11-28 Thread Daniel Sturm

Daniel Sturm  added the comment:

TBH I saw this more as an opportunity to get used to the whole system, how to 
create a patch, etc. :) Should've made it clearer at the start that this is 
unlikely to ever be a problem, sorry (didn't see a way to set priority to low 
myself).


If my math isn't completely off, the highest possible value here is 
hi + (hi - 1) so this only occurs if hi > (MAX_SSIZE_T + 1) / 2. So this would 
only work out if we had such an array containing only a handful different 
objects. And then that's me assuming that a list is actually a thin wrapper 
around an array of PyObject*.

--

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



[issue13742] Add a key parameter (like sorted) to heapq.merge

2012-01-09 Thread Daniel Stutzbach

Changes by Daniel Stutzbach :


--
nosy: +stutzbach

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



[issue8777] Add threading.Barrier

2011-05-26 Thread Daniel Stutzbach

Changes by Daniel Stutzbach :


--
stage:  -> committed/rejected

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



[issue12192] Doc that collection mutation methods return item or None

2011-05-27 Thread Daniel Stutzbach

Daniel Stutzbach  added the comment:

> Comment: This rule applies to special methods like __getitem__
> and __setitem__. 'lis.append(item)' is equivalent to
> lis.__setitem__(len(lis):len(lis), item), so it should not be so
> surprising that it has the same return.

It's not true for all special methods.  __iadd__ and __imul__ return the list 
itself.

That's a minor nitpick though.  +1 on adding "and return None" to the 
docstrings of methods that often trip people up.  Not everyone will read them, 
but some people will.

--
nosy: +stutzbach

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



[issue11610] Improved support for abstract base classes with descriptors

2011-06-11 Thread Daniel Urban

Daniel Urban  added the comment:

It doesn't work with staticmethod:

>>> import abc
>>> 
>>> class C(metaclass=abc.ABCMeta):
... @staticmethod
... @abc.abstractmethod
... def foo(x):
... raise NotImplementedError()
... 
>>> class D(C):
... @staticmethod
... def foo(x):
... return x + 1
... 
>>> D()
Traceback (most recent call last):
  File "", line 1, in 
TypeError: Can't instantiate abstract class D with abstract methods foo.__func__
>>>

--

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



[issue12345] Add math.tau

2011-06-17 Thread Daniel Stutzbach

Daniel Stutzbach  added the comment:

On Wed, Jun 15, 2011 at 8:10 PM, Nick Coghlan wrote:

> I'd like to add a new constant to the math module:
>
>  tau = 2*math.pi
>
> Rather than repeating all the reasons for why tau makes more sense than pi
> as the fundamental circle constant, I'll just refer interested readers to
> http://tauday.com/

(The following is best if read aloud using your best pirate impression)

I'd rather name the new constant "matey".  Then we have:

The circumference of a circle is: r matey
The area of a circle is: one-quarter r r matey
etc.

--
nosy: +stutzbach
Added file: http://bugs.python.org/file22397/unnamed

___
Python tracker 
<http://bugs.python.org/issue12345>
___On Wed, Jun 15, 2011 at 8:10 PM, Nick Coghlan <mailto:rep...@bugs.python.org";>rep...@bugs.python.org> 
wrote:
I'd like to add a new constant to the math module:

  tau = 2*math.pi

Rather than repeating all the reasons for why tau makes more sense than pi as 
the fundamental circle constant, I'll just refer interested readers to http://tauday.com/"; target="_blank">http://tauday.com/
(The following is best if read aloud using your best pirate 
impression)I'd rather name the new constant 
"matey".  Then we have:The 
circumference of a circle is: r matey
The area of a circle is: one-quarter r r 
mateyetc.-- Daniel Stutzbach
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11610] Improved support for abstract base classes with descriptors

2011-06-20 Thread Daniel Urban

Daniel Urban  added the comment:

I've posted some comments on Rietveld.

--

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



[issue12374] Execution model should explain compile vs definition vs execution time

2011-06-24 Thread Daniel Urban

Changes by Daniel Urban :


--
nosy: +durban

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



[issue12459] time.sleep(-1.0) behaviour

2011-07-01 Thread Daniel Urban

Changes by Daniel Urban :


--
nosy: +durban

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



[issue12457] type() returns incorrect type for nested classes

2011-07-01 Thread Daniel Urban

Changes by Daniel Urban :


--
nosy: +durban

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



[issue8639] Allow callable objects in inspect.getargspec

2011-07-09 Thread Daniel Urban

Changes by Daniel Urban :


--
nosy: +durban

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



[issue12559] gzip.open() needs an optional encoding argument

2011-07-14 Thread Daniel Urban

Daniel Urban  added the comment:

Here is a patch. If the code changes are acceptable I can also make a 
documentation patch.

(I'm surprised to see 3.2 in "Versions". I thought 3.2 only gets bugfixes...)

--
keywords: +patch
nosy: +durban
Added file: http://bugs.python.org/file22661/issue12559.patch

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



[issue12559] gzip.open() needs an optional encoding argument

2011-07-15 Thread Daniel Urban

Daniel Urban  added the comment:

> If we go this way, the "errors" and "newline" argument should be added
> as well.

Yeah, I thought about that. I can make a new patch, that implement this, if 
needed. Though it seems there is a real problem, the one that Amaury Forgeot 
d'Arc mentioned. I can't think of a way to solve it in a backwards compatible 
way.

--

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



[issue12575] add a AST validator

2011-07-16 Thread Daniel Urban

Changes by Daniel Urban :


--
nosy: +durban

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



[issue12434] Strengthen 2.7 io types warning

2011-07-18 Thread Daniel Stutzbach

Daniel Stutzbach  added the comment:

On Sat, Jul 16, 2011 at 2:04 AM, Eli Bendersky wrote:

> Therefore, I propose to change this error message to:
>  "unicode argument expected, got '%s'"
>  as Terry suggested.
>

Sounds good to me.

--
Added file: http://bugs.python.org/file22687/unnamed

___
Python tracker 
<http://bugs.python.org/issue12434>
___On Sat, Jul 16, 2011 at 2:04 AM, Eli Bendersky <mailto:rep...@bugs.python.org";>rep...@bugs.python.org> 
wrote:
Therefore, I propose to change this error message to:
 "unicode argument expected, got '%s'"
 as Terry suggested.Sounds good to 
me. -- Daniel Stutzbach
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12608] crash in PyAST_Compile when running Python code

2011-07-22 Thread Daniel Urban

Changes by Daniel Urban :


--
nosy: +durban

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



[issue12599] Use 'is not None' where appropriate in importlib

2011-07-22 Thread Daniel Urban

Changes by Daniel Urban :


--
nosy: +durban

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



[issue12617] Mutable Sequence Type can work not only with iterable in slice[i:j] = t

2011-07-23 Thread Daniel Urban

Changes by Daniel Urban :


--
nosy: +durban

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



[issue12647] Add __bool__ to None

2011-07-28 Thread Daniel Urban

Changes by Daniel Urban :


--
nosy: +durban

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



[issue12657] Cannot override JSON encoding of basic type subclasses

2011-07-30 Thread Daniel Urban

Changes by Daniel Urban :


--
nosy: +durban

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



[issue11640] Shelve references globals in its __del__ method

2011-08-01 Thread Daniel Stutzbach

Daniel Stutzbach  added the comment:

Could you add a comment above the lines defining self._BytesIO, describing why 
they're being set?  Someone else might see them as unnecessary and rip them out 
if there's no explanation.

Can a test launch Python in a subprocess, set up the appropriate data 
structure, let the subprocess Python shutdown, then check the subprocess's 
stderr for the error?

It's a little convoluted, but perhaps it could be built into a general utility 
function that could be used to test __del__ methods in other modules, too.

Not sure that it's worth the effort though.

--

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



[issue12612] Valgrind suppressions

2011-08-01 Thread Daniel Stutzbach

Changes by Daniel Stutzbach :


--
nosy: +stutzbach

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



  1   2   3   4   5   6   7   8   9   10   >