Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

punycode: runtime deprecation #35092

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -831,12 +831,15 @@ The [`require.extensions`][] property is deprecated.
### DEP0040: `punycode` module
<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/35092
description: Added support for `--pending-deprecation`.
- version: v7.0.0
pr-url: https://github.com/nodejs/node/pull/7941
description: Documentation-only deprecation.
-->

Type: Documentation-only
Type: Documentation-only (supports [`--pending-deprecation`][])

The [`punycode`][] module is deprecated. Please use a userland alternative
instead.
Expand Down
10 changes: 10 additions & 0 deletions lib/punycode.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
'use strict';

const { getOptionValue } = require('internal/options');
if (getOptionValue('--pending-deprecation')){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (getOptionValue('--pending-deprecation')){
if (getOptionValue('--pending-deprecation')) {

Linter doesn't process this file as it's in .eslintignore.

process.emitWarning(
'The `punycode` module is deprecated. Please use a userland ' +
'alternative instead.',
'DeprecationWarning',
'DEP0040',
);
}

/** Highest positive signed 32-bit float value */
const maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1

Expand Down
10 changes: 5 additions & 5 deletions test/message/core_line_numbers.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict';
require('../common');
const punycode = require('punycode');
const path = require('path');

// This test verifies that line numbers in core modules are reported correctly.
// The punycode module was chosen for testing because it changes infrequently.
// If this test begins failing, it is likely due to a punycode update, and the
// The path module was chosen for testing because it changes infrequently.
// If this test begins failing, it is likely due to a path update, and the
// test's assertions simply need to be updated to reflect the changes. If a
// punycode update was not made, and this test begins failing, then line numbers
// path update was not made, and this test begins failing, then line numbers
// are probably actually broken.
punycode.decode('x');
path.dirname(0);
17 changes: 10 additions & 7 deletions test/message/core_line_numbers.out
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
punycode.js:42
throw new RangeError(errors[type]);
^
internal/validators.js:*
throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
^

RangeError: Invalid input
at error (punycode.js:42:8)
at Object.decode (punycode.js:*:*)
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type number (0)
at new NodeError (internal/errors.js:*:*)
at validateString (internal/validators.js:*:*)
at Object.dirname (path.js:1128:5)
at Object.<anonymous> (*test*message*core_line_numbers.js:*:*)
at Module._compile (internal/modules/cjs/loader.js:*:*)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:*:*)
at Module.load (internal/modules/cjs/loader.js:*:*)
at Function.Module._load (internal/modules/cjs/loader.js:*:*)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:*:*)
at internal/main/run_main_module.js:*:*
at internal/main/run_main_module.js:*:* {
code: 'ERR_INVALID_ARG_TYPE'
}
10 changes: 9 additions & 1 deletion test/parallel/test-punycode.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Flags: --pending-deprecation

// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
Expand All @@ -20,7 +22,13 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';
require('../common');
const common = require('../common');

const punycodeWarning =
'The `punycode` module is deprecated. Please use a userland alternative ' +
'instead.';
common.expectWarning('DeprecationWarning', punycodeWarning, 'DEP0040');

const punycode = require('punycode');
const assert = require('assert');

Expand Down