[issue43028] seeking past the end of a file unexpected behavior

2021-01-25 Thread Cotton Seed


Cotton Seed  added the comment:

Christian, thanks for the quick response and the clarification. I understand my 
mistake now.  Thanks!

--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue43028] seeking past the end of a file unexpected behavior

2021-01-25 Thread Christian Heimes


Christian Heimes  added the comment:

The high level and low level variants behave the same if you pass in the same 
flags. You are using the append flag in "open()", but you don't pass the 
os.O_APPEND flag to "os.open()".

>>> import os
>>> fd = os.open('log', os.O_WRONLY | os.O_APPEND | os.O_CREAT)
>>> os.lseek(fd, 1, os.SEEK_SET)
1
>>> os.write(fd, b'foo')
3
>>> os.close(fd)
>>> os.stat('log').st_size
3

>>> fd = os.open('log2', os.O_WRONLY | os.O_CREAT)
>>> os.lseek(fd, 1, os.SEEK_SET)
1
>>> os.write(fd, b'foo')
3
>>> os.close(fd)
>>> os.stat('log2').st_size
4

--
nosy: +christian.heimes

___
Python tracker 

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



[issue43028] seeking past the end of a file unexpected behavior

2021-01-25 Thread Cotton Seed


New submission from Cotton Seed :

Seeking past the end of a file with file objects does not match the same code 
implemented in terms of file descriptors.  Is this the intended behavior?

Smallest example I could find:

f = open('new_file', 'ab')
print(f.seek(1))
print(f.write(b'foo'))
print(f.tell())
f.close()

This program outputs: 1, 3, 4 as expected, but only creates a 3-byte file:

and creates a 3-byte file:
$ hexdump -C new_file
  66 6f 6f  |foo|
0003

If I use open(..., buffering=0), or flush before the tell, it outputs: 1, 3, 3.

The obvious code with file descriptors:

fd = os.open('log', os.O_WRONLY | os.O_CREAT)
print(os.lseek(fd, 1, os.SEEK_SET))
os.write(fd, b'foo')
os.close(fd)

works as expected, creating a 4-byte file.

Could this be related this issue:

https://bugs.python.org/issue36411

?

--
components: IO
messages: 385692
nosy: cotton.seed
priority: normal
severity: normal
status: open
title: seeking past the end of a file unexpected behavior
versions: Python 3.7, Python 3.8

___
Python tracker 

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



[issue42973] argparse: mixing optional and positional arguments... not again

2021-01-25 Thread Glenn Linderman


Glenn Linderman  added the comment:

for more helpful  => far more helpful

--

___
Python tracker 

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



[issue42973] argparse: mixing optional and positional arguments... not again

2021-01-25 Thread Glenn Linderman


Glenn Linderman  added the comment:

OK, I think I see what you are doing here. Thanks for your responses.

And probably it is the bare-bones minimum feature that allows 
user-implementation of "as complex as desired" combinations of optionals and 
context-sensitive positionals.

In the docs fruits example, though, I think the input and output are 
inconsistent: you have a brown banana reported as yellow?

I guess I could think of enhancements to simplify common cases. For example, 
each positional might want to track/save values for some number of optionals. 
So one could write custom code to do that, like your fruit basket, or one could 
imagine a canned approach, where the list of optionals was passed as a 
parameter when defining the positionals.  This could be built as a wrapper for 
add_argument, that would call a more general version of the AddFruit Action.  
Perhaps a special parameter could also indicate saving the values of all 
optionals at the point of parsing the positional, giving each positional a 
complete set of optionals that apply.

Your feature of having the optional apply to only one positional would be a 
harder thing, especially if you wanted to have both kinds of optionals: that 
apply to the next positional, or that apply to all following positionals. But 
hmm.  Maybe not much harder: just have two lists of optionals passed to the 
positional: a list of each kind.

Does the namespace still contain the default value for an optional after it has 
been used?  It looks like it might, so your fruit example could be reduced to 
not needing the DEFAULT_COLOR variable, but rather change references to it to 
use 

  self._get_default_metavar_for_positional(action) 

?  That avoids using a global variable, and is for more helpful for the "list 
of optionals to be reset on each use" rather than re-creating the more complex 
data structure required to hold all the defaults.

I'm not sure how that plays with optionals that use append or append_const 
storage methods, nor do I fully understand the comment in "def 
_copy_items(items):"

I think if you could avoid the global variable, your implementation would be 
stronger. And if you provide, either as a sample subclass, or argparse new 
feature, the ability to do the things I mention here, it would be even 
stronger, as it would allow the user to deal with the more powerful 
capabilities without needing as much understanding of argparse internals.

--

___
Python tracker 

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



[issue43027] Calling _PyBytes_Resize() on 1-byte bytes may raise error

2021-01-25 Thread Ma Lin

New submission from Ma Lin :

PyBytes_FromStringAndSize() uses a global cache for 1-byte bytes:
https://github.com/python/cpython/blob/v3.10.0a4/Objects/bytesobject.c#L147

if (size == 1 && str != NULL) {
struct _Py_bytes_state *state = get_bytes_state();
op = state->characters[*str & UCHAR_MAX];
if (op != NULL) {
Py_INCREF(op);
return (PyObject *)op;
}
}

_PyBytes_Resize() will raise an error when (refcount != 1):
https://github.com/python/cpython/blob/v3.10.0a4/Objects/bytesobject.c#L3029

Then this code will raise an exception:

obj1 = PyBytes_FromStringAndSize("a", 1);
obj2 = PyBytes_FromStringAndSize("a", 1);
ret = _PyBytes_Resize(, 2);  // ret is -1

BTW, 0-byte bytes comes from a global singleton, but _PyBytes_Resize() 
processes it before checking refcount:
https://github.com/python/cpython/blob/v3.10.0a4/Objects/bytesobject.c#L3021

if (Py_SIZE(v) == 0) {
if (newsize == 0) {
return 0;
}
*pv = _PyBytes_FromSize(newsize, 0);
Py_DECREF(v);
return (*pv == NULL) ? -1 : 0;
}
if (Py_REFCNT(v) != 1) {
goto error;
}

_PyBytes_Resize() doc:

Only use this to build up a brand new bytes object; don’t use this if the
bytes may already be known in other parts of the code. It is an error to
call this function if the refcount on the input bytes object is not one.

--
components: Interpreter Core
messages: 385689
nosy: malin
priority: normal
severity: normal
status: open
title: Calling _PyBytes_Resize() on 1-byte bytes may raise error
type: behavior
versions: Python 3.10, Python 3.8, Python 3.9

___
Python tracker 

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



[issue41962] Make threading._register_atexit public?

2021-01-25 Thread Ben Darnell


Ben Darnell  added the comment:

I have resolved my issue here by moving from ThreadPoolExecutor to a plain 
threading.Thread that I manage by hand 
(https://github.com/tornadoweb/tornado/commit/15832bc423c33c9280564770046dd6918f3a31b4).
 Therefore I no longer need this for myself and I leave it up to you to decide 
whether there's anything worth doing at this point.

--

___
Python tracker 

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



[issue43015] Add str.replaceall?

2021-01-25 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

Versions 3.6-3.9 are all in feature-freeze, so the earliest this could be added 
is version 3.10.

--
nosy: +steven.daprano
versions:  -Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



[issue43026] Missing words renders meaning unclear in fcntl.html

2021-01-25 Thread Ezra


Change by Ezra :


--
versions: +Python 3.10

___
Python tracker 

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



[issue43025] Use normal 'i' character to denote imaginary part of complex numbers

2021-01-25 Thread Eric V. Smith


Eric V. Smith  added the comment:

Good point on surveying other languages for a PEP. You're further along in your 
thinking than I am!

--

___
Python tracker 

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



[issue43025] Use normal 'i' character to denote imaginary part of complex numbers

2021-01-25 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

I think it always helps to look at what other languages do. It doesn't 
mean that we must follow them, but it may help us decide that the choice 
made in Python 1 was a mistake and it is worth going through the pain of 
deprecation, or that it is still justified and we should stick to the 
current design. If everyone else is making a different decision, it pays 
to at least consider why. If they're making the same decision we did, 
that helps justify what we did.

For what it's worth, although my personal preference would be for i, I 
think that going through a disruptive deprecation period is not 
justified. j is good enough. I haven't got an opinion on supporting both 
i and j.

Eric, if you do follow through with writing a PEP, remember that you 
have to make the best case that you can for the change. And you might be 
surprised: when Guido volunteered me to write the dict addition PEP, I 
initially intended it to be rejected. I never expected that it would be 
accepted with a change of operator.

--

___
Python tracker 

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



[issue42973] argparse: mixing optional and positional arguments... not again

2021-01-25 Thread Tadek Kijkowski


Tadek Kijkowski  added the comment:

This is, I think, smallest functional example for matching optional parameters 
with positionals - fruits.py:

  import argparse
  
  DEFAULT_COLOR="plain"
  
  class AddFruitAction(argparse.Action):
 def __call__(self, parser, namespace, values, option_string=None):
for fruit in values:
   namespace.fruits.append({'name': fruit, 'color': namespace.color})
   namespace.color = DEFAULT_COLOR
  
  def show_fruits(fruits):
 for fruit in fruits:
print(f"{fruit['color']} {fruit['name']}")
  
  parser = argparse.ArgumentParser(greedy=True)
  parser.add_argument('--color', default=DEFAULT_COLOR)
  parser.add_argument('fruits', nargs='*', action=AddFruitAction, default=[])
  args = parser.parse_args()
  show_fruits(args.fruits)

It starts with 'namespace.color' set to 'DEFAULT_COLOR' - 
'default=DEFAULT_COLOR' takes care of that, and with 'namespace.fruits' set to 
empty list - via 'default=[]'.

For each group of positional command-line arguments, AddFruitAction is called 
with one or more fruit names in 'value'. The method iterates over them adding 
series of dicts to the 'fruits' list. The 'namespace.color' is immediately 
reset to default value, because we want the 'color' to apply to one following 
'fruit'. If we wanted the 'color' to apply to all following 'fruits' the action 
class could just leave it alone.

After parsing is done, we get our namespace assigned to args, with list of 
color + fruit name pairs in 'args.fruits'.

--

___
Python tracker 

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



[issue42973] argparse: mixing optional and positional arguments... not again

2021-01-25 Thread Tadek Kijkowski


Tadek Kijkowski  added the comment:

>> Is it up to the special handler of the positional parameter to read and save 
>> the values of the optional parameters specified so far?

Yes, in order to get anything more that just concatenated list of positional 
parameters, one has to provide specialized action class. Basic functionality is 
easy to implement, as you can see in the fruits.py example.

>> ... how are you saving that context?

Entire context is stored in the namespace object. Action class has access to 
all previous parameters via the namespace and it can modify the namespace as 
needed. Standard 'store' action just adds value to the namespace, but 
specialized action can anything.

>> What about the ones unspecified so far?

They are obviously not available for the action processing positional 
parameters preceeding them, but will be present in the resulting namespace and 
can be processed after parsing is done.

>> Can one even read and save the default value?

I'm not sure what do you mean, but it all depend on how action class deals with 
it.

>> And where does it get stored? Is the value of the positional parameter 
>> turned into a dict or class containing its own value + the saved optional 
>> parameters?

It all gets stored in the namespace. Turning positionals + optionals into a 
dict or class seems most reasonable, but it all depends on how action class 
will deal with them.

>> I think I have seen Unix command line programs that had rich semantics 
>> similar to what you are proposing, where the sequence of repeated optional 
>> args could affect handling of later positionals but not earlier ones.

For example 'tar' with '-C' parameter which applies to all files following it.

--

___
Python tracker 

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



[issue43025] Use normal 'i' character to denote imaginary part of complex numbers

2021-01-25 Thread Eric V. Smith


Eric V. Smith  added the comment:

I don't think it really matters what other languages do. We're not designing 
this from scratch. We need to reflect that state we're in, which is many, many 
lines of working code using 'j'. I see the two options as: support 'i' and 'j', 
or break existing code and switch to 'i'. I don't think either option makes 
sense.

--
title: Use normal 'i -> Use normal 'i' character to denote imaginary part of 
complex numbers

___
Python tracker 

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



[issue43025] Use normal 'i

2021-01-25 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

https://mathworld.wolfram.com/j.html

D and SmartBASIC use a literal suffix "i" for imaginary numbers. I can't 
find any other languages which support literal syntax for complex 
numbers, but I haven't looked very far.

https://www.researchgate.net/profile/Ken_Hawick/publication/267386724_Notes_on_Complex_Numbers_for_Computer_Scientists/links/54c7474f0cf238bb7d0a5c67/Notes-on-Complex-Numbers-for-Computer-Scientists.pdf

https://en.wikipedia.org/wiki/Complex_data_type

--
nosy: +steven.daprano
title: Use normal 'i' character to denote imaginary part of complex numbers -> 
Use normal 'i

___
Python tracker 

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



[issue43026] Missing words renders meaning unclear in fcntl.html

2021-01-25 Thread Ezra


New submission from Ezra :

At https://docs.python.org/3/library/fcntl.html the docs read:

the fcntl module exposes the F_OFD_GETLK, F_OFD_SETLK and F_OFD_SETLKW 
constants, which working with open file description locks.

The exact intended meaning is unclear, perhaps:

the fcntl module exposes the F_OFD_GETLK, F_OFD_SETLK and F_OFD_SETLKW 
constants, which are used for working with open file description locks.

--
assignee: docs@python
components: Documentation
files: meaning_unclear.png
messages: 385680
nosy: EzraBC, docs@python
priority: normal
severity: normal
status: open
title: Missing words renders meaning unclear in fcntl.html
type: behavior
versions: Python 3.9
Added file: https://bugs.python.org/file49766/meaning_unclear.png

___
Python tracker 

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



[issue33387] Simplify bytecodes for try-finally, try-except and with blocks.

2021-01-25 Thread Irit Katriel


Irit Katriel  added the comment:

There's another place that needs to be updated: 
https://docs.python.org/3/library/dis.html#opcode-SETUP_WITH

need to replace WITH_CLEANUP_START by WITH_EXCEPT_START

--

___
Python tracker 

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



[issue33387] Simplify bytecodes for try-finally, try-except and with blocks.

2021-01-25 Thread Irit Katriel


Change by Irit Katriel :


--
status: closed -> open

___
Python tracker 

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



[issue42901] [Enum] move member creation to __set_name__ in order to support __init_subclass__

2021-01-25 Thread Ethan Furman


Change by Ethan Furman :


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

___
Python tracker 

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



[issue42915] enum.Flag ~ bitwise negation is very slow and can't be defined as a Flag value

2021-01-25 Thread Ethan Furman


Ethan Furman  added the comment:

Fixed in 3.10 in issue38250.

Also fixed in my 3rd-party library, aenum 3.0:

   (https://pypi.org/project/aenum/)

--
resolution:  -> wont fix
stage:  -> resolved
status: open -> closed
superseder:  -> enum.Flag should be more set-like
type:  -> behavior

___
Python tracker 

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



[issue33387] Simplify bytecodes for try-finally, try-except and with blocks.

2021-01-25 Thread Irit Katriel


Change by Irit Katriel :


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

___
Python tracker 

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



[issue38250] enum.Flag should be more set-like

2021-01-25 Thread Ethan Furman


Ethan Furman  added the comment:

Thank you to everyone involved.  :-)

To answer the first three points that started this issue:

1. iteration -> each single-bit flag in the entire flag, or a
   combinations of flags, is returned one at a time -- not the
   empty set, not other multi-bit values

2. length is implemented -> `len(Color.BLUE | Color.RED) == 2`

3. subset is implemented as containment checking:
   `Color.BLUE in (Color.RED | Color.BLUE) is True`

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

___
Python tracker 

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



[issue31405] shutil.which doesn't find files without PATHEXT extension on Windows

2021-01-25 Thread Mitchell Young


Mitchell Young  added the comment:

I am struggling with the same issue as Anthony. To provide a more direct 
response to Manjusaka's query:

python -c "import os; print(os.environ.get(\"PATHEXT\", 
\"\").split(os.pathsep))"
['.COM', '.EXE', '.BAT', '.CMD', '.VBS', '.VBE', '.JS', '.JSE', '.WSF', '.WSH', 
'.MSC']

Like Anthony, wondering if this should be it's own issue. Simply supporting 
paths with separators shouldn't, I think, lead to any of the ambiguities of 
matching a file exactly, without PATHEXT treatment.

--
nosy: +mitchelly

___
Python tracker 

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



[issue42369] Reading ZipFile not thread-safe

2021-01-25 Thread Jen Garcia


Change by Jen Garcia :


--
nosy: +cuibonobo

___
Python tracker 

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



[issue42986] pegen parser: Crash on SyntaxError with f-string on Windows

2021-01-25 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
priority: normal -> release blocker

___
Python tracker 

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



[issue42973] argparse: mixing optional and positional arguments... not again

2021-01-25 Thread Glenn Linderman

Glenn Linderman  added the comment:

On 1/25/2021 12:43 PM, Tadek Kijkowski wrote:
> Tadek Kijkowski  added the comment:
>
> I added tests and docs to the PR. How does it look now?
Could you send me the docs privately?

I'm trying to understand what you are suggesting, without reading the code.

I realize that you are trying to apply different values of optional 
parameters to positional parameters... how are you saving that context? 
Is it up to the special handler of the positional parameter to read and  
save the values of the optional parameters specified so far? What about 
the ones unspecified so far? Can one even read and save the default value?

And where does it get stored? Is the value of the positional parameter 
turned into a dict or class containing its own value + the saved 
optional parameters?

I do agree that the even though the parse_intermixed_args was sufficient 
for the use case I had at the time, and has been sufficient for me so 
far, that it  not fully flexible, and I think I have seen Unix command 
line programs that had rich semantics similar to what you are proposing, 
where the sequence of repeated optional args could affect handling of 
later positionals but not earlier ones.

So I applaud your efforts here, but simply reading the issue, and having 
forgotten most of the internal workings of argument parser since getting 
the compromise going, I think reading your docs would help clarify it 
for me.

--

___
Python tracker 

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



[issue2636] Adding a new regex module (compatible with re)

2021-01-25 Thread STINNER Victor


STINNER Victor  added the comment:

It's now a third party project: https://pypi.org/project/regex/

If someone wants to move it into the Python stdlib, I suggest to start on the 
python-ideas list first.

I close the issue as REJECTED.

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

___
Python tracker 

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



[issue43022] Unable to dynamically load functions from python3.dll

2021-01-25 Thread Paul Moore


Paul Moore  added the comment:

> PathAllocCombine() is Windows 8+, so sample code that uses it would only be 
> for Python 3.9+.

Yeah, I'm probably going to remove that. I mainly used it because I'm *so* 
spoiled by Python, writing code in C where I have to actually implement stuff 
for myself rather than just using a stdlib function, just feels so tiresome 
these days :-)

Thanks for the other suggestions.

--

___
Python tracker 

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



[issue38250] enum.Flag should be more set-like

2021-01-25 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset 7aaeb2a3d682ecba125c33511e4b4796021d2f82 by Ethan Furman in 
branch 'master':
bpo-38250: [Enum] single-bit flags are canonical (GH-24215)
https://github.com/python/cpython/commit/7aaeb2a3d682ecba125c33511e4b4796021d2f82


--

___
Python tracker 

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



[issue42955] Add sys.stdlib_module_names: list of stdlib module names (Python and extension modules)

2021-01-25 Thread STINNER Victor


STINNER Victor  added the comment:

Update: attribute renamed to sys.stdlib_module_names.

--
title: Add sys.module_names: list of stdlib module names (Python and extension 
modules) -> Add sys.stdlib_module_names: list of stdlib module names (Python 
and extension modules)

___
Python tracker 

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



[issue42955] Add sys.module_names: list of stdlib module names (Python and extension modules)

2021-01-25 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 9852cb38112a4f8d11e26c3423643ea994d5a14f by Victor Stinner in 
branch 'master':
bpo-42955: Rename module_names to sys.stdlib_module_names (GH-24332)
https://github.com/python/cpython/commit/9852cb38112a4f8d11e26c3423643ea994d5a14f


--

___
Python tracker 

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



[issue43022] Unable to dynamically load functions from python3.dll

2021-01-25 Thread Eryk Sun


Eryk Sun  added the comment:

> uses a code snippet like this.

PathAllocCombine() is Windows 8+, so sample code that uses it would only be for 
Python 3.9+.

I'd prefer the function pointer to be returned as an out parameter, and return 
an HRESULT status as the result. If LoadLibraryExW() or GetProcAddress() fails, 
map the error code via HRESULT_FROM_WIN32(GetLastError()). And log to stderr 
instead of exiting with an error() call.

--

___
Python tracker 

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



[issue43022] Unable to dynamically load functions from python3.dll

2021-01-25 Thread Paul Moore


Paul Moore  added the comment:

> I think here you're in a very small minority who could get away with this, 
> and so I'd hesitate to make it sound like the recommended approach.

Well, the evidence here is that maybe even I shouldn't be doing this :-)

> What I'd actually recommend (on Windows) is to bundle a copy of Python with 
> your application.

That's actually precisely what I'm doing. But I don't exactly have an 
"application", in the sense that I suspect you mean, which is the difficulty.

I'm trying to address the problem that it's a real pain to ship Python scripts 
as "utilities" on a Windows system. You want such scripts to still be plain 
text, because you typically hack on them a lot. You can't rely on shebangs and 
the launcher, because I continually find that PATHEXT doesn't include ".py" so 
they don't run properly, and "py name_of_script.py" doesn't do path searches. 
And anyway, I don't want to run the scripts with my system Python, because I 
don't want to dump all my dependencies in there.

So what I have is a small stub, that looks for a .py file of the same name, 
alongside the executable (so myutil.exe looks for myutil.py). Rather than using 
the system Python, it looks for a copy of Python in a subdirectory next to the 
script, and uses that. I can then install dependencies in the dedicated 
interpreter.

(And yes, PEP 582 would help make things easier in this area, too, but it never 
gained enough traction.)

I use the embedded distribution as that interpreter. I may be able to use a 
virtualenv instead, but I've not tried that yet.

Multiple copies of the launcher, one per script, and you're done :-)

To be honest, it really sucks that this is the most reliable way of managing 
small utility scripts in Python on Windows. But every other solution I've tried 
has had its own issues. I'd *much* prefer something standard, but I don't know 
how to bundle this in a way that makes it straightforward for "ordinary" users, 
so I've decided just to solve my own problem and leave it at that :-)

--

___
Python tracker 

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



[issue42384] Inconsistent sys.path between python and pdb

2021-01-25 Thread Guido van Rossum


Guido van Rossum  added the comment:


New changeset c10180ea1458aa0ffd7793cb75629ebffe8a257e by Andrey Bienkowski in 
branch '3.8':
[3.8] bpo-42384: pdb: correctly populate sys.path[0] (GH-23338) (#24320)
https://github.com/python/cpython/commit/c10180ea1458aa0ffd7793cb75629ebffe8a257e


--

___
Python tracker 

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



[issue42384] Inconsistent sys.path between python and pdb

2021-01-25 Thread Guido van Rossum


Guido van Rossum  added the comment:


New changeset f2df7958fb82cd927e17152b3a1bd2823a76dd3e by Andrey Bienkowski in 
branch '3.9':
[3.9] bpo-42384: pdb: correctly populate sys.path[0] (GH-23338) (#24321)
https://github.com/python/cpython/commit/f2df7958fb82cd927e17152b3a1bd2823a76dd3e


--

___
Python tracker 

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



[issue42383] Pdb does not correclty restart the target if it changes the current directory

2021-01-25 Thread Guido van Rossum


Guido van Rossum  added the comment:


New changeset 501d4a51e32c7bbba255598adc307660b5af891a by Andrey Bienkowski in 
branch 'master':
bpo-42383: pdb: do not fail to restart the target if the current directory 
changed (#23412)
https://github.com/python/cpython/commit/501d4a51e32c7bbba255598adc307660b5af891a


--
nosy: +gvanrossum

___
Python tracker 

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



[issue37319] Deprecate using random.randrange() with non-integers

2021-01-25 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue33387] Simplify bytecodes for try-finally, try-except and with blocks.

2021-01-25 Thread Irit Katriel


Irit Katriel  added the comment:

I'm reopening this to delete an obsolete comment left behind.

--
nosy: +iritkatriel
status: closed -> open

___
Python tracker 

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



[issue33387] Simplify bytecodes for try-finally, try-except and with blocks.

2021-01-25 Thread Irit Katriel


Change by Irit Katriel :


--
pull_requests: +23153
stage: resolved -> patch review
pull_request: https://github.com/python/cpython/pull/24334

___
Python tracker 

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



[issue37319] Deprecate using random.randrange() with non-integers

2021-01-25 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset f066bd94b9225a5a3c4ade5fc3ff81e3c49b7b32 by Serhiy Storchaka in 
branch 'master':
bpo-37319: Improve documentation, code and tests of randrange. (GH-19112)
https://github.com/python/cpython/commit/f066bd94b9225a5a3c4ade5fc3ff81e3c49b7b32


--

___
Python tracker 

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



[issue33129] Add kwarg-only option to dataclass

2021-01-25 Thread Paul Bryan


Change by Paul Bryan :


--
nosy: +pbryan

___
Python tracker 

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



[issue43022] Unable to dynamically load functions from python3.dll

2021-01-25 Thread Paul Moore


Paul Moore  added the comment:

Confirmed. The following code works as I want:

Py_Main_t get_pymain(wchar_t *base_dir) {
wchar_t *dll_path;
HRESULT hr = PathAllocCombine(
base_dir, L"python\\python3.dll",
PATHCCH_ALLOW_LONG_PATHS, _path
);
if (hr != S_OK) {
error(L"Could not construct Python DLL path");
}

HMODULE py_dll = LoadLibraryExW(dll_path, 0, 
LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
if (!py_dll) {
error(L"Could not load Python DLL %ls", dll_path);
}
LocalFree(dll_path);

Py_Main_t py_main = (Py_Main_t)GetProcAddress(py_dll, "Py_Main");
if (!py_main) {
error(L"Could not locate Py_Main function");
}

return py_main;
}


If people think it's worthwhile, I can put together a change to 
https://docs.python.org/3/extending/embedding.html#embedding-python-in-another-application
 (maybe a new section, "Embedding on Windows by dynamically loading the stable 
ABI"?) that uses a code snippet like this.

--

___
Python tracker 

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



[issue36675] Doctest directives and comments missing from code samples

2021-01-25 Thread Jim DeLaHunt


Jim DeLaHunt  added the comment:

My goodness, things get complex sometimes. 

If we cannot make Sphinx preserve doctest directives and comments, perhaps we 
should go back to the historical bug discussion to look at workarounds which we 
considered earlier. For instance, maybe we should modify the text surrounding 
the examples to explain that doctests directives should appear there, but that 
our tool chain currently removes them.

At the moment, I see doctest directives in the doctest source code at: 
https://github.com/python/cpython/blob/master/Doc/library/doctest.rst#directives
 
which do not appear in the corresponding HTML output at:
https://docs.python.org/3/library/doctest.html#directives 

How about rewording the text before each of those examples? Or maybe finding 
some way to show those examples as literal text which Sphinx won't modify, even 
if it is not formatted like Python code examples?

By the way, the discussion of this same problem back in 2011-2012 is at #12947 
. At that time, we applied a "monkey patch" to the Sphinx code. I haven't read 
the discussion closely enough to figure out if such a patch would help now.

--

___
Python tracker 

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



[issue43022] Unable to dynamically load functions from python3.dll

2021-01-25 Thread Steve Dower


Steve Dower  added the comment:

> I wonder whether it would be worth having a section in the docs somewhere 
> explaining how to do this, or more generally what the "best practices" are 
> for embedding?

Yes, it would be great. I think there are a few pieces in Doc/using/windows.rst 
already, and maybe a few bits in the embedding/extending section, but more 
would be valuable here.

> If I were to try to put something together, would that be worthwhile?

It would give us something concrete to argue about, at least ;) Speaking of 
arguing...

(Earlier post)
> The reason I want to use the stable ABI is so that I can upgrade the embedded 
> distribution without needing to rebuild the C code.

I think here you're in a very small minority who could get away with this, and 
so I'd hesitate to make it sound like the recommended approach.

What I'd actually recommend (on Windows) is to bundle a copy of Python with 
your application. The embeddable distro is specifically for this purpose, and 
once you've done that then there's no need to worry about the version changing 
at all (unless you do it yourself).

What's missing *here* is any kind of guide or walkthrough on how to do it. I 
think I imagined that I'd have the time and inclination to do some myself, but 
obviously I never have. Ultimately, I'd definitely be suggesting "just fix your 
Python version and load it directly" for embedders, so probably wouldn't have 
helped with what you're trying to do here anyway, Paul.

--

___
Python tracker 

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



[issue42973] argparse: mixing optional and positional arguments... not again

2021-01-25 Thread Tadek Kijkowski


Tadek Kijkowski  added the comment:

I added tests and docs to the PR. How does it look now?

--

___
Python tracker 

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



[issue38307] Provide Class' end line in pyclbr module

2021-01-25 Thread Aviral Srivastava


Aviral Srivastava  added the comment:

How do I generate the endline no? Initially, I could
do, stack[-1][0].end_lineno = start[0] - 1 but how do I this now given that the 
recent changes are operating on the AST instead of the token stream?

--
nosy: +kebab-mai-haddi

___
Python tracker 

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



[issue43022] Unable to dynamically load functions from python3.dll

2021-01-25 Thread Paul Moore


Paul Moore  added the comment:

Thanks, I'll give that a try. It sounds like I'm just using the APIs 
incorrectly, which would be good (in the sense that I can do what I wanted, I 
just didn't know how ;-))

I wonder whether it would be worth having a section in the docs somewhere 
explaining how to do this, or more generally what the "best practices" are for 
embedding? If I were to try to put something together, would that be worthwhile?

> I noted that the path to "python3.dll" must be fully qualified.

Just to note, my actual code does use an absolute path, I was over-simplifying 
here. But it's worth being clear on it, particularly if I do write something 
for the docs.

--

___
Python tracker 

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



[issue42920] How to add end_lineno in pyclbr?

2021-01-25 Thread Aviral Srivastava


Aviral Srivastava  added the comment:

But how do I generate the endline no? Initially, I could
do, stack[-1][0].end_lineno = start[0] - 1 but how do I this now?

Best,
Aviral Srivastava
LinkedIn

| Website


On Thu, Jan 14, 2021 at 11:12 AM Batuhan Taskaya 
wrote:

>
> Batuhan Taskaya  added the comment:
>
> It is actually much easier now, considering that we are operating on the
> AST instead of the token stream. You probably only have to add a new field
> to Function/Class classes for end_lineno and access .end_lineno attribute
> here just like how we do for .lineno
>
> https://github.com/python/cpython/blob/971235827754eee6c0d9f7d39b52fecdfd4cb7b4/Lib/pyclbr.py#L212-L214
> 
>
> --
>
> ___
> Python tracker 
>  
> >
> ___
>

--

___
Python tracker 

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



[issue43017] Improve error message in the parser when using un-parenthesised tuples in comprehensions

2021-01-25 Thread Andre Roberge


Andre Roberge  added the comment:

Such a change would be very useful and appreciated by other users as reported 
on https://github.com/aroberge/friendly-traceback/issues/167 and asked about on 
StackOverflow
https://stackoverflow.com/questions/60986850/why-does-creating-a-list-of-tuples-using-list-comprehension-requires-parentheses

--
nosy: +aroberge

___
Python tracker 

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



[issue36086] Split IDLE into separate feature in Windows installer

2021-01-25 Thread Andre Roberge


Andre Roberge  added the comment:

I do not use IDLE (except for testing) and would not be affected by such a 
change.

However, many tutorials and books intended for beginners instruct users to use 
IDLE, with the assumption that it is available out of the box. Removing IDLE 
would immediately make instructions from those tutorials and books obsolete and 
needlessly confuse beginners who often struggle installing anything additional 
to a basic Python installation.

I just checked and if I right-click on a Python file, I see 29 entries in the 
contextual menu, 28 of which would be unaffected if IDLE would be removed.

If IDLE were not included by default (or if it required clicking on a 
checkbox), I think that the number of questions in various beginners forum 
about installing IDLE would quickly become a real annoyance for people that 
strive to help beginners.

--
nosy: +aroberge

___
Python tracker 

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



[issue43022] Unable to dynamically load functions from python3.dll

2021-01-25 Thread Eryk Sun


Eryk Sun  added the comment:

I noted that the path to "python3.dll" must be fully qualified. But let me 
stress that point. You cannot use the relative path "path/to/python3.dll" with 
LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR. The loader will fail the call as an invalid 
parameter.

Unlike POSIX, a Windows path that contains slashes may be handled as a relative 
path in search contexts, if it lacks a drive or leading slash. In the case of 
LoadLibraryW(L"path/to/python3.dll"), the loader will try to resolve 
"path/to/python3.dll" against every directory in the DLL search path, which may 
not even include the current working directory.

--

___
Python tracker 

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



[issue43025] Use normal 'i' character to denote imaginary part of complex numbers

2021-01-25 Thread Eric V. Smith


Eric V. Smith  added the comment:

As I said in msg385648, I don't think it's feasible.

Maybe I'll write a PEP just to get it rejected so we can point to it when this 
discussion comes up, which it does a few times a year.

--

___
Python tracker 

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



[issue43025] Use normal 'i' character to denote imaginary part of complex numbers

2021-01-25 Thread Emmanuel Arias


Emmanuel Arias  added the comment:

> Now, it's feasible change i for j on cpython? Asking from my ignorance on 
> this case.

j for i, sorry

--

___
Python tracker 

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



[issue35523] Remove old ctypes callback workaround: creating the first instance of a callback

2021-01-25 Thread Ned Deily


Ned Deily  added the comment:

It is certainly not good that some of the vfx users are seeing a crash. On the 
other hand, at this stage of Python 3.7's life cycle only security-related 
fixes are accepted as a primary goal is to keep 3.7 as stable and unchanged as 
possible for those users still using it. We always recommend using a fully 
supported version, today either 3.8.7 (for several more months) or 3.9.1. It is 
unfortunate that the Fedora patch wasn't applied upstream earlier when it would 
have been exposed across all platforms. If we could be more certain that 
applying it now would have no side effects on other platforms, it might be an 
easier call. As long as the vfx project is building and supporting its own 
copies of Python 3.7, I think it would be better for them to carry the Fedora 
patch locally if they want it until they migrate to a newer version of Python.

--

___
Python tracker 

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



[issue43025] Use normal 'i' character to denote imaginary part of complex numbers

2021-01-25 Thread Emmanuel Arias


Emmanuel Arias  added the comment:

Personally, it's more natural use 'j' for complex number, but it's true that in 
many math book (or that I used) letter 'i' is used.

Now, it's feasible change i for j on cpython? Asking from my ignorance on this 
case.

--
nosy: +eamanu

___
Python tracker 

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



[issue43025] Use normal 'i' character to denote imaginary part of complex numbers

2021-01-25 Thread Eric V. Smith


Eric V. Smith  added the comment:

Even if we wanted to switch to "i" we'd have to continue to also support "j": 
there's a ton of existing code that uses it. Since "j" is used by some fields 
(including my own) for the imaginary part of complex numbers, and since I don't 
think we want to have two ways to do the same thing, I think this proposal 
should be objected.

But if you really want to pursue it, I suggest starting a discussion on the 
python-ideas mailing list.

--
nosy: +eric.smith

___
Python tracker 

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



[issue43022] Unable to dynamically load functions from python3.dll

2021-01-25 Thread Eryk Sun


Eryk Sun  added the comment:

> h = LoadLibraryW(L"some/path/to/python3.dll")

You should be using LoadLibraryExW(). It's a one-time call. You do not need to 
set the default flags via SetDefaultDllDirectories().

--

___
Python tracker 

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



[issue43022] Unable to dynamically load functions from python3.dll

2021-01-25 Thread Eryk Sun


Eryk Sun  added the comment:

> So I need to dynamically load *both* python3.dll and python39.dll, 
> but if I do that I can get the functions from python3.dll? 

No, just load the fully-qualified name of "python3.dll", with the loader flags 
LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS -- or 
LOAD_WITH_ALTERED_SEARCH_PATH.

--

___
Python tracker 

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



[issue43022] Unable to dynamically load functions from python3.dll

2021-01-25 Thread Paul Moore


Paul Moore  added the comment:

Thinking about what you said, "the loader waits to load it until first accessed 
via GetProcAddress()" did you mean by that, that the following code should work:

h = LoadLibraryW(L"some/path/to/python3.dll")
py_main = GetProcAddress(h, "Py_Main")

(with some/path/to/python39.dll being loaded on the second line)? Because if 
so, then that's what doesn't work for me.

Or are you suggesting that I do

AddDllDirectoryW(L"some/path/to");
h = LoadLibraryW(L"python3.dll");
py_main = GetProcAddress(h, "Py_Main");


Because I didn't think to try that - and I'm not 100% sure how I'd have to do 
stuff like LOAD_LIBRARY_SEARCH_USER_DIRS and/or SetDefaultDllDirectories to 
make that work. I find the Microsoft docs on all of this really complex and 
hard to follow if you're a non-expert :-(

--

___
Python tracker 

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



[issue43025] Use normal 'i' character to denote imaginary part of complex numbers

2021-01-25 Thread Christian Heimes


Christian Heimes  added the comment:

Your statement is not correct. A lot of people use "j" in fields of electrical 
engineering and signal processing to express the imaginary part. The letter "i" 
is commonly used for electric current in these fields.

--
nosy: +christian.heimes

___
Python tracker 

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



[issue43022] Unable to dynamically load functions from python3.dll

2021-01-25 Thread Paul Moore


Paul Moore  added the comment:

So I need to dynamically load *both* python3.dll and python39.dll, but if I do 
that I can get the functions from python3.dll? What's the point in doing that? 
Surely I might as well just load python39.dll and get the functions from there, 
in that case.

I hoped that by using python3.dll, I'd be able to avoid needing to deal with 
the version-specific DLL at all, so making my code portable to any version of 
Python 3. I'm pretty sure that's how it works if I statically link to 
python3.dll...

--

___
Python tracker 

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



[issue43025] Use normal 'i' character to denote imaginary part of complex numbers

2021-01-25 Thread Bhuvanesh Bhatt


Bhuvanesh Bhatt  added the comment:

Nobody these days uses j to represent the imaginary part of complex numbers. 
Regardless of what Guido wrote earlier, this issue should be fixed.

--
title: Use normal 'i -> Use normal 'i' character to denote imaginary part of 
complex numbers
type:  -> enhancement
versions: +Python 3.9

___
Python tracker 

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



[issue43025] Use normal 'i

2021-01-25 Thread Bhuvanesh Bhatt


New submission from Bhuvanesh Bhatt :

In Python, the letter 'j' denotes the imaginary unit. It would be great if we 
would follow mathematics in this regard and let the imaginary unit be denoted 
with an 'i'.

--
messages: 385641
nosy: bhuvaneshbhatt
priority: normal
severity: normal
status: open
title: Use normal 'i

___
Python tracker 

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



[issue43022] Unable to dynamically load functions from python3.dll

2021-01-25 Thread Eryk Sun


Eryk Sun  added the comment:

"python3.dll" doesn't directly depend on "python39.dll", so the loader waits to 
load it until first accessed via GetProcAddress(). It should remember the 
activation context of "python3.dll", such as whether it was loaded with a 
fully-qualified path and LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | 
LOAD_LIBRARY_SEARCH_DEFAULT_DIRS -- or LOAD_WITH_ALTERED_SEARCH_PATH. It works 
for me.

--
nosy: +eryksun

___
Python tracker 

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



[issue42979] _zoneinfo: zoneinfomodule_exec() doesn't check for PyDateTime_IMPORT failure

2021-01-25 Thread hai shi


Change by hai shi :


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

___
Python tracker 

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



[issue42955] Add sys.module_names: list of stdlib module names (Python and extension modules)

2021-01-25 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +23151
pull_request: https://github.com/python/cpython/pull/24332

___
Python tracker 

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



[issue43013] IDLE: update code, mostly by cleanups of 2.x or 2to3 artifacts

2021-01-25 Thread Anthony Sottile


Anthony Sottile  added the comment:

> Anthony: removing 'set' from 'list(set(interable))' is wrong if 'set' were 
> added to remove duplicates.

It's not removed, it's changed to a set comprehension (which was added in 2.7 
and 3.0)

pyupgrade is very battle tested, having been run on pip, pytest, and many open 
source projects

--

___
Python tracker 

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



[issue35615] "RuntimeError: Dictionary changed size during iteration" when copying a WeakValueDictionary

2021-01-25 Thread Daniel Romberg


Daniel Romberg  added the comment:

I think this issue needs to be reopened. The problem has not been solved 
completely. We experience a lot fewer crashes in weakref than before this fix, 
however, there are recursive situations in which copy() is invoked while 
iterating the WeakValueDictionary (e.g., in our case it is a signal/slot 
implementation where the slots are stored in a WeakValueDictionary). 
_commit_removals(), which is called at the beginning of the copy operation, 
might change the dictionary if there are items that are to be removed. If there 
is an ongoing iteration, the corresponding RuntimeError is raised.

I haven't thought that through entirely, but I wonder whether the copy (and 
also deepcopy) operation could just blindly copy everything without "committing 
removals". After the copy, both instances would do their _commit_removals on 
their own upon access.

--
nosy: +djromberg

___
Python tracker 

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



[issue43024] improve signature (in help, etc) for functions taking sentinel defaults

2021-01-25 Thread Irit Katriel


Irit Katriel  added the comment:

The PR changes the output to:

>>> help(traceback.print_exception)
Help on function print_exception in module traceback:

print_exception(exc, /, value=, tb=, limit=None, file=None, 
chain=True)

--

___
Python tracker 

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



[issue43024] improve signature (in help, etc) for functions taking sentinel defaults

2021-01-25 Thread Irit Katriel


New submission from Irit Katriel :

The "sentinel" default value don't render nicely in the signature:

>>> import traceback
>>> help(traceback.print_exception)
Help on function print_exception in module traceback:

print_exception(exc, /, value=, tb=, limit=None, file=None, chain=True)

--

___
Python tracker 

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



[issue43024] improve signature (in help, etc) for functions taking sentinel defaults

2021-01-25 Thread Irit Katriel


Change by Irit Katriel :


--
Removed message: https://bugs.python.org/msg385634

___
Python tracker 

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



[issue43024] improve signature (in help, etc) for functions taking sentinel defaults

2021-01-25 Thread Irit Katriel


Change by Irit Katriel :


--
Removed message: https://bugs.python.org/msg385635

___
Python tracker 

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



[issue43024] improve signature (in help, etc) for functions taking sentinel defaults

2021-01-25 Thread Irit Katriel


Irit Katriel  added the comment:

The PR changes the output to:

>>> help(traceback.print_exception)
Help on function print_exception in module traceback:

print_exception(exc, /, value=, tb=, limit=None, file=None, 
chain=True)

--

___
Python tracker 

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



[issue43024] improve signature (in help, etc) for functions taking sentinel defaults

2021-01-25 Thread Irit Katriel


Change by Irit Katriel :


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

___
Python tracker 

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



[issue43024] improve signature (in help, etc) for functions taking sentinel defaults

2021-01-25 Thread Irit Katriel


Change by Irit Katriel :


--
type:  -> enhancement

___
Python tracker 

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



[issue43024] improve signature (in help, etc) for functions taking sentinel defaults

2021-01-25 Thread Irit Katriel


New submission from Irit Katriel :

The "sentinel" default value don't render nicely in the signature:

>>> help(traceback.print_exception)
Help on function print_exception in module traceback:

print_exception(exc, /, value=, tb=, 
limit=None, file=None, chain=True)

--
components: Library (Lib)
messages: 385634
nosy: iritkatriel
priority: normal
severity: normal
status: open
title: improve signature (in help, etc) for functions taking sentinel defaults
versions: Python 3.10

___
Python tracker 

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



[issue42869] pydoc does not append .html to documentation

2021-01-25 Thread Julien Palard


Change by Julien Palard :


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

___
Python tracker 

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



[issue42869] pydoc does not append .html to documentation

2021-01-25 Thread Julien Palard


Julien Palard  added the comment:


New changeset eb9983c59b0683270328b5c40a115bb028209511 by Julien Palard in 
branch 'master':
bpo-42869: Avoid an HTTP redirection. (GH-24174)
https://github.com/python/cpython/commit/eb9983c59b0683270328b5c40a115bb028209511


--

___
Python tracker 

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



[issue36675] Doctest directives and comments missing from code samples

2021-01-25 Thread Julien Palard


Julien Palard  added the comment:

Due to https://github.com/python/cpython/pull/24282 this is sadly un-fixed.

Either we find another way to fix this, either we wait 3 releases and we 
re-commit https://github.com/python/cpython/pull/23620.

--
resolution: fixed -> later
stage: resolved -> 
status: closed -> open

___
Python tracker 

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



[issue42843] What min_sphinx for Python 3.10

2021-01-25 Thread Julien Palard


Change by Julien Palard :


--
resolution:  -> not a bug
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue42843] What min_sphinx for Python 3.10

2021-01-25 Thread Julien Palard


Julien Palard  added the comment:


New changeset 5c1f15b4b1024cbf0acc85832f0c623d1a4605fd by Julien Palard in 
branch 'master':
bpo-42843: Keep Sphinx 1.8 and Sphinx 2 compatibility (GH-24282)
https://github.com/python/cpython/commit/5c1f15b4b1024cbf0acc85832f0c623d1a4605fd


--

___
Python tracker 

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



[issue12669] test_curses skipped on buildbots

2021-01-25 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It was fixed in other way in issue42789. If __stdout__ is not a terminal, the 
code falls back to __stderr__, and it is not terminal either, it tries to open 
/dev/tty. If neither works, it uses a regular temporary file as terminal, but 
savetty()/resetty() and few tests are skipped.

It would be better to use pty, but I found that it does not work if tests 
output more than 2 KB. For now I do not know how to fix it.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue43013] IDLE: update code, mostly by cleanups of 2.x or 2to3 artifacts

2021-01-25 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

There are about 40 open PRs with 'idle' or 'idlelib' in title.  I only found 2 
or 3 with merge conflicts related to this issue -- and they are easy to fix.  
There are more conflicts from other patches (some fixed).  These are usually 
more difficult to fix as when a PR adds code where another patch later adds 
code and both additions need to be kept, in the proper order.

TODO: 4 built-in name parameters, 6 .keys(), 7 pyupgrade.  The latter found 
fixups in about 15 idlelib files and a few test files.  I may do these for 
individual files that are well tested or are being worked on.
---

Anthony: removing 'set' from 'list(set(interable))' is wrong if 'set' were 
added to remove duplicates.

--

___
Python tracker 

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



[issue43023] Remove a redundant check in _PyBytes_Resize()

2021-01-25 Thread Ma Lin


Ma Lin  added the comment:

Found a new issue, can be combined with this issue.

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

___
Python tracker 

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



[issue43013] IDLE: update code, mostly by cleanups of 2.x or 2to3 artifacts

2021-01-25 Thread Terry J. Reedy


Terry J. Reedy  added the comment:


New changeset 26af2fae189629d22a87aaf01b92d6f4de92b958 by Miss Islington (bot) 
in branch '3.9':
bpo-43013: Fix old tkinter module names in idlelib (GH-24326)
https://github.com/python/cpython/commit/26af2fae189629d22a87aaf01b92d6f4de92b958


--

___
Python tracker 

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



[issue43023] Remove a redundant check in _PyBytes_Resize()

2021-01-25 Thread Ma Lin


Change by Ma Lin :


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

___
Python tracker 

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



[issue43023] Remove a redundant check in _PyBytes_Resize()

2021-01-25 Thread Ma Lin


New submission from Ma Lin :

Above code already cover this check:

if (Py_SIZE(v) == newsize) {
/* return early if newsize equals to v->ob_size */
return 0;
}
if (Py_SIZE(v) == 0) {
-   if (newsize == 0) {
-   return 0;
-   }
*pv = _PyBytes_FromSize(newsize, 0);
Py_DECREF(v);
return (*pv == NULL) ? -1 : 0;
}

--
messages: 385626
nosy: malin
priority: normal
severity: normal
status: open
title: Remove a redundant check in _PyBytes_Resize()
versions: Python 3.10

___
Python tracker 

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



[issue42955] Add sys.module_names: list of stdlib module names (Python and extension modules)

2021-01-25 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 483359174e92489e13959977824806734f1a8cdd by Victor Stinner in 
branch 'master':
bpo-42955: Fix sys.module_names doc (GH-24329)
https://github.com/python/cpython/commit/483359174e92489e13959977824806734f1a8cdd


--

___
Python tracker 

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



[issue42955] Add sys.module_names: list of stdlib module names (Python and extension modules)

2021-01-25 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +23148
pull_request: https://github.com/python/cpython/pull/24329

___
Python tracker 

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



[issue42955] Add sys.module_names: list of stdlib module names (Python and extension modules)

2021-01-25 Thread STINNER Victor


STINNER Victor  added the comment:

I merged my PR, thanks for the feedback and reviews.

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

___
Python tracker 

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



[issue43022] Unable to dynamically load functions from python3.dll

2021-01-25 Thread Jeremy Kloth


Change by Jeremy Kloth :


--
nosy: +jkloth

___
Python tracker 

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



[issue42955] Add sys.module_names: list of stdlib module names (Python and extension modules)

2021-01-25 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset db584bdad32d81e42b71871077a8008036f5c048 by Victor Stinner in 
branch 'master':
bpo-42955: Add sys.modules_names (GH-24238)
https://github.com/python/cpython/commit/db584bdad32d81e42b71871077a8008036f5c048


--

___
Python tracker 

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



[issue36086] Split IDLE into separate feature in Windows installer

2021-01-25 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

turtledemo currently requires a couple of modules from idlelib.  One to syntax 
color examples, another to display the help file.  So turtledemo would have to 
be patched if IDLE were separate from tkinter.

--

___
Python tracker 

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



[issue43022] Unable to dynamically load functions from python3.dll

2021-01-25 Thread Paul Moore


New submission from Paul Moore :

I am writing a small application using the embedded distribution to run a 
script supplied by the user. The requirements are very simple, so all I need to 
do is set up argv and call Py_Main.

I'm trying to load the Py_Main function dynamically (for flexibility - see 
below) but GetProcAddress returns 0 when loading the function from python3.dll 
(the stable ABI). This seems to be because the symbols in python3.dll are 
special "fowarding" symbols, that GetProcAddress can't handle.

Is there a way to dynamically load the Python API from the stable ABI? If there 
isn't currently, could one be added?

To explain my requirements in a bit more detail, I don't want to statically 
link, because I want to put the Python distribution in a subdirectory, so that 
it isn't visible on PATH along with my executable, but I'd rather avoid the 
complexities involved in adding a dedicated SxS manifest to point the loader to 
the correct subdirectory for the python3.dll.

Furthermore, I want to provide a graceful fallback if the Python distribution 
is missing (initially, just a friendly error message, but in future maybe 
locating an alternative Python installation to use) and static linking won't 
allow that as I can't recover control if the expected Python DLL isn't present.

The reason I want to use the stable ABI is so that I can upgrade the embedded 
distribution without needing to rebuild the C code. I could search for 
python3X.dll, and just ignore the stable ABI. But that's more filesystem code 
than I really want to write in C... And honestly, I feel that dynamically 
linking is a perfect use case for the stable ABI, so it really should be 
supported.

--
components: Windows
messages: 385621
nosy: paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Unable to dynamically load functions from python3.dll
type: behavior
versions: Python 3.9

___
Python tracker 

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



[issue43013] IDLE: update code, mostly by cleanups of 2.x or 2to3 artifacts

2021-01-25 Thread miss-islington


miss-islington  added the comment:


New changeset 7370be30017f81d2f41f1b4b2abf31dd9a3f8fb1 by Miss Islington (bot) 
in branch '3.8':
bpo-43013: Fix old tkinter module names in idlelib (GH-24326)
https://github.com/python/cpython/commit/7370be30017f81d2f41f1b4b2abf31dd9a3f8fb1


--

___
Python tracker 

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



[issue43013] IDLE: update code, mostly by cleanups of 2.x or 2to3 artifacts

2021-01-25 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

PR for 3. For 2.x, tkinter comprised several modules that became tkinter 
submodules. For 3.0, 'import tkOld' was replaced by 'import tkinter.new as 
tkOld', where 'new' is lowercase version of 'Old'.  Fix remaining instances of 
tkColorChooser, tkFileDialog, tkSimpleDialog, and tkMessageBox by replacing 
'tkOld' with 'new' and import with 'from tkinter import new'.  Replace 'tkFont' 
with 'tkfont' instead of 'font' since 'font' is already used and leave import 
in 'as' form.  There are no remaining instances of SimpleDialog or 
tkCommonDialog.

--
stage: patch review -> 

___
Python tracker 

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



[issue43013] IDLE: update code, mostly by cleanups of 2.x or 2to3 artifacts

2021-01-25 Thread Terry J. Reedy


Terry J. Reedy  added the comment:


New changeset 879986d8a932c4524cb6ff822afc9537de16e28d by Terry Jan Reedy in 
branch 'master':
bpo-43013: Fix old tkinter module names in idlelib (GH-24326)
https://github.com/python/cpython/commit/879986d8a932c4524cb6ff822afc9537de16e28d


--

___
Python tracker 

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



[issue43013] IDLE: update code, mostly by cleanups of 2.x or 2to3 artifacts

2021-01-25 Thread miss-islington


Change by miss-islington :


--
pull_requests: +23147
pull_request: https://github.com/python/cpython/pull/24328

___
Python tracker 

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



[issue43013] IDLE: update code, mostly by cleanups of 2.x or 2to3 artifacts

2021-01-25 Thread miss-islington


Change by miss-islington :


--
pull_requests: +23146
pull_request: https://github.com/python/cpython/pull/24327

___
Python tracker 

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



[issue43013] IDLE: update code, mostly by cleanups of 2.x or 2to3 artifacts

2021-01-25 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
pull_requests: +23145
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/24326

___
Python tracker 

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



  1   2   >